From 642073d0d9bf38986b48ada951a4ae627093c342 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 20 Jan 2011 08:12:51 -0500 Subject: [PATCH] Add btrfs post. --- posts/btrfs.mkdwn | 70 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 posts/btrfs.mkdwn diff --git a/posts/btrfs.mkdwn b/posts/btrfs.mkdwn new file mode 100644 index 0000000..c00caff --- /dev/null +++ b/posts/btrfs.mkdwn @@ -0,0 +1,70 @@ +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 + # mkbtrfs -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][space], +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 + +[btrfs]: http://btrfs.wiki.kernel.org/ +[ext2]: http://en.wikipedia.org/wiki/Ext2 +[KiB]: http://en.wikipedia.org/wiki/Kibibyte +[space]: https://btrfs.wiki.kernel.org/index.php/FAQ#Why_are_there_so_many_ways_to_check_the_amount_of_free_space.3F +[snapshots]: https://btrfs.wiki.kernel.org/index.php/UseCases#Snapshots_and_subvolumes + +[[!tag tags/linux]] -- 2.26.2