Xen 
 
Home Products Support Community News
 
   

You have a bunch of choices:

  1. Download KnownGoodImages

  2. Install the OS on a real disk and then dd the image or use phy:<path> instead of file:<path>

  3. Use qemu to install one (~ 30 mins for a minimal install)

  4. Create your own (fun!)
  5. Install a normal Linux OS on host machine
    • The host OS files will be copied to guest OS image. Here we assume the Linux OS is installed on /dev/hda2
  6. Create image file
    • The image size should be big enough to accommodate entire OS. Here we assume the size is 1G

# dd if=/dev/zero of=hd.img bs=1M count=1 seek=1024
  • Make the partition table
    • The image file will be treated as harddisk, so make partition table on the image file.

# losetup /dev/loop0 hd.img
# fdisk /dev/loop0
press 'n' to add new partition
press 'p' to choose primary partition
press '1' to set partition number
press "Enter" keys to choose default value of "First Cylinder" parameter.
press "Enter" keys to choose default value of "Last Cylinder" parameter.
press 'w' to write partition table and exit
# losetup -d /dev/loop0
  • Make file system and install grub

# ln -s /dev/loop0 /dev/loop
# losetup /dev/loop0 hd.img
# losetup -o 32256 /dev/loop1 hd.img
# mkfs.ext3 /dev/loop1
# mount /dev/loop1 /mnt
# mkdir -p /mnt/boot/grub
# cp /boot/grub/stage? /boot/grub/e2fs_stage1_5 /mnt/boot/grub
# umount /mnt
# grub
grub> device (hd0) /dev/loop
grub> root (hd0,0)
grub> setup (hd0)
grub> quit
# rm /dev/loop
# losetup -d /dev/loop0
# losetup -d /dev/loop1

  • The option "-o 32256" of losetup is to skip the partition table in the image file.

    We need /dev/loop because grub is expecting a disk device name, where name represents the entire disk and name1 represents the first partition.

  • Copy OS files to image

# mkdir -p /mnt/host
# mount /dev/hda2 /mnt/host
# mkdir -p /mnt/guest
# losetup -o 32256 /dev/loop0 hd.img
# mount /dev/loop0 /mnt/guest
# cp -ax /mnt/host/{root,dev,var,etc,usr,bin,sbin,lib} /mnt/guest
# mkdir /mnt/guest/{proc,sys,home,tmp}
# umount /mnt/host 
  • Edit the /etc/fstab of guest image. Usually, the fstab should look like this

# vim /mnt/guest/etc/fstab
/dev/hda1               /                       ext3    defaults 1 1
none                    /dev/pts                devpts  gid=5,mode=620 0 0
none                    /dev/shm                tmpfs   defaults 0 0
none                    /proc                   proc    defaults 0 0
none                    /sys                    sysfs   defaults 0 0
  • umount image file

# umount /mnt/guest
# losetup -d /dev/loop0

Now, the guest OS image hd.img is ready. We normally test that the guest image works ok using qemu

InstallGuestImage (last edited 2005-08-10 01:42:39 by ArunSharma)