I'm currently migrating my netbook's SSD to btrfs to save space and increase corruption checking. Here are my notes on what I did.
The netbook uses a USB stick to store its entire file system. Small
and slow, but cheap (actually, this USB stick was free as in beer ;).
I initially tried to convert to btrfs on the fly, but I'd previously
had it running ext2 with 1 KiB blocks, and btrfs-convert
didn't like the small blocks.
So we'll have to create a new filesystem from scratch. Plug the USB stick into a real computer to rework the drive, and copy the data off the old partition:
# mkdir /mnt/btrfs
# mount /dev/sdb2 /mnt/btrfs
# mkdir /tmp/old
# rsync -av /mnt/btrfs/ /tmp/old/
Unmount and create a new file system on your partition:
# umount /dev/sdb2
# mkfs.btrfs -L GENTOO -m single -d single /dev/sdb2
Note that I've disabled raid for both the metadata and data to save space. This will make it harder to recover from corruption, but the checksumming will still detect the presence of corruption. Now, mount the new filesystem:
# mount -t btrfs -o compress,compress-force,ssd,noacl /dev/sdb2 /mnt/btrfs
and populate /mnt/btrfs
with the filesystem for the netbook:
# rsync -av /tmp/old/ /mnt/btrfs/
I'm not sure exactly how much space I've saved (I forgot to check while I was still in ext2), and free space is a tricky issue, but:
$ df -h /dev/sdb2
Filesystem Size Used Avail Use% Mounted on
/dev/sdb2 3.7G 1.3G 2.5G 34% /tmp/a
$ btrfs filesystem df /mnt/btrfs/
Data: total=1.47GB, used=951.89MB
Metadata: total=776.00MB, used=289.24MB
System: total=4.00MB, used=4.00KB
# btrfs filesystem show /dev/sdb2
Label: 'GENTOO' uuid: 3c4ba41f-13ca-4549-b093-e0114e748d88
Total devices 1 FS bytes used 1.21GB
devid 1 size 3.66GB used 2.24GB path /dev/sdb2
Btrfs Btrfs v0.19
So now there is plenty of breathing room.
Besides checksumming and compression, I was also interested in snapshots. Take a snapshot with
# btrfs subvolume snapshot /mnt/btrfs /mnt/btrfs/snapshot_name
Mount the snapshot with
# mount -t btrfs -o subvol=snapshot_name,... /dev/sdb2 /mnt/btrfs