Boot Debian from an USB device

Posted by sebas on Mon 9 Oct 2006 at 12:49

Here is a very short (but in my opinion very useful) how-to for creating an USB boot device, which enables you to boot Debian from your memory stick.

We are assuming that your USB device is indicated by /dev/sda, and that you are interested in Debian stable (other distributions are untested, but should work).

First unmount your memory stick.

sudo umount /dev/sda

Now download the boot.img.gz, which is necessary to make your USB device bootable:

cd ~
wget ftp://ftp.debian.org/debian/dists/stable/main/installer-i386/current/images/hd-media/boot.img.gz

Extract this image and write it to your USB device:

sudo zcat ~/boot.img.gz > /dev/sda

Now mount the volume to /mnt:

sudo mount /dev/sda /mnt

In this case a Debian Stable net-install image is used. You may also use a business card iso. Nevertheless, you should be sure to use the same version of the ISO-image as the image.tar.gz that was used before.

Download the ISO to the USB device:

cd /mnt/
sudo wget http://cdimage.debian.org/debian-cd/3.1_r3/i386/iso-cd/debian-31r3-i386-netinst.iso

Now you can unmount the volume:

cd ~
sudo umount /dev/sda

You can remove the USB device, and plug it in your new system. Of course you should tell your BIOS to boot from USB.

There is a copy of this how-to on the website of our company VirtualConcepts

 

 


Posted by barney (193.108.xx.xx) on Mon 9 Oct 2006 at 13:31
sudo zcat ~/boot.img.gz > /dev/sda
Will only work if your user has write access to /dev/sda. You probably want to do
sudo sh -c 'zcat ~/boot.img.gz > /dev/sda'

[ Parent | Reply to this comment ]

Posted by Anonymous (81.19.xx.xx) on Mon 9 Oct 2006 at 15:35
Is this really booting from a USB device, or simply installing from a USB device?

[ Parent | Reply to this comment ]

Posted by sebas (82.171.xx.xx) on Mon 9 Oct 2006 at 19:14
[ View Weblogs ]
Good point.. it's about installing from an USB device. Sorry for the confusion.

[ Parent | Reply to this comment ]

Posted by JoshTriplett (66.93.xx.xx) on Mon 23 Oct 2006 at 02:55
I tend to use "tee" for this, since it takes an output file directly on the command line:
zcat ~/boot.img.gz | sudo tee /dev/sda > /dev/null
In general, this also has the advantage of not running the command generating the output as root.

[ Parent | Reply to this comment ]

Posted by ybiC (72.196.xx.xx) on Mon 9 Oct 2006 at 16:04

Nice write-up, yo.

Depending on the contents of your /etc/fstab, the mount command might need to look something like this: mount -t msdos /dev/sda /mnt

[ Parent | Reply to this comment ]

Posted by Nilshar (88.191.xx.xx) on Tue 10 Oct 2006 at 08:21
[ View Weblogs ]
Nice.
I have a 4Gb USB stick, I was wondering if it is possible to have a full debian system on it and boot on it, any idea ?

[ Parent | Reply to this comment ]

Posted by Anonymous (80.99.xx.xx) on Tue 10 Oct 2006 at 09:06

[ Parent | Reply to this comment ]

Posted by Nilshar (88.191.xx.xx) on Tue 10 Oct 2006 at 09:15
[ View Weblogs ]
Thanks

[ Parent | Reply to this comment ]

Posted by Anonymous (84.77.xx.xx) on Fri 13 Oct 2006 at 23:24
You could try ftp://ftp.caliu.cat/pub/distribucions/xarnoppix/Xarnoppix-4.11-i3 86.iso

From live cd one can install to usb device, later booting from usb with linux dirconf=configuration_name it's posible to use many persistent configurations.

It's kde based and catalan localized but in fact wit more than 3 Gb free ( 700 MB FAT16 + ext2 2300 MB ) you can install a lot of locales ;-)

[ Parent | Reply to this comment ]

Posted by Anonymous (87.2.xx.xx) on Wed 25 Oct 2006 at 09:33
You could also try Debian Live, even if usb target is not supported yet (although is scheduled to), you can copy the files from the generated image or the downloadable iso in your usb key, then install syslinux, and you have a live debian system on usb. Tried, it works.

[ Parent | Reply to this comment ]

Posted by MG (72.204.xx.xx) on Sat 27 Jan 2007 at 01:36
Sure, easy.
http://wiki.grml.org/doku.php?id=usb#grml2usb

But 4GB is enough for complete grml plus your own apps
http://grml.org/grml2hd/
In this case, tweak /etc/fstab to minimize flash writes, so: tmpfs for /tmp, /var/run, /var/lock, /var/log, etc. (not /var/tmp, which must persist).

Also consider the exceptionally shock-resistant WD Passport (under 100 bucks) following advice from
http://os.newsforge.com/os/06/02/22/2221258.shtml

[ Parent | Reply to this comment ]

Posted by Anonymous (202.72.xx.xx) on Mon 30 Oct 2006 at 12:29
Thanks, worked a treat!

[ Parent | Reply to this comment ]

Posted by Anonymous (69.176.xx.xx) on Fri 9 Nov 2007 at 17:25
It would be nice if the zcat process would not make the partition so small.

Any tips on making it larger and still be bootable?

[ Parent | Reply to this comment ]

Posted by Anonymous (83.241.xx.xx) on Fri 27 Jan 2012 at 09:24
I'm also curious about that. When I do "zcat boot.img.gz > /dev/sdb" with boot.img from ftp://ftp.debian.org/debian/dists/testing/main/installer-amd64/cu rrent/images/hd-media/boot.img.gz is the resulting fs 239 MB large and 100% full so I can't copy anything there.

The USB stick didn't have a FS on it when I started, can that be the reason for my failure?

[ Parent | Reply to this comment ]

Posted by Anonymous (193.214.xx.xx) on Mon 23 Jun 2008 at 15:51
I managed to put the image on a usb stick and boot. When i choose "detect ethernet card" it finds nothing, even though the command lspci finds 2 ethernet cards.

Does this image officially support install over network, because i really cant get it to work. "ethernet card not found" hauts me!

-Alf :)

[ Parent | Reply to this comment ]

Posted by Anonymous (62.236.xx.xx) on Tue 25 Nov 2008 at 12:02
Good guide!

But here is one MAJOR problem. Its very easy to over write first 240MB of your harddrive if you are using scsi or sata harddrive. So make sure that your usb-stick is /dev/sda before you copy -> paste from this site.

[ Parent | Reply to this comment ]

Posted by Anonymous (94.96.xx.xx) on Mon 6 Apr 2009 at 21:14
duh, if i'm using Windows how to make the Debian boot from usb key?

duh, try this http://unetbootin.sourceforge.net/ :-P

[ Parent | Reply to this comment ]

Posted by Anonymous (85.127.xx.xx) on Sun 10 Jan 2010 at 12:51
this howto is NOT working !!
it stops after searching ISO on media

although iso is on my pendrive and -o loop mounted to /cdrom

red screen saying that nothign is seen. :(

[ Parent | Reply to this comment ]

Posted by Anonymous (62.16.xx.xx) on Fri 29 Jan 2010 at 05:16
There is one big flaw with this guide, and you suffered from it.

Dig shows that ftp.debian.org and cdimage.debian.org are different servers, so the boot.img.gz file and the iso file doesn't always add up (different GCC or something). Happened to me once too. Just remember to download from the same ftp server and you should be good to go.

These are my sources:

Lenny i386
boot.img.gz - netinst.iso

Lenny amd64
boot.img.gz - netinst.iso

PS: I've used this guide so many times I can't even remember. It has only failed me twice.

One time when I downloaded the boot.img.gz from a different server, and the second it was some writing errors while copying to the USB stick.

[ Parent | Reply to this comment ]

Posted by Anonymous (88.104.xx.xx) on Tue 14 Sep 2010 at 19:47
Okay, I couldn't find the ARM boot.img.gz but I found one called boot.img and I compressed it to boot.img.gz will this work? I cannot test by booting from it because my only ARM sustem is coming in the post(should be here tomorrow)

[ Parent | Reply to this comment ]

Posted by Anonymous (161.67.xx.xx) on Thu 7 Oct 2010 at 12:08
Please replace /dev/sda device with , for example, /dev/sdX.
Otherwise I guess that many people will erase important data from their main hard disk.

[ Parent | Reply to this comment ]

Posted by Anonymous (213.136.xx.xx) on Wed 14 Sep 2011 at 16:42
it's usually better to note that anyone using this guide HAVE to ensure which device his stick lives on. Usually doing "dmesg" suffices:
# dmesg

[1635627.664036] usb 1-2: new high speed USB device using ehci_hcd and address 3
[1635627.796968] usb 1-2: New USB device found, idVendor=0781, idProduct=556b
[1635627.796974] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[1635627.796979] usb 1-2: Product: Cruzer Edge
[1635627.796982] usb 1-2: Manufacturer: SanDisk
[1635627.796985] usb 1-2: SerialNumber: 200517389209D132C49B
[1635627.797983] usb 1-2: configuration #1 chosen from 1 choice
[1635627.798823] scsi5 : SCSI emulation for USB Mass Storage devices
[1635627.799272] usb-storage: device found at 3
[1635627.799275] usb-storage: waiting for device to settle before scanning
[1635632.796270] usb-storage: device scan complete
[1635632.797002] scsi 5:0:0:0: Direct-Access     SanDisk  Cruzer Edge      1.01 PQ: 0 ANSI: 2
[1635632.799874] sd 5:0:0:0: [sdb] 7821312 512-byte logical blocks: (4.00 GB/3.72 GiB)
[1635632.801369] sd 5:0:0:0: [sdb] Write Protect is off
[1635632.801375] sd 5:0:0:0: [sdb] Mode Sense: 03 00 00 00
[1635632.801379] sd 5:0:0:0: [sdb] Assuming drive cache: write through
[1635632.803965] sd 5:0:0:0: [sdb] Assuming drive cache: write through
[1635632.803999]  sdb: sdb1
[1635632.809841] sd 5:0:0:0: [sdb] Assuming drive cache: write through
[1635632.809876] sd 5:0:0:0: [sdb] Attached SCSI removable disk
so device is /dev/sdb here and it holds one partition (/dev/sdb1) in this case

[ Parent | Reply to this comment ]

Posted by guest25411 (184.19.xx.xx) on Tue 7 Feb 2012 at 10:07
generated Error 404
cd /mnt/
root@home:/mnt# wget http://cdimage.debian.org/debian-cd/3.1_r3/i386/iso-cd/debian-31r 3-i386-netinst.iso
--2012-02-07 05:02:00-- http://cdimage.debian.org/debian-cd/3.1_r3/i386/iso-cd/debian-31r 3-i386-netinst.iso
Resolving cdimage.debian.org... 130.239.18.138, 130.239.18.163, 2001:6b0:e:2018::163, ...
Connecting to cdimage.debian.org|130.239.18.138|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://caesar.acc.umu.se/debian-cd/3.1_r3/i386/iso-cd/debian-31r3 -i386-netinst.iso [following]
--2012-02-07 05:02:00-- http://caesar.acc.umu.se/debian-cd/3.1_r3/i386/iso-cd/debian-31r3 -i386-netinst.iso
Resolving caesar.acc.umu.se... 130.239.18.142, 2001:6b0:e:2018::142
Connecting to caesar.acc.umu.se|130.239.18.142|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2012-02-07 05:02:01 ERROR 404: Not Found.

[ Parent | Reply to this comment ]

Sign In

Username:

Password:

[Register|Advanced]

 

Flattr

 

Current Poll

What do you use for configuration management?








( 239 votes ~ 1 comments )