Title: Create bootable Debian usb stick Subject: Procedure to create bootable usb flash drive wiht Debian using debootstrap # #-------------------- # Parition usb flash: #-------------------- # Create 1 parition, # must be partition 2 (bios grub requires) fdisk /dev/sdb #-------------------- # Create filesystem: #-------------------- # Must be ext3 mkfs.ext3 /dev/sdb2 #-------------------- # Label Filesystem: #-------------------- # Write Label e2label /dev/sdb2 usbboot # List UUID info: blkid/dev/sdb2 # # /dev/sdb2: LABEL="usbboot" UUID="345bf73c-ef6c-464a-ac99-243ec5661dc0" TYPE="ext3" # #-------------------- # Creating an Debian image using debootstrap #-------------------- mkdir debian-chroot mount /dev/sdb2 debian-chroot debootstrap --arch amd64 lenny ./debian-chroot http://ftp.debian.org/debian #---------------------- # Enter chroot #---------------------- chroot ./debian-chroot /bin/bash #---------------------- # CHROOTED: Create /etc/fstab #---------------------- cat > /etc/fstab <<'EOF' proc /proc proc defaults 0 0 LABEL=usbboot / etx3 defaults 0 0 EOF #---------------------- # CHROOTED: mount /proc and /sys #---------------------- mount -t proc proc /proc mount -t sysfs sysfs /sys #---------------------- # CHROOTED: set netowrk interfaces for dhcp #---------------------- cat >> /etc/network/interfaces <<'EOF' allow-hotplug eth0 iface eth0 inet dhcp allow-hotplug eth1 iface eth1 inet dhcp EOF #---------------------- # CHROOTED: Set hostname #---------------------- echo 'USB-BOOT' >> /etc/hostname cat > /etc/hosts <<'EOF' 127.0.0.1 localhost.localdomain localhost USB-BOOT EOF #---------------------- # CHROOTED: dns #---------------------- cat /etc/resolv.conf #---------------------- # CHROOTED: set debian sources #---------------------- cat >> /etc/apt/sources.list <<'EOF' deb http://ftp.us.debian.org/debian/ lenny main deb http://security.debian.org/ lenny/updates main deb http://backports.debian.org/debian-backports lenny-backports main EOF #---------------------- # CHROOTED: install kernel #---------------------- apt-get install aptitude alias apts='aptitude search -F "%p %V %v"' apts linux-image # # linux-image 2.6.35.22. # linux-image-2.6 # linux-image-2.6.32-305-ec2 2.6.32-305 # linux-image-2.6.35-22-generic 2.6.35-22. # linux-image-2.6.35-22-server 2.6.35-22. # linux-image-2.6.35-22-virtual 2.6.35-22. # linux-image-ec2 2.6.32.305 # linux-image-generic 2.6.35.22. # linux-image-server 2.6.35.22. # linux-image-virtual 2.6.35.22. # apt-get install linux-image-generic # Do not pick any disks to install grub # continue without installing grub. #---------------------- # CHROOTED: set groups #---------------------- # groups addgroup --system admin #---------------------- # CHROOTED: create admin user #---------------------- useradd -s /bin/bash -g admin -m -k /dev/null user #---------------------- # CHROOTED: set passwords #---------------------- passwd root # toot passwd user # toot #---------------------- # CHROOTED: Set sudo #---------------------- # Anyone in admin group can sudo cat >> /etc/sudoers <<'EOF' Defaults env_reset,insults,timestamp_timeout=0 %admin ALL=(ALL) ALL EOF #---------------------- # CHROOTED: exit #---------------------- exit #---------------------- # unmount, finish #---------------------- sync umount debian-chroot/proc umount debian-chroot/sys umount debian-chroot