$ sudo gdisk /dev/vdc
GPT fdisk (gdisk) version 1.0.3
Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present
Creating new GPT entries.
Command (? for help): n
Partition number (1-128, default 1):
First sector (34-2097118, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-2097118, default = 2097118) or {+-}size{KMGTP}:
Current type is 'Linux filesystem'Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to 'Linux filesystem'Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/vdc.
The operation has completed successfully.
$ sudo lvdisplay
--- Logical volume ---
LV Path /dev/test-pv-1/test-lv
LV Name test-lv
VG Name test-pv-1
LV UUID T0V5dm-tnLT-EpyZ-LnWM-FSfL-u2r1-xzZ2cs
LV Write Access read/write
LV Creation host, time pollochangVM, 2022-09-20 23:37:16 +0800
LV Status available
# open 1 LV Size 4.98 GiB
Current LE 319 Segments 1 Allocation inherit
Read ahead sectors auto
- currently set to 256 Block device 253:0
執行
在這邊我把新增硬碟空間位置通通加進去。
1
sudo lvextend -l+100%FREE /dev/test-pv-1/test-lv
執行結果
1
2
3
$ sudo lvextend -l+100%FREE /dev/test-pv-1/test-lv
Size of logical volume test-pv-1/test-lv changed from 4.98 GiB (319 extents) to <5.97 GiB (382 extents).
Logical volume test-pv-1/test-lv successfully resized.
調整檔案系統大小
1
sudo resize2fs -p /dev/test-pv-1/test-lv
如果磁碟格式是 xfs 需要用 xfs_growfs
1
sudo xfs_growfs /dev/test-pv-1/test-lv
執行結果
1
2
3
4
5
$ sudo resize2fs -p /dev/test-pv-1/test-lv
resize2fs 1.44.5 (15-Dec-2018)Filesystem at /dev/test-pv-1/test-lv is mounted on /test-disk; on-line resizing required
old_desc_blocks = 1, new_desc_blocks =1The filesystem on /dev/test-pv-1/test-lv is now 1564672(4k) blocks long.
檢查
1
2
3
$ sudo df -h # 檢查目前的硬碟狀況Filesystem Size Used Avail Use% Mounted on
/dev/mapper/test--pv--1-test--lv 5.8G 24K 5.5G 1% /test-disk