Use case: use Btrfs compression for external HDD
Create Btrfs file system and enable LZO
Depeding on how you would like to make use of Btrfs features:
- use the external USB HDD as 1 single partition (block device)
- create 2 partitions (2 block devices) and form a raid1 or raid0 for data (-d), metadata is replicated on all devices by default, unless you manually specify by using -m
Example
mktfs.btrfs /dev/sdd
Enable LZO Compression
Make use of the compression by adding the option when mounting
sudo mount -o compress=lzo /dev/sdd /mnt/btrfs
Btrfs is flexible, LZO compression can be enabled on a subvolume basis
Create a subvolume named subvol1
btrfs subvolume create /mnt/btrfs/subvol1
OR
btrfs subvol create /mnt/btrfs/subvol1
Mount the subvolume and enable compression
mount -t btrfs -o compress=lzo,subvol=subvol1 /dev/sdd /mnt/subvol1
NOTE:
Defragment
Defragment can be done to files or directories.
Files
btrfs filesystem defrag file1 file2
Folders
btrfs filesystem defragment /btrfs/junk /btrfs/rubbish
Reference
Compression and Defragmentation
http://www.funtoo.org/wiki/BTRFS_Fun
http://docs.oracle.com/cd/E37670_01/E37355/html/ol_btrfs.html