Grant McWilliams

Tech Virtualization Xenserver Howtos Create an LVM CD repository

Create an LVM CD repository

 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 local Logical Volume.

First we need to know the name of the LVM Volume Group. This is taken from the Storage Repository's UUID. To get this we'll use xe host-list. 

[root@cloud1 ~]# xe sr-list type=lvm
uuid ( RO)                : 36bf480a-5df9-4453-50f0-2bac4a86cb42
          name-label ( RW): localsr-cloud1
    name-description ( RW): 
                host ( RO): cloud1.acs.edcc.edu
                type ( RO): lvm
        content-type ( RO): user

Using xe sr-list type=lvm shows only our local Storage Repository which has the UUID of 36bf480a-5df9-4453-50f0-2bac4a86cb42. We'll now use the vgs command to give us the names of all Volume Groups including VG_XenStorage-36bf480a-5df9-4453-50f0-2bac4a86cb42 which matches our SR UUID.

 

[root@cloud1 ~]# vgs
  VG                                                 #PV #LV #SN Attr   VSize   VFree  
  VG_XenStorage-25d1bb9d-193a-78f4-ba74-24aa6c14baf7   1  62   0 wz--n- 223.55G 193.07G
  VG_XenStorage-36bf480a-5df9-4453-50f0-2bac4a86cb42   1   2   0 wz--n- 923.50G 723.50G

 

We want to note that our Volume Group has 723.50 GB of space free. 

 

[root@cloud1 ~]# lvcreate -L 20G -n LVMISO VG_XenStorage-36bf480a-5df9-4453-50f0-2bac4a86cb42
  Logical volume "LVMISO" created

 

[root@cloud1 ~]# lvs 
 LV                         VG                                                 Attr   LSize   
  LVLOCAL                   VG_XenStorage-36bf480a-5df9-4453-50f0-2bac4a86cb42 -wi--- 200.00G                                      
  LVMISO                    VG_XenStorage-36bf480a-5df9-4453-50f0-2bac4a86cb42 -wi-a-  20.00G                                      
  MGT                       VG_XenStorage-36bf480a-5df9-4453-50f0-2bac4a86cb42 -wi---   4.00M                                      

 

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

[root@cloud1 ~]# mkfs -t ext3 /dev/VG_XenStorage-36bf480a-5df9-4453-50f0-2bac4a86cb42/LVMISO 
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 LVMISO mountpoint.

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

 

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/VG_XenStorage-36bf480a-5df9-4453-50f0-2bac4a86cb42/LVMISO  /media/LVMISO   ext3    defaults 0 0

 

Mount the Logical Volume and verify it's mounted using df.

 

[root@cloud1 ~]# mount /media/LVMISO/
[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/mapper/VG_XenStorage--36bf480a--5df9--4453--50f0--2bac4a86cb42-LVMISO
                      20642428    176200  19417652   1% /media/LVMISO

 

 

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

 

xe sr-create name-label="LVM ISO" type=iso \
 device-config:location=/media/LVMISO/ \ 
 evice-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): LVM 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/LVMISO) and use wget to download the iso file.

 

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

 

Verify that XCP sees it using xe cd-list. 

 

[root@cloud1 LVMISO]# 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/LVMISO directory.