2012年3月16日金曜日

HDDの初期設定(Ubuntu)

1. HDDを増設させる
一つ目にHDDはジャンパーピンがmasterになっているので、
二つ目として増設させるHDDのジャンパーピンをslaveにする。

※ケーブルセレクティングで自動認識してもよい。
この場合もジャンパーピンも指定しておくようにする。
(参考) : http://homepage2.nifty.com/kamurai/HDD2.htm


2. ドライブ類への信号ケーブルを接続する
マスターは黒色に、スレイブは灰色に接続。
(参考) : http://asugi23.web.infoseek.co.jp/diyf/diy503.htm#2


3. diskが認識されるか確認する。
PCを起動させて、
>sudo fdisk -l
Disk /dev/sda ...
...
Disk /dev/sdb ...
...

今回は二枚目を指したので、
sdaが元々ささっていたHDD(マスター)で、sdbが今回さしたスレイブのHDDだとわかる。




4. HDDをext3でフォーマットする方法
>su
>fdisk /dev/sdb
Command (m for help): p

Disk /dev/sdb: 80.1 GB, 80060424192 bytes
255 heads, 63 sectors/track, 9733 cylinders, total 156368016 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xfcf06737

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1           16065   156360644    78172290    f  W95 Ext'd (LBA)
/dev/sdb5           16128   156360644    78172258+   7  HPFS/NTFS/exFAT

Command (m for help): d
Partition number (1-5): 1

Command (m for help): d
No partition is defined yet!

Command (m for help): p

Disk /dev/sdb: 80.1 GB, 80060424192 bytes
255 heads, 63 sectors/track, 9733 cylinders, total 156368016 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xfcf06737

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4, default 1):
Using default value 1
First sector (2048-156368015, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-156368015, default 156368015):
Using default value 156368015

Command (m for help): p

Disk /dev/sdb: 80.1 GB, 80060424192 bytes
117 heads, 63 sectors/track, 21213 cylinders, total 156368016 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xfcf06737

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048   156368015    78182984   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
>

>mkfs.ext3 /dev/sdb1 mke2fs 1.41.14 (22-Dec-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
4890624 inodes, 19545746 blocks
977287 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
597 block groups
32768 blocks per group, 32768 fragments per group
8192 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 31 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
>
(参考) : http://omnioo.com/omnioolab/ubuntu-910/system/hddext3.php 

(参考) : http://blog.ysk.me/199


5. フォーマットしたHDDをマウントする
>cd /mnt
>mkdir home
>mount /dev/sdb1 /mnt/home
>df -k

>vi /etc/fstab
#
/dev/sdb1       /mnt/home       ext3    defaults        1       2
#

>mount -a
>df -k
>reboot

6. NFSの設定
(1).
まずはMaster側にサーバーを、Slave側にクライアントを入れる。
Master node側から
>su
サーバー側設定
>apt-get install portmap nfs-kernel-sever
クライアント側設定
>RSH apt-get install -y portmap nfs-common

(2). 公開用ディレクトリーを作る。
>cd /
>mkdir mnt/home

(3). Master側で/etc/exports を編集
>vi /etc/exports
#/dev/sdb1 mounted to /mnt/home. exported by (usrname) (date)
/mnt/home 192.168.1.0/24(rw,sync,fsid=1,no_root_squash,no_subtree_check)
#

(4). Master側でNFSを再起動させる
>service nfs-kernel-server restart

(5). ディレクトリをSlaveにマウントさせる(元のホームディレクトリも待避させる。)
>RSH "mv /home /home2; mkdir -p /misc/home; ln -s /misk/home /home"
>RSH "mount -t nfs 192.168.1.1:/mnt/home /home"

(6).  起動時に自動的にマウント
Slave側で、/etc/fstabファイルを変更する。
>su
>vi  /etc/fstab
#
192.168.1.1:/mnt/home /home nfs defaults 0 2
#
(参考) : http://www.atmarkit.co.jp/flinux/rensai/linuxtips/756fstabnum.html

>mount -a
logoutしてできたか確認する。
>df -h

(7). Master nodeの/homeを退避させ、/mnt/homeを/homeにリンクさせる。
>cd /
>mv home/ home2/
>ln -s /mnt/home /home
>df -h
logoutしてできたか確認する。
>df -h

0 件のコメント:

コメントを投稿