Debian U盘制作方法
chinajz
c_xvidtune@hotmail.com
http://spaces.msn.com/chinajz
这次制作没有编译内核,u盘 256M usb1.1接口。
一、制作环境:
1. debian网络安装光盘:debian-31r0a-i386-netinst.iso;
2. U盘:256M,usb1.1接口;
3. 笔记本电脑:dell D800 ,mem 256M ,hd 40G
4.OS:debian sid (kernel 2.6.15.4)+RHEL 4 U2
二、制作步骤:
1.用fdisk分区u盘(这步可省略,放在下步做,但有时粗心直接装至sda导致系统可能不正常运行)
debian:~# fdisk /dev/sda
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): p
Disk /dev/sda: 263 MB, 263454720 bytes
9 heads, 56 sectors/track, 1020 cylinders
Units = cylinders of 504 * 512 = 258048 bytes
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1020, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1020, default 1020):
Using default value 1020
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 83
Command (m for help): p
Disk /dev/sda: 263 MB, 263454720 bytes
9 heads, 56 sectors/track, 1020 cylinders
Units = cylinders of 504 * 512 = 258048 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 1020 257012 83 Linux
Command (m for help): a
Partition number (1-4): 1
Command (m for help): p
Disk /dev/sda: 263 MB, 263454720 bytes
9 heads, 56 sectors/track, 1020 cylinders
Units = cylinders of 504 * 512 = 258048 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 1020 257012 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
2.用debian光盘直接安装到u盘(不要装grub,不然你会后悔的,因为如果你装grub,系统会以为你从u盘启动,本地硬盘grub将不能正常工作),然后在chroot 状态下安装grub
3. 在已经装好的linux上用chroot启动U盘linux操作。(在我的电脑上,光盘上resuce模式后,在控制台(Ctrl+Alt F2)可以完全操作成功,但做出的内核启动选项配置映象文件initrd.img不能正常启动,我想可能是光盘版本太低的缘故。execute a shell下则不能完成。)
建议最好在控制台下操作,而不要到xwindow下操作(如果操作最好只开一个xterm),防止对硬盘linux系统误操作.
3.1增大U盘自由空间,用chroot启动U盘linux
debian:~# mkdir -p /mnt/u
debian:~# mount /dev/sda1 /mnt/u
debian:~# rm /mnt/u/var/cache/apt/archives/*
debian:~# rm /mnt/u/tmp/*
debian:~# chroot /mnt/u
以下操作全在u盘的linux环境里,别搞错了.
3.2定制源
vi /etc/apt/sources.list
# /etc/apt/sources.list generated by apt-spy v3.1
deb http://debian.cn99.com/debian/ sid main
apt-get update
3.3删除旧内核
apt-get remove kernel-image-旧内核版本
3.4安装新内核
apt-get install module-init-tools
apt-get install kernel-image-2.6-686
3.4 升级u盘linux至sid最新版
rm /var/cache/apt/archives/*
rm /. Trash/*
apt-get upgrade
rm /var/cache/apt/archives/*
rm /. Trash/*
3.5 配置编译映象文件initrd.img的相关文件
3.5.1 修改mkinitrd.conf
vi /etc/mkinitrd/mkinitrd.conf
增加usb 1.1和2.0接口及usb-storage编译的选项:
ehci_hcd
uhci_hcd
ohci_hcd
usb-storage
3.5.2 修改modules,这里设定内核装载时间为15s
vi /etc/mkinitrd/modules
# The length (in seconds) of the startup delay during which linuxrc may be
# interrupted.
DELAY=15
3.5.3 修改fstab文件
vi /etc/fstab
# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
/dev/sda1 / ext3 defaults,errors=remount-ro 0 1
/dev/hdc /media/cdrom0 iso9660 ro,user,noauto 0 0
3.6 制作内核启动选项配置映象文件initrd.img
mount -tproc none /proc
如果你电脑上硬盘linux系统和u盘linux系统版本一样,可用以下简便操作
mkinitrd -o /boot/initrd.img-$(uname -r) $(uname -r)
如果不一样,查下/lib/modules/目录
ls /lib/modules/
以2.6.15-1-686为例
mkinitrd -o /boot/initrd.img-2.6.15-1-686 2.6.15-1-686
3.7 制作u盘的grub引导
grub-install /dev/sda1
exit
4.修改/boot/grub/menu.lst文件
对usb是2.0和1.1接口,在我的电脑上/boot/grub/menu.lst不一样才能正常启动:
usb 1.1U盘
#/boot/grub/menu.lst
title Debian GNU/Linux, kernel 2.6.15.4
root (hd0,0)
kernel /boot/vmlinuz-2.6.15.4 vga=792 root=/dev/sda1 ro
initrd /boot/initrd.img-2.6.15.4
savedefault
boot
usb 2.0移动硬盘
#/boot/grub/menu.lst
title Debian GNU/Linux, kernel 2.6.15.4
root (hd1,0)
kernel /vmlinuz-2.6.15.4 vga=792 root=/dev/sda1 ro
initrd /initrd.img-2.6.15.4
savedefault
boot
### END DEBIAN AUTOMAGIC KERNELS LIST
选择从u盘重新启动电脑,或在另一台电脑上从usb启动,应该会成功。如果有什么问题欢迎联系:
我的 email是:
c_xvidtune@hotmail.com
制作了u盘debian系统的img文件,真想有个空间大的主页,提供下载.
有兴趣的,几个人专门做个各个版本linux的U盘版下载页面,呵呵,想法是不是有点意思?