======LiveUsb======
=====簡介=====
製作Live Usb的概念與早期救援磁片是一樣的,就是透過其他裝置媒體,像是軟碟、CD、MO、USB等裝置,裝載有開機載入程式(BootLodar)及小型作業系統。
本篇重點在利用USB裝置媒體來製作LiveUSB。LiveUSB大致區分有**CD**式及**硬碟**式兩類;CD式將LiveCD灌入USB中來達到開機功能,硬碟式就是像一般安裝作
業系統(2000,XP,win7,Linux等)到電腦中一樣。
=====CD式作法=====
- 自動程式包:[[http://unetbootin.sourceforge.net/|Unetbootin]],[[http://www.cyut.edu.tw/~ckhung/p/mk-boot-usb/index.en.php|Mk-boot-usb]]
- 手工打造
* 盡量準備 >= 2G的USB隨身碟
* 預設分割目標:
| 分割區 | 容量 | 裝載系統 |
|第一分割區(主要分割)| 1GB |Ext2 安裝開機載入程式(GRUB)及ttyLinux |
|第二分割區(主要分割) | 2GB |Ext2 Fedora 15 |
|第三分割區(主要分割)| 1GB| Fat32 裝資料使用|
* 分割硬碟:[root@andy /]#/sbin/fdisk -l
~略~
Disk /dev/sdb: 4127 MB, 4127195136 bytes
197 heads, 15 sectors/track, 2727 cylinders
Units = cylinders of 2955 * 512 = 1512960 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 2727 4029135 b W95 FAT32
[root@andy /]# /sbin/fdisk /dev/sdb
Command (m for help):d
Command (m for help): n
Command action
e extended
p primary partition (1-4)
Partition number (1-4): 1
First cylinder (1-2727, default 1): (Press Enter)
Last cylinder or +size or +sizeM or +sizeK (1-2727, default 2727):+1024M
Command (m for help):a
以上只間單介紹 /sbin/fdisk 分割一個主要分割區
~略~
* 安裝(BootLoader)Grub開機管理程式:假設以完成分割[root@andy /]# /sbin/fdisk -l
~略~
Disk /dev/sdb: 4127 MB, 4127195136 bytes
197 heads, 15 sectors/track, 2727 cylinders
Units = cylinders of 2955 * 512 = 1512960 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 678 ~略~ 1001737+ 83 Linux
/dev/sdb2 679 2033 2002012+ 83 Linux
/dev/sdb3 2034 2727 1025385 b W95 FAT32
掛載/dev/sdb1 的掛載點為 /media/disk,再安裝GRUB boot loader開機載入程式
[root@andy /]# mount /dev/sdb1 /media/disk
[root@andy disk]# /sbin/grub-install --root-directory=/media/disk /dev/sdb
* 修改grub.conf:
可以參考洪朝貴老師網站所寫的GRUB設定檔[[http://www.cyut.edu.tw/~ckhung/b/sa/menu.lst|menu.list]]
[root@andy disk]#vim /media/disk/boot/grub/grub.conf
default 0
timeout 10
splashimage=/boot/grub/gnu-tux-usb.xpm.gz
## End Default Options ##
title ttylinux
kernel /boot/ttylinux/isolinux/bzImage load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=8192 ro root=/dev/ram0
initrd /boot/ttylinux/isolinux/filesys
* 另外對於DSL,Debian或是slax版本的開機選單參數範本
title DSL 4.4.10
kernel (hd0,16)/dsl-4.4.10/boot/isolinux/linux24 ramdisk_size=100000 init=/etc/init lang=us apm=power-off vga=791 nomce noapic quiet knoppix_dir=dsl-4.4.10/KNOPPIX BOOT_IMAGE=knoppix
initrd (hd0,16)/dsl-4.4.10/boot/isolinux/minirt24.gz
title slax 6.1.2 work space
kernel (hd0,16)/slax-6.1.2/boot/vmlinuz ramdisk_size=6666 root=/dev/ram0 rw autoexec=xconf;telinit~4 from=/slax-6.1.2/ changes=/slax-6.1.2/slax/
initrd (hd0,16)/slax-6.1.2/boot/initrd.gz
title Clonezilla live 1.2.7-11-i686
kernel (hd0,16)/clonezilla/live/vmlinuz boot=live config noswap nolocales edd=on nomodeset ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_keymap="" ocs_live_batch="no" ocs_lang="" vga=788 ip=frommedia nosplash live-media-path=/clonezilla/live
initrd (hd0,16)/clonezilla/live/initrd.img
* 複製LiveCD資料到usb分割區中:
選定ttyLinux這個精簡版本[[http://www.minimalinux.org/ttylinux/Download/bootcd-i386-5.3.iso.gz|bootcd-i386-5.3.iso.gz]]
[root@andy disk]#mkdir -p /media/disk/boot/ttylinux
下載的ttyLinux iso檔,掛載到/media/disk2/
[root@andy disk]#mount -o loop bootcd-i386-5.3.iso /dev/media/disk2 && cd /media/disk2
[root@andy disk2]#cp -a . /media/disk/boot/ttylinux/
* 測試:
將BIOS調成USB-HDD開機,測試是否能進入開機選單及載入KERNEL並進入作業系統。
另外,有安裝qemu這個套件的話,可以使用QEMU模擬測試看看
[root@andy disk2]#umount /dev/sdb1
[root@andy disk2]#qemu -usb /dev/sdb
=====硬碟式作法=====
- [[http://www.wretch.cc/blog/billypan101&article_id=8891814|如何把ubuntu 7.04(完整Linux系統,非Live CD)裝入隨身碟中(傻瓜必勝版)]]
- [[http://rj.twbbs.org/wiki/debian/install/install_debian_to_usb|將Debian安裝於USB]]
=====參考資料=====
- [[http://www.cyut.edu.tw/~ckhung/b/sa/usb-boot.php|資訊人權貴]]
- [[http://www.cyut.edu.tw/~ckhung/b/slax/menu.php|Grub 選單設定]]
- [[http://rj.twbbs.org/wiki/|Rj]]
- [[http://shanview.blogspot.com/2011/01/syslinux-usb-linux.html|syslinux 在 USB 上建立可開機的 linux ]]
- [[http://wiki.centos.org/zh-tw/HowTos/InstallFromUSBkey|Centos_Wiki USB 儲存器來安裝 CentOS ]]
- [[https://launchpad.net/win32-image-writer|
Image Writer for Windows]]
- [[http://laoguang.blog.51cto.com/6013350/1109871|用U盤自動化安裝CentOS]]