Ldom with ZFS
Logical Domains offers a powerful and consistent methodology for creating virtualized server environments across the entire CoolThreads server range:
* Create multiple independent virtual machines quickly and easily
using the hypervisor built into every CoolThreads system.
* Leverage advanced Solaris technologies such as ZFS cloning and
snapshots to speed deployment and dramatically reduce disk
capacity requirements.
In this entry I will demonstrate the integration between Ldom and ZFS
Architecture layout

Downloading Logical Domains Manager and Solaris Security Toolkit
Download the Software
Download the zip file (LDoms_Manager-1_1.zip) from the Sun Software Download site. You can find the software from this web site:
http://www.sun.com/ldoms
Unzip the zip file.
# unzip LDoms_Manager-1_1.zip
Please read the REDME file for any prerequisite
The installation script is part of the SUNWldm package and is in the Install subdirectory.
# cd LDoms_Manager-1_1
Run the install-ldm installation script with no options.
# Install/install-ldm
Select a security profile from this list:
a) Hardened Solaris configuration for LDoms (recommended)
b) Standard Solaris configuration
c) Your custom-defined Solaris security configuration profile
Enter a, b, or c [a]: a
Shut down and reboot your server
# /usr/sbin/shutdown -y -g0 -i6
Use the ldm list command to verify that the Logical Domains Manager is running
# /opt/SUNWldm/bin/ldm list
NAME STATE FLAGS CONS VCPU MEMORY UTIL UPTIME
primary active -n-c-- SP 32 16256M 0.0% 2d 23h 27m
Creating Default Services
You must create the following virtual default services initially to be able to use them later:
vdiskserver – virtual disk server
vswitch – virtual switch service
vconscon – virtual console concentrator service
Create a virtual disk server (vds) to allow importing virtual disks into a logical domain.
# ldm add-vds primary-vds0 primary
Create a virtual console concentrator (vcc) service for use by the virtual network terminal server daemon (vntsd)
# ldm add-vcc port-range=5000-5100 primary-vcc0 primary
Create a virtual switch service
(vsw) to enable networking between virtual network
(vnet) devices in logical domains
# ldm add-vsw net-dev=e1000g0 primary-vsw0 primary
Verify the services have been created by using the list-services subcommand.
# ldm list-services
Set Up the Control Domain
Assign cryptographic resources to the control domain.
# ldm set-mau 1 primary
Assign virtual CPUs to the control domain.
# ldm set-vcpu 4 primary
Assign memory to the control domain.
# ldm set-memory 4G primary
Add a logical domain machine configuration to the system controller (SC).
# ldm add-config initial
Verify that the configuration is ready to be used at the next reboot
# ldm list-config
factory-default
initial [next poweron]
Reboot the server
# shutdown -y -g0 -i6
Enable the virtual network terminal server daemon, vntsd
# svcadm enable vntsd
Create the zpool
# zpool create ldompool c1t2d0 c1t3d0
# zfs create ldompool/goldimage
# zfs create -V 15g ldompool/goldimage/disk_image
Creating and Starting a Guest Domain
Create a logical domain.
# ldm add-domain goldldom
Add CPUs to the guest domain.
ldm add-vcpu 4 goldldom
Add memory to the guest domain
# ldm add-memory 2G goldldom
Add a virtual network deviceto the guest domain.
# ldm add-vnet vnet1 primary-vsw0 goldldom
Specify the device to be exported by the virtual disk server as a virtual disk to the guest domain
# ldm add-vdsdev /dev/zvol/dsk/ldompool/goldimage/disk_image vol1@primary-vds0
Add a virtual disk to the guest domain.
# ldm add-vdisk vdisk0 vol1@primary-vds0 goldldom
Set auto-boot and boot-device variables for the guest domain
# ldm set-variable auto-boot\?=false goldldom
# ldm set-var boot-device=vdisk0 goldldom
Bind resources to the guest domain goldldom and then list the domain to verify that it is bound.
# ldm bind-domain goldldom
# ldm list-domain goldldom
NAME STATE FLAGS CONS VCPU MEMORY UTIL UPTIME
primary active -n-cv- SP 4 4G 0.2% 15m
goldldom bound ------ 5000 4 2G
Start the guest domain
# ldm start-domain goldldom
Connect to the console of a guest domain
# telnet 0 5000
Trying 0.0.0.0...
Connected to 0.
Escape character is '^]'.
Connecting to console "goldldom" in group "goldldom" ....
Press ~? for control options ..
{0} ok
Jump-Start the goldldom
{0} ok boot net - install
We can login to the new guest and verify that the file system is zfs
# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
rpool 14.9G 1.72G 13.2G 11% ONLINE -
Restore the goldldom configuration to an "as-manufactured" state with the sys-unconfig command
# sys-unconfig
This program will unconfigure your system. It will cause it
to revert to a "blank" system - it will not have a name or know
about other systems or networks.
This program will also halt the system.
Do you want to continue (y/n) y
Press ~. in order to return to the primary domain
Stop the guest domain
# ldm stop goldldom
Unbind the guest domain
# ldm unbind goldldom
Snap shot the disk image
# zfs snapshot ldompool/goldimage/disk_image@sysunconfig
Create new zfs file system for the new guest
# zfs create ldompool/domain1
Clone the goldldom disk image
# zfs clone ldompool/goldimage/disk_image@sysunconfig ldompool/domain1/disk_image
# zfs list
NAME USED AVAIL REFER MOUNTPOINT
ldompool 17.0G 117G 21K /ldompool
ldompool/domain1 18K 117G 18K /ldompool/domain1
ldompool/domain1/disk_image 0 117G 2.01G -
ldompool/goldimage 17.0G 117G 18K /ldompool/goldimage
ldompool/goldimage/disk_image 17.0G 132G 2.01G -
ldompool/goldimage/disk_image@sysunconfig 0 - 2.01G -
Creating and Starting the second Domain
# ldm add-domain domain1
# ldm add-vcpu 4 domain1
# ldm add-memory 2G domain1
# ldm add-vnet vnet1 primary-vsw0 domain1
# ldm add-vdsdev /dev/zvol/dsk/ldompool/domain1/disk_image vol2@primary-vds0
# ldm add-vdisk vdisk1 vol2@primary-vds0 domain1
# ldm set-var auto-boot\?=false domain1
# ldm set-var boot-device=vdisk1 domain1
# ldm bind-domain domain1
# ldm list-domain domain1
NAME STATE FLAGS CONS VCPU MEMORY UTIL UPTIME
domain1 bound ------ 5001 8 2G
Start the domain
# ldm start-domain domain1
Connect to the console
# telnet 0 5001
{0} ok boot net -s
Copyright 1983-2008 Sun Microsystems, Inc. All rights reserved.
Use is subject to license terms.
Booting to milestone "milestone/single-user:default".
Configuring devices.
Using RPC Bootparams for network configuration information.
Attempting to configure interface vnet0...
Configured interface vnet0
Requesting System Maintenance Mode
SINGLE USER MODE
# zpool import -f rpool
# zpool export rpool
# reboot
Answer the configuration questions
Login to the new domain and verify that we have zfs file system
# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
rpool 14.9G 1.72G 13.2G 11% ONLINE -
Personally I don't feel very happy with 'zfs clone' as it makes you dependant of the master snapshot which you cannot remove. For ultimate flexibility, I recommend to use the combination of 'zfs send | zfs receive'
Posted by Dominik Frey on April 20, 2009 at 01:08 PM IDT #
I think the point of the clone is that it saves you disk space so you can get more ldoms for your buck.
Posted by Richard on April 28, 2009 at 11:38 AM IDT #
But i tried with zfs send | receive and i got following error when i added the destination disk as vdisk in my LDOM
Boot device: /virtual-devices@100/channel-devices@200/disk@0:a File and args:
SunOS Release 5.10 Version Generic_138888-05 64-bit
Copyright 1983-2008 Sun Microsystems, Inc. All rights reserved.
Use is subject to license terms.
NOTICE:
***************************************************
* This device is not bootable! *
* It is either offlined or detached or faulted. *
* Please try to boot from a different device. *
***************************************************
NOTICE:
spa_import_rootpool: error 22
Cannot mount root on /virtual-devices@100/channel-devices@200/disk@0:a fstype zfs
panic[cpu0]/thread=180e000: vfs_mountroot: cannot mount root
Posted by Fugitive on August 07, 2009 at 01:20 PM IDT #