March 2, 2012

Solaris 10: modify multiple zfs datasets and add a filesystem to multiple zones in few line

Posted in Solaris at 11:13 am by alessiodini

Yesterday i was very funny doing a task. I had to upgrade /export/home dataset to “legacy” and add that filesystem within xml for 26 local zones.

For this purpose , i wrote first a script that checks every ‘/export/home dataset’ without legacy attribute.
the script is here

I tried it on a global zone:

root@system8 # ./check_legacy
rootdg_system241/export_home 24K 8.21G 24K /mnt_system241/root/export/home
rootdg_system242/export_home 2.55M 7.81G 2.55M /mnt_system242/root/export/home
rootdg_system243/export_home 285M 7.52G 285M /mnt_system243/root/export/home
rootdg_system244/export_home 459M 7.37G 459M /mnt_system244/root/export/home
rootdg_system245/export_home 347M 7.94G 347M /mnt_system245/root/export/home
rootdg_system246/export_home 17.4M 6.27G 17.4M /mnt_system246/root/export/home
rootdg_system247/export_home 12.0M 8.09G 12.0M /mnt_system247/root/export/home
rootdg_system261/export_home 285M 7.25G 285M /mnt_system261/root/export/home

After i did something similar to next command( zfs.log has previous output ):

root@system8 # for i in `cat /tmp/zfs.log | awk ‘{ print $1 }’`; do echo zfs set mountpoint=legacy $i; done

zfs set mountpoint=legacy rootdg_system241/export_home
zfs set mountpoint=legacy rootdg_system242/export_home
(…)

This task required an /export/home umount, so i mounted them manually after.
As last step i wrote a 1line command for configure /export/home within xml for every zone. The code is here

😀

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: