And yes, welcome now to the btrfs. We're running this demonstration on openSUSE.
We need to install btrfs, add new disk files to work with.
We don't need to worry about partitioning.
We can use a complete disk. Add the btrfs to one disk and mount it,
check our filesystem and check the filesystem size, and then dynamically add
another disk to see the filesystem grow before our eyes.
Are you ready?
Come on.
Let's find our openSUSE system.
Now don't forget, we are now working on openSUSE.
We can gain our administrative privileges in the same way, so sudo ‑i, but
our installation of software is going to be using the zypper command, so
zypper in ‑y, and then the program files that we want, btrfsprogs. That
might take a little while as we update the cache, but I cut out the
installation there, so we've got now our btrfs program installed, and we
can go through and create ourselves a couple of disk files using the
fallocate command.
So we're going to create a couple of 1 GB files, so disk1 and disk2.
And we can see how easy it is just using the up arrow key.
Now again, we need to use losetup to create device files from these
disks, so we can use ‑f to find the next available, show me what it is,
and then link to disk1, and then, of course, go through and link to
disk2. And we can see there that we've got loop0 and loop1 available for
us on our openSUSE system.
So this allows me, then to go through and use my mkfs and then btrfs. We can see
the dot and tab completion coming in to help me a little bit here. As we go
through, then and format it with a btrfs filesystem,
we get volume management and filesystems all in one, and
that's what we want to be able to demonstrate.
And we're going to be formatting our loop0.
We only need to worry about the loop0 device.
With that done,
we're going to go through and create a mount point, so
mkdir. We might as well just call it data.
We don't really need a subdirectory structure below that, and then we're
going to mount our loop0 device into that directory.
The reason why we put it into the directory is we kind of work with our
filesystems and expect our filesystems to be mounted. When we look at df
‑h, if we don't specify the filesystem,
we see everything, but obviously going through looking at data,
we can see there that we've got loop0 mounted to data and having 1 GB of space.
We can also go through and look at btrfs filesystem and show for the
data directory, and we can see there that there's one device involved,
and we've got 1 GB of space. Now whilst our filesystem is mounted and
in use, we can then go through and do a btrfs device add and add in,
then our second disk.
So, of course, that's going to be /dev/loop1.
And we need to specify the filesystem to add it to, and we're going
to be adding it through to that data directory. So you can see why we
wanted it mounted in the first place.
Our filesystem is in use. We've just doubled its
size, and look how easy that was.
We added in an unformed matted device, but that space is available.
We go and look at our filesystem show again. We can see now
that we've got two disks involved in it,
each of 1 GB. So that's going to give 2 GB of disk space, and we're going to
see that by repeating the df command. And we can see now that we've got 2 GB of
disk space mounted through to our data directory.
So this, then shows some of the simple benefits of btrfs. It's included in,
say, in openSUSE and Ubuntu. Red Hat Enterprise Linux 8 have excluded it now,
but that's probably because they're using their own status filesystem for their advanced filesystem management.