从U盘安装操作系统
2015-11-19 12:07:17 阿炯

U盘安装系统越来越方便,以后说不定光盘安装会成为历史。目前几乎所有主流的操作系统都会有iso格式的镜像文件发布,U盘由于其擦写方便,到处可用,已经成为目前安装系统的主流。本文介绍为Linux和FreeBSD制作产U盘启动,Windows可用像深度U盘启动制作工具之类的工具实现。

U盘安装Debian

U盘资料备份好,iso文件准备好,确定U盘设备号,假定为/dev/sdc,则使用命令:
dd if=<file> of=/dev/sdX bs=4M; sync

(注意不是/dev/sdX1,否则会出现‘isolinux.bin missing or corrupt'错误)
参考命令:http://www.debian.org/CD/faq/index.en.html#write-usb

dd if=<file> of=<device> bs=4M; sync

dd if=freeoa-11.7-x64-dvd1.iso of=/dev/sdc bs=8M status=progress;sync

dd if=<文件名> of=<设备文件名> bs=4M; sync

参数说明:
<文件名> 是映像的名称,例如 "netinst.iso"
<设备文件名> 是 U盘所对应的设备文件名,例如 /dev/sda,/dev/sdb。请小心确认输入了正确的设备文件名, 因为如果填写错误,该指令同时也能轻易写入硬盘而导致资料受损!
"bs=4M" 告诉 dd 每次读写 4 MiB 区块来增加效能; 原来的默认值是 512 位元组,相较之下会很慢
"sync" 是用来确定指令结束之前所有的写入都已完成。

<file> is the name of the input image, e.g. netinst.iso

<device> is the device matching the USB flash drive, e.g. /dev/sda, /dev/sdb. Be careful to make sure you have the right device name, as this command is capable of writing over your hard disk just as easily if you get the wrong one!

bs=4M tells dd to read/write in 4 megabyte chunks for better performance; the default is 512 bytes, which will be much slower.

The sync is to make sure that all the writes are flushed out before the command returns.

除了上述给 Linux 系统的步骤以外,也有 win32diskimager 程序可以在 Windows 中建立可开机的 USB 盘。提示: win32diskimager 默认只会显示输入档名为 *.img 的档案,而 Debian 映像的档名为 *.iso。 如果要使用此工具,请记得更改过滤器为 *.*。

Windows平台下还可以使用Universal USB Installer软件,下载地址:http://www.pendrivelinux.com/universal-usb-installer-easy-as-1-2-3/

从U盘引导安装FreeBSD(Making FreeBSD iso bootable on a USB drive)

memstick
This can be written to an USB memory stick (flash drive) and used to do an install on machines capable of booting off USB drives. It also supports booting into a "livefs" based rescue mode. There are no pre-built packages.

As one example of how to use the memstick image, assuming the USB drive appears as /dev/da0 on your machine something like this should work:
dd if=FreeBSD-9.0-RELEASE-amd64-memstick.img of=/dev/da0 bs=10240 conv=sync

Be careful to make sure you get the target (of=) correct.
dd if=bsdisk.iso of=/dev/sdd bs=10240 conv=sync
233255+0 records in
233255+0 records out
2388531200 bytes (2.4 GB) copied, 715.281 s, 3.3 MB/s

How to put a FreeBSD installation ISO onto a USB Flash Drive

Assumes USB drive uses device da0, which is usually the case. Modify device names as needed. Unless special permissions have been set up, the commands usually need to be run as root.
./fbsd-install-iso2img.sh ./8.2-RELEASE-amd64-bootonly.iso ./8.2-RELEASE-amd64-bootonly.img

Use fbsd-install-iso2img.sh script to convert the ISO into an appropriate disk image. (Paths assume script and all files are in the current directory; modify paths as appropriate.)

NOTE THAT MEMORYSTICK IMAGES ARE NOW AVAILABLE FOR FREEBSD STARTING WITH VERSION 8, SO THE ISO-TO-IMG CONVERSION STEP ABOVE IS NOT NEEDED.

注意:MEMORYSTICK镜像从FREEBSD 8开始可用了,所以不需要其上所述的ISO-TO-IMG转换步骤。只需下载和使用memorystick并按下面的步骤操作即可。

fdisk -BI /dev/da0
Create a bootable BSD slice on the USB flash drive, using the entire disk. THIS DESTROYS ALL DATA ON THE FLASH DRIVE! (Ignore the "Geom not found" warning.)

bsdlabel -B -w da0s1
Put a BSD label on the flash drive and copy bootstrap code to it.

newfs -U -L FreeBSDboot /dev/da0s1a
Create a FreeBSD file system on the flash drive.

dd if=8.2-RELEASE-amd64-bootonly.img of=/dev/da0 bs=10k conv=sync
Copy the image file to the USB flash drive.

参考链接
http://www.jeffchan.com/freebsd-iso-to-usb.html

理解bsd的分区规则
http://www.kuqin.com/docs/freebsd-handbook/disk-organization.html