Articles

Ubuntu installation via USB stick+hard disk mix

In howto on Apr 11, 2010 by theoryl Tagged: , , , , , , ,

The easiest way to install Ubuntu on a machine is of course to go grab a CD image from the Ubuntu release page and burn it. If for whatever reason, you can’t burn the CD, be it you have a machine without a CD drive or with a CDROM but not CDRW, or, like this author, you don’t have a writable disc, the alternative is to use a USB stick. There already exist a variety of tools out there to “convert” a USB stick into a boot-able media like a CD, such as usb-creator in Ubuntu and UNetbootin for both Windows & Linux. However, if your USB stick has < 700 MB of memory, or, like this author, it has some faulty memory sector**, fear not — here’s a guide for you!
(** received a bunch of SQUASHFS errors and the help page didn’t help)

This guide assumes that you want to:

  1. dual boot Windows and Ubuntu in the machine, with Windows being already installed. This is the “target” machine. The tested Ubuntu version is Lucid Lynx 10.04 beta 2, but this guide should work for all Ubuntu versions >8.04.

and you have:

  1. a USB stick with a minimum of 15 MB of memory (to be safe, get one with >25 MB);
  2. the BIOS of the target machine does support booting via a USB media. Its Windows partition should be large enough to hold the Ubuntu installation disc image (~700 MB);
  3. another machine that is already running Unix/Linux. Strictly speaking, this is only used to prepare the boot sector in the USB stick. Presumably Windows can do it too, this author just didn’t try;
  4. free time and an adventurous soul.

The articles referenced below helped this author a lot. It is therefore strongly recommended to go through these well-written articles before you attempt this guide:

  1. https://help.ubuntu.com/community/Installation/FromUSBStick
  2. https://help.ubuntu.com/9.10/installation-guide/i386/boot-usb-files.html


The very first step is to partition the hard disk of the target machine. If you have Windows Vista or Windows 7 and don’t want to pay for commercial software, you can follow the instructions from SEO Gadget or from How-To Geek. Allow at least 3 GB for the Ubuntu system files and twice the amount of its RAM for the swap space. Download the installation disc image from the Ubuntu release page. Select the “alternative” install CD. For some reason, the “desktop” CD won’t work for this author. Make sure you put the disc image (e.g. ubuntu-10.04-beta2-alternate-i386.iso) at the first level of your Windows partition (typically C:/), because the installer will only search the first level for the image file.

Now switch to another machine that is already running Linux. Go to http://archive.ubuntu.com/ubuntu/dists/lucid/main/installer-i386/current/images/hd-media/ and download boot.img.gz, initrd.gz and vmlinuz. Plug in the USB stick. If it is mounted automatically, unmount it. In GUI, just go to the mounted folder, right click and select “unmount”; or in command line (CLI), do:

umount <name-of-mounted-folder>

Then, find out the name of the partition assigned to the USB stick. It should be:

/dev/sdX1

where X is an alphabet, typically b, because a is taken by the hard disk. To check which alphabet it is, do:

sudo fdisk -l

It should be clear to you which one is the USB partition. Now, fire up GParted:

sudo gparted

Choose your USB partition at the top right corner. Format the USB partition (i.e. /dev/sdX1) to FAT32. Then select “Manage Flags” and check “boot”. Go to superuser mode and extract boot.img.gz that was downloaded earlier to the USB partition:

sudo -s
zcat boot.img.gz > /dev/sdX1

Now mount the USB stick again. Either you can unplug it and plug in again, or do:

mount /dev/sdX1 /mnt

Copy initrd.gz and vmlinuz to the USB stick. After that, edit the syslinux.cfg configuration file in the USB stick to have at least these two lines:

default vmlinuz
append initrd=initrd.gz

For the graphical installer you might want to add “video=vesa:ywrap,mtrr vga=788” (without quotes) to the second line. The boot-able USB stick is now set up. Please make sure to unmount it properly.

Next, boot up the target machine using the USB stick and install as usual. For some strange reason, the installer might enter directly the text mode without asking. If this happens to you, here are two how-to’s about text-mode Ubuntu installation: from psychocats and from Novell. The installer must locate the .iso image residing in the Windows NTFS partition, otherwise you are in trouble. Note that since you are doing a dual boot, you might want to format the Ubuntu partition as ext3 (default is ext4), because there is no ext4 support in Windows yet. By the way, Ubuntu can be installed in either a primary or logical partition and boot perfectly fine.

After all the installation blah blah, if you have everything, then you are done, congrats!! If unfortunately you boot into a text-mode Ubuntu with only a tty terminal, you will need to do the following. First, mount the Windows partition (presumably it is /dev/sda1; if not, change accordingly):

sudo mkdir /mnt/ntfs
sudo mount /dev/sda1 /mnt/ntfs -t ntfs -o nls=utf8,umask=0222

Then mount the Ubuntu installation image (the .iso file should be right under /mnt/ntfs if it was stored at C:/; if not, change accordingly):

sudo mkdir /mnt/iso
sudo mount /mnt/ntfs/ubuntu-10.04-beta2-alternate-i386.iso /media/iso
-t iso9660 -o loop

Add the .iso image as a local repository by inserting /mnt/iso into the list of repositories:

sudo nano /etc/apt/sources.list
deb file:///mnt/iso/ lucid main restricted

Commit the change and install ubuntu-desktop, which is the full graphical version of Ubuntu (or kubuntu-desktop if you prefer KDE to GNOME):

sudo apt-get update
sudo apt-get install ubuntu-desktop

Voila! Congratulations, you now have a fully-working Ubuntu system without any need of CD/DVD or crazy USB stick! (Of course, the author could have done without all this headache by going to a store and buy a piece of CD-R, but life would be much less interesting, don’t you think?)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: