Tuesday February 05, 2008
The virtual disk backend can be a physical disk, a physical disk slice, a file or a volume from a volume management framework (like ZFS, SVM, VxVM...).
A backend is exported from a domain with the command "ldm add-vdsdev" (or "ldm add-vdiskserverdevice"):
# ldm add-vdsdev <backend> <volume_name>@<service_name>
And it is assigned to another domain with the command "ldm add-vdisk":
# ldm add-vdisk <disk_name> <volume_name>@<service_name> <domain>
Note that a backend is effectively exported when the domain <domain> is bound.
Virtual Disk Export Options
There are two ways a backend can be exported as a virtual disk, either as a full disk or as a single slice disk. Currently, the way a backend is exported (either as a full disk or as single slice disk) depends on the type of backend (whether it is a disk, a slice, a file or a volume). The next section (Virtual Disk Backend) explains how each type of backend is exported.
When a backend is exported to a domain as a full disk, it will appear in that domain as a regular disk with 8 slices (s0 to s7). Such a disk is visible with the format(1m) command and its partition table can be changed using either the fmthard(1m) or format(1m) command.
A full disk will also be visible from the Solaris installer and can be selected as a disk device on which Solaris can be installed.
When a backend is exported to a domain as a single slice disk, it will appear in that domain as a disk with a single partition (s0). Such a disk is not visible with the format(1m) command and its partition table can not be changed.
A single slice disk will not be visible from the Solaris installer and can not be select as a disk device on which Solaris can be installed.
The virtual disk backend is the location where data of a virtual disk are effectively be stored. This backend can be a physical disk, a physical disk slice, a file or a volume (ZFS, SVM, VxVM...). The way a backend is exported (either as a full disk or as single slice disk) depends on the type of backend. Remember that it is not possible to install Solaris on a single slice disk.
| Backend | Export | Solaris Installation |
|---|---|---|
| Physical Disk | Full Disk | Possible |
| Physical Disk Slice | Single Slice Disk | Not Possible |
| File | Full Disk | Possible |
| Volume (ZFS, SVM, VxVM...) | Single Slice Disk* | Not Possible* |
(*) This will change once bug 6514091 (vDisk server should export volumes as full disks) is fixed.
Here is some additional information about each type of backend:
A physical disk is exported as a full disk. In that case, virtual disk drivers (vds and vdc) forward I/Os from the virtual disk and act as a pass-through to the physical disk.
A physical disk can be exported by exporting the slice 2 (s2) of the disk.
Example: exporting a physical disk as a virtual disk
To export the physical disk c1t48d0 as a virtual disk, we have to export the slice 2 of that disk (c1t48d0s2):
# ldm add-vdsdev /dev/dsk/c1t48d0s2 c1t48d0@primary-vds0
Once the disk is exported, it can be assigned to a domain. Here it is
assigned to the domain "test":
# ldm add-vdisk pdisk c1t48d0@primary-vds0 test
Finally the disk is accessible from the guest domain "test" as a full
disk (i.e. a regular disk with 8 slices); here the disk is accessible as c0d1:
# ls -1 /dev/dsk/c0d1s*
/dev/dsk/c0d1s0
/dev/dsk/c0d1s1
/dev/dsk/c0d1s2
/dev/dsk/c0d1s3
/dev/dsk/c0d1s4
/dev/dsk/c0d1s5
/dev/dsk/c0d1s6
/dev/dsk/c0d1s7
A physical disk slice is exported as a single slice disk. In that case, virtual disk drivers (vds and vdc) forward I/Os from the virtual disk and act as a pass-through to the physical disk slice.
Example: exporting a physical disk slice as a virtual disk
To export the slice 0 of the physical disk c1t57d0 as a virtual disk, we have to export the device corresponding to that slice (c1t57d0s0):
# ldm add-vdsdev /dev/dsk/c1t57d0s0 c1t57d0s0@primary-vds0
Once the disk is exported, it can be assigned to a domain. Here it is
assigned to the domain "test":
# ldm add-vdisk pslice c1t57d0s0@primary-vds0 test
Finally the disk is accessible from the guest domain "test" as a single
slice disk (i.e. a disk with only 1 slice: s0); here the disk is accessible
as c0d13:
# # ls -1 /dev/dsk/c0d13s*
/dev/dsk/c0d13s0
A file is exported as a full disk. In that case, virtual disk drivers (vds and vdc) forward I/Os from the virtual disk and manage the partitioning of the virtual disk. The file is eventually a disk image storing data of all slices of the virtual disk.
When a file is exported as a virtual disk and no partitionning information is stored into that file then the system will automatically write a default disk label into the file and define a default partionning with two slices (0 and 2) covering the entire disk. Note that this behavior will change once bug 6575050 (vds should support unformatted disks) is fixed.
Example: exporting a file as a virtual disk
To export the file /ldoms/domain/test/fdisk0 as a virtual disk, we first have to create it. The size of the file will define the size of the virtual disk. Here we create a 100mb blank file to get a 100mb virtual disk:
# mkfile 100m /ldoms/domain/test/fdisk0
Then the file can be directly exported as a virtual disk:
# ldm add-vdsdev /ldoms/domain/test/fdisk0 fdisk0@primary-vds0
Once the file is exported, it can be assigned to a domain. Here it is
assigned to the domain "test":
# ldm add-vdisk fdisk fdisk0@primary-vds0 test
Finally the disk is accessible from the guest domain "test" as a full
disk (i.e. a regular disk with 8 slices); here the disk is accessible as c0d5:
# ls -1 /dev/dsk/c0d5s*
/dev/dsk/c0d5s0
/dev/dsk/c0d5s1
/dev/dsk/c0d5s2
/dev/dsk/c0d5s3
/dev/dsk/c0d5s4
/dev/dsk/c0d5s5
/dev/dsk/c0d5s6
/dev/dsk/c0d5s7
A volume is exported as a single slice disk. In that case, virtual disk drivers (vds and vdc) forward I/Os from the virtual disk and act as a pass-through to the volume.
Example: exporting a ZFS volume as a virtual disk
To export the ZFS volume zdisk0 as a virtual disk, we first have to create it. The size of the volume will define the size of the virtual disk. Here we create a 100mb volume to get a 100mb virtual disk:
# zfs create -V 100m ldoms/domain/test/zdisk0
Then we have to export the device corresponding to that ZFS volume:
# ldm add-vdsdev /dev/zvol/dsk/ldoms/domain/test/zdisk0 zdisk0@primary-vds0
Once the volume is exported, it can be assigned to a domain. Here it is
assigned to the domain "test":
# ldm add-vdisk zdisk0 zdisk0@primary-vds0 test
Finally the disk is accessible from the guest domain "test" as a single slice disk
(i.e. a disk with only 1 slice: s0); here the disk is accessible as c0d9:
# ls -1 /dev/dsk/c0d9s*
/dev/dsk/c0d9s0
FAQ
You have probably only exported single slice disks (disk slices or volume). The Solaris installer does not handle single slice disks so it thinks that the system has no disk and the installation fails.
You need to export a full disk (a physical disk or a file) and start the installation again.
You can export a physical CDROM/DVD like you export a physical disk by exporting the slice 2 (s2) of the CDROM/DVD. However the exported CDROM/DVD will be seen as a regular disk and not as a CDROM/DVD, and you can access the content of the CDROM/DVD from Solaris but you can not boot from that CDROM/DVD.
As a consequence you can export a Solaris CDROM/DVD and but you can not use it to install Solaris by booting the exported CDROM/DVD. So you can not install a guest domain from a CDROM/DVD. This will be improved when bug 6434615 (vDisk needs to support booting/installing from DVDs) is fixed.
You are probably exporting as a virtual disk a backend that is not accessible or that can not be exported (for example a file that does not exist). On the service domain, check the /var/adm/messages file for any error messages from the vds driver. This should give you some hints about what is wrong with which backend.
For example, a message like this one:
vds: [ID 877446 kern.info] vd_setup_vd(): /ldoms/domain/test/fdisk/fdisk01 is currently inaccessible (error 2)means that /ldoms/domain/test/fdisk/fdisk01 can not be exported because it does not exist (error 2 = ENOENT = No such file or directory, see "man -s2 intro").
When you export a file as a virtual disk, you may want to access the content of the disk image when the guest domain is down and you may want to mount one of the slices defined in the disk image (i.e. in the file). Unfortunately this is currently not possible.
lofi is currently not able to deal with a disk image, and it will present the disk as a one slice. If a slice is defined at the beginning of the file (i.e. at offset 0 of the virtual disk) then you may be able to access that slice using lofi, but any other slice will be inaccessible. This should be improved once bug 4765069 (RFE: lofiadm should be VTOC aware) is fixed.
Currently the only way to access any slice of a disk image (file) is to create a guest domain, export the file as a virtual disk to that domain and access the corresponding slice of the virtual disk from the guest domain.
bug 6514091 reported as fixed. Is it only fixed in Opensolaris or also in Ldoms 1.0.1?
Posted by d K on February 21, 2008 at 12:19 PM PST #
Bug 6514091 is currently only fixed in OpenSolaris. It will also be fixed in the next Solaris 10 update (Solaris 10 update 5).
Posted by Alexandre Chartre on February 21, 2008 at 12:26 PM PST #