> ---8<---  run last in client_end_script ---8<---
> 
> #!/bin/sh
> 
> zpool list | grep -w data > /dev/null || exit 0
> 
> echo /sbin/zpool export data
> /sbin/zpool export data
> echo /sbin/mount -F lofs /devices /a/devices
> /sbin/mount -F lofs /devices /a/devices
> echo chroot /a /sbin/zpool import data
> chroot /a /sbin/zpool import data
> 
> 
> 
> 
> The final step is the trick ;)
> 
> 
> /Tomas

Thomas thank you a million times over for this suggestion. I had a few little 
hangups getting this implemented, but here is the script-fu that accomplished 
it. Some of it is still a bit kludgy for my tastes, but I expect (Sun are you 
listening) that zfs root and zfs targets will be supported natively in 
jumpstart soon enough. The shuffle of data after the ufsdump/restore is a 
little different if your inital jumpstart profile puts var and usr on seperate 
partitions. I think that dump/restore in the current CVS repo for opensolaris 
might have different behavior.

#Define some usefule variables
DISK1=`/bin/echo ${SI_DISKLIST}|/bin/awk -F, '{print $1}'`
DISK2=`/bin/echo ${SI_DISKLIST}|/bin/awk -F, '{print $2}'`
#create the base zfs mirror device pool
echo "rebuild device nodes"
devfsadm
echo "rebuilding device nodes on target root"
devfsadm -r /a
echo "Destroy existing base zpool"
zpool destroy -f base
echo "Create new base zpool as a mirror of slice 3 from both disks"
zpool create -m none base mirror ${DISK1}s3 ${DISK2}s3
echo "Create base/var zfs vol"
zfs create -o mountpoint=legacy -o atime=off base/var
echo "Create base/usr zfs vol"
zfs create -o mountpoint=legacy -o atime=off base/usr
echo "Create base/spool zfs vol"
zfs create -o mountpoint=legacy -o atime=off base/spool
echo "Creating and setting perms for /a/var.z"
mkdir /a/var.z
chmod 755 /a/var.z
chown 0:0 /a/var.z
echo "Creating and setting perms for /a/usr.z"
mkdir /a/usr.z
chmod 755 /a/usr.z
chown 0:0 /a/usr.z
echo "Adding lines to vfstab for zfs mounts"
echo "base/var  -       /var    zfs     -       yes     -">>/a/etc/vfstab
echo "base/usr  -       /usr    zfs     -       yes     -">>/a/etc/vfstab
echo "base/spool        -       /var/spool      zfs     -       yes     
-">>/a/etc/vfstab
echo "mounting var.z and usr.z"
mount -F zfs base/var /a/var.z
mount -F zfs base/usr /a/usr.z
echo "dumping /a/usr to /a/usr.z"
(cd /a/usr.z;ufsdump 0f - /a/usr|ufsrestore rf -;mv ./usr/* ./;rmdir ./usr)
echo "dumping /a/var to /a/var.z"
(cd /a/var.z;ufsdump 0f - /a/var|ufsrestore rf -;mv ./var/* ./;rmdir ./var)
echo "export base zpool"
/sbin/zpool export base
echo "loop /devices to /a/devices"
/sbin/mount -F lofs /devices /a/devices
echo "import to base zpool to /a chroot"
chroot /a /sbin/zpool import base
mv /a/var /a/var.local
mv /a/usr /a/usr.local
echo "Creating and setting perms for /a/var"
mkdir /a/var
chmod 755 /a/var
chown 0:0 /a/var
echo "Creating and setting perms for /a/usr"
mkdir /a/usr
chmod 755 /a/usr
chown 0:0 /a/usr
echo "unmounting /a/var.z and /a/usr.z"
umount /a/var.z
umount /a/usr.z
echo "importing zpool base again for the final time"
zpool import -f base
echo "mounting /a/usr and /a/var for sane shutdown"
mount -F zfs base/var /a/var
mount -F zfs base/usr /a/usr
echo "move spool contents"
mv /a/var/spool /a/var/spool.old
echo "create new mount point"
mkdir /a/var/spool
chmod 755 /a/var/spool
chown 0:3 /a/var/spool
echo "mounting new spool zfs vol"
mount -F zfs base/spool /a/var/spool
echo "moving spool contents into new mount"
mv /a/var/spool.old/* /a/var/spool/
echo "Finished!"
 
 
This message posted from opensolaris.org
_______________________________________________
zfs-discuss mailing list
zfs-discuss@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/zfs-discuss

Reply via email to