用U盘安装FreeBSD 8.0


尝试在我的X40 上安装FreeBSD 8.0 的时候遇到了个不大不小的问题。
IBM的原装USB式CD-ROM支持从光盘启动,但是当进入sysinstall,选择安装介质时,却无法发现安装光盘。
能够通过光驱启动并执行上面的程序,却无法在该程序中识别同一个光驱,真是咄咄怪事。

原本打算通过另外的机器架设FTP,无奈驱动不全,连无线网卡都无法在sysinstall 里启用。

好在FreeBSD 从版本8.0开始,提供了专为USB盘安装准备的8.0-RELEASE-i386-memstick.img 这样的封装格式。于是就动起了从U盘安装的脑筋。

我准备的是Sony 高速8G U盘,编号USM8GLX。
写入U盘的系统是位于同一台X40 上的Linux Mint 8。

将U盘插入系统,进入Linux 的控制台,输入sudo fdisk -l 查看加载信息(仅摘录相关段落):

Disk /dev/sdb: 8019 MB, 8019509248 bytes 175 heads, 32 sectors/track, 2796 cylinders Units = cylinders of 5600 * 512 = 2867200 bytes Disk identifier: 0xc3072e18     Device Boot      Start        End      Blocks  Id  System /dev/sdb1  *          1        2797    7831535+  b  W95 FAT32

由此看来,U盘上原本的分区在Linux 系统中被识别为/dev/sdb1,那么U盘这个设备就是/dev/sdb了。

接下来就是把下载好的img 文件用dd 写入U盘了。

dd if=~/8.0-RELEASE-i386-memstick.img of=/dev/sdb bs=10240 conv=sync 90157+0 records in 90157+0 records out 923207680 bytes (923 MB) copied, 114.977 s, 8.0 MB/s

等待大约2分钟做后,安装FreeBSD 的U盘制作好了,现在可以用来启动机器了。

注意,要恢复U盘的初始状态最好是用/dev/zero 重写整个U盘。例如:

dd if=/dev/zero of=/dev/sdb bs=4096

这一步视整个U盘尺寸大小而定,8G的盘基本上要15分钟左右了。
完成以上步骤之后,可以用Linux 对U盘进行格式化,就又恢复成普通盘了。

追加一下万一在Linux 下不能自动mount U盘时,对U盘进行格式化的方法。
先用sudo fdisk -l找出U盘的设备名称。假设识/dev/sdb.并且此时fdisk应该报告在/dev/sdb 上没有找到任何分区。例如:

Disk /dev/sdb: 8019 MB, 8019509248 bytes 247 heads, 62 sectors/track, 1022 cylinders Units = cylinders of 15314 * 512 = 7840768 bytes Disk identifier: 0x8f0bd969       Device Boot      Start        End      Blocks  Id  System

然后对/dev/sdb 进行分区:

sudo fdisk /dev/sdf    Command (m for help): m Command action    a  toggle a bootable flag    b  edit bsd disklabel    c  toggle the dos compatibility flag    d  delete a partition    l  list known partition types    m  print this menu    n  add a new partition    o  create a new empty DOS partition table    p  print the partition table    q  quit without saving changes    s  create a new empty Sun disklabel    t  change a partition's system id    u  change display/entry units    v  verify the partition table    w  write table to disk and exit    x  extra functionality (experts only)    Command (m for help): n Command action    e  extended    p  primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-1022, default 1):  Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-1022, default 1022):  Using default value 1022    Command (m for help): w The partition table has been altered!    Calling ioctl() to re-read partition table. Syncing disks.

用n 建立新分区,并选择p 建立第1个主分区,至于cylinder 直接回车选默认值即可。完了之后输入w 保存。

然后就是格式化U盘了。

sudo fdisk -l Disk /dev/sdf: 8019 MB, 8019509248 bytes 247 heads, 62 sectors/track, 1022 cylinders Units = cylinders of 15314 * 512 = 7840768 bytes Disk identifier: 0x8f0bd969       Device Boot      Start        End      Blocks  Id  System /dev/sdf1              1        1022    7825423  83  Linux    sudo mkfs.vfat /dev/sdf1  mkfs.vfat 3.0.3 (18 May 2009)

用mkfs.vfat 对U盘格式化之后,重新插入U盘,应该就能自动mount 出来了。

相关内容