Add new virtual disk in XEN \"hot\
It is usual that after several years the space forecasts in a virtual machine are exceeded, in many cases because the project for which it has been destined is being a success and requires a larger storage size. What in principle may be a joy, also involves extra effort, since if the machine is in production, and we have more users, it means that we cannot turn off the machine for an hour to perform maintenance tasks. Thanks to XEN we can change the virtual hard disk without having excessive problems
This task can be performed with virtual disks as an .img file or with LVM, this last option being the one we are going to discuss below:
lvcreate -L 20GB -n machineHD2 vg
We format with the file system we want, in our case ext3:
mkfs -t ext3 machineHD2
Once the new disk is created, we have to attach it to the virtual machine, that is, hot plugging. To do this we execute the following command:
xm block-attach web phy:/dev/vg/maquinaHD2 /dev/hdb1 w
At this point we already have the machine with one more disk in DomU. The next step is to modify the machine configuration so that it is added automatically when it starts. If for example we have something similar to:
disk = [ “phy:/dev/vg/maquinaHD,hda,w”]
We add the new machineHD2 disk as an hdb drive:
disk = [ “phy:/dev/vg/web.img,hda,w”, “phy:/dev/vg/maquinaHD2,hdb,w” ]
After this, we only need to edit the /etc/fstab file so that it is automatically mounted at each boot and mount the new device. And if necessary, migrate the relevant data.