Operating System - Linux
1753536 Members
6623 Online
108795 Solutions
New Discussion юеВ

Re: Hot Adding Disk to Virtualized Guest

 
SOLVED
Go to solution
Eric Singer
Frequent Advisor

Hot Adding Disk to Virtualized Guest

This year one of my projects is to move our production application environment into a VM. One of the problems I've foreseen using our current Xen based Virutalization is that I can not add a disk into a running Guest VM. So far the only way I've been able to add disks to any of our guest VMs is to shut them down, add the disks to the configuration file and start the VM.

Our current traditional server based environment allows me to add disks on the fly, but I haven't seen a Linux virtualization solution that will allow this.

Does anyone know how to add disks hot into a Xen guest, or does the new KVM based virtualization allow you to do this?

Thanks
Eric Singer
7 REPLIES 7
Steven E. Protter
Exalted Contributor

Re: Hot Adding Disk to Virtualized Guest

Shalom Eric,

Every solution I've seen requires you to down the system before adding disk.

If your system has access to a Fiber Channel adapter, a LUN can be presented to the World Wide Name (WWN) of the Fiber Channel adapter and additional space may be able to be added via LVM without a boot.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Eric Singer
Frequent Advisor

Re: Hot Adding Disk to Virtualized Guest


We are using Fiber Channel adapters to our servers. Adding and removing disks to Dom0 by way of SCSI bus scans is pretty easy, however adding that disk to a running DomU is problematic.

In today├в s non-virtual environment I do not have to bring down our production environment to add diskspace. Just presented the LUN and scan the scsi bus, no downtime taken and nobody notices a thing. I├в d very much like that in our new virtual environment.

Thanks
J. Maestre
Honored Contributor
Solution

Re: Hot Adding Disk to Virtualized Guest

Apparently you can to that with the "xm block-attach" command.

Eric Singer
Frequent Advisor

Re: Hot Adding Disk to Virtualized Guest

Thank you very much! I'll test that out.
westb
Advisor

Re: Hot Adding Disk to Virtualized Guest

This is what we do:
1. Create a new lun, get the WWN and create an entry in /etc/multipath.conf. Use friendly names, easier to keep track of things.
2. Present the new lun to dom0
3. On dom0, scan for the new disk using:
echo "- - -" > /sys/class/scsi_host/host0/scan
echo "- - -" > /sys/class/scsi_host/host1/scan
4. Attach the new disk to the running domU using:
xm block-attach domU_name phy:/dev/mapper/new_disk xvdm w

In this example, the new disk on the domU will be named xvdm. Then you can put it into an existing VG and dynamically grow a filesystem.

There are a couple of gotchas using this method:
1. You need to modify the domU config file and add in the new disk or it won't be there the next time you start it.
2. Attaching the new disk using xm is not very forgiving; i.e. wrong disk name, attach wrong disk etc. You can also do this with virt-manager and also using virsh.

Eric Singer
Frequent Advisor

Re: Hot Adding Disk to Virtualized Guest

Fantastic! I was able to hot add and remove a test disk.

[root@rllxovf5 ~]# xm block-attach 426_rloveric phy:/dev/mapper/Eric_Test_Disk1 sda w

[root@rloveric ~]# mkfs -t ext3 /dev/sda1
[root@rloveric ~]# mkdir /test
[root@rloveric ~]# mount /dev/sda1 /test
[root@rloveric ~]# umount /test

[root@rllxovf5 ~]# xm block-detach 426_rloveric sda

Thank you for all your help!
Eric Singer
Eric Singer
Frequent Advisor

Re: Hot Adding Disk to Virtualized Guest

Solution Found, closing thread.