Now, whilst RAID might be absolutely wonderful, do we really
want to bother with all of that configuration and remembering
to send to our configuration file?
I think not.
We're going to take a look at using BTRFS.
We don't have to worry with our partitioning, we don't have to worry
with our configuration, and we just worry about formatting our file
system. Now, isn't that what we want?
Yes, it is.
How do we do it?
I'll show you. We go through working on my openSUSE system.
We can go through and make sure that we've got a couple of
new loop devices that we can work with.
When we've got those loop devices,
we format with the BTRFS file system, specifying the metadata
to be mirrored and our data to be mirrored.
And that's it.
We can then go through and choose one of the devices to mount to a
directory, and we're up and running. If we're uncertain about it,
we can actually go through and check the amount of free space
that we have inside of our mount directory.
Yes, we really need to see that the magic is there,
so working on our openSUSE system,
we're going to go through and create a RAID volume in BTRFS.
Now here we've got a brand‑new Vagrant VirtualBox for openSUSE, so I can
go through and gain some administrative privileges.
We'll go through and make sure that we've got BTRFS installed, so
don't forget we're using the zypper command, and then install ‑y so
we're not prompted, and then btrfs and progs.
Once we've got this then installed, of course, we'll be able to format our
file systems with a BTRFS program. Now, BTRFS is available in openSUSE, but
it's also available in their enterprise products.
So we're not saying there's nothing that makes this a cheaper or less
reliable product, it is really good, and we're going to see how easily
it is to go through and create a RAID array.
Now for this, then, we're going to need some disks.
If I go through and say this is a complete fresh setup, so I don't have
any of my loopback devices at the moment, so I can go through and create
some disks. So we know how to do this now.
We'll create a couple of 1 GB disks, and we can go through then and
call it, let's say, disk0, up arrow key, and create disk1, and then
run our losetup command, and of course, we can go through and choose
to link to disk0 and then disk1.
So all of this is looking good.
And now the magic really starts to happen.
We go through and run our mkfs.btrfs. We can specify that
our metadata will be raid1, so the information about the
RAID array will be mirrored.
We can specify our physical data will also be mirrored.
So we can set up our properties that we want for our RAID array and
then go through and include our /dev/loop0 and loop1. Hit the big
Enter key, and this is all there is to it.
We've now created a RAID array. We've used 2 GB of space, but we're only
going to have 1 GB available. As I go through then and just take a look,
we can go through and mount /dev/loop0, so only one device that I need
to go through and mount, and we'll just put it in the temporary
directory for mounting /mnt.
Go and look at our free space, so df ‑h for the mount directory, and
we can see then that gives me 1 GB of disk space.
Okay.
We can also go through and take a look at this from the
perspective of BTRFS, so btrfs, and we can go through into a file
system and disk‑free for the mount directory.
So we can see then that we've got our data, system, metadata as
all raid1, and we're really looking at the space being used
rather than so much our free space.
We can kind of prove this. If I go through and use the dd
command, again, using an input file, =/dev/zero, so we're just
writing a whole load of zeros, and we can have our output file
=/, and we want /mnt/file1.
So we're going to write to file1 in our mounted directory.
We can have a block size of 1 MB, and we can write,
let's say, 800 of these, so 800 MB. So, count equals 800.
Okay, it has to be a capital M, but at least we can see it does help me.
So this is then going through creating then our files.
So 800 records have been written through. We can see there
that it's creating the 100 MiB file.
But if we go through and clear the screen and go back and look at
our last command that started df, we can see then our free space,
and we can see then that we've gone down a little bit, 800 MB
used, 113 MB now available.
So we've only got that 1 GB of space. When we look at it from the BTRFS
perspective, so rerunning the BTRFS file system df and /mnt,
we can actually see then that our space has gone up, and it's not
really showing me that disk‑free, it's more the disk use, and we
can see then that we've got 800 MB of data that has been used,
but at least it is RAIDed. And how simple was it to create? This is what we want as administrators.