Making a Bootable USB Drive for Linux
2013-Jun-16, Sunday 23:32![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Conveniently timed to my previous entry I recently upgraded my laptop to Debian Wheezy. This involved redoing my backup boot drive to contain bootloader updates, so I can detail the process I used.
Partition the USB drive
Use whatever partition manager you're comfortable with. cfdisk, fdisk, gparted, whatever.
# cfdisk /dev/sdb
If you want to use the USB stick on Windows normally, note that Windows will only see the first partition of a thumbdrive. This is great for hiding the fact it's a bootable drive!
# fdisk -lu /dev/sdb ... Sector size (logical/physical): 512 bytes / 512 bytes ...
Device | Boot | Start | End | Blocks | Id | System |
---|---|---|---|---|---|---|
/dev/sdb1 | 8064 | 14259815 | 7125876 | b | W95 FAT32 | |
/dev/sdb2 | * | 14259816 | 15240575 | 490380 | 83 | Linux |
Don't start the first partition at the very beginning. Here I've got it started about 4k in. This gap is important: grub will install itself into the gap--if there isn't enough room, grub won't install.
You'll also notice that I've allocated 512MB to what will become /boot (sdb2). This is serious overkill, but also means I don't have to be particularly cautious about uninstalling old kernel versions to avoid running out of room.
Format the Partitions
Naturally, we should format these partitions:
# mkfs -t vfat /dev/sdb1 # mkfs -t ext3 /dev/sdb2
Install grub
Then mount our soon-to-be /boot drive into /boot (if you're familiar with grub-install, you can mount it elsewhere):
# mount /dev/sdb2 /boot
And install grub:
# grub-install /dev/sdb
Naturally, your next step should be to test that it boots. And maybe even test that it appears as a normal thumbdrive on a Windows computer.
When Doing a Fresh Install
NB: This is from-memory. I have not done this recently.
If you're doing a fresh install, partition the USB drive from another computer. Make sure the thumbdrive is plugged in during the install process, and when configuring drive partitions and directory locations, simply select /dev/sdb2 (or whichever is appropriate for the USB drive's second partition) as the device on to which to put /boot.
rss feed
Date: 2013-Jun-17, Monday 13:45 (UTC)Re: rss feed
Date: 2013-Jun-18, Tuesday 04:02 (UTC)Cool. Thanks!
Though it's no trouble cross-posting--Dreamwidth has the capability built-in, so it's zero effort on my part--and my plan is to continue to leave cross-posting on for the forseeable future. I still like LiveJournal as a platform, DW just happens to be a little closer in spirit to the LJ of yesteryear.