環境ごとの方法で VM の仮想 HDD サイズを適当に広げる
parted で LVM パーテーションを広げる
parted
parted の中で
resizepart 2 100%
「2」 のところは parted 中に 「p」 で表示されるパーテーション ID
pvresize で Physical volume を広げる
pvresize /dev/sda2
lvresize で Logical volume を広げる
lvresize -l +100%FREE /dev/fedora/root
xfs_growfs でファイルシステムを広げる
xfs_growfs /
/dev/mapper/fedora-root や /dev/fedora/root だと 「is not a mounted XFS filesystem」 と言われるのでマウントしてる場所を指定
詳細なメッセージ
Partition
[ners@fedora]~% sudo parted
GNU Parted 3.2
/dev/sda を使用
GNU Parted へようこそ! コマンド一覧を見るには 'help' と入力してください。
(parted) p
モデル: VMware Virtual disk (scsi)
ディスク /dev/sda: 34.4GB
セクタサイズ (論理/物理): 512B/512B
パーティションテーブル: msdos
ディスクフラグ:
番号 開始 終了 サイズ タイプ ファイルシステム フラグ
1 1049kB 525MB 524MB primary ext4 boot
2 525MB 17.2GB 16.7GB primary lvm
(parted) resizepart 2 100%
(parted) p
モデル: VMware Virtual disk (scsi)
ディスク /dev/sda: 34.4GB
セクタサイズ (論理/物理): 512B/512B
パーティションテーブル: msdos
ディスクフラグ:
番号 開始 終了 サイズ タイプ ファイルシステム フラグ
1 1049kB 525MB 524MB primary ext4 boot
2 525MB 34.4GB 33.8GB primary lvm
(parted) quit
通知: 必要であれば /etc/fstab を更新するのを忘れないようにしてください。
Physical volume
[ners@fedora]~% sudo pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name fedora
PV Size <15.51 GiB / not usable 2.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 3970
Free PE 0
Allocated PE 3970
PV UUID l40WuM-FQW5-JtdX-p5cJ-l1zg-V4gj-v2qArN
[ners@fedora]~% sudo pvresize /dev/sda2
Physical volume "/dev/sda2" changed
1 physical volume(s) resized / 0 physical volume(s) not resized
[ners@fedora]~% sudo pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name fedora
PV Size <31.51 GiB / not usable 2.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 8066
Free PE 4096
Allocated PE 3970
PV UUID l40WuM-FQW5-JtdX-p5cJ-l1zg-V4gj-v2qArN
Logical volume
[ners@fedora]~% sudo lvdisplay
--- Logical volume ---
LV Path /dev/fedora/swap
LV Name swap
VG Name fedora
LV UUID PVneBn-vK7i-yAZq-6Qtg-vllg-kAiy-sSh39g
LV Write Access read/write
LV Creation host, time localhost, 2018-03-11 20:07:19 +0900
LV Status available
# open 2
LV Size 820.00 MiB
Current LE 205
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/fedora/root
LV Name root
VG Name fedora
LV UUID o2ZpzA-BQcx-FKQ0-863v-sKeS-bvdz-AO7MlE
LV Write Access read/write
LV Creation host, time localhost, 2018-03-11 20:07:19 +0900
LV Status available
# open 1
LV Size <14.71 GiB
Current LE 3765
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
[ners@fedora]~% sudo lvresize -l +100%FREE /dev/fedora/root
Size of logical volume fedora/root changed from <14.71 GiB (3765 extents) to <30.71 GiB (7861 extents).
Logical volume fedora/root successfully resized.
[ners@fedora]~% sudo lvdisplay
--- Logical volume ---
LV Path /dev/fedora/swap
LV Name swap
VG Name fedora
LV UUID PVneBn-vK7i-yAZq-6Qtg-vllg-kAiy-sSh39g
LV Write Access read/write
LV Creation host, time localhost, 2018-03-11 20:07:19 +0900
LV Status available
# open 2
LV Size 820.00 MiB
Current LE 205
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/fedora/root
LV Name root
VG Name fedora
LV UUID o2ZpzA-BQcx-FKQ0-863v-sKeS-bvdz-AO7MlE
LV Write Access read/write
LV Creation host, time localhost, 2018-03-11 20:07:19 +0900
LV Status available
# open 1
LV Size <30.71 GiB
Current LE 7861
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
ファイルシステム
[ners@fedora]~% sudo xfs_growfs /
meta-data=/dev/mapper/fedora-root isize=256 agcount=9, agsize=439552 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0 spinodes=0 rmapbt=0
= reflink=0
data = bsize=4096 blocks=3855360, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 3855360 to 8049664
[ners@fedora]~% df
ファイルシス 1K-ブロック 使用 使用可 使用% マウント位置
devtmpfs 491096 0 491096 0% /dev
tmpfs 504300 0 504300 0% /dev/shm
tmpfs 504300 780 503520 1% /run
tmpfs 504300 0 504300 0% /sys/fs/cgroup
/dev/mapper/fedora-root 32188416 15040604 17147812 47% /
tmpfs 504300 0 504300 0% /tmp
/dev/sda1 487652 168315 289641 37% /boot
tmpfs 100860 0 100860 0% /run/user/0