# Say I have a clean external harddrive connected to a working linux machine, # Now I want to install debian on it so it boots when I insert it into some other computer. # Say the harddrive is connected as /dev/sdx. All data on it may be wiped. # Create partitions on that harddrive. # You can use `sudo cfdisk /dev/sdx` or `gksudo gnome-disks` for pointy-clicky. # Say we now have partion /dev/sdx1 created to become the new root filesystem. hd=/dev/sdx root_partition=/dev/sdx1 # Create file system: mkfs.ext4 $root_partition # mount mount_at=/mnt mount $root_partition $mount_at # Install debian. Let's say testing. This may take a minute. debootstrap testing $mount_at http://deb.debian.org/debian/ # make sure special magic linux stuff exists and chroot for i in dev dev/pts proc sys run; do mount -B "/$i" "${mount_at}/$i"; done chroot $mount_at bash # the chroot forgot above vars... hd=/dev/sdx root_partition=/dev/sdx1 # The new system has no kernel yet. apt-get install linux-image-amd64 # The new system has no fstab yet. Assuming that upon boot, the new root disk # will be /dev/sda1, we could use that. Probably safer would be to use the # uuid: uuid="$(dumpe2fs $root_partition | grep UUID | sed 's/.*:[ \t]*//')" echo $uuid cat /etc/fstab # rm /etc/fstab cat >> /etc/fstab < /etc/grub.d/40_custom <