0. 准备一个8GB的u盘,准备CentOS的iso,我用的是dvd的iso,可以从 http://mirrors.ta139.com/centos/6/isos/x86_64/ 下载
1. 制作u盘的系统需要安装了syslinux,我的版本是3.11
2. u盘分区成如下格式
[php]
- fdisk -l /dev/sdb
- Disk /dev/sdb: 8000 MB, 8000110592 bytes
- 255 heads, 63 sectors/track, 972 cylinders
- Units = cylinders of 16065 * 512 = 8225280 bytes
- Device Boot Start End Blocks Id System
- /dev/sdb1 * 1 65 522081 b W95 FAT32
- /dev/sdb2 66 972 7285477+ c W95 FAT32 (LBA)
3. 分别格式化两个分区
[php]
- mkfs.vfat -n BOOT /dev/sdb1
- mkfs.vfat -n DATA /dev/sdb2
4. mount DATA分区,mount第一个iso,复制一些数据到DATA分区,再把iso都复制到DATA分区,然后umount DATA分区
[php]
- mkdir -p /media/iso /media/DATA
- mount /dev/sdb2 /media/DATA
- mount -o loop /path/to/CentOS-6.0-x86_64-bin-DVD1.iso /media/iso/
- cp -rv /media/iso/images /media/DATA
- cp -rv /path/to/CentOS-6.0-x86_64-bin-DVD*.iso /media/DATA
- umount /media/DATA
[php]
- dd if=/usr/lib/syslinux/mbr.bin of=/dev/sdb
- syslinux -s /dev/sdb1
- mkdir -p /media/BOOT
- mount /dev/sdb1 /media/BOOT
- cp /media/iso/isolinux/isolinux.bin /media/BOOT/syslinux.bin
- cp /media/iso/isolinux/isolinux.cfg /media/BOOT/syslinux.cfg
- cp /media/iso/isolinux/vmlinuz /media/BOOT
- cp /media/iso/isolinux/initrd.img /media/BOOT
[php]
- default CentOS
- prompt 0
- label CentOS
- kernel vmlinuz
- append initrd=initrd.img method=hd:sdb2:/