Total Pageviews

Friday, 28 December 2012

在优盘上安装DEBIAN




It takes about 123 MB to store everything here, so I would say you need a
256 MB USB Memory Stick, however , since I did not spend much time to go to
the gym and lose some weight, it is possible to further shrink it down. Some
tricks people use are: use a 2.4 kernel, busybox, use packages with
ulibc, delete all docs, dpkg stuff, use a compressed filesystem

I purposely choose sarge, a now obsolete release, and kernel 2.6.8, just
because I get it to work and I would recommend you to do the same, but if
you are brave enough you can try other kernel. You may encounter other
problems because 2.6.12 and above use a different mkinitrd, udev, so...


mkdir -p /mnt/usb    
fdisk /dev/sda1
mkfs -t reiserfs /dev/sda1
mount /dev/sda1 /mnt/usb

cd ~tmtong/projects/usbboot/
[ ! -d x86-sarge ] && cdebootstrap sarge x86-sarge
cp -a x86-sarge/* /mnt/usb/


grub-install --no-floppy --recheck --root-directory=/mnt/usb /dev/sda

nano /mnt/usb/etc/apt/sources.list
deb http://mirrors.kernel.org/debian/ sarge main non-free contrib
deb http://security.debian.org/ sarge/updates main non-free contrib


nano /mnt/usb/etc/fstab
proc            /proc           proc    defaults        0       0
/dev/sda1       /               reiserfs    defaults    0       0
usbdevfs        /proc/bus/usb   usbdevfs        defaults        0       0

cp /etc/resolv.conf /mnt/usb/etc
mkdir -p /mnt/usb/etc/network
cp /etc/network/interfaces /mnt/usb/etc/network
cp /etc/hostname /mnt/usb/etc/

nano /mnt/usb/etc/hosts
127.0.0.1 localhost.localdoman localhost


mkdir -p /mnt/usb/etc/mkinitrd
nano /mnt/usb/etc/mkinitrd/modules
sd_mod
ehci-hcd
uhci-hcd
ohci-hcd
usb-storage

nano /mnt/usb/etc/mkinitrd/mkinitrd.conf
MODULES=most
DELAY=10
ROOT=probe
UMASK=022
MKIMAGE='mkcramfs %s %s > /dev/null'
BUSYBOX=no
PKGSCRIPTS=yes
INITRD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH


nano /mnt/usb/boot/grub/menu.lst

default         0
timeout         3
hiddenmenu
title           Debian GNU/Linux, kernel 2.6.8-2-386
root            (hd0,0)
kernel          /boot/vmlinuz-2.6.8-2-386 root=/dev/sda1 ro
initrd          /boot/initrd.img-2.6.8-2-386
savedefault
boot

nano /etc/bash.bashrc
export LC_ALL=en_US.ISO_8859-1
export LC_CTYPE=en_US.ISO_8859-1
export LANG=en_US.ISO_8859-1
export LESSCHARSET=latin1




chroot /mnt/usb
mount -t proc /proc proc
apt-get update
apt-get upgrade

apt-get install locales
choose en_US.ISO_8859-1 only

apt-get install kernel-image-2.6.8-2-386 discover localepurge
choose en en_US only

passwd

rm -f /etc/mtab
ln -s /proc/mounts /etc/mtab

apt-get --purge remove aptitude exim4 exim4-base exim4-config info \
ed fdutils manpages man-db nvi ppp \
pppconfig pppoeconf setserial telnet

apt-get clean
rm -f /var/lib/apt/lists/*debian*

umount /proc
exit

reboot