How to add a secondary hard disk to Xen DomU

If you would like to add a secondary hard disk to a guest VM (i.e., domU) on Xen, you can do the following.

First, create a disk image for the secondary hard disk on dom0, as follows:

$ sudo dd if=/dev/zero of=/vm/dfs2-disk2.img bs=1024k count=10000

Then edit Xen configuration for the domU guest VM to include the hard disk.

$ vi DomU-config-file
disk = ['file:/vm/dfs1.img,xvda,w','file:/vm/dfs1-disk2.img,xvdb,w']

Next, power on and boot into the guest VM.

Finally, you need to make the newly attached hard disk available to the guest VM by formatting and mounting it.

$ sudo mkfs.ext3 /dev/xvdb

$ sudo vi /etc/fstab
/dev/xvdb /mnt ext3 defaults 0 0
$ sudo mount -a

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

The following two tabs change content below.
Dan Nanni is the founder and also a regular contributor of Xmodulo.com. He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.
Your name can also be listed here. Write for us as a freelancer.

Leave a comment

Your email address will not be published. Required fields are marked *