I would like to use Btrfs on two mirrored drives (RAID 1), used for archive data on a desktop system (media files, etc.), for redundancy/availability and potential self-healing functionality in case of a drive failure.
This implies that I don't want any additional (server-oriented) functionality, such as deduplication, file compression or ARC on the filesystem, which should reduce the resource demands on a regular desktop system with more limited CPU and RAM headroom, compared to NAS or server systems.
How do I correctly setup Btrfs with the core functionality and none of these additional, more demanding features on a recent Ubuntu system (18.04+)? What else could be configured to reduce the consumption of system resources?
I have read various guides and think I know how to install Btrfs and that most of these features are not enabled by default, but since a correct initial setup is very important in this case, I would like to make absolutely sure there are no misunderstandings or differences in the Ubuntu-specific setup.
Detailed questions:
Is it enought to install btrfs-tools to set this up or is something else needed, also for scrubbing and defragmentation?
You mention that the disks can be used with or without partitions, what are the (dis)advantages of either option?
Do you happen to know whether any kind of (L2) adaptive replacement cache is being used by default? (I would rather defragment regularly instead of setting aside RAM for it.)
You wrote that lzo-compression will increase (read/write?) speeds, without going into too much detail, how does this work?
You can use partitioning or not while using btrfs.
With partitioning first create partition tables and partitions on both disks. Lets say
/dev/sdb1
and/dev/sdc1
.Then create
btrfs
filesystem by runningYou are done.
Note: The previous command creates a
btrfs
filesystem on specified partitions. You don't need to "format" it neither before nor after running this command.mkfs.btrfs
is fully sufficient to create a filesystem.Now you can mount this raid to any directory you like by
You can mount either of disks with the same result: the raid will be mounted.
You can mount it permanently in
/etc/fstab
. If you don't set specific options there, like compression, they won't be used.Alternatively you don't have to create partitions and can directly create raid on devices by:
There is no much difference between both methods, but I prefer to have partitions traditionally.
I am not aware of any settings that will "reduce the consumption of system resources". The kernel module doesn't consume much by itself. If you don't need any features like deduplication or compression simply don't use them.
But take in account that
lzo
compression in most cases speeds up the disks and also increase storage space, because decompression is faster than reading from disk.Answering detailed questions:
btrfs-tools
is installed by default and nothing else is needed to managebtrfs
filesystem.There is no much difference if you plan to use your disks only for the raid. It doesn't affect performance in any way. But if you create partition tables on disks, you'll be able to shrink your btrfs raid partition one one or both disks and create some other filesystem(s) on part of the disk(s). It adds a bit of flexibility for the future. You can shrink btrfs partitions even when a disk is in use.
I am not aware of any available for a user settings regarding L2 cache usage. You can do a manual or automatic defragmentation. There is
autodefrag
mount option available for automatic defragmentation. I didn't notice much RAM usage withautodefrag
, but that's need testing if RAM is a real problem.You can mount your raid with
compress=lzo
option. If you do it on an empty raid, all files will be compressed. You can also enable compression later, but in that case already existing data won't be automatically compressed, only new data will. But you can always do a defragmentation of the existing data with-clzo
option. That will compress the existing data.I always use
lzo
because it adds some performance for HDDs, saves some read/write cycles for SSDs and gives extra space for both.Example of
fstab
entry withautodefrag
andlzo
:UUID can be taken from
sudo blkid
orgparted
.This way you compress the filesystem with
lzo
: