HOWTO: Enable zfs compression when installing OpenSolaris 2008.05
By glagasse on Apr 25, 2008
Currently the simplified installer we're using for OpenSolaris 2008.05 (aka Project Indiana) doesn't support specifying zfs options for the zpool that gets created on the target disk during installation. You can always turn options on after installation but compression is one option that isn't applied retroactively and so really benefits either new zfs filesystems created after installation or being turned on when the initial zfs pool is created. Enabling compression for the zfs pool that gets created during installation isn't all that difficult. Here's how you do it.
Step 1: Boot the OpenSolaris 2008.05 live media
Step 2: Once booted and sitting at the Gnome desktop, open a terminal window by right-clicking on the desktop and click on the open terminal selection
Step 3: Create a new file with the following content (vi set_options.sh)
until [ "`zpool list rpool`" ];
pfexec zfs set compression=on rpool
# For some reason, the rpool/ROOT dataset (which is the root filesystem
# doesn't inherit the compression property from the parent
# pool like the other datasets. So, we'll just set it manually
pfexec zfs set compression=on rpool/ROOT
Save the file and make it executable (chmod +x set_options.sh)
Step 4: Now run the script (./set_options.sh)
Step 5: Double click on the Install icon on the desktop and proceed as normal
That's all there is to it. Once you start the installation (after you answer the few questions required) the installer will setup a zfs pool on your target disk. When that happens the script will set the compression property on that pool and the script will exit. Thus your entire installation (at least a very high percentage of it) will be compressed where it can.
Laptop users or users that will only have a single disk may also want to change the copies property of the zpool so that in the case of disk errors zfs will have more than one place to look for the data in order to attempt a recovery. Just add the following to the end of the script above. This will store two copies of data instead of just one.
pfexec zfs set copies=2 rpool
pfexec zfs set copies=2 rpool/ROOT