把 Linux Live CD 裝進 USB 隨身碟

目的: 將 Linux Live CD 裝入 USB 隨身碟, 除能使用 USB 隨身碟開機之外, 剩餘空間亦可讓 Windows 或其他作業系統使用

環境

安裝相關工具

切割隨身碟磁區

umount /dev/sdb?

fdisk /dev/sdb

※刪除所有已存在的磁區
Command (m for help): d

※新增磁區
Command (m for help): n

※第一個磁區 = Data Partition, 不要全部用完, 保留 700MB 給 Linux Live CD 用
Command action: p
Partition number (1-4): 1
First cylinder (1-245, default 1): (直接按 Enter)
Last cylinder or +size or +sizeM or +sizeK: +1228M

※再新增一個磁區
Command (m for help): n

※第二個磁區 = Linux Live CD Partition
Command action: p
Partition number (1-4): 2
First cylinder (151-245, default 151): (直接按 Enter)
Last cylinder or +size or +sizeM or +sizeK: (直接按 Enter)

※變更第一磁區為 FAT32, 可在 Windows 使用 Data Partition
Command (m for help): t

Partition number (1-4): 1
Hex code (type L to list codes): b

※變更第二磁區為 FAT16, 可使用 SYSLINUX Boot Loader
Command (m for help): t

Partition number (1-4): 2
Hex code (type L to list codes): 6

※第二磁區標註開機旗標 (for SYSLINUX)
Command (m for help): a

Partition number (1-4): 2

※查看磁區配置情況
Command (m for help): p

DeviceBootStartEnd

Blocks

IdSystem
/dev/sdb1 11501204843+bW95 FAT32
/dev/sdb2*151245763087+6FAT16


※寫入以上設置內容, 離開 fdisk
Command (m for help): w

mkfs.vfat -F 32 /dev/sdb1

mkfs.vfat -F 16 /dev/sdb2

mkdir /mnt/iso /mnt/usb

mount -o loop live-cd.iso /mnt/iso

mount /dev/sdb2 /mnt/usb

把 SLAX 裝進 USB 隨身碟

SLAX Linux: http://www.slax.org/
使用版本: slax-5.1.8.1

cp -a /mnt/iso/* /mnt/usb

mv /mnt/usb/isolinux.cfg /mnt/usb/syslinux.cfg

umount /mnt/usb

syslinux -sf /dev/sdb2

qemu /dev/sdb (測試能否開機)

lilo -M /dev/sdb (若開機失敗, 用這個指令修正 MBR)

把 DSL (Damn Small Linux) 裝進 USB 隨身碟

Damn Small Linux: http://www.damnsmalllinux.org/
使用版本: dsl-3.4.3

Loader: SYSLINUX

cp -a /mnt/iso/boot/isolinux/* /mnt/usb

cp -a /mnt/iso/KNOPPIX /mnt/usb

cd /mnt/usb

mv isolinux.cfg syslinux.cfg

mv isolinux.bin syslinux.bin

cd && umount /mnt/usb

syslinux -sf /dev/sdb2

qemu /dev/sdb (測試能否開機)

lilo -M /dev/sdb (若開機失敗, 用這個指令修正 MBR)

Loader: GRUB

cp -a /mnt/iso/boot/isolinux/* /mnt/usb

cp -a /mnt/iso/KNOPPIX /mnt/usb

mkdir -p /mnt/usb/boot/grub

cp /mnt/usb/linux24 /mnt/usb/boot

cp /mnt/usb/minirt24.gz /mnt/usb/boot

cp /boot/grub/stage? /boot/grub/fat_stage1_5 /mnt/usb/boot/grub (*1_5 依磁區類型選用)

touch /mnt/usb/my-usb

grub --no-floppy

grub> find /my-usb

(hd1,1)

grub> root (hd1,1)

Filesystem type is fat, partition type 0x6

grub> setup (hd1)

grub> quit

vi /mnt/usb/boot/grub/grub.conf

default 0
timeout 10

title My Live-USB
root (hd0,1)
kernel /boot/linux24
initrd /boot/minirt24.gz

umount /mnt/usb

qemu /dev/sdb (測試能否開機)

把 Ubuntu 裝進 USB 隨身碟

Ubuntu Linux: http://www.ubuntu.com/
使用版本: ubuntu-7.04-desktop-i386

cd /mnt/iso

cp -rf casper disctree dists install pics pool preseed .disk \
    isolinux/* md5sum.txt README.diskdefines ubuntu.ico \
    install/mt86plus /mnt/usb

cd /mnt/usb

mv isolinux.cfg syslinux.cfg

mv isolinux.bin syslinux.bin

vi syslinux.cfg

※拿掉所有的 /cdrom/ 字串
:%s/\/cdrom\///g

※於 initrd.gz quiet 之間加入 ramdisk_size=1048576 root=/dev/ram rw
:%s/gz qu/gz ramdisk_size=1048576 root=\/dev\/ram rw qu/g

※將原本 DEFAULT /casper/vmlinuz 改成如下
DEFAULT usb

※複製 LABEL live, 改成如下
LABEL usb
menu label ^Start Ubuntu in persistent mode
kernel /casper/vmlinuz
append file=preseed/ubuntu.seed boot=casper persistent initrd=/casper/initrd.gz ramdisk_size=1048576 root=/dev/ram rw quiet splash --

:x!

cd && umount /mnt/usb

syslinux -sf /dev/sdb2

qemu /dev/sdb (測試能否開機)

lilo -M /dev/sdb (若開機失敗, 用這個指令修正 MBR)


參考資料

arrow
arrow
    全站熱搜

    alex0126 發表在 痞客邦 留言(0) 人氣()