I have a 4GByte-USB-Stick and want to install Debian on it, so I can carry Debian in my pocket and user (almost) any PC.
Prepare the Stick
Inside the Host-OS
Note, I use Debian to create this stick, folowing packages should be installed
apt-get install debootstrap gparted grub
- Use gparted to partition my USB Stick:
- First 500 MByte FAT32 partition so that I can share Data with windows
- Second ca. 3500 MByte ext4 partition for Debian
- Have a look at USB-Stick performance and reformat the second partition with the right options.
- create a Folder on my Debian-host to mount the usb stick
# mkdir /mnt/usb
# mount /dev/sdh2 /mnt/usb/
# debootstrap --arch i386 stable /mnt/usb
- chroot to the usb-system:
# chroot /mnt/usb
Inside the USB-Stick (chroot)
- install what you need to work:
apt-get install less vim locales ssh console-setup
dpkg-reconfigure locales
- (optional) adapt /etc/apt/sources.list to reach a nearer mirror, then update cache:
apt-get update
apt-get install linux-image-686
- Ignore the error messages about df not working: we did not mount /proc
apt-get install grub
- Grub also complains a lot. Ignore this to. When Grub asks if you are sure you do not want to install grub in a partition, say yes.
Install Grub
From the host-OS (not USB Stick!)
- Be sure to change /dev/sdh to your usb stick drive (not patition) in folowing line
grub-install --recheck --root-directory=/mnt/usb /dev/sdh
- Edit /mnt/usb/boot/grub/grub.cfg to match this:
menuentry 'boot Debian' {
insmod part_msdos
insmod ext2
search --no-floppy --fs-uuid --set root <your UUID here>
echo 'Loading Linux'
linux /vmlinuz root=UUID=<your UUID here> ro quiet
echo 'Loading initial ramdisk'
initrd /initrd.img
}
You are done, boot on your USB stick and do what you want on your new Debian GNU/Linux! I used the chroot to install kde (kde-plasma-desktop), iceweasel and so on, so I can do something else during the installation.
What next
- set the level of questions debconf should ask:
Sources
http://www.flimzy.com/index.php/Install_Debian_on_USB