EC2のUbuntuであれば、比較的かんたんにディスク拡張が行なえます。
AWS EBSのルートディスク拡張した際のサイズ拡張のやりかた
RedHat7では同じ手順で行えなかったのでここにやり方を記載しておきます。
$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.0 (Maipo)
# 必要なものをインストール
$ yum install cloud-utils-growpart
$ yum install gdisk
$ df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/xvda2 xfs 6.0G 1.4G 4.7G 24% /
devtmpfs devtmpfs 7.8G 0 7.8G 0% /dev
tmpfs tmpfs 7.7G 0 7.7G 0% /dev/shm
tmpfs tmpfs 7.7G 17M 7.7G 1% /run
tmpfs tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup
# 520GBのはずが6GBしか認識してない
$ fdisk -l /dev/xvda
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/xvda: 558.3 GB, 558345748480 bytes, 1090519040 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 label type: gpt
# Start End Size Type Name
1 2048 4095 1M BIOS boot parti
2 4096 12587007 6G Microsoft basic
# こっちでも確認
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 520G 0 disk
├─xvda1 202:1 0 1M 0 part
└─xvda2 202:2 0 6G 0 part /
# fdisk 実行
$ fdisk /dev/xvda
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
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.
Command (m for help): p
Disk /dev/xvda: 558.3 GB, 558345748480 bytes, 1090519040 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 label type: gpt
# Start End Size Type Name
1 2048 4095 1M BIOS boot parti
2 4096 12587007 6G Microsoft basic
Command (m for help): d
Partition number (1,2, default 2): 2
Partition 2 is deleted
Command (m for help): n
Partition number (2-128, default 2):
First sector (34-1090519006, default 4096):
Last sector, +sectors or +size{K,M,G,T,P} (4096-1090519006, default 1090519006):
Created partition 2
Command (m for help): p
Disk /dev/xvda: 558.3 GB, 558345748480 bytes, 1090519040 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 label type: gpt
# Start End Size Type Name
1 2048 4095 1M BIOS boot parti
2 4096 1090519006 520G Linux filesyste
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
# 最後に再起動
$ shutdown -r now
# 再起動後に確認
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda2 520G 1.4G 519G 1% /
devtmpfs 7.8G 0 7.8G 0% /dev
tmpfs 7.7G 0 7.7G 0% /dev/shm
tmpfs 7.7G 17M 7.7G 1% /run
tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup