Ubuntu扩逻辑卷
root@cnsh-kbsr:~# fdisk -l
GPT PMBR size mismatch (1048575999 != 2097151999) will be corrected by w(rite).
Disk /dev/sda: 1000 GiB, 1073741824000 bytes, 2097152000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: EA770C2D-0C8E-4338-91B5-40AD70489B50
Device Start End Sectors Size Type
/dev/sda1 2048 1050623 1048576 512M EFI System
/dev/sda2 1050624 3147775 2097152 1G Linux filesystem
/dev/sda3 3147776 1048573951 1045426176 498.5G Linux filesystem
Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 498.5 GiB, 535256104960 bytes, 1045422080 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
root@cnsh-kbsr:~# parted -l
Warning: Not all of the space available to /dev/sda appears to be used, you can
fix the GPT to use all of the space (an extra 1048576000 blocks) or continue
with the current setting?
Fix/Ignore? fix
Model: Msft Virtual Disk (scsi)
Disk /dev/sda: 1074GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 538MB 537MB fat32 boot, esp
2 538MB 1612MB 1074MB ext4
3 1612MB 537GB 535GB
Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 535GB
Sector size (logical/physical): 512B/4096B
Partition Table: loop
Disk Flags:
Number Start End Size File system Flags
1 0.00B 535GB 535GB ext4
root@cnsh-kbsr:~# fdisk /dev/sda
Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n
Partition number (4-128, default 4):
First sector (1048573952-2097151966, default 1048573952):
Last sector, +sectors or +size{K,M,G,T,P} (1048573952-2097151966, default 2097151966):
Created a new partition 4 of type 'Linux filesystem' and of size 500 GiB.
Command (m for help): t
Partition number (1-4, default 4): 4
Partition type (type L to list all types): 8e
Type of partition 4 is unchanged: Linux filesystem.
Command (m for help): w
The partition table has been altered.
Syncing disks.
root@cnsh-kbsr:~# pvcreate /dev/sda4
Physical volume "/dev/sda4" successfully created.
root@cnsh-kbsr:~#
root@cnsh-kbsr:~# pvs
PV VG Fmt Attr PSize PFree
/dev/sda3 ubuntu-vg lvm2 a-- <498.50g 0
/dev/sda4 lvm2 --- 500.00g 500.00g
root@cnsh-kbsr:~#
root@cnsh-kbsr:~# vgs
VG #PV #LV #SN Attr VSize VFree
ubuntu-vg 1 1 0 wz--n- <498.50g 0
root@cnsh-kbsr:~#
root@cnsh-kbsr:~# vgextend ubuntu-vg /dev/sda4
Volume group "ubuntu-vg" successfully extended
root@cnsh-kbsr:~#
root@cnsh-kbsr:~# vgs
VG #PV #LV #SN Attr VSize VFree
ubuntu-vg 2 1 0 wz--n- 998.49g <500.00g
root@cnsh-kbsr:~# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
ubuntu-lv ubuntu-vg -wi-ao---- <498.50g
root@cnsh-kbsr:~#
root@cnsh-kbsr:~# lvextend -L +499G /dev/ubuntu-vg/ubuntu-lv
Size of logical volume ubuntu-vg/ubuntu-lv changed from <498.50 GiB (127615 extents) to <997.50 GiB (255359 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.
root@cnsh-kbsr:~# resize2fs /dev/ubuntu-vg/ubuntu-lv
resize2fs 1.44.1 (24-Mar-2018)
Filesystem at /dev/ubuntu-vg/ubuntu-lv is mounted on /; on-line resizing required
old_desc_blocks = 63, new_desc_blocks = 125
The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 261487616 (4k) blocks long.
root@cnsh-kbsr:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 7.8G 0 7.8G 0% /dev
tmpfs 1.6G 588K 1.6G 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 981G 465G 472G 50% /
tmpfs 7.9G 0 7.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 7.9G 0 7.9G 0% /sys/fs/cgroup
/dev/sda2 976M 151M 759M 17% /boot
/dev/sda1 511M 6.6M 505M 2% /boot/efi
tmpfs 1.6G 0 1.6G 0% /run/user/0
tmpfs 1.6G 0 1.6G 0% /run/user/1000