Glen Pitt-Pladdy :: BlogLinux Mint 17 with Compressed btrfs | |||
Out the box Linux Mint installs without btrfs support. The one big advantage of btrfs is when running a VM it allows for compression and that reduces the about of IO. Storage is almost always the bottleneck for VMs so this is an important factor. It's also useful if you use it on a USB flash drive (slow) as a diagnostic tool. This assumes that you have a separate /boot mountpoint with an easily readable filesystem like ext4. That ensures you can always get up and running. So, here's how to do this. Initial InstallDo your usual install. If you want LVM then you either need to choose that option or manually create the LVs as you want before install. Once you are up and running, then we can start the conversion. Before we go any further ensure that btrfs-tools are installed: # apt-get install btrfs-tools At this point you might light to snapshot the VM. ConversionBoot again from the LiveCD again. Once up, install btrfs-tools as above. This is only an install in the LiveCD environment and needed for the conversion. Next we can run the conversion - you need to work out what your root device is. In my case it's an LV: # btrfs-convert /dev/vg00/root This will sit and thrash the disk for a while as it converts the filesystems. Now we need to get this back to a bootable state. Mount the filesystem where you can get to it, plus the other virtual filesystems: # mount /dev/vg00/root /mnt/ Then chroot into this environment and mount the /boot mountpoint: # chroot /mnt/ Next edit /etc/fstab and change the filesystem type to btrfs and set compression: /dev/mapper/vg00-root / btrfs space_cache,compress=zlib 0 1 Additionally, btrfs has an automatic defragmentation feature which might be useful if you are using magnetic storage. You can add the autodefrag option to the mountpoint options above. At this point everything should be fine, except preparations for boot. For this we need to update the initramfs and grub: # update-initramfs -u And then reboot..... With a bit of luck it will come up fine else you will need to debug that or roll back the snapshot... you did take a snapshot? Cleanup and CompressSo far we've got up and running, but conversion creates a subvolume containing the old ext4 filesystem and if everything is fine then that's no longer needed. To remove that: # btrfs subvolume delete /ext2_saved/ Now we are left with a quite full filesystem which is not compressed, but has compression enabled for new writes: # df -h / What we need to do now is compress the existing data to reduce space. This is a little bit misleading sometimes due to the imprecise way btrfs calculates space, but goes something like this: # btrfs filesystem defragment -vrc / That should run a while compressing all the existing files and show you what it's up to. This generates loads of IO so expect the disk to thrash as it rewrites everything. After this you should have considerably less space used: # df -h / From here you can remove any snapshots created for safety and continue to use it as normal. |
|||
Disclaimer: This is a load of random thoughts, ideas and other nonsense and is not intended to be taken seriously. I have no idea what I am doing with most of this so if you are stupid and naive enough to believe any of it, it is your own fault and you can live with the consequences. More importantly this blog may contain substances such as humor which have not yet been approved for human (or machine) consumption and could seriously damage your health if taken seriously. If you still feel the need to litigate (or whatever other legal nonsense people have dreamed up now), then please address all complaints and other stupidity to yourself as you clearly "don't get it".
Copyright Glen Pitt-Pladdy 2008-2023
|
Comments: