How to expand Xen virtual hard disk space by Linux

  

Xen virtual machine can be used for server application integration, software development testing, etc., and the application is more and more widely used, but in the process of using, there will be insufficient space of Xen virtual hard disk space. How to solve it? The following small series will introduce you to how to expand the space of Xen virtual hard disk, let's learn together.

The method herein is applicable to the case of image file ext2 and ext3 file system:

Close Virtual Machine:

code is as follows:

# /usr/sbin/xm shutdown vm01

Append 4GB to the virtual machine image file (.img):

The code is as follows:

# dd if=/dev/Zero bs=1024k count=4096 》》 /vm/vm01.img

Scan check image file:

The code is as follows:

# /sbin/e2fsck -f /vm /vm01.img

This time just increased the size of the image file (hard disk). This image file is not a normal file. It contains a loop file system that can be mounted/umount, so you need to adjust the file system size. Otherwise, If you enter the virtual machine, df will find that the hard disk size has not changed:

The code is as follows:

# /sbin/resize2fs /vm/vm01.img

Restart the Xen virtual machine :

The code is as follows:

# /usr/sbin/xm create vm01

After entering the virtual machine, check the hard disk size:

Code is as follows:

# /usr/sbin/xm console vm01

# df -h

Here is the mount/umount, say a little off topic, from technology In view, the current VPS is actually not safe, because the VPS service provider can mount/umount your virtual machine files, partitions, and even write content at any time. If the root password of the server where your virtual machine is located is If the bad guys get it, then there is no security at all, and the bad guys can do whatever they want on your virtual machine. So security is a big problem in cloud computing, especially those that are built on virtual technologies. This may also be the reason why companies are reluctant to use public clouds. Some Startups just put unimportant data. On cloud storage like Amazon S3, it's better to keep confidential data for yourself. Therefore, VPSee believes that private clouds will have more room for development.

The above is a way to expand the Xen virtual hard disk space by Linux. Modifying the size of the Xen virtual hard disk is equivalent to modifying the size of the Xen image file, which can add 4 GB of space.

Copyright © Windows knowledge All Rights Reserved