The filesystem content (VDSmanager)
From ISPWiki
Contents |
filesystem content (VDSmanager)
The filesystem file is located in the directory that holds the virtual machine. The file format:
line with the hard drives' images (up to four lines)
drive=type:name:size:resize-type
- drive - hard drive, such as hda, hdb, hdc or hdd.
- type - image type or creation method.
- img - pre-defined image-file connected to the machine.
- lvm - LVM-disk.
- new - you need to create an image and connect it to the virtual machine. It can have img or kvm type, depending on the settings and available disk space.
- tar - create a new disk and paste the content of the name archive.
- name - image name. Once the filesystem file has been processed (disks have been created, etc.), the image name will renew and include a path.
- size - if a root disk is created, this will be the minimal image size. If not, this is the image size.
- resize-type - type of the disk resizing.
- с - create a required disk and paste the content of the old one.
- n - the size cannot be altered.
- r - changing the file size (or the lvm-device). The file system must be resized with user privileges.
Example
hdb=new:NAME:5000:n
A 5000 MB virtual hard drive will be created. Its size cannot be altered.
Connecting an iso-image
cdrom=/path/to/cdrom.iso
Please note, that cdrom is connected as secondary master disk, thus the hdc-disk and cdrom disks cannot be used together.
Booting
boot=c
Booting from the first hard drive
boot=d
Booting from с cd-rom The latest versions of ofqemu-kvm allow you to set priority and call the boot menu (see man qemu)
Root partition
This parameter is used for configuring the settings and changing image size.
root=hda
Creating disk templates for KVM (VDSmanager)
To convert a KVM-based virtual machine into a template
- Follow the procedures below
- Copy the template content to the directory that holds the virtual machine (normally, /kvm/machines/NAME/ )
- Execute the /kvm/machines/NAME/install script (a parameter is a path to the directory with virtual machine)
- Process the file filesystem
- Create the net.conf with parameters file
- Execute the network_conf script
- Execute the setpass script
- You need to know the following scripts for setting up the network and root password.
- network_conf - configuring the network. Parameters that are transferred to the script
- $1 - path to the virtual machine directory
- $2 - path to the catalogue with the root image
- setpass - setting up the root passwords. Parameters:
- $1 - path to the virtual machine directory
- $2 - path to the catalogue with the root image
- $3 - root hash password
- network_conf - configuring the network. Parameters that are transferred to the script
- To run the configuration scripts, the file system must be "known" to the images , for example, ext2 or ext3
If the network_conf or setpass files are missing, VDSmanager will copy the template and try to alter the hard drive image size.
For the system to boot correctly, two hard drivers are installed: the first disk is a boot drive with the mounting point /boot, the second disk is the main drive with the mounting point /.
For example, we have created a VPS with two hard drives, such as hda - /kvm/machines/test.com/10.1.1.2_boot.img 200 MB in size and hdb - /kvm/machines/test.ru/10.1.1.2 4Gb in size. Its name is test.com, the IP-address is 10.1.1.2. The operating system is Fedora-12-i386.
Once the system has been installed, you need to make it work as a template
- Edit /boot/grub/grub.conf, /etc/fstab
- Disable selinux
Please note, that a hard drive partition created during the installation process will be called /dev/sdb1 If you wish to create partitions through VDSmanager and change their size, you need to change /dev/sdb1 into /dev/sdb in the guest system.
Mount the root disk image to the /tmp/mnt directory
mount -o loop,offset=32256 /kvm/machines/test.ru/10.1.1.2 /tmp/mnt
The offset parameter defines the address of the partition's beginning (normally, this is sector 63, a sector size is 512 byte). Run the command below to learn information about partitions
fdisk -lu /kvm/machines/test.ru/10.1.1.2
If the partition was created through VDSmanager, you do not need to provide the parameter.
Archive the disk content:
tar -czpf /kvm/machines/test.ru/root.tgz -C /tmp/mnt .
umount /tmp/mnt
Create a directory for the template
mkdir /kvm/template/TEMPLATE-NAME
Copy the machine into that directory
cp /kvm/machines/test.ru/* /kvm/template/TEMPLATE-NAME
Delete the old disk
rm /kvm/template/TEMPLATE-NAME/10.1.1.2
Rename
mv /kvm/template/TEMPLATE-NAME/10.1.1.2_boot /kvm/machines/test.ru/boot.img
if the boot partition for our machine is created as lvm, add the command
dd if=/dev/kvm00/10.1.1.2_boot of=/kvm/template/TEMPLATE-NAME/boot.img
Archive
tar -czf /kvm/template/TEMPLATE-NAME/image /kvm/template/TEMPLATE-NAME/boot.img /kvm/template/TEMPLATE-NAME/root.tgz
Delete:
rm /kvm/template/TEMPLATE-NAME/boot.img /kvm/template/TEMPLATE-NAME/root.tgz
Delete the old machine from VDSmanager
Edit the filesystem file:
hda=img:boot.img:200:n hdb=tar:root.tgz:2000:c boot=c root=hdb
Add
tar -xzf $1/image -C $1 rm $1/image
Edit /usr/local/ispmgr/etc/vdsmgr.conf add the lines below
disktemplate "TEMPLATE-NAME" {
Path /kvm/template/TEMPLATE-NAME
Status ok
}
The template is ready.
