- 论坛徽章:
- 0
|
USB Linux
系统的启动流程:
开机--Bois自检(硬件检测)---init 19 ---读取第一个可以引导的设备的MBR--- GRUB读取grub.conf---grub根据配置文件加载指定的内核镜像,初始化内存盘----初始化内存盘驱动必要的硬件,然后内核加载----产生第一个进程init ---init /etc/inittab ,判断运行级别---init 运行 rc.sysinit脚本,进行系统初始化:读取fstab进行必要的挂载 ----进去相应的级别,加载对应级别的服务启动脚本,接着rc.local--》根据运行级别,产生不同的登录界面
#cat /etc/redhat-release
查看系统版本
制作步骤:
1;备份U盘数据,再破坏U盘数据
dd if=/dev/sdb of=/tmp/sdb_mbr bs=512k count=1
意思:假如sdb为U盘的话,读取sdb的前512k的内容,并且存到/tmp/sdb_mbr。即为备份MBR
恢复MBR如下
dd if=/tmp/sdb_mbr of=/dev/sdb
破坏数据如下:
dd if=/dev/zero of=/dev/sdb bs=512K count=1
w95 FAT32<-----------------------------------------分区fdisk用b
分区安排:
/ 512M (必须 “打*”)
swap 256-512M(可选)
使用剩余的空间作盘U盘使用的分区(只能在linux使用)
2、在U盘产生系统必要目录结构
# rpm -ivh --root=/mnt --nodeps /share/rhel_source/Server/filesystem-2.4.0-2.i386.rpm
3、找到必要的工具和命令,安装到USB
bash-3.2-24.el5
基本操作命令 : cp mv ls
# rpm -qf `which cp`
coreutils-5.97-19.el5
系统管理命令: init shutdown
SysVinit-2.86-15.el5
分区管理命令: fdisk mount
util-linux-2.13-0.50.el5
网络命令:ifconfig
net-tools-1.60-78.el5
进程管理命令: ps free top
procps-3.2.7-11.1.el5
文本终端下鼠标驱动:gpm-1.20.1-74.1
portmap
帐号验证相关 : /etc/passwd , passwd , shadow
setup-2.5.58-4.el5
passwd-0.73-1
shadow-utils-4.0.17-14.el5
编辑器:vim-enhanced-7.0.109-4.el5_2.4z
yum install --installroot=/mnt bash coreutils SysVinit util-linux net-tools procps portmap setup passwd shadow-utils openssh-clients vim-enhanced gpm
-----------------
可选:
openssh-server-4.3p2-29.el5
openssh-clients-4.3p2-29.el5
安装完必须同步数据一次
sync
4、产生一个initrd镜像文件
# mkinitrd --with usb_storage /mnt/boot/initrd `uname -r`
5、拷贝内核镜像和内核对应的模块文件
# cp /boot/vmlinuz-2.6.18-128.el5 /mnt/boot/vmlinuz
# cp /lib/modules/2.6.18-128.el5/ /mnt/lib/modules/ -r
# sync
5、安装grub
# rpm -ivh --force --nodeps --nopre --nopost --root=/mnt/ /share/rhel_source/Server/grub-0.97-13.2.i386.rpm
安装grub的第一阶段的引导程序到mrb里(1-446字节)
[root@dns usb]# grub-install --root-directory=/usb --recheck /dev/sdb
grep: /mnt/usb/boot/grub/device.map: 没有那个文件或目录
mv: 无法 stat “/mnt/usb/boot/grub/device.map”: 没有那个文件或目录
Probing devices to guess BIOS drives. This may take a long time.
Installation finished. No error reported. 《————— 看这里
This is the contents of the device map /mnt/usb/boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.
(fd0) /dev/fd0
(hd0) /dev/sda
(hd1) /dev/sdb
# vim /mnt/boot/grub/device.map
(hd0) /dev/sdb
# vim /mnt/boot/grub/grub.conf
default=0
timeout=8
title Usb Linux
root (hd0,0)
kernel /boot/vmlinuz
initrd /boot/initrd
6、设置U盘root密码
chroot /mnt
pwconv
passwd root
cat /etc/shadow
exit
# cp /etc/skel/.bash* /mnt/root/
# sync |
|