![]() |
| ◆ | ユーザーディレクトリ・ホームページファイル |
|
一般的には /home ディレクトリに各ユーザーのホームディレクトリやその下にメールボックス等が作成され、ホームページファイルは
/var/www/html ディレクトリに
格納される設定になっている 色々な種類のサーバーやホームページを作って行く段階で FTPを使い各種データをサーバーにアップしようとした場合、ユーザーは自分のホームディレクトリにしかアクセスできないので各種データのアップ先をユーザー のホームディレクトリと同じディレクトリにする しかし、セキュリティー等を考えた時ユーザーのホームディレクトリがシステムファイルと同一HDDにあるのは問題があり、システムがクラッシュした場合等には各種データも消えてしまう可能性が大きい ので新たにHDDを増設し、そのHDD内に各ユーザーのホームディレクトリを作成し各種 データを格納する |
|
| ◆ | 増設HDDの確認 |
| HDDを増設したら正しく認識されているか確認 | |
|
[root@centos]# fdisk -l ← 入力 Disk /dev/sda: 10.1 GB, 10110320640 bytes ← 既存のHDD 255 heads, 63 sectors/track, 1229 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000ef6d3 Device Boot Start End Blocks Id System /dev/sda1 * 1 64 512000 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 64 1230 9359360 8e Linux LVM Disk /dev/sdb: 13.6 GB, 13578485760 bytes ← 増設したHDD 240 heads, 63 sectors/track, 1754 cylinders Units = cylinders of 15120 * 512 = 7741440 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x2ad42ad3 Device Boot Start End Blocks Id System /dev/sdb1 * 1 1753 13252648+ c W95 FAT32 (LBA) 以下略 |
|
|
P-ATA(IED)の場合 Primary/Master : sda Primary/Slave : sdb Secondary/Master : sdc Secondary/Slave : sdd S-ATA の場合 1番ポート : sda 2番ポート : sdb 3番ポート : sdc 4番ポート : sdd 上記のように増設HDDの情報が表示されれば 認識されている |
|
| ◆ | 領域の確保及びフォーマット |
| fdiskコマンドを使いHDDの領域確保を行う | |
| <他のPCで利用していた古いHDDの場合> | |
|
[root@centos]# fdisk /dev/sdb ← 入力 WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): p ← 入力(パーティションの確認) Disk /dev/sdb: 13.6 GB, 13578485760 bytes 240 heads, 63 sectors/track, 1754 cylinders Units = cylinders of 15120 * 512 = 7741440 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x2ad42ad3 Device Boot Start End Blocks Id System /dev/sdb1 * 1 1753 13252648+ c W95 FAT32 (LBA) Command (m for help): d ← 入力(パーティションの削除) Selected partition 1 Command (m for help): p ← 入力(パーティションの確認) Disk /dev/sdb: 13.6 GB, 13578485760 bytes 240 heads, 63 sectors/track, 1754 cylinders Units = cylinders of 15120 * 512 = 7741440 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x2ad42ad3 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): 1 ← 入力(基本領域の番号を指定する) First cylinder (1-1754, default 1): ← 何も入力しないでEnterを押す Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-1754, default 1754): ← 何も入力しないでEnterを押す Using default value 1754 Command (m for help): p ← 入力(基本領域の設定を確認する) Device Boot Start End Blocks Id System /dev/sdb1 1 1754 13260208+ 83 Linux Command (m for help): w ← 入力(保存して終了する) The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. |
|
| <新しいHDDの場合> | |
|
[root@centos]# fdisk /dev/sdb ← 入力 WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): n ← 入力(新しい領域を作る) Command action e extended p primary partition (1-4) p ← 入力(基本領域を作る) Partition number (1-4): 1 ← 入力(基本領域の番号を指定する) First cylinder (1-1754, default 1): ← 何も入力しないでEnterを押す Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-1754, default 1754): ← 何も入力しないでEnterを押す Using default value 1754 Command (m for help): p ← 入力(基本領域の設定を確認する) Device Boot Start End Blocks Id System /dev/sdb1 1 1754 13260208+ 83 Linux Command (m for help): w ← 入力(保存して終了する) The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. |
|
| HDDのフォーマット | |
|
[root@centos]# mkfs.ext3 /dev/sdb1 ← 入力 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 829056 inodes, 3315052 blocks 165752 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=3397386240 102 block groups 32768 blocks per group, 32768 fragments per group 8128 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208 Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 38 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. |
|
| ◆ | 増設HDDのマウント |
| 増設したHDDを /home
に割り当てる 既存の /home にある各ユーザーのデータをバックアップし、増設したHDDに各ユーザーのデータを移動し、増設HDDを /home として利用 これにより /home は独立したHDDにできホームページや各ユーザーのファイルディレクトリの容量も増やす事ができる |
|
|
[root@centos]# mkdir /home_backup ← 入力(バックアップ先ディレクトリの作成) [root@centos]# mv /home/* /home_backup/ ← 入力(/home のデータをバックアップディレクトリへ移動) [root@centos]# mount /dev/sdb1 /home <--- 入力(増設HDDをマウント) [root@centos]# mv /home_backup/* /home/ <--- 入力(増設HDDへバックアップした /home データへ移動) |
|
| PCを起動する度に増設したHDDをマウントするのは面倒なので /etc/fstab を編集して、起動時に増設したHDDが自動的にマウントされるように設定 | |
|
[root@centos]# vi /etc/fstab ← 入力 途中略 /dev/sdb1 /home ext3 defaults 1 2 ← 最終行に追記 |
|
| ※別の利用方法 増設したHDDを /home/all_usr に割り当てる 既存の /home 内に /all_usr を割り当て増設HDDを /home/all_usr として各ユーザーの共有ディレクトリとして利用 これにより /home/all_usr は独立したHDDにでき各ユーザーの共有ディレクトリや各ユーザー共有のアプリケーションのインストール先として利用できる |
|
|
[root@centos]# mkdir /home/all_usr ← 入力(wwwディレクトリの作成) [root@centos]# mount /dev/sdb1 /home/all_usr <--- 入力(増設HDDをマウント) [root@centos]# chmod 777 /home/all_usr <--- 入力(アクセス権の変更) |
|
| PCを起動する度に増設したHDDをマウントするのは面倒なので /etc/fstab を編集して、起動時に増設したHDDが自動的にマウントされるように設定 | |
|
[root@centos]# vi /etc/fstab ← 入力 途中略 /dev/sdb1 /home/all_usr ext3 defaults 1 2 ← 最終行に追記 |
|