Welcome to the part 7 of “Installing Linux on USB” series. In this part we will learn how to create a USB flash drive which can be used as an installation media to install Debian Linux.
Purpose: In this post we will see how can we prepare a bootable USB Debian Lenny installation media to install Debian Linux on any storage device (IDE/USB hard drives). Note that this post is a bit different than the rest of the post in the USB series as in this post we talk about preparing an “USB Installation Media” rather than talking about how to install on USB devices. So basically the end result of this tutorial would be that you can install Debian Lenny from a USB stick rather than from the traditional CD-ROMs
Background: There are many ways you can install Debian Linux (Lenny) namely:
2. Through Floppy disks
3. Through USB sticks (We will covers this)
4. Through Network boot (PXE boot)
Method 1 is the most popular and the easiest.
Method 2 is outdated and very few people use it
Method 3 and 4 are not very straight forward although Debian people have done an excellent job to make it as simple as possible.
Step 1: Get a computer running Linux & a USB flash drive
You will need a computer which is already running Linux and a USB flash drive (a.k.a. USB stick) of size at least 256 MB which we will prepare as our installation media.
Step 2: Insert your USB stick into your computer
Insert the USB stick into the computer running Linux and make sure it gets detect by the kernel. Most of the recent kernels and Linux OS can detect USB devices on-the-fly without requiring to do anything special. You can check if the USB device got detect or not by giving the following command:
and you should see something like this:
[373982.581725] sd 8:0:0:0: [sdc] 4001760 512-byte hardware sectors (2049 MB)
[373982.582718] sd 8:0:0:0: [sdc] Write Protect is off
[373982.582718] sd 8:0:0:0: [sdc] Mode Sense: 03 00 00 00
[373982.582718] sd 8:0:0:0: [sdc] Assuming drive cache: write through
[373982.584152] sd 8:0:0:0: [sdc] 4001760 512-byte hardware sectors (2049 MB)
[373982.585718] sd 8:0:0:0: [sdc] Write Protect is off
[373982.585718] sd 8:0:0:0: [sdc] Mode Sense: 03 00 00 00
[373982.585718] sd 8:0:0:0: [sdc] Assuming drive cache: write through
[373982.589280] sd 8:0:0:0: [sdc] Attached SCSI disk
Step 3: Download the boot image file for USB device
Now download the boot.img.gz file from here.
Note: That this image corresponds to i386 architecture. You will need to find your corresponding architecture image from here. Here the architecture refers to the type of system on which you are going to install Debian Lenny.
For example, if your if you are going to install on a AMD64 machine then you need to go to /installer-amd64/ directory and download the boot.img.gz file from here.
Step 4: Prepare your USB stick to boot
Note: This step will erase all your data on your USB drive.
Now give the following command:
# zcat boot.img.gz > /dev/sdX
where sdX – is your USB device name (mine is “sdc” in this tutorial)
Now it is a good idea to remove un-plug and plug back in your USB devices so that the new partition table/structure is recognized by the Linux system. I had to do this. This refreshes the drives partition table stored by udev.
Check: You can check by giving the following command:
# mount /dev/sdX /mnt/
and you should be able to see installation files like syslinux.cfg, setup.exe, etc.
Note: There is no suffix “1″ or “2″ as is /dev/sdc1 or /dev/sdc2 once you copy the boot.img.gz image. Basically there are no partitions. The partition itself is just one big disk.
Step 5: Grab a net install or business CD image
Till now we have just prepared the USB stick to boot but we still need an installation image which we can use to install Debian. You have two options:
Step 6: Copy the downloaded image to USB stick
Now all you need to do (as a final step) is to copy the downloaded ISO image (from above step) to your USB stick. To do this give the following command:
#mount /dev/sdX /mnt
# cp <path/to/iso/image> /mnt
That’s it. You have successfully created a USB installation disk which can carry anywhere with you to Install Debian Linux. Just plugin the USB stick to the computer on which you would like to install Debian Lenny and set the BIOS to boot from USB stick. No CD-ROMs required!