Prerequisites 

  • XCP/Xenserver

 Utilizing an ISO image in a VM's cdrom drive is fairly easy to do but because of the limited size of the Control Domain's (dom0) operating system partition it's difficult to download ISO images to /opt/xensource/packages/iso and it isn't really recommended to put them there anyway. In this tutorial we'll create a CD repository using an additional hard drive on Dom0.

First we need to know the device name of the disk. 

[root@cloud1 media]# cat /proc/partitions 
major minor  #blocks  name
   8        0  976762584 sda
   8        1    4194304 sda1
   8        2    4194304 sda2
   8        3  968371393 sda3
   8       16  234431064 sdb

 

Our new drive is /dev/sdb. We can see it doesn't have a partition on it otherwise it would be named /dev/sdb1. We don't know however, if it's being used by LVM so we'll check that with the pvs command. The pvs command shows if it's been used for LVM. Since it doesn't show up we can procede. 

[root@cloud1 media]# pvs
  PV         VG                                                 Fmt  Attr PSize   PFree  
  /dev/sda3  VG_XenStorage-36bf480a-5df9-4453-50f0-2bac4a86cb42 lvm2 a-   923.50G 703.50G

 

Use fdisk to add a partition to the drive and then check it again by catting /proc/partitions.  (step not shown)

 

[root@cloud1 media]# cat /proc/partitions 
major minor  #blocks  name

   8        0  976762584 sda
   8        1    4194304 sda1
   8        2    4194304 sda2
   8        3  968371393 sda3
   8       16  234431064 sdb
   8       17  234428481 sdb1

 

Now that we have our partition we need to format it with the ext3 filesystem.  

[root@cloud1 ~]# mkfs -t ext3 /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)<
2621440 inodes, 5242880 blocks
262144 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
160 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks: 
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
4096000

Writing inode tables: done                           
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 22 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

 Now we need to make our EXTISO mountpoint.

[root@cloud1 ~]# mkdir /media/EXTISO

 

Add the entry to the fstab so it will be mounted on bootup. The following line for this tutorial should be added to the /etc/fstab using your favorite text editor.

 

/dev/sdb1  /media/EXTISO   ext3    defaults 0 0

 

Mount the partition and verify it's mounted using df.

 

[root@cloud1 ~]# mount /media/EXTISO/
[root@cloud1 ~]# df Filesystem           1K-blocks      Used Available Use% Mounted on /dev/sda1              4128448   2012164   1906572  52% / none                    524444         0    524444   0% /dev/shm /dev/sdb1            20642428    176200  19417652   1% /media/EXTISO

  

Create the iso Storage Repository using the /media/EXTISO location. 

 

xe sr-create name-label="EXT ISO" type=iso \
 device-config:location=/media/EXTISO/ \ 
device-config:legacy_mode=true content-type=iso

 

Verify that the Storage Repository was created and is type iso. 

[root@cloud1 ~]# xe sr-list type=iso
uuid ( RO)                : 5dddd3c4-96bf-e316-2c84-8f4c80684d31
          name-label ( RW):EXT ISO
    name-description ( RW): 
                host ( RO): cloud1.acs.edcc.edu
                type ( RO): iso
        content-type ( RO): iso

 

Now we need to download an ISO disk for use in a VM. For this purpose we'll download the CentOS 6.3 Live DVD. Cd into your new Storage Repository directory (/media/EXTISO) and use wget to download the iso file.

 

[root@cloud1 ~]# cd /media/EXTISO 
[root@cloud1 EXTISO]# wget http://mirror.flhsi.com/centos/6.3/isos/x86_64/CentOS-6.3-x86_64-LiveDVD.iso [root@cloud1 EXTISO]# xe sr-scan uuid=5dddd3c4-96bf-e316-2c84-8f4c80684d31

 

Verify that XCP sees it using xe cd-list. 

 

[root@cloud1 EXTISO]# xe cd-list
uuid ( RO)          : 0549c68a-e38d-4cd8-9974-ba0b9167ff5a
    name-label ( RW): CentOS-6.3-x86_64-LiveCD.iso

 

The CentOS-6.3 iso disk is now available to be plugged into a VM. Anytime you want to make another ISO image available just download them into the /media/EXTISO directory.