Jump to content


Photo

Local ISO Repository

Started by Andrew Odom , 23 December 2009 - 12:13 AM
11 replies to this topic

Andrew Odom Members

Andrew Odom
  • 3 posts

Posted 23 December 2009 - 12:13 AM

I was very irritated when I discovered that XenServer did not have a local ISO repository option (like many of its competitors), and that in order for me to store my ISO's on the server I would need a CIFS or NFS guest to hold them.

I started doing research on how to implement this behind the scenes and I got everything working and figured I'd share. I'd like to credit two sources which gave me the ideas. WIKI Post

Note, these changes are UNSUPPORTED and only tested on ONE BOX. You have been warned.

I started out with a fresh LVM Storage Repository.

1. Do a scan of LVM and get the VG name of your drive
\# pvscan
PV /dev/9VS0ZEVB-5:0:0:0 VG XSLocalEXT-9bfee586-ecb0-94cc-1ef7-20c372bb673a lvm2 [1.36 TB / 0 free]
...
PV /dev/HDT7210 VG VG_XenStorage-90d06e03-18b9-7918-e2df-8210727d52e1 lvm2 [931.50 GB / 731.50 GB free]
Total: 5 [4.55 TB\] / in use: 5 \[4.55 TB\] / in no VG: 0 \[0 ]

2. Create the volume on the volume group (put your VG_ id instead of mine)
\# lvcreate -L 75G -n LinuxISO VG_XenStorage-90d06e03-18b9-7918-e2df-8210727d52e1

3. Doing a lvscan will give you the logical volumes ID:
\# lvscan
ACTIVE '/dev/XSLocalEXT-9bfee586-ecb0-94cc-1ef7-20c372bb673a/9bfee586-ecb0-94cc-1ef7-20c372bb673a' [1.36 TB] inherit
...
inactive '/dev/VG_XenStorage-90d06e03-18b9-7918-e2df-8210727d52e1/MGT' [4.00 MB] inherit
inactive '/dev/VG_XenStorage-90d06e03-18b9-7918-e2df-8210727d52e1/LinuxISO' [75.00 GB] inherit

4. Create your filesystem (use your device name above) (I prefer ext2 over ext3 since we don't really need the journaling)
\# mkfs.ext2 /dev/VG_XenStorage-90d06e03-18b9-7918-e2df-8210727d52e1/LinuxISO
OR
\# mkfs.ext3 /dev/VG_XenStorage-90d06e03-18b9-7918-e2df-8210727d52e1/LinuxISO

5. Create the mount folder, and also the link to the xen folder.
\# mkdir /mnt/iso_linux
\# ln -s /mnt/iso_linux /var/opt/xen/
*NOTE:* As a linux guru I thought "Why the heck would I need this?! Why not just mount it to /var/opt/xen/iso_linux." BAD IDEA. Xen, for some reason, attempts to mount/unmount that folder when you do anything with the SR or PBD. I ran into several issues where the PBD refresh would unmount the ISO folder, causing all the ISOs to be orphaned in XenCenter. You're better off tricking Xen into thinking the isos are actually on the root volume by symlinking it. Trust me :)

6. Add this line to your /etc/fstab using nano or vi (use your device names above for the first parameter)
/dev/VG_XenStorage-90d06e03-18b9-7918-e2df-8210727d52e1/LinuxISO /mnt/iso_linux ext2 noauto 0 0

7. Add the following text to the end of the file /etc/rc.local
vgchange -a y
mount /mnt/iso_linux

8. Two options here: reboot or execute /etc/rc.local

9. Now create the storage repositories:
\# xe sr-create name-label=ISO_Linux type=iso device-config:location=/var/opt/xen/iso_linux/ content-type=iso device-config:options=" -o bind"

10. Congrats! You should now have two blank ISO repositories in XenCenter. You can now start uploading ISO's using SCP, WinSCP, etc. Place them in /mnt/iso_microsoft or /mnt/iso_linux.
Once you put the isos up, the should look like this (no folders, just ISO files on the root of that partition):
\# ls /mnt/iso_linux/ -1
CentOS-5.2-x86_64-bin-DVD.iso
CentOS-5.3-i386-bin-DVD.iso
...

ISOs that are placed after the storage repository is created will not show up until a reboot. Since Xen did not provide an easy way to reconnect these pseudo-repositories (*\*cough\** XenCenter requires reinputting the connection parameters when reattaching a SR), we will create a script which you can run to unplug/plug the pbd. I've created this as /bin/pbdrefresh . You can rename it or place it at another location if you like.

\# touch /bin/pbdrefresh
\# chmod +x /bin/pbdrefresh
\# nano /bin/pbdrefresh

Paste this script into the file:

#!/bin/bash

if [ -z "$1" ]; then
echo "First parameter must be SR name"
else
srid=$(xe sr-list name-label=$1 | grep "^uuid" | egrep -o "[a-z0-9\]+-\[a-z0-9-]+")
echo "sr id is $srid"
if [ -z "$srid" ]; then
echo "Could not find SR ID"
else
pbdid=$(xe pbd-list sr-uuid=$srid | grep "^uuid" | egrep -o "[a-z0-9\]+-\[a-z0-9-]+")
echo "pbd id is $pbdid"
if [ -z "$pbdid" ]; then
echo "Could not find PBD ID"
else
# unplug, then replug, pause 5 seconds inbetween
xe pbd-unplug uuid=$pbdid
sleep 5
xe pbd-plug uuid=$pbdid
fi
fi
fi

And voila! To refresh your ISO repository, simply type pbdrefresh (RepositoryName) ie:
\# pbdrefresh ISO_Linux

*NOTE:* I've had some strange issues when doing this while a transfer is in progress. Make sure you only run the script after an ISO is uploaded.
*NOTE:* Also, you may get this error message when refreshing the PBD. Just unmount all ISO files from the servers and run the script again:
This operation cannot be performed because this VDI is in use by some other operation
vdi: f0f98fbd-be1e-40d1-a0d4-ce1ae76b4b1b (iso_name.iso)



Julian Chesterfield Citrix Employees

Julian Chesterfield
  • 30 posts

Posted 23 December 2009 - 10:45 AM

There is a local ISO repository on XenServer hosts under /opt/xensource/packages/iso. This stores the persistent windows PV tools ISO used by XAPI. You can upload ISOs to this directory, although note that you need to synchronise all ISO directories across hosts in the pool. This directory is somewhat space limited so may not be suitable for all purposes. Another alternative is to insert a physical disk into the machine, format it using mkfs.ext3, and then mount it to a root filesystem mntpoint.

You should create ISO SRs from the CLI using:

xe sr-create type=iso device-config:legacy_mode=true device-config:location=/path/to/mntpoint

Setting the legacy_mode flag should avoid all the remounting issues you describe in your post. Also note that you can refresh ISO VDIs by calling:

xe sr-scan uuid=<SR UUID>

without having to PBD.unplug PBD.plug.



Andrew Odom Members

Andrew Odom
  • 3 posts

Posted 24 December 2009 - 04:25 PM

Thank you for the reply Julian.

I did see the /opt/xensource/packages/iso folder and SR, but the filesystem which the XenServer resides on is much too small to hold the ISO files that I have collected.

I believe I did try the legacy mode at one point but I'm not sure if it worked or not. The method I came up with for the sr-create was an exact replica of the xe-mount-iso-sr command (including the options=" -o bind"). The only reason I don't recommend using the xe-mount-iso-sr command is that it would not work when mounting multiple SR folders.

Also, thanks for the sr-scan command, I did not notice that command before and I will give it a try once I'm on the xenserver again.

It really would be nice if this functionality could be built into the XenCenter. Single server setups like mine would really benefit from being able to store ISOs on the server and the ability to upload ISO's from the XenCenter console.



Peter Bayerl Members

Peter Bayerl
  • 17 posts

Posted 26 April 2010 - 10:49 AM

Thanks a lot for this detail how to creating local stored ISO Images on the XenServer. Found several How To's but
they all doesn't work as well. But sorry Guys at Citrix why the hell you are not going to implement this feature by default in the XenCenter? This is what we all need when it comes to Best Practice ...

By the way I have tried both methods and was not able to create an ISO Library. Using the default ISO repository directory I get an error message after copied 2.3 GB of my Windows 2008 R2 ISO, and the first description I don't get an Disk but still can see that 15GB of my local Storage is used. Anyway I will burn a CD and used this old fashioned method to install my Servers. Next one will be a VMWare host again ...

Edited by: Peter Bayerl on 26.04.2010 06:59

Edited by: Peter Bayerl on 26.04.2010 07:05



Paul Svirin Members

Paul Svirin
  • 84 posts

Posted 27 April 2010 - 07:10 PM

Maybe a strange idea but why one can't make an NFS share on the same XenServer host and mount it?
It will be an emulation of local ISO storage.

---
iSCSI SAN software
http://www.starwindsoftware.com



Julio Cuz Members

Julio Cuz
  • 11 posts

Posted 18 April 2011 - 11:09 PM

I'm getting an error message at step #6 where it says to add the command to the /etc/fstab file. I entered a new line on that file as -> /dev/VG.../LinuxISO /mnt/iso_linux ext2 noauto 0 0
and even after rebooting the server, something happens here because when I execute command on line #7 it says it's not recognized.
Please help.
Thank you.



Michael Picher Members

Michael Picher
  • 1 posts

Posted 27 August 2011 - 12:07 PM

The correct format for the xe sr-create would be:

xe sr-create name-label=NAME type=iso device-config:legacy_mode=true device-config:location=ISOSTORAGELOCATION content-type=iso

So, make a dir first:

mkdir /var/opt/xen/iso

Then the following example makes a storage repository called ISOs:

xe sr-create name-label=ISOs type=iso device-config:legacy_mode=true device-config:location=/var/opt/xen/iso content-type=iso

Mike

Edited by: mpicher on Aug 27, 2011 8:52 AM



Benjamin Kunz Members

Benjamin Kunz
  • 2 posts

Posted 21 June 2012 - 09:02 AM

Worked, using sr-create method from the previous post results in a perfectly working transparent iso sr.

So, there is no need for scripts beyond rc.local.

I assume the method outlined in the original post is overly complicated - i did this from scratch from my own research a few years ago and i seem to remember it being simpler. But it works.

Linux xenserver-0 2.6.32.12-0.7.1.xs6.0.2.542.170665xen #1 SMP Tue Jan 17 15:14:24 EST 2012 i686 i686 i386 GNU/Linux



James Cannon Citrix Employees

James Cannon
  • 2,743 posts

Posted 21 June 2012 - 10:27 PM

Hi Peter,

It is not in XenCenter due to the small size of the root file system. We have a lot of architecture from before Citrix picked up XenSource in 2007. Dom 0 was intentionally meant to be small in order to allow maximum space on 3rd partition (Local Storage) for Guest VM VDIs. With other virtualization solutions, there is no Control VM that provides resources to Guest VMs. Often, you have an underlying operating system that provides emulation to the VMs running on top of it. Personally, I have been using an old Linux SLES VM as a NFS ISO repository. I do recommend install from network, as ISOs do become dated over time (more so for Linux than Windows).

The local ISO repository has been available since the early days of XenServer, which was often managed via the CLI. I guess legacy, does mean legacy in that situation. On a side note, there would be enough demand to have this feature to justify coding for it. I suspect that virtual appliance (gues VMs) will fulfil this role in future. If someone is smart enough to see this opportunity, perhaps there is some money to be made. ;)

Regards,
+James Cannon+



Benjamin Kunz Members
  • #10

Benjamin Kunz
  • 2 posts

Posted 22 June 2012 - 07:16 AM

James,

it is just a question of convenience, network load/speed and ease of setup, especially in small business setups, especially for servers that provide VMs to developers for testing - from personal experience.

If a user can just throw a load of ISOs - that quite often are already available somewhere - onto the same server that runs the VMs it solves a whole lot of potential issues that may be present with a remote CIFS or NFS repo. I much prefer this setup.

Now as you have also pointed out, i could just create a first VM to provide NFS. This however opens other problems and most notably uses valueable guest space resources.

During the first real deployment of xs i did years ago i ran into this question - and a couple of unrelated ones that contributed majorly to this decision - and there i customized the dom0 installation a lot. This solution turned out quite robust and i put maybe 4 weeks* into all of it (IIRC i was bootstrapping gcc on it, then various packages from small things like screen, to a complete bacula system, cifs server for easy access to iso repository etc.)

If Citrix would be willing to invest the time, i suppose they would gain acceptance with smaller deployments where presumably ESX dominates despite its price simply because small deployments often means cheap administrators..

An alternative would be to lock down and minimize dom0 even further, but ship with a default user control VM... But IMHO this would be a suboptimal approach.

* i should say including planning, desaster recovery preparations, documentation etc..

Edited by: sonopard on 22.06.2012 03:18



Adrian Pintilie Members
  • #11

Adrian Pintilie
  • 9 posts

Posted 06 September 2012 - 03:35 PM

I have a similar problem. I want to create a local ISO repository (server is in a datacenter and i have no access to NFS mounts) but the main partition is too small (5 GB).

Can I create an ISO Repository in the Local Storage? I have plenty of space left there.



Adrian Pintilie Members
  • #12

Adrian Pintilie
  • 9 posts

Posted 06 September 2012 - 03:44 PM

I figured it out:

xe sr-create name-label=<name> type=iso device-config:location=<name> device-config:legacy_mode=true content-type=iso

where <name> can be your Local Storage.