如何新增硬碟

在 FreeBSD 裡面新增硬碟其實很簡單。
首先把硬碟掛上去,你可以用 DOS 的 pfdisk.exe 來分割新的 partition,或是以 DOS 的 fdisk.exe 割一個 primary partition,再用 pfdisk.exe 把 partition ID 改成 165 (十進位)。
* 如果你想用 FreeBSD 的 fdisk,在進入 FreeBSD 後先以 Step-4 的方法建立 /dev/sd0s2*,再執行 fdisk sd0 觀察 sd0 的硬碟分割狀況,如下範例︰(這是 1G 的 SCSI Fireball,已經割了一個 primary FreeBSD partition)
From:http://www.douzhe.com/mirrors/fanqiang.com/a1/b2/20010416/150114_b.html
******* Working on device /dev/rsd0 *******
parameters extracted from in-core disklabel are:
cylinders=1042 heads=64 sectors/track=32 (2048 blks/cyl)
Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=1042 heads=64 sectors/track=32 (2048 blks/cyl)
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 0 is:
sysid 165,(FreeBSD/NetBSD/386BSD)
start 32, size 614368 (299 Meg), flag 80
beg: cyl 0/ sector 1/ head 1;
end: cyl 299/ sector 32/ head 63
The data for partition 1 is: <<<--- 欲新建於此 !!!
^^^^^^^^^^^^
The data for partition 2 is:
The data for partition 3 is:
再來就要開始分割了,鍵入 fdisk -i sd0,首先它會問你硬碟的參數,如︰
******* Working on device /dev/rsd0 *******
parameters extracted from in-core disklabel are:
cylinders=1042 heads=64 sectors/track=32 (2048 blks/cyl)
Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=1042 heads=64 sectors/track=32 (2048 blks/cyl)
Do you want to change our idea of what BIOS thinks ? [n]
如果有錯誤 (注意︰你必須非常 解各種 translation 的數據),不然不需要修改,直接回答 n 或按 Enter 跳過。 (在本範例中,這顆 Fireball 沒有經過 SCSI Translate,所以數據為 cyl=1042, heads=64, sec/track=32)
再來它會依次問你 primary 1,2,3,4 的分割狀況,根據你的情形回答,不改變的回答 n,要改變的回答y。比方說,第二個 primary partition (在 FreeBSD 中為 partition 1, 由零開始) 是空的,你想建立成 FreeBSD partition,你應該會看到︰
The data for partition 1 is:
Do you want to change it? [n]
這時候回答 y,再來它會問你︰
Supply a decimal value for "sysid" [0]
請回答 165,這是 UFS 的 partition ID。 接下來是此 partition 的開始位址︰
Supply a decimal value for "start" [0]
由於此範例中新增的 partition 是從第 300MB 開始,大小為742MB, 因此 start 應為 300*2048 = 614400。 你要是不會算的話,把前面已經存在的 partition 資料加起來,如︰
partition 0: start 32, size 614368 (299 Meg), flag 80
start+size (32+614368) 就是囉!
要是你是從該硬碟的最前面開始,start 請回答 "32" !! 注意︰不是 0 !! 因為要預留一些空間給 MBR 之類的。
再來它會問你該 partition 的大小,如︰
Supply a decimal value for "size" [0]
請回答 MB*2048,如此範例為 742*2048 = 1519616。
再來它會問你是否要明確的定義從那個 cyl 的那個 head 開始︰
Explicitly specifiy beg/end address ? [n]
這除了超人以外,是沒有必要去明確定義的。就回答 n 就好了。
然後它會把這個新建的 partition 資料印出來,如︰
sysid 165,(FreeBSD/NetBSD/386BSD)
start 614400, size 1519616 (742 Meg), flag 0
beg: cyl 300/ sector 1/ head 0;
end: cyl 17/ sector 32/ head 63
Are we happy with this entry? [n]
如果你確定無誤後,回答 y 繼續。
然後它會繼續問你後面剩下的 partition 是否要更動,如果沒有的話就一路回答 n 到所有的 partition 完。 然後它會問你是否要改變 active 的 partition,如︰
Do you want to change the active partition? [n]
如果不是開機用的 partition 就不要更動了。
最後它會確定你要不要更動 partition table,如︰
Should we write new partition table? [n]
確定的話,復頌一遍大鎯頭的名言︰ "Trust me, I know what I am doing !" 再回答 y。
後悔的話回答 n 或按 Ctrl-C 都可以,你的 partition table 就不會被更動。
@@建立新的 device nodes ︰
cd /dev
./MAKEDEV sd0
./MAKEDEV sd0s1a
這樣會在 /dev 下建立出 sd0s1a, sd0s1b, sd0s1c, ... ,sd0s1h
構思好你的 slice 分割情形,例如 sd0s1 是 300MB 大小,你想要把一開始的 30MB 割給 /tmp,把再來的 64MB 割給 swap, 在把最後的 206MB 給 /home。 當然在分割的時候你只要分兩種情形,是FileSystem 或是 Swap, 要 mount 到那裡是 /etc/fstab 中定義的。
@@建立一個空的 disklabel
$ disklabel -r -w sd0s1 auto
@@執行 disklabel -e sd0s1 你應該會看到︰
# /dev/rsd0s1c:
type: SCSI
disk: sd0s1
label:
flags:
bytes/sector: 512
sectors/track: 32
tracks/cylinder: 64
sectors/cylinder: 2048
cylinders: 299
sectors/unit: 614368
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0 # milliseconds
track-to-track seek: 0 # milliseconds
drivedata: 0
@@partitions:
# size offset fstype [fsize bsize bps/cpg]
c: 614368 0 unused 0 0 # (Cyl. 0 - 299*)

Please follow and like us:

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *