If you have ever tried to install an older version of Ubuntu server, you may have found that versions 10.04 and earlier do not work very well when booted from USB.
Below is one work around I’ve found to the problem:
These instructions assume you are logged in as root. Remember to amend all paths accordingly to your environment, and read the instructions all the way through first.
1. mkdir /tmp/iso
2. mkdir /tmp/newiso
3. mount -o loop /home/mirek/Downloads/ubuntu-10.04.4-server-amd64.iso /tmp/iso/
4. cp -a /tmp/iso/* /tmp/newiso/
5. cd /tmp/newiso/install/
6. gunzip initrd.gz
7. mkdir newinitrd
8. cd newinitrd/
9. cpio -id < ../initrd
10. created text file /mountUSB and paste into it all these lines:
#! /bin/sh
MP=”/iso”;
if [ ! -d "$MP" ]; then
mkdir $MP;
USB=$(cat /proc/partitions | tail -1 | cut -ds -f2);
echo “MOUNTING /dev/s$USB to $MP… “;
mount /dev/s$USB $MP;
ln -sf /iso/ubuntu-10.04.4-server-amd64.iso /dev/sr0
fi
11. chmod 0777 mountUSB
12. vi etc/inittab and comment out line looking like “tty2::askfirst:-/bin/sh” and insert right after this one “tty2::askfirst:/bin/sh /mountUSB ”, save it.
13. find . | cpio –create –format=’newc’ > ../initrd
14. cd ..
15. gzip initrd
16. rm -fr newinitrd/
17. cd ..
18. mkisofs -D -r -V “$IMAGE_NAME” -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o /tmp/ubuntu-10.04.4-server-amd64-custom.iso .
19. Copy newely created image to your USB pen drive and amend grub.cfg file accordingly.
20. rm -fr /tmp/iso
21. rm -fr /tmp/newiso
22. rm /tmp/ubuntu-10.04.4-server-amd64-custom.iso (assuming you’ve copied it already)
Here are some additional notes on some of the steps:
3. Mount iso image into folder to copy it’s content.
9. Extract initrd compressed with cpio into current folder
10. This simple script will pull out last position from /proc/partitions file which should be your pendrive although this solution isn’t very good, but it worked for me. Then it mounts it and creates symbolic link of the iso file to /dev/sr0 which is cd-rom.
12. Adding the script to initab will allow you to run it just by pressing CTRL+ALT+F2 and then ENTER but you can skip this step and during installation press just mentioned keys and then type in script name to achieve exactly same result.
13. Recreate initrd into cpio file
18. Recreate iso image.
Following these instructions should allow you to create a bootable USB drive for Ubuntu server. Please note, versions later than 10.04 work fine with USB, so you only really need to follow these steps if you need to install and older version from USB.