Howto: Mount New File System To Running Solaris 10 Zone

Categorías:

I recently came across the need to mount a new file system to a Solaris 10 non-global zone without rebooting the actual zone. There are other ways to accomplish this same task but most of the solutions I’ve found required rebooting the non-global zone. Unfortunately, we could not take an outage by rebooting the non-global zone yet the file system needed to be added to the zone.
The method below describes a way in which you can mount a new file system (UFS) to a running Solaris 10 zone without the need of a reboot.


Prerequisites:
Limitations:

  • Assumptions:
  • All commands need to be run from the global zone as the root user unless otherwise specified.
  • A Solaris 10 host with at least one running non-global zone.
  • You can not unmount the file system from the non-global zone. Some say this is a benefit

Lets get started!
Done. No need to reboot the non-global zone!

  • Log into the global zone and create the new file system like you normally would. In this example, I use SVM to create a new metadevice (d1000), one way mirror (d2000), and a 1Gig soft partition (d2001). Your mileage may vary.
# metainit d1000 1 1 c1t5d0s0 -i 128k
# metainit d2000 -m d1000
# metainit d2001 -p d2000 1g
# echo y | newfs -i 8192 /dev/md/rdsk/d2001
    Create the block and character devices for the zone. Run “ls -lL” against the newly created soft partition (d2001) to find the major and minor character and block values.
# ls -lL /dev/md/*dsk/d2001
brw-r----- 1 root sys 85, 2001 Oct 6 13:46 /dev/md/dsk/d2001
crw-r----- 1 root sys 85, 2001 Oct 6 13:47 /dev/md/rdsk/d2001

NOTE: The major and minor values are 85 and 2001, respectively. Notice that the “dsk” device is a“block-type” file and “rdsk” device is a “character-type” file.

  •  Run mknod to create the two special files for the zone. Keep in mind that the name of the two files need to be saved down the myzone device path.
# mknod /zones/myzone1/dev/md/dsk/d2001 b 85 2001
# mknod /zones/myzone1/dev/md/rdsk/d2001 c 85 2001
  •  Correct the permissions and ownerships of the new d2001 block-type and character-type files.
# chmod 640 /zones/myzone1/dev/md/*dsk/d2001
# chown root:root /zones/myzone1/dev/md/*dsk/d2001
  •  Create a mount point in the “myzone1″ non-global zone.
# mkdir /zones/myzone1/root/wandisimo
  •  Confirm its not already mounted
# mount | grep wandisimo

You should not get anything back from the command above.

  • Mount the file system
# mount /dev/md/dsk/d2001 /zones/myzone1/root/wandisimo

You are probably thinking to your self, “Why couldn’t we just skip to this step and be done with it?” From my testing, if the block and character files are not created down the “myzone1″ device path first, it fails to mount. If you were to add the soft partition using zonecfg or by adding it to the zone XML file then rebooting the non-global zone, the boot process actually creates the block and character device for you.
NOTE: Even though the file system successfully gets mounted, it will not show up in a “df” output as actually being mounted.

  • Check to see if its mounted
# df -h | grep wandisimo

You should not get any output.

  • Confirm the file system is in fact mounted by running the mount command
# mount | grep wandisimo
/zones/myzone1/root/wandisimo on /dev/md/dsk/d2001 read/write/setuid/devices/intr/largefiles/logging/xattr/onerror=panic/dev=15407d3 on Tue Oct 6 14:11:45 2009
  •  Log into the running non-global zone (myzone1) to confirm the file system is indeed mounted
# zlogin myzone1
(myzone1)# df -h /wandisimo
Filesystem size used avail capacity Mounted on
/wandisimo 1008M 1.0M 947M 1{29abae026baad3be178e8b4d9df8b452ab37360abfdefacab414000aba9cdfd4} /wandisimo

If you would like to make this permanent, you will need to add it to the /etc/vfstab in the global zone.

Tomado de : http://alittlestupid.com/2009/10/22/howto-mount-new-file-system-to-running-solaris-10-zone/

Sin respuestas

Deja un comentario