SUMMARY: ZFS and Separating /var

From: Tom Zurita <tzurita_at_dsolutionz.com>
Date: Wed Oct 28 2009 - 15:49:18 EDT
Thanks to James Noyes for having the right answer.  Here is a summary  
what he said and what I did:

> "ZFS root has special requirements for the "core" filesystems, root  
> (/),
> /var, /usr, and /opt.  They CAN be broken out after the fact (I  
> frequently
> go back and break out /usr myself) but you need to be careful about  
> how.
>
> If you look at your ZFS root setup, you'll see that your root (/)  
> filesystem
> is actually a dataset called "rpool/ROOT/somename".  The "core"  
> filesystems
> for a given install of the OS *must* all live under a single named  
> dataset
> hierarchy like that.  In other words, they'll *have* to look like  
> this if
> you do a "zfs list":
>
> rpool/ROOT/somename
> rpool/ROOT/somename/opt
> rpool/ROOT/somename/usr
> rpool/ROOT/somename/var
>
> Seems simple, but getting there can be tricky, since there's a few  
> details
> that often get missed.  Like the fact that the "core" filesystems are
> mounted directly and early on by the boot process, NOT by the  
> automatic
> generalized mounting of zfs filesystems that comes later.
>
> The basic steps:
>
> - Boot into single-user mode, either from CD/DVD or from a jumpstart  
> server.
> - Import your root pool, temporarily setting it up to mount on /a:
>   zpool import -R /a rpool
> - Mount your root dataset on /a if it isn't already:
>   zfs mount rpool/ROOT/somename
> - Move your existing var directory out of the way:
>   cd /a;mv var var2
> - Create your new var dataset:
>   zfs create rpool/ROOT/somename/var
> - Mount your new /var dataset if it isn't already:
>   zfs mount rpool/ROOT/somename/var
> - Transfer the old var to the new var.  You used cpio, I use tar:
>   cd /a/var2;tar cfE - * .??* | (cd /a/var;tar xvf -)
> - DO NOT set the "mountpoint" property on the new var dataset.  Let  
> it be
>  inherited from the parent root (/) dataset.
> - INSTEAD, set the "canmount" property on the new var dataset to  
> "noauto":
>   zfs set canmount=noauto rpool/ROOT/somename/var
> - Repeat if desired for /usr and /opt, starting with step of moving  
> the
>  real directory out of the way.
> - Unmount all your ZFS filesystems:
>   zfs unmount -a
> - Reboot, and life should be good.
>
> I personally like to set refquotas on my var datasets, to mimic the  
> old
> behavior of having /var contained so it can't run away and consume all
> available disk space like it can on a zpool/zfs setup.
>
> A side bonus in this configuration is that you can have more than  
> one root
> dataset and switch back and forth between them, and the system will  
> just
> automagically handle it.  For example, here's my zfs list:
>
> NAME                                 USED  AVAIL  REFER  MOUNTPOINT
> bladepool                           15.3G  51.7G    97K  /bladepool
> bladepool/ROOT                      9.22G  51.7G    21K  legacy
> bladepool/ROOT/s10u8                9.22G  51.7G   463M  /
> bladepool/ROOT/s10u8/opt            4.58G  51.7G  4.58G  /opt
> bladepool/ROOT/s10u8/usr            3.40G  51.7G  3.40G  /usr
> bladepool/ROOT/s10u8/var             812M  51.7G   812M  /var
> bladepool/ROOT/s10u7                10.2G   570M   454M  /
> bladepool/ROOT/s10u7/opt            5.65G  2.35G  5.65G  /opt
> bladepool/ROOT/s10u7/usr            3.39G  2.61G  3.39G  /usr
> bladepool/ROOT/s10u7/var             725M  3.29G   725M  /var
>
> and I can boot back and forth from Update 7 to Update 8 quickly and  
> easily.
> Also, I can (and did) use Live Upgrade to move to the next version of
> Solaris with a single reboot.  When Update 9 comes out, I'll be able  
> to do
> it all over again painlessly."


I basically followed it exactly as recommended and did the following:

1.  Boot into single-user mode, was x86 so selected the failsafe  
option in Grub
2.  Import your root pool, temporarily setting it up to mount on /a: -  
On boot it asked me if I wanted to mount rpool read/write on /a.  I  
said yes and continued
	a.  zpool import -R /a rpool - NOT NEEDED
	b. Mount your root dataset on /a if it isn't already: - DONE AT BOOT
	c.  zfs mount rpool/ROOT/somename - DONE AT BOOT
3. Move your existing var directory out of the way:
4. cd /a;mv var var2
5. Create your new var dataset:
	a. zfs create rpool/ROOT/somename/var
	b. mount your new /var dataset if it isn't already: -DONE VIA ZFS  
CREATE - NOT NEEDED
		1. zfs mount rpool/ROOT/somename/var
6. Transfer the old var to the new var.  You used cpio, I use tar: (my  
preference is pio bu
	a.  cd /a/var2;tar cfE - * .??* | (cd /a/var;tar xvf -)
7. DO NOT set the "mountpoint" property on the new var dataset.  Let  
it be inherited from the parent root (/) dataset.
	a. INSTEAD, set the "canmount" property on the new var dataset to  
"noauto":
  	b. zfs set canmount=noauto rpool/ROOT/somename/var
8. Reboot, and life should be good.

Regards,


Tom Zurita
tzurita@dsolutionz.com
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Wed Oct 28 14:50:28 2009

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:44:15 EST