沈云峰
发布于 2023-04-23 / 5 阅读 / 0 评论 / 0 点赞

Linux扩容

扩容剩余磁盘空间

 sudo lvresize -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv

新增扩展盘进行扩容

新增磁盘分区

armor@docker:~# sudo fdisk /dev/sda


Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


GPT PMBR size mismatch (209715199 != 629145599) will be corrected by write.
The backup GPT table is not on the end of the device. This problem will be corrected by write.


Command (m for help): n
Partition number (4-128, default 4):
First sector (209713152-629145566, default 209713152):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (209713152-629145566, default 629145566):


Created a new partition 4 of type 'Linux filesystem' and of size 200 GiB.


Command (m for help): p
Disk /dev/sda: 300 GiB, 322122547200 bytes, 629145600 sectors
Disk model: QEMU HARDDISK   
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 9FD87B41-A400-4DD9-AE87-C852ACB2854D


Device         Start       End   Sectors  Size Type
/dev/sda1       2048      4095      2048    1M BIOS boot
/dev/sda2       4096   2101247   2097152    1G Linux filesystem
/dev/sda3    2101248 209713151 207611904   99G Linux filesystem
/dev/sda4  209713152 629145566 419432415  200G Linux filesystem


Command (m for help): w
The partition table has been altered.
Syncing disks.

扩展pv并查看

 sudo pvcreate /dev/sda4

 sudo pvdisplay

扩展vg并查看

 sudo vgextend ubuntu-vg /dev/sda4

 sudo vgdisplay

扩展lv并查看

 sudo lvextend /dev/mapper/ubuntu--vg-ubuntu--lv /dev/sda4

 sudo lvdisplay

扩展根文件系统

 sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv

 


评论