LVMを使用したVMのディスクサイズを広げる
VMのスナップショットをすべて削除する.
VMのストレージの容量をふやす(例:30GB→60GB)
partedの操作を追加する
koyama@doktor-stg2:~$ sudo parted
GNU Parted 3.3
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p free
Model: VMware Virtual disk (scsi)
Disk /dev/sda: 64.4GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
17.4kB 1049kB 1031kB Free Space
1 1049kB 2097kB 1049kB bios_grub
2 2097kB 1076MB 1074MB ext4
3 1076MB 32.2GB 31.1GB
32.2GB 64.4GB 32.2GB Free Space
(parted) resizepart 3
End? [32.2GB]? 100%
(parted) p free
Model: VMware Virtual disk (scsi)
Disk /dev/sda: 64.4GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
17.4kB 1049kB 1031kB Free Space
1 1049kB 2097kB 1049kB bios_grub
2 2097kB 1076MB 1074MB ext4
3 1076MB 64.4GB 63.3GB
(parted) q
Information: You may need to update /etc/fstab.
LVMを拡張する.
koyama@doktor-stg1:~$ sudo pvdisplay
--- Physical volume ---
PV Name /dev/sda3
VG Name ubuntu-vg
PV Size <29.00 GiB / not usable 0
Allocatable yes
PE Size 4.00 MiB
Total PE 7423
Free PE 2303
Allocated PE 5120
PV UUID 1aEd5h-RrxI-GkE6-Nc0d-asO0-FwzT-4dtAGS
koyama@doktor-stg1:~$ sudo pvresize /dev/sda3
Physical volume "/dev/sda3" changed
1 physical volume(s) resized or updated / 0 physical volume(s) not resized
koyama@doktor-stg1:~$ sudo pvdisplay
--- Physical volume ---
PV Name /dev/sda3
VG Name ubuntu-vg
PV Size <59.00 GiB / not usable 16.50 KiB
Allocatable yes
PE Size 4.00 MiB
Total PE 15103
Free PE 9983
Allocated PE 5120
PV UUID 1aEd5h-RrxI-GkE6-Nc0d-asO0-FwzT-4dtAGS
koyama@doktor-stg1:~$ sudo lvdisplay
--- Logical volume ---
LV Path /dev/ubuntu-vg/ubuntu-lv
LV Name ubuntu-lv
VG Name ubuntu-vg
LV UUID tE0w4g-hrTW-ltsG-fFmb-R2vH-msnV-X6Ng9q
LV Write Access read/write
LV Creation host, time ubuntu-server, 2021-09-15 01:30:09 +0000
LV Status available
# open 1
LV Size 20.00 GiB
Current LE 5120
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
koyama@doktor-stg1:~$ sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
Size of logical volume ubuntu-vg/ubuntu-lv changed from 20.00 GiB (5120 extents) to <39.00 GiB (9983 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.
koyama@doktor-stg1:~$ sudo lvdisplay
--- Logical volume ---
LV Path /dev/ubuntu-vg/ubuntu-lv
LV Name ubuntu-lv
VG Name ubuntu-vg
LV UUID tE0w4g-hrTW-ltsG-fFmb-R2vH-msnV-X6Ng9q
LV Write Access read/write
LV Creation host, time ubuntu-server, 2021-09-15 01:30:09 +0000
LV Status available
# open 1
LV Size <39.00 GiB
Current LE 9983
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
koyama@doktor-stg1:~$ sudo vgdisplay
--- Volume group ---
VG Name ubuntu-vg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size <59.00 GiB
PE Size 4.00 MiB
Total PE 15103
Alloc PE / Size 9983 / <39.00 GiB
Free PE / Size 5120 / 20.00 GiB
VG UUID 4mUGXE-c11k-DpxS-OcRu-WfuK-6DzL-ZhYRRp
ファイルシステムを拡張する.
koyama@doktor-stg1:~$ sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 8
The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 15465472 (4k) blocks long.
koyama@doktor-stg1:~$ df -Th | grep -v k3s
Filesystem Type Size Used Avail Use% Mounted on
udev devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs tmpfs 394M 1.8M 392M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv ext4 58G 17G 39G 31% /
tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/sda2 ext4 976M 203M 707M 23% /boot
/dev/loop1 squashfs 56M 56M 0 100% /snap/core18/1944
/dev/loop2 squashfs 11M 11M 0 100% /snap/helm/353
/dev/loop0 squashfs 56M 56M 0 100% /snap/core18/2128
/dev/loop3 squashfs 68M 68M 0 100% /snap/lxd/21545
/dev/loop4 squashfs 62M 62M 0 100% /snap/core20/1081
/dev/loop5 squashfs 33M 33M 0 100% /snap/snapd/12883
/dev/loop6 squashfs 70M 70M 0 100% /snap/lxd/19188
/dev/loop7 squashfs 33M 33M 0 100% /snap/snapd/13170