事前にハードディスクドライブを接続しておく。
OS: Debian GNU/Linux Sarge
現在接続中のHDDを調べる
# cat /proc/ide/ide0/hda/media
disk
# cat /proc/ide/ide0/hdb/media
disk
# cat /proc/ide/ide1/hdc/media
cdrom
# cat /proc/ide/ide1/hdd/media
cat: /proc/ide/ide1/hdd/media: そのようなファイルやディレクトリはありません
# cat /proc/ide/hda/model
FUJITSU MPE3136AT
# cat /proc/ide/ide0/hdb/model
ST380011A
# cat /proc/ide/ide1/hdc/model
FX001DE
# cat /proc/ide/ide1/hdd/model
cat: /proc/ide/ide1/hdd/model: そのようなファイルやディレクトリはありません
/proc/ide/hda とかの短縮パス系でもOK.
現在使用中のファイルシステムを調べる
# df -ahT
Filesystem Type サイズ 使用 残り 使用% マウント位置
/dev/hda1 ext3 73G 32G 38G 47% /
proc proc 0 0 0 - /proc
devpts devpts 0 0 0 - /dev/pts
tmpfs tmpfs 252M 0 252M 0% /dev/shm
usbfs usbfs 0 0 0 - /proc/bus/usb
パーティションの設定
追加したHDDを /dev/hdb として、
# fdisk /dev/hdb
n -> p -> 1 のような流れ。最後に w で書き込み。わからなくなったら m でヘルプを見る。
# fdisk /dev/hdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
The number of cylinders for this disk is set to 9729.
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)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-9729, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-9729, default 9729):
Using default value 9729
Command (m for help): p
Disk /dev/hdb: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 1 9729 78148161 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
ファイルシステム ext3 でフォーマット
# mkfs -t ext3 /dev/hdb1
mke2fs 1.40-WIP (14-Nov-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
9781248 inodes, 19537040 blocks
976852 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
597 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
e2fsck でファイルシステムのチェック(不要?)
e2fsck はマウント前に実行する必要がある。
-c このオプションを指定すると e2fsck は badblocks(8) プログラムを呼び出してファイルシステムの不良ブロックを探し、見つかったものを不良ブロック inode に加える。このオプションが 2 つ指定されると、不良ブロックのスキャンは非破壊的 read-write テストを用いて行われる。
(中略)
-f ファイルシステムが clean な場合でも、強制的にチェックする。
(中略)
-p ファイルシステムを質問なしで自動的に修復 (preen) する。
man e2fsck 「e2fsck - Linux ext2/ext3 ファイルシステムをチェックする」
# e2fsck -c -f -p /dev/hdb1
マウントする
# mkdir /hoge
# mount /dev/hdb1 /hoge
/etc/fstab で定常的にマウント設定
# cat /etc/fstab
# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
/dev/hda1 / ext3 defaults,errors=remount-ro 0 1
/dev/hda5 none swap sw 0 0
/dev/hdb1 /hoge ext3 defaults 0 2
/dev/hdc /media/cdrom0 iso9660 ro,user,noauto 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto 0 0
参考
tags: zlashdot Linux
Posted by NI-Lab. (@nilab)