HOWTO: Enable zfs compression when installing OpenSolaris 2008.05

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)

#!/bin/sh

until [ "`zpool list rpool`" ];
do
    :
done

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

Comments:

Glenn, thanks for this tip. I'm posting this from a fresh install of Indiana beta 2a, and it's great.

Some readers might not realize that enabling ZFS compression also tends to make I/O performance FASTER. Although most users don't experience faster disk I/O with compression on other systems, ZFS and compression also set a new standard in this regard. Of course, this depends on a specific workload, but certainly worth a try for everyone!

Regards.

Posted by Wes W. on April 29, 2008 at 10:58 PM PDT #

You might need to change this to specifically wait for the ROOT dataset to be created, as I've seen rpool/ROOT end up with a local setting of no compression using the current bits on my system when using this script.

Posted by Dave Miner on April 30, 2008 at 05:04 AM PDT #

Thanks Dave. For some reason the rpool/ROOT dataset doesn't inherit the compression property from the parent pool like the other datasets. Perhaps because of it's special status (legacy)? Setting the property manually for the rpool/ROOT dataset at the same time does work however. Waiting until the rpool/ROOT dataset is created didn't change anything, I still needed to explicitly set the compression property for it.

Posted by Glenn Lagasse on May 01, 2008 at 08:25 AM PDT #

Post a Comment:
Comments are closed for this entry.
About

glagasse

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today