IThastobecool.com Geeks have opinions too!

5Sep/102

Step by step guide: Installing Citrix XenClient RC2 from USB

Ok, so RC2 for Citrix XenClient was released, great.. but I had a bit of a problem… because I have replaced the cd-rom drive of my laptop computer with a secondary hard drive which I use for XenClient. So I needed an alternate installation method for XenClient that didn’t involve booting from the CD… Booting from USB seemed the logical choice… but that wasn’t as trivial as I first thought it would be, at least not when using a Windows workstation to create your bootable USB Winking smile. If you use a Linux workstation it’s very easy…

Linux:

Insert the XenClient installer CD and run:

sh /mount/cdrom/usb_inst.sh dialog

assuming that you have mounted the cdrom to /mount/cdrom ofcourse.

Windows:

Ok, but what if you’re like me and don’t have a Linux workstation lying around to create your bootable USB? No worries, I found a way to make a bootable USB stick/disk by using a few GNUWin32 tools that are available Smile.

Setup your workspace
First we need to create a directory structure so we have an easy way to create the bootable USB installation.

Create a directory called XC_USB somewhere and the subfolders needed (in my example I create it under the root of D: )

mkdir d:\XC_USB
mkdir d:\XC_USB\staging
mkdir d:\XC_USB\bin

Insert your XenClient CD or mount the ISO file and copy the contents of the isolinux folder to the staging directory

xcopy H:\isolinux D:\XC_USB\staging /y

Copy the packages.main folder to the staging directory

xcopy H:\packages.main D:\XC_USB\staging\packages.main\ /y /s /e

Get the tools
Download the following tools and extract them to the bin directory created above.

HINT: In all the gnuwin32 zip files the files you need are located in the bin subfolder of the zip file.
IMPORTANT: For syslinux it is very important that you do NOT USE the syslinux 4.x release, but the 3.x release. Seeing as the mboot.c32 from the cd was created with syslinux 3.x it will not work with 4.x. The syslinux.exe is located in the win32 folder in the zip file.

Your XC_USB\bin folder should now look like this:

image

Slipstream the source files
First, we need to slipstream the packages.main files into the initrd (rootfs.gz) of the installer.

Unzip the rootfs.gz file

D:\XC_USB\bin\gzip.exe –9 –f –d D:\XC_USB\staging\rootfs.gz

Change directory to XC_USB\staging (important for inserting the packages.main into the initrd)

cd D:\XC_USB\staging

Slipstream the packages.main directory into the decompressed initrd (rootfs)

d:\XC_USB\bin\find.exe packages.main –print | d:\XC_USB\bin\cpio.exe --create --append --format newc --verbose --file rootfs

What this trick does: we create a list of file using find –print and use that list as input for cpio to append to the rootfs archive.

Next we need to find and replace packages.main\ with packages.main/ (remember this is going to be a linux install environment, so using a backslash as file separator will result in errors)

d:\XC_USB\bin\sed –b "s/packages.main\\/packages.main\//" < rootfs > rootfs2
del rootfs
ren rootfs2 rootfs

When that is done it’s time to create and slipstream the answerfile.

Creating the answerfile

For a full reference of the answerfiles please consult this answerfiles.txt
(Open with Notepad++ or another linux-aware text editor)

Creating the answerfile is very easy, just create a new textfile.
Here is an example for you:
Interactive installation (default)

IMPORTANT: There 2 very important sections in the answerfile I provided.

<preinstall>
# !/bin/bash
sed '/[ -r "\${INSTALL_SOURCE_DIR}/\${PACKAGES_DOT_MAIN}/\${DOM0_ROOTFS}" ] || exit \${CheckFail}/s/^/#/' /install/stages/Check-initrd-data > Check-initrd-data.tmp
cat Check-initrd-data.tmp > /install/stages/Check-initrd-data
chmod 755 /install/stages/Check-initrd-data
</preinstall>

This is used to comment out a line the Check-initrd-data installation script of the XenClient installer, that causes installation to fail. If you remove this preinstall script, your installation will not succeed! Read my previous blogpost for more details on this.

<source type="bootmedia"></source>

This tells the XenClient installer to look for the packages.main folder in the root of the booted media (so XenClient knows it is working with a slipstreamed installation)

Other then those 2 options you are free to do whatever in your answerfile Smile
When you created your answerfile, save it in the staging directory. We are going to slipstream it in the initrd as well. In this example I will use answerfile.henk

cd d:\XC_USB\staging
d:\XC_USB\bin\find answerfile.henk | d:\XC_USB\bin\cpio.exe --create --append --format newc --verbose --file rootfs

Compress the initrd (rootfs) file

D:\XC_USB\bin\gzip –9 –f D:\XC_USB\staging\rootfs

Preparing the syslinux.cfg file

First, rename isolinux.cfg to syslinux.cfg in the staging directory

ren isolinux.cfg syslinux.cfg

Open syslinux.cfg in notepad or another text editor and insert the following:

Make sure all filenames are leaded by a slash /. The filenames are:

  • mboot.c32 –> /mboot.c32
  • xen.gz –> /xen.gz
  • vmlinuz –> /vmlinuz
  • rootfs.gz –> /rootfs.gz

Remove the eject_cdrom=1 entry from all 3 boot options

Or use the following command to do it for you, if you are lazy like me, beware it is a oneliner, might not appear so due to website formatting

D:\XC_USB\bin\sed “s/mboot.c32/\/mboot.c32/” < syslinux.cfg | D:\XC_USB\bin\sed “s/xen.gz/\/xen.gz/” | D:\XC_USB\bin\sed “s/vmlinuz/\/vmlinuz/” | D:\XC_USB\bin\sed “s/rootfs.gz/\/rootfs.gz/” | d:\xc_usb\bin\sed “s/eject_cdrom=1//”  > syslinux.cfg.tmp | del syslinux.cfg | ren syslinux.cfg.tmp syslinux.cfg

Edit the answerfile= entry to match the filename of your answerfile, again, this entry must be lead by a /. So in my case it would be:

answerfile=/answerfile.henk

Finally my syslinux.cfg will look like this:

DEFAULT xenclient
DISPLAY bootmsg.txt
PROMPT 1
TIMEOUT 20
LABEL xenclient
kernel /mboot.c32
append /xen.gz max_cstate=0 console=com1 com1=115200/921600,8n1,magic --- /vmlinuz quiet root=/dev/ram rw start_install=new  answerfile=/answerfile.henk console=xencons console=/dev/tty2 --- /rootfs.gz
LABEL verbose
kernel /mboot.c32
append /xen.gz max_cstate=0 console=com1,vga com1=115200/921600,8n1,magic --- /vmlinuz quiet root=/dev/ram rw start_install=new  answerfile=/answerfile.henk console=xencons --- /rootfs.gz
LABEL automatic
kernel /mboot.c32
append /xen.gz max_cstate=0 console=com1 com1=115200/921600,8n1,magic --- /vmlinuz quiet root=/dev/ram rw start_install=new  answerfile=/answerfile.henk console=xencons console=/dev/tty2 --- /rootfs.gz

Preparing the USB disk/stick

Make sure you formatted your usb stick/disk using fat32 filesystem

Copy all files except your answerfile and the packages.main directory to your usb disk/stick (no harm if you do copy them though)

copy D:\XC_USB\staging\* F:\

After that it’s time to syslinux the target partition to make it bootable.

D:\XC_USB\bin\syslinux.exe –a –f F:

And that’s it! Open-mouthed smile
Now just boot your system from USB and install XenClient from USB Smile.

Have fun!

-Henk Hofs

Comments (2) Trackbacks (1)
  1. Hi, your screenshot (http://www.ithastobecool.com/wp-content/uploads/2010/09/image1.png) shows syslinux.exe = 71KB, but this is the size of the 4.02 version. The 3.86 version is 28KB.

    Thanks for the article, just what I needed. Haven’t tested yet….

  2. Hi Dee,

    thx for pointing that out… I took this screenshot when I was still trying to get it to run with pxelinux 4.02.. but found out that wouldn’t work…

    I replaced the screenshot :)


Leave a comment

(required)

*