Thursday, November 22, 2012

Failed to exclude directories when running flarcreate on Solaris 8

When I tried to prepare a flash archive (flar) from an old Solaris 8 physical machine, I wanted to exclude two directories (say, /one and /two). I checked the syntax from web (and the man page), it should be:

flarcreate -n -c -S -R / -x /one -x /two
where -c is enable compression, -S is ignore size stats, -R is the root path

However, the directories /one and /two are still in the flar !

After doing some investigation and research from the web, it is believed that there is a bug of this script of the current version. Since it's too old and I don't want to apply any patch on it, I'd rather modify the script a bit in order fulfill my requirement:



Make a copy of the following files:
cp -p /etc/mnttab /etc/mnttab.flar
cp -p /usr/sbin/flarcreate /usr/sbin/flarcreate.orig


Then modify the script /usr/sbin/flarcreate and the file /etc/mnttab. From the script, you will see that it actually looks for any mointpoint to be included from /etc/mnttab, so we just remove the unwanted entries on /etc/mnttab.flar and change the script to read /etc/mnttab.flar instead of /etc/mnttab:

done </etc/mnttab
  (there should be two lines)

Then I rerun the script again: flarcreate -n -c -S -R /
Please note that this time -x is no longer here as it is not necessary now.
Finally my flar without the unwanted mount points is created !



If it is a one time creation, it'd better toe revert back what we have done in the system:       
cp -p /usr/sbin/flarcreate.orig /usr/sbin/flarcreate
cp -p /etc/mnttab.flar /etc/mnttab

Next I will share how to use the flar to create a zone in a Solaris 10 container.