2009年4月29日水曜日

ハードディスクを増設する その2

PCがハードディスクを認識してくれたので、パーテションを切ってフォーマットし、マウントします。

パーテション作成
fdiskコマンドを使用します。
rootでfdiskコマンドを使用します。引数にパーティションを作成したいハードディスクのパスを指定します。今回は/dev/sdb
$ sudo fdisk /dev/sdb

The number of cylinders for this disk is set to 38913.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help):

と出ます。会話形式で設定できます。ここでmを押すと、コマンド一覧が見られます。

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)

まず、pで現在の状況を確認します。

Command (m for help): p

Disk /dev/sdb: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xa491436f

Device Boot Start End Blocks Id System
何も表示されない
空のハードディスクなので、何も表示されません。次に、パーテションの作成のためにnを押します。基本パーテションの1番目を5Gバイトだけ作りたいときは以下のようになります。

Command (m for help): n
Command action
e extended 拡張パーテショ
p primary partition (1-4) 基本パーテション
p 基本パーテションを選択
Partition number (1-4): 1 基本パーテションの1番目
First cylinder (1-38913, default 1): シリンダーの番号 何も選択しないと、次の番号から始まる。
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-38913, default 38913): 5000M 終わりのシリンダー番号か、使用するサイズ。今回は5G = 5000Mバイト

Command (m for help): p

Disk /dev/sdb: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x6a61c320

Device Boot Start End Blocks Id System
/dev/sdb1 1 5000 40162468+ 83 Linux 新しいパーテションが出来上がっている。

Command (m for help): w 記録して保存

今回はもう一つ、残りの容量すべてを使ったパーテションを作りました。最終的にはこうなります。

Command (m for help): p

Disk /dev/sdb: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xa491436f

Device Boot Start End Blocks Id System
/dev/sdb1 1 609 4891761 83 Linux
/dev/sdb2 610 38913 307676880 83 Linux



フォーマット

フォーマットします。mkfsコマンドを使用します。今回はファイルシステムにext3を使いたいので、-tオプションでext3を指定します。

mkfs -t ext3 /dev/sdb1
mkfs -t ext3 /dev/sdb2

マウント
上のsdb2のパーティションを/home/sambaにマウントします。こうすることで、システム回りとデータ置き場を物理的に切り離します。

#mkdir /home/samba
#mount /dev/sdb2 /home/samba

再起動後にはマウント設定がクリアされてしまう(らしい)ので、/etc/fstabを書き換えておきます。
# file system mount point type options dump pass
/dev/sdb2 /home/samba ext3 defaults,noatime 0 0

以上で設定は終わりです。

参考
http://www.express.nec.co.jp/linux/distributions/knowledge/system/fdisk.html
http://www.itmedia.co.jp/help/tips/linux/l0112.html

0 件のコメント: