Mounting File Systems in Running Non-Global Zones
You can mount file systems in a running non-global zone. The following procedures
are covered.
As the global administrator in the global zone, you can import raw and block devices into a non-global zone. After the devices are imported, the zone administrator has access to the disk. The zone administrator can then create a new file system on the disk and perform one of the following actions:
As the global administrator, you can also mount a file system from the global zone into the non-global zone.
How to Import Raw and Block Devices by Using zonecfg
This procedure uses the lofi file driver, which exports a file as a
block device.
- Become superuser, or assume the Primary Administrator role.
To create the role and assign the role to a user, see Using the Solaris Management Tools With RBAC (Task Map) in System Administration Guide: Basic Administration.
- Change directories to /usr/tmp.
global# cd /usr/tmp
- Create a new UFS file system.
global# mkfile 10m fsfile
- Attach the file as a block device.
The first available slot, which is /dev/lofi/1 if no other lofi devices have
been created, is used.
global# lofiadm -a `pwd`/fsfile
You will also get the required character device.
- Import the devices into the zone my-zone.
global# zonecfg -z my-zone
zonecfg:my-zone> add device
zonecfg:my-zone:device> set match=/dev/rlofi/1
zonecfg:my-zone:device> end
zonecfg:my-zone> add device
zonecfg:my-zone:device> set match=/dev/lofi/1
zonecfg:my-zone:device> end
- Reboot the zone.
global# zoneadm -z my-zone boot
- Log in to the zone and verify that the devices were successfully imported.
my-zone# ls -l /dev/*lofi/*
You will see a display that is similar to this:
brw------- 1 root sys 147, 1 Jan 7 11:26 /dev/lofi/1
crw------- 1 root sys 147, 1 Jan 7 11:26 /dev/rlofi/1
See Also
For more information, see the lofiadm(1M) and lofi(7D) man pages.
How to Mount the File System Manually
You must be the zone administrator and have the Zone Management profile to
perform this procedure. This procedure uses the newfs command, which is described in
the newfs(1M) man page.
- Become superuser, or have the Zone Management rights profile in your list of
profiles.
- In the zone my-zone, create a new file system on the disk.
my-zone# newfs /dev/lofi/1
- Respond yes at the prompt.
newfs: construct a new file system /dev/rlofi/1: (y/n)? y
You will see a display that is similar to this:
/dev/rlofi/1: 20468 sectors in 34 cylinders of 1 tracks, 602 sectors
10.0MB in 3 cyl groups (16 c/g, 4.70MB/g, 2240 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
32, 9664, 19296,
- Check the file system for errors.
my-zone# fsck -F ufs /dev/rlofi/1
You will see a display that is similar to this:
** /dev/rlofi/1
** Last Mounted on
** Phase 1 - Check Blocks and Sizes
** Phase 2 - Check Pathnames
** Phase 3 - Check Connectivity
** Phase 4 - Check Reference Counts
** Phase 5 - Check Cyl groups
2 files, 9 used, 9320 free (16 frags, 1163 blocks, 0.2% fragmentation)
- Mount the file system.
my-zone# mount -F ufs /dev/lofi/1 /mnt
- Verify the mount.
my-zone# grep /mnt /etc/mnttab
You will see a display similar to this:
/dev/lofi/1 /mnt ufs
rw,suid,intr,largefiles,xattr,onerror=panic,zone=foo,dev=24c0001
1073503869
How to Place a File System in /etc/vfstab to Be Mounted When the Zone Boots
This procedure is used to mount the block device /dev/lofi/1 on the file
system path /mnt. The block device contains a UFS file system. The following
options are used:
logging is used as the mount option.
yes tells the system to automatically mount the file system when the zone boots.
/dev/rlofi/1 is the character (or raw) device. The fsck command is run on the raw device if required.
- Become superuser, or have the Zone Management rights profile in your list of
profiles.
- In the zone my-zone, add the following line to /etc/vfstab:
/dev/lofi/1 /dev/rlofi/1 /mnt ufs 2 yes logging
How to Mount a File System From the Global Zone Into a Non-Global Zone
Assume that a zone has the zonepath /export/home/my-zone. You want to mount
the disk /dev/lofi/1 from the global zone into /mnt in the non-global zone.
You must be the global administrator in the global zone to perform
this procedure.
- Become superuser, or assume the Primary Administrator role.
To create the role and assign the role to a user, see Using the Solaris Management Tools With RBAC (Task Map) in System Administration Guide: Basic Administration.
- To mount the disk into /mnt in the non-global zone, type the following
from the global zone:
global# mount -F ufs /dev/lofi/1 /export/home/my-zone/root/mnt
See Also
For information about lofi, see the lofiadm(1M) and lofi(7D) man pages.