Install Ubuntu from a flash disk

Props to Tim for this one.

First you need to obtain the necessary files. You will need boot.img.gz from the Debian installer. You also need the Ubuntu net install iso which is located here (Hardy i386) or here (amd-64).

Next, mount the usb disk. Check mount to see what device (from here on out assume /dev/sda) its being mounted as. Unmount the disk. Do the following as root (THIS WILL DESTROY ALL DATA ON THE DISK):

zcat boot.img.gz > /dev/sda

Once it finishes, mount the usb disk again (assume that the disk is mounted at /mnt/bootdisk). You should see a bunch of files in there. If you have a large disk you’ll notice that it does not report the correct size. Don’t worry that is normal. Mount the Ubuntu iso by doing the following:

mount -t iso9660 -o loop,ro /path/to/mini.iso /mnt/ubuntu

First we need to do some house cleaning inside the bootdisk mount point.

rm /mnt/bootdisk/linux26
rm /mnt/bootdisk/initrd26.gz
rm /mnt/bootdisk/syslinux.cfg

Copy the Ubuntu files over:

cp /mnt/ubuntu/* /mnt/bootdisk/

The majority of the files will be overwritten.

The last thing to do is create a config file. We just deleted syslinux.cfg earlier and didn’t replace. Do the following to correct that:

mv /mnt/bootdisk/isolinux.cfg /mnt/bootdisk/syslinux.cfg

That’s it! Unmount the drive and you’re good to go.

15 thoughts on “Install Ubuntu from a flash disk

  1. Hi,
    Thanks for the tip. Can you also use the whole installer CD if you have a big enough flash disk, instead of the netinst version?

    -tayfun

  2. Thanks for sharing this info :) I just made a stick for a friend, whos CD-rom had failed on the laptop, now we can install gutsy instead of having a constant Windows XP loop :P

    When that’s done, I’m going to try what tayfun asked about, I too don’t see why it wouldn’t work, but we decided to go what allready does :)

  3. Actually, the Debian install image is 123ish MB, so even if you had a bigger flash drive it would only recognize it as 123 MB. What I did was get WinImage and extract the image to the flash disk (it asked me to resize and I said yes). Afterwards, just follow the delete/copy/replace steps mentioned, even from within Windows.

    I hit a snag because the Gutsy loader(?) is not the same as the Sarge one, so I had to copy vmlinuz and initrd.gz from the /casper/ directory to the root and change all occurrences of /casper/vmlinuz to vmlinuz and /casper/initrd.gz to initrd.gz in syslinux.cfg. Afterwards it will give you some errors, when you come to a “boot:” prompt type “vmlinuz” and press enter twice. It should boot into Ubuntu.

  4. I am left at the line:
    sudo mount -t iso9660 -o loop,ro /path/to/mini.iso /mnt/ubuntu
    I’m told that the mounting point /mnt/ubuntu does not exist…
    How do I fix that?

  5. You’ll have to create this mountpoint on the machine you’re working on.

    mkdir /mnt/ubuntu

  6. That seems to work, thank you very much…
    Though I now get to two new problems..
    There are no files named initrd26.gz or linux26 – but I have deleted the files linuz and initrd.gz.
    When I try to graphically copy the files from the iso – it says that there isn’t enough space – on my 1gb usb-stick..
    What to do?

  7. This may sound like a stupid question, but do you have free space on the usb-stick? If you’ve deleted something, but not emptied the trash, you’ve likely got files sitting in .Trash taking up space.

    (Sorry I don’t have a bit more helpful response at the moment, it’s rather late and that’s the first thing that came to mind.)

  8. Whoa – that’s a fast reply – thanx..
    Unfortunetly I have no files in trash – but when I did the zcat boot.img.gz > /dev/sda
    – it deleted all files, so there ought to be plenty space..
    Before following your recipe, I partitioned and formatted the stick..
    When I look under properties for the /media/ubuntu inst – which is my stick it says that it has 7,6MB on it – which seems resonable, but it also states, that there is 0 byte free space..
    BTW here the time is 08:39 am :-)

  9. Out of curiosity, when you deleted the files, did you use the graphical interface, or did you delete them via the command line?

  10. I used the CLI..
    It just seems that the boot.img.gz takes up all the space..

  11. I’ll bring a flash drive home from work today and check this out for you. (I know, I’m one of the five people in the developed world without one.)

  12. I just ran through this without problems. Can I suggest starting over from scratch and seeing where you make it?

    kyle@min:~/Desktop/ubuntu $ wget http://http.us.debian.org/debian/dists/sarge/main/installer-i386/current//images/hd-media/boot.img.gz
    kyle@min:~/Desktop/ubuntu # wget http://archive.ubuntu.com/ubuntu/dists/edgy/main/installer-i386/current/images/netboot/mini.iso
    kyle@min:~/Desktop/ubuntu $ ls -al
    total 16736
    drwxr-xr-x 2 kyle kyle 4096 2007-12-04 00:45 .
    drwxrwxr-x 8 kyle kyle 4096 2007-12-04 00:33 ..
    -rw-r–r– 1 kyle kyle 8248928 2006-08-04 15:01 boot.img.gz
    -rw-r–r– 1 root root 8849408 2006-10-20 20:42 mini.iso
    root@min:~/Desktop/ubuntu # mkdir /mnt/ubuntu
    root@min:~/Desktop/ubuntu # mkdir /mnt/bootdisk
    root@min:/media # df -h
    /dev/sde1 63M 44M 20M 70% /media/disk
    root@min:/media # umount /media/disk
    root@min:~/Desktop/ubuntu # zcat boot.img.gz > /dev/sde

    gzip: stdout: No space left on device
    root@min:~/Desktop/ubuntu # mount /dev/sde /mnt/bootdisk
    root@min:~/Desktop/ubuntu # mount -t iso9660 -o loop,ro mini.iso /mnt/ubuntu
    root@min:~/Desktop/ubuntu # cd /mnt/bootdisk
    root@min:/mnt/bootdisk # ls
    disk.lbl f2.txt f5.txt f8.txt initrd.gz linux syslinux.cfg
    f10.txt f3.txt f6.txt f9.txt initrd.list linux26 syslinux.txt
    f1.txt f4.txt f7.txt initrd26.gz ldlinux.sys splash.rle
    root@min:/mnt/bootdisk # rm linux26 initrd26.gz syslinux.cfg
    root@min:/mnt/bootdisk # cp /mnt/ubuntu/* .
    root@min:/mnt/bootdisk # mv isolinux.cfg syslinux.cfg

  13. This was ecactly what I needed…

    Now I have it working – I suspect that is was all the way back in the partitioning, that something went wrong… Not sure – But thanx for the great effort you put into this Kyle – I really appriciate it.. Didn’t know that people like you was still to be found.

  14. Not a problem at all, I’m glad I could help. If you run into any other issues (related or not) let me know and I’ll do my best.

Leave a Reply

Your email address will not be published. Required fields are marked *