I needed to prepare a usb flash memory stick to boot, I need it to test the implementation I`m working on for my GSoC project. I recalled the things I learned when I used to be a gentoo user in 2003/2004. That time we needed to install and prepare all the system from scratch by hand, but this is one another history.
Note-1: I assume you know how to use [c]fdisk, debootstrap, chroot, and understand what a partition table means.
![]()
Note-2: These are just few notes I did while preparing my environment, it wasn`t based on some other tutorial or how-to, so you may find better tips and techniques for taking the same results;
Here we go:
1- Plug the stick and delete/create the partitions, for example;
su cfdisk /dev/sdb2
Log in as root and create the partitions as you want.
I always use to have at least two partitions an 100Mb ext2 partition for /boot dir and the remaining space to root file system - of course it depends on your system usage.
2 - make the file systems;
mkfs.ext2 /dev/sdb1 mkfs.ext3 /dev/sdb2
I created two partitions, sdb1 the boot partition and sdb2 for root file system.
3 - mount your partitions somewhere;
mkdir /media/f-stick mount /dev/sdb2 /media/f-stick mkdir /media/f-stick/boot mount /dev/sdb1 /media/f-stick/boot mount proc /media/f-stick/proc -t proc mount sys /media/f-stick/sys -t sysfs
Mounted the boot and root filesystem, the proc and sysfs as well.
4 - now we have all the needed partitions mounted. Time to prepare the basic system;
apt-get install debootstrap debootstrap sid /media/f-stick http://ftp.us.debian.org/debian/
Install debootstrap if you don`t have it already and use it to create the basic system. Please read the debootstrap`s manpage for detailed informations on its usage.
5 - chroot your brand new system and maintain it:
cp /etc/hosts /media/f-stick/etc/hosts chroot /media/f-stick /bin/bash apt-get install less grub linux-image-2.6-686 exit
Install some basic softwares, debootstrap will not install a linux kernel for you neither a boot loader.
6 - install grub stage1 to your stick`s mbr:
grub-install --root-directory=/media/f-stick /dev/sdb
7 - edit the device.map and leave only hd0 sdb;
vim /media/f-stick/boot/grub/device.map
8 - chroot again and set things up, like root password, add a new user, set its password and so on;
update-grub couldn`t probe the devices and define the sdb device, so it didn`t generate the menu.lst on my system, but I copied it from my main box and edited it to fit my needs.