Red Hat Enterprise Linux でディスク増設

RHEL 7系でOracle12cを使っていますが、何気にRHELでディスク増設をする手順をド忘れすることが多いので、メモしておきます。コマンドは赤字です。

 

 

RHEL7は、ディスク領域フォーマットのデフォルトがxfsになりました。ので、ここではxfsで増設する手順をメモします。作業はすべてrootでの作業です。

 

 

1.ディスクを物理的に増設する。

  今はVMWareなどのクラウドでやることが多いと思います。それぞれのやり方でまずはディスク増設します。

 

 

 


2.fdiskで増設ディスクのデバイスを確認

[root@db ~]# fdisk -l

Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト
Disk label type: dos
ディスク識別子: 0x000b555e

バイス ブート 始点 終点 ブロック Id システム
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 104857599 51379200 8e Linux LVM

Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト


Disk /dev/mapper/rhel-root: 50.5 GB, 50457477120 bytes, 98549760 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト


Disk /dev/mapper/rhel-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト

 

 

 


3.パーティション作成

 fdiskコマンドで対話形式で作っていきます。

 

[root@db ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x1eb132e5.

コマンド (m でヘルプ): p

Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト
Disk label type: dos
ディスク識別子: 0x1eb132e5

バイス ブート 始点 終点 ブロック Id システム

コマンド (m でヘルプ): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
パーティション番号 (1-4, default 1): 1
最初 sector (2048-209715199, 初期値 2048):
初期値 2048 を使います
Last sector, +sectors or +size{K,M,G} (2048-209715199, 初期値 209715199):
初期値 209715199 を使います
Partition 1 of type Linux and of size 100 GiB is set

コマンド (m でヘルプ): p

Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト
Disk label type: dos
ディスク識別子: 0x1eb132e5

バイス ブート 始点 終点 ブロック Id システム
/dev/sdb1 2048 209715199 104856576 83 Linux

コマンド (m でヘルプ): w
パーティションテーブルは変更されました!

ioctl() を呼び出してパーティションテーブルを再読込みします。
ディスクを同期しています。

 

 

 

 

4.xfsでフォーマット

[root@db ~]# mkfs -t xfs /dev/sdb1
meta-data=/dev/sdb1 isize=512 agcount=4, agsize=6553536 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=26214144, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=12799, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0

 

 

 

5.マウントポイント作成

[root@db ~]# mkdir /data

 

 

 

 

6.マウント実行

[root@db ~]# mount /dev/sdb1 /data

 

 

 

7.ファイルシステム設定ファイルの更新

vi /etc/fstab
以下を追加し保存します。

/dev/sdb1 /data xfs defaults 0 0

 

 

 

8.確認

[root@db ~]# df -T
ファイルシス タイプ 1K-ブロック 使用 使用可 使用% マウント位置
/dev/mapper/rhel-root xfs 49250820 23789844 25460976 49% /
devtmpfs devtmpfs 1436456 0 1436456 0% /dev
tmpfs tmpfs 1448736 0 1448736 0% /dev/shm
tmpfs tmpfs 1448736 9612 1439124 1% /run
tmpfs tmpfs 1448736 0 1448736 0% /sys/fs/cgroup
/dev/sda1 xfs 1038336 145596 892740 15% /boot
tmpfs tmpfs 289748 0 289748 0% /run/user/0
/dev/sdb1 xfs 104805380 32944 104772436 1% /data

 

 

 

ちゃんと増えてますね。よかった。

 

ではでは。