Installing Linux on USB – Part 7: Install Debian Linux from USB drives
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:
1. Through CDs/DVDs which you can download from Debian’s website or obtain from vendors.
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:
# dmesg
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.585718] sdc:
[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:
1. Download the netinst (Net Install) ISO image of size 150-180MB from here.
or
2. Download the businesscard image of size 40 MB from here.
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
#umount /dev/sdX
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!
Happy Installing!!!
Part 8: Review – Installing Linux on USB

Free Email Subscription









February 25th, 2009 at 3:27 am
[...] Part 7: Install Debian Linux from USB drives Share and Enjoy: [...]
February 25th, 2009 at 9:56 pm
[...] Part 7: Install Debian Linux from USB drives Share and Enjoy: [...]
February 26th, 2009 at 6:01 pm
[...] a USB flash drive which can be used as an installation media to install Debian Linux. Read it here Purpose: In this post we will see how can we prepare a bootable USB Debian Lenny installation media [...]
March 2nd, 2009 at 1:44 am
[...] HOWTO: Create a USB Debian Installation flash drive This is a drop-dead-simple guide in the plainest possible language to creating a bootable USB drive that will install Debian. Knowing how to do this is an important part of eliminating socially, environmentally and politically irresponsible RO media from the world. [...]
March 3rd, 2009 at 12:00 am
Great series! I will buy a netbook. However, most of them haven’t a DVD drive. A bootable pen-drive with installation image (or complete system) is very useful. Thank you!
Reply to this comment
March 12th, 2009 at 8:41 pm
[...] Part 7 [...]
March 18th, 2009 at 1:56 pm
If you have a system that has a USB port but can’t boot from it, it probably has a floppy drive. So boot from Smart Boot Manager: http://linux.simple.be/tools/sbm – I’m doing this now.
Reply to this comment
April 24th, 2009 at 10:08 am
Enjoying reading your blog. Hard work always pays off.
Reply to this comment
April 29th, 2009 at 7:17 am
Excellent tutorial. Works like a charm.
Thanks!
Reply to this comment
Admin Reply:
April 30th, 2009 at 1:29 pm
Thank you.
Reply to this comment
May 26th, 2009 at 4:38 pm
I get invalid compressed format.
Im using the larger iso image.
Im going to try the business card and see what happens.
Later
Reply to this comment
Admin Reply:
May 27th, 2009 at 1:34 am
At which step are you getting the compression error?
Reply to this comment
Kilo Reply:
May 28th, 2009 at 10:38 pm
Hey.
I figured it out.
I was using Puppy Linux to copy the files over to my usb stick, but there was no status bar as to how finished the copying was so I was assuming that it was all done when I pulled the usb stick out. This resulted in a partial .iso image copy.
Everything is fine now.
Thanks for the reply
Kilo
Reply to this comment
Admin Reply:
May 28th, 2009 at 11:09 pm
Glad to know that it worked out for you. Have fun.
Reply to this comment
June 12th, 2009 at 5:16 am
Hey I had to use the command :
sudo dd if=boot.img of=/dev/sdb
because my boot.img wasn’t with .gz …
I hope that it works
Thanks for the tutorial man !
Reply to this comment
June 20th, 2009 at 6:37 pm
Tried it several times. “zcat boot.img.gz > /dev/sdb” [sdb=where my flash drive appears] only spews garbage in the terminal window and doesn’t touch the drive. Eventually everything stops in the terminal window with a whole series of “-su” commands. using dd seems to have actually copied something. Of course, it blew away the partition table, making the device unbootable. Unfortunately fat16 doesn’t seem to be an acceptable filetype to Debian Etch … will try someone else’s instructions. Thanks.
Reply to this comment
henry Reply:
February 1st, 2010 at 12:20 pm
I get the same issue using zcat….
Reply to this comment
Admin Reply:
February 15th, 2010 at 10:20 am
Are you root? Also some people have reported success using “dd” command instead of zcat. See the previous comments..
Reply to this comment
July 2nd, 2009 at 10:09 am
Nice howto.
Another –maybe easier– way is:
http://unetbootin.sourceforge.net/
Reply to this comment
July 29th, 2009 at 10:47 am
I need to create the boot flash drive on a Win XP machine. Can I do this simply by creating the directory structure and copying the files in as per the above instructions?
Reply to this comment
Admin Reply:
August 5th, 2009 at 12:29 pm
You mean you need to create a Bootable USB drive with Windows XP on it? Or do you need to create a USB drive from which you can install Windows XP?
Reply to this comment
August 5th, 2009 at 1:02 pm
No, I meant create a bootable usb drive with Debian GNU/Linux on it, on a Win XP machine. But it’s ok, that unetbootin link above looks as though it will do the trick.
Reply to this comment
September 23rd, 2009 at 4:12 pm
Thanks for the tutorial.
The USB drive booted fine and went through the Debian install process without a problem until it needed to write the partition table of the disk I was installing to. The drive has been successfully detected but it fails consistently trying to create the partitions…
If I use the same ISO image and use a CDROM to install it works fine…
Any ideas??
Reply to this comment
Admin Reply:
September 23rd, 2009 at 4:34 pm
Try looking at the messages during the install process as mentioned here:
http://blogs.koolwal.net/2009/05/06/tip-inspecting-linux-installation-process-behind-the-scenes/
Also are you trying to write/create partitions on the USB drive from which you booted? I hope not…
Reply to this comment
September 23rd, 2009 at 5:43 pm
Thanks. Appreciate the tip about the install messages. Problem solved…
I was installing over the top of an existing Linux (which I had used in the first steps of the process). It looks like, the install process searched the existing partitions for the install ISO (which was on the USB drive but also still on the old Linux install). It looks like it found the ISO on the hard drive first, and then kept the partition mounted. So of course it didn’t want to change the partition table of a mounted drive.
Reply to this comment
October 27th, 2009 at 3:51 pm
This procedure can also be accomplished in Windows using “win32diskimager-RELEASE-0.1-r15-win32″ to unpack and write the boot.img file to a boot stick and then copying the Debian ISO file on to it. It’s much simpler this way, no command line is needed and, you don’t need to have a Linux box already up and running to do it.
Reply to this comment
December 15th, 2009 at 8:51 pm
Thanks very much, this is an excellent tutorial.
Reply to this comment
January 5th, 2010 at 5:23 am
The how to is simple but as soon as I boot hte machine with the USB,
the black screen of death appears.
The pc is a pentium III compaq, and the howto not working
it is better a way with syslinux, cuz damnsmalllinux boot pendrive works great.
Reply to this comment
January 5th, 2010 at 9:11 am
it worked !! huurra
I found what was the error.
The mbr of the pendrive was not ok.
I had to do :
syslinux -s /dev/sda1
zcat procedure
then
mount and copy the iso file to the pendrive
then during the plpboot floppydisk
start pc
put floppy disk plpboot and without usb pendrive in pc
press ctrl + esc
I get plp screen
then
i place the usb pendrive in hte usb port of hte pc
plp boot pages certainly detects it
then select USB
and that s it! USB pendrive install of debian starts and pc is now installed
thank you !
Reply to this comment
January 19th, 2010 at 8:33 am
[...] instaliavimas iš USB, anks?iau kelet? kartu s?kmingai naudojausi unetbootin. Ta?iau po koki? 3 bandym?: vien? kart? instaliavo sen? versij? (nes unetbootin nelabai atnaujina šaltini? iš kur imami failai), bandant sukurt iš ISO instaliacija prasid?jo lik ir s?kmingai, bet po to nerado CD, kurio šiuo atveju ir nebuvo. Pasitel?k?s ? pagalb? google visgi radau gana nesud?ting? ir aiški? instrukcij?. [...]
February 1st, 2010 at 9:40 pm
Hi there.
Great installation help…thanks, fixed my problem.
Anyone reading this guys stuff should bookmark it.
Reply to this comment
February 12th, 2010 at 4:39 pm
Thank you for that clear explanation.
My question is what do you have to do to install the Debian system itself on the USB Flash. The above explanation seems to create and installation USB Flash in liu of an installation CD.
Thanks
Peter
Reply to this comment
Admin Reply:
February 15th, 2010 at 9:59 am
Hi Peter,
Have you seen this article?
http://blogs.koolwal.net/2009/01/28/installing-linux-on-usb-part-2-install-debian-lenny-on-usb-hard-drive/
It exactly explains what you are looking for.
Reply to this comment
March 1st, 2010 at 10:11 pm
Heya, Thanks for the howto,
Lately I have been doing all my debian installs via this method with ONE important addendum:
On the HDD make a small fat partition as the first and zcat boot.img.gz > /dev/sdX1 then it all works out fine. use gparted later to remove the first partition.
cheers
Reply to this comment