XenServer – Creating a local ISO repository

Starting a new job, I’m essentially starting from scratch, as far as development infrastructure goes – The live sites are hosted on a cpanel server with ftp access only – so debugging is basically a moot point – and there have been no development sites for quite a while – it’s a simple case of edit in dreamweaver/eclipse/zend studio/etc and FTP up and ‘see how it goes’ – so it’s either sync up the dev sites from current codebase, or start them from scratch with something a little more industry-standard.  Granted these are much smaller projects than my previous jobs, but they have the potential to still need multiple developers committing source changes, etc, in the somewhat near future.  So the current ftp-the-changes-up-to-the-server just won’t cut it.   My first step is running up a quick XenServer install, and bringing up a few VM’s for Subversion, LAMP, Jira, etc.  yes, they could all run on one, but if there’s one thing I’ve learnt of the years, it’s keep your environments separated.  Especially source control from development!

The environment here isn’t big enough to justify anything like I have in my small hosting business, with a SAN-backed XenServer cluster with HA licensing etc.  So a standalone XS server it is.  15 mins after finding a spare monitor, I had XenServer running.  And that’s about where I went ‘oh, bugger, ISO repository!’ – That’s right, there’s no fileserver in this office at present, so a-googling I went!

As it turned out, it wasn’t too bad at all 🙂  We basically create a small volume in LVM, mounted it, and add it as an ISO Storage Repository.

First up, get the name of the Volume Group

# pvscan
  PV /dev/sda3   VG VG_XenStorage-c0972b3b-ef4a-346f-42d2-8ddae19499da   lvm2 [690.62 GB / 690.61 GB free]
  Total: 1 [690.62 GB] / in use: 1 [690.62 GB] / in no VG: 0 [0   ]

Ok, so in this case, our VG is VG_XenStorage-c0972b3b-ef4a-346f-42d2-8ddae19499da. Now we want to create a Logical Volume.  I made it 40GB – if I was running small SCSI/SAS disks, I’d probably have made it smaller, but this box has a 750gb SATA disk.

[root@xenserver01 ~]# lvcreate -L 40G -n ISO VG_XenStorage-c0972b3b-ef4a-346f-42d2-8ddae19499da
  Logical volume "ISO" created

And of course, format it.  I use ext2 for anything ‘basic’, as I don’t need journalling, and I like my performance, especially in a SAN environment.  Not that that’s an issue here with a local disk, but it’s a good habit to form 😉

[root@xenserver01 ~]# mkfs.ext2 /dev/VG_XenStorage-c0972b3b-ef4a-346f-42d2-8ddae19499da/ISO 
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
5242880 inodes, 10485760 blocks
524288 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
320 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, 7962624
Writing inode tables: done                            
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

Well, that was easy. Let’s make a new directory to mount the LV.

[root@xenserver01 ~]# mkdir /mnt/iso_import

Mount the Storage Repository. Make sure that all Volume Groups are active, mount it, and attach it as a storage repository..

[root@xenserver01 ~]# vgchange -a y
  3 logical volume(s) in volume group "VG_XenStorage-c0972b3b-ef4a-346f-42d2-8ddae19499da" now active
[root@xenserver01 ~]# mount /dev/VG_XenStorage-c0972b3b-ef4a-346f-42d2-8ddae19499da/ISO  /mnt/iso_import/
[root@xenserver01 xen]# xe-mount-iso-sr /mnt/iso_import -o bind

Sweet, and make it come up at boot!

[root@xenserver01 ~]# cat >> /etc/rc.local << __END__
vgchange -a y
mount /dev/VG_XenStorage-c0972b3b-ef4a-346f-42d2-8ddae19499da/ISO  /mnt/iso_import/
xe-mount-iso-sr /mnt/iso_import -o bind
__END__

And we’re done!

Oh, and obviously, scp some isos to it! 🙂

Published by Damien Gardner

My Google Profile+

Join the Conversation

1 Comment

Leave a comment