Skip to content

Instantly share code, notes, and snippets.

@DavidGriffith
Created March 17, 2017 04:21
Show Gist options
  • Save DavidGriffith/0c28201ad4fcca8039df6316410d217d to your computer and use it in GitHub Desktop.
Save DavidGriffith/0c28201ad4fcca8039df6316410d217d to your computer and use it in GitHub Desktop.
Debian installer on a USB key with a writable file system.
Debian installer on a USB key with a writable file system.
I couldn't find a concise article about creating a Debian installer USB
key with a writable file system, so here is my take. This assumes you
have an available Linux system. Note that some old BIOSes might not
happily boot USB drives created in this way.
* Install the packages syslinux dosfstools mbr
* Insert the thumb drive and find the device using dmesg
* Install a Master Boot Record to the drive (install-mbr /dev/sdX)
* Create a DOS filesystem (mkdosfs /dev/sdX1)
* Put syslinux on the drive (syslinux /dev/sdX1)
Now mount the drive.
Add the initial ramdisk image and kernel binary (initrd.gz and vmlinuz) from
http://http.us.debian.org/debian/dists/stable/main/installer-amd64/current/images/hd-media/
Add a Debian installation ISO. This may be netinst, a CD, DVD, or BD.
For a BD, you will need to repartition and reformat[1] the thumb
drive for ext4fs or some other Linux filesystem. This is because a
FAT32 filesystem cannot handle files larger than 4 GB.
Create a text file on the drive named "syslinux.cfg". At a bare
minimum, it should contain a single line:
default vmlinuz initrd=initrd.gz
Here's the new and "proper" way to do it:
DEFAULT BootUSB
LABEL BootUSB
KERNEL vmlinuz
APPEND initrd=initrd.gz
TIMEOUT 1
Automating the installation is very helpful and a big reason for why
you'd want a writable installer thumb drive in the first place.
This is the syslinux.cfg file you need to get that started:
DEFAULT BootUSB
LABEL BootUSB
KERNEL vmlinuz
APPEND initrd=initrd.gz auto file=/hd-media/preseed.cfg locale=en_US
console-keymaps-at/keymap=us
TIMEOUT 1
Now you'll need a file "preseed.cfg" placed in the root of the thumb
drive. See http://www.debian.org/releases/stable/amd64/apb.html.en for
more information.
Here's something basic:
d-i debian-installer/locale string en_US.UTF-8
d-i keymap select us
d-i keyboard-configuration/xkb-keymap select us
d-i clock-setup/utc boolean true
d-i time/zone string US/Pacific
d-i clock-setup/ntp boolean true
d-i passwd/user-default-groups string cdrom floppy sudo audio dip \
video plugdev netdev scanner bluetooth vboxusers
d-i partman/mount_style select traditional
d-i mirror/country string US
d-i mirror/http/hostname string http.us.debian.org
d-i mirror/http/directory string /debian
d-i popularity-contest/participate boolean false
d-i apt-setup/use_mirror boolean true
d-i pkgsel/include string build-essential devscripts flex bison gdb \
autoconf automake cmake pkg-config libtool intltool-debian
Footnotes
=========
[1]
If you want to put a bluray ISO on your thumb drive, you'll need to
repartition and reformat the drive for ext4fs or some other Linux
filesystem. Run "sudo fdisk /dev/sdX", the delete all partitions. Make
a new primary partition taking up the whole drive. Mark it type 83 for
Linux. Mark it bootable. Type 'w' to write the partition info, then
quit. Back to the command line, type "mkfs.ext4 /dev/sdX1". This
formats the partition. Mount the drive. Type "extlinux --install
/flash" or wherever you mounted the drive. The extlinux utility comes
with the syslinux package.
Sources
=======
http://hyper.to/blog/link/debian-installer-on-a-usb-key/
https://www.debian.org/releases/stable/amd64/ch04s03.html.en
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment