Trick installer to use btrfs root with compression
An easier way to do this is to alter the mount
command of the live environment.
- Boot as usual to the live session.
-
Move the
mount
executable to another location:sudo mv /bin/mount /bin/mount.bin
-
Edit a new file using
sudoedit /bin/mount
and save the following script into it (alter the options as you like; here we have addedcompress
):#!/bin/sh if echo "$@" | grep -q -- "-t btrfs"; then /bin/mount.bin "$@" -o compress else /bin/mount.bin "$@" fi
You can also match block devices like
/dev/sda1
instead of-t btrfs
and chainelif
s to use different mount options for different devices and filesystems. -
Copy the original permissions over to the new script:
sudo chmod --reference=/bin/mount.bin /bin/mount
Install as usual and your btrfs partition will be mounted with the specified options (here,
compress
).- After the installation is finished, before exiting the live envirement, alter the
/etc/fstab
of the newly installed system to match the specified options, so it will use the same options on new boots.
I used: defaults,noatime,compress-force=lzo,space_cache
as mount options.
This works with quantal daily (30/6/12).
I used the btrfs partition as /
and a swap partition.
Credits go to this post (in this thread), which in turn cites this blog post.
Just after the installer mounts your partition, you could try to switch to a shell and do a mount -o remount,compress /target
, this might work.
I came across this thread as because I was looking to install Linux Mint Debian Edition on a flash drive and installing on compressed btrfs from the get-go. Although these solutions were not directly applicable to reaching my results I used some of this information to reach my target.
The problem was that the point of the installer formatting and mounting the partition and starting copying files was right next to each other, as so I was unable to perform the "remount" option mentioned by others above.
The LMDE version of the installer script was in python (usr/lib/live-installer/installer.py). I'm not sure if it is the same with Ubuntu, but if it is, this will be directly applicable. This allowed me to edit the script and add this line right under the line that origionally mounted the partition for "/"
os.system("mount -o remount,compress /dev/sda3 /target -t btrfs")
of coures the "/dev/sda3" will vary depending on your device.
I understand this is an Ubuntu forum, but like I said it came up with the search and this solution would be directly relevant if the installer is python based. We are all Debian here anyways, right!?