Introduction
This procedure is to guide me through making a basic Debian+XFCE bootable USB stick.
It is heavily based on David Bremner’s procedure at http://www.cs.unb.ca/~bremner/blog/posts/bootable-usb/, but tweaked for less manual work and to add the software I want.
Procedure
- For next time:
- prepare the image offline and then dd it over the USB stick; the stick is too slow to do installs onto
- configure a caching-only name server so we get access to root domain servers, rather than having to reconfigure /etc/resolv.conf for each location; don’t use bind for this
- Attach the USB stick, identify the device and wipe it by running:
dmesg
and identify the stick, e.g. /dev/sdc.
- Set some environment variables needed by the rest of this procedure:
DEV=/dev/sdc MNT=/mnt
- Blank the USB stick:
dd if=/dev/zero of=$DEV bs=1M
and wait dd until complains there is no space left on the device.
- Partition the stick, create the filesystem and mount it by running:
parted $DEV mklabel msdos mkpart primary ext2 1 -1 set 1 boot on quit mkfs -t ext3 ${DEV}1 mount ${DEV}1 $MNT
- Install the base system by running:
debootstrap --variant=minbase jessie $MNT http://httpredir.debian.org/debian/ grub-install --boot-directory $MNT/boot ${DEV}1
- Fix up some small things:
cp /etc/fstab $MNT/etc/fstab blkid -p ${DEV}1 | cut -f2 -d' ' >> $MNT/etc/fstab vi /mnt/etc/fstab # I like to set a blank password on a USB stick perl -pi -e 's/root:[^:]*:/root::/' $MNT/etc/shadow
- Chroot into the stick by running:
mount -o bind /dev $MNT/dev mount -o bind /sys $MNT/sys mount -o bind /proc $MNT/proc chroot $MNT
- Install software:
apt-get install linux-base linux-image-amd64 grub-pc xfce4 net-tools \ vim-gtk man-db iceweasel console-data telnet iputils-ping \ xfwm4-themes nmap tcpdump xfce4-goodies screen ethtool nmap \ lvm2 lshw bind9-host bind9
- Tailor root’s environment a bit:
touch $MNT/root/.hushlogin echo 'PS1="\\h\\$ "' >> $MNT/root/.bashrc
- Prevent NIC renaming:
rm $MNT/etc/udev/rules.d/70-persistent-net.rules ln -s /dev/null $MNT/etc/udev/rules.d/70-persistent-net.rules
- Clean up by running:
exit umount $MNT/proc umount $MNT/sys # I found a dbus-daemon process was holding /mnt/dev open fuser -c $MNT/dev kill <pids-holding-$MNT/dev/-open> umount $MNT/dev umount $MNT sync
and remove the stick.
See also