![扩展虚拟服务器上的分区](https://linux22.com/image/778040/%E6%89%A9%E5%B1%95%E8%99%9A%E6%8B%9F%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%8A%E7%9A%84%E5%88%86%E5%8C%BA.png)
我要求将虚拟服务器的磁盘大小从 20 GB 扩展到 80 GB。
此后,磁盘大小/dev/sda
增加到 80 GiB。但大小/dev/sda2
保持不变,为 19.5 GiB:
root@localhost:/home/worker# fdisk -l
Disk /dev/sda: 80 GiB, 85899345920 bytes, 167772160 sectors
Disk model: Virtual disk
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: dos
Disk identifier: 0x520f1760
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 999423 997376 487M 83 Linux
/dev/sda2 999424 41943039 40943616 19.5G 8e Linux LVM
Disk /dev/mapper/vg00-lv00: 1.93 GiB, 2046820352 bytes, 3997696 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/vg00-lv01: 17.63 GiB, 18912116736 bytes, 36937728 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
我可以使用以下命令修复此问题growpart
:
root@localhost:# growpart /dev/sda 2
CHANGED: partition=2 start=999424 old: size=40943616 end=41943040 new: size=166772703 end=167772127
root@localhost:/home/worker# fdisk -l
Disk /dev/sda: 80 GiB, 85899345920 bytes, 167772160 sectors
Disk model: Virtual disk
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: dos
Disk identifier: 0x520f1760
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 999423 997376 487M 83 Linux
/dev/sda2 999424 167772126 166772703 79.5G 8e Linux LVM
但是我的文件系统仍然没有足够的空间。
root@localhost:# df -h
Filesystem Size Used Avail Use% Mounted on
udev 947M 0 947M 0% /dev
tmpfs 196M 928K 195M 1% /run
/dev/mapper/vg00-lv01 18G 17G 180M 99% /
tmpfs 977M 20K 977M 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 977M 0 977M 0% /sys/fs/cgroup
/dev/sda1 456M 147M 276M 35% /boot
tmpfs 196M 0 196M 0% /run/user/1000
从谷歌上我了解到我还必须以某种方式增加分区。但是在网上我只找到了关于如何在“ext4”或其他类型上执行此操作的信息。在我的例子中,类型指定为LVM2_member
。我不知道如何处理。
root@localhost:# blkid
/dev/mapper/vg00-lv00: UUID="d236bafc-c18c-49aa-816d-85f0c7afc810" TYPE="swap"
/dev/mapper/vg00-lv01: UUID="77ae49d6-38e3-44c5-a20b-e10972c8ee21" TYPE="ext4"
/dev/sda1: UUID="de2cb53e-6086-4fd5-99a9-1c22674a4f91" TYPE="ext4" PARTUUID="520f1760-01"
/dev/sda2: UUID="R5VWXg-jamB-5dWM-PpwY-7a49-LRz7-Vrvdl2" TYPE="LVM2_member" PARTUUID="520f1760-02"
我试过lvextend
没有效果:
root@localhost:/home/worker#df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 969104 0 969104 0% /dev
tmpfs 199936 928 199008 1% /run
/dev/mapper/vg00-lv01 18114384 17097768 183380 99% /
tmpfs 999668 20 999648 1% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
tmpfs 999668 0 999668 0% /sys/fs/cgroup
/dev/sda1 466664 149872 281888 35% /boot
tmpfs 199932 0 199932 0% /run/user/1000
root@localhost:/home/worker# lvextend -l +100%FREE /dev/mapper/vg00-lv01
New size (4509 extents) matches existing size (4509 extents).
root@localhost:/home/worker# df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 969104 0 969104 0% /dev
tmpfs 199936 928 199008 1% /run
/dev/mapper/vg00-lv01 18114384 17097788 183360 99% /
tmpfs 999668 20 999648 1% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
tmpfs 999668 0 999668 0% /sys/fs/cgroup
/dev/sda1 466664 149872 281888 35% /boot
tmpfs 199932 0 199932 0% /run/user/1000
更多信息
root@localhost:# vgdisplay -v vg00
--- Volume group ---
VG Name vg00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size <19.52 GiB
PE Size 4.00 MiB
Total PE 4997
Alloc PE / Size 4997 / <19.52 GiB
Free PE / Size 0 / 0
VG UUID ZRC0sL-qOeU-Uyfp-Qbo4-m06c-CwEt-xpFTsO
--- Logical volume ---
LV Path /dev/vg00/lv00
LV Name lv00
VG Name vg00
LV UUID fQt2D5-OofH-m0yQ-jRP8-MJog-gcKp-3GhTa4
LV Write Access read/write
LV Creation host, time somehost, 2021-05-20 11:12:52 +0000
LV Status available
# open 2
LV Size <1.91 GiB
Current LE 488
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/vg00/lv01
LV Name lv01
VG Name vg00
LV UUID e3zugo-eu0a-gWgm-ULmN-LstF-tdNg-3uMPWZ
LV Write Access read/write
LV Creation host, time somehost, 2021-05-20 11:12:52 +0000
LV Status available
# open 1
LV Size 17.61 GiB
Current LE 4509
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Physical volumes ---
PV Name /dev/sda2
PV UUID R5VWXg-jamB-5dWM-PpwY-7a49-LRz7-Vrvdl2
PV Status allocatable
Total PE / Free PE 4997 / 0
和
root@localhost:#lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.4 LTS
Release: 20.04
Codename: focal
感谢您的帮助。
答案1
联系支持人员后找到了解决方案。 https://www.ionos.de/hilfe/index.php?id=4315
基本上,申请之前的步骤pvresize /dev/sda2
缺失了lvextend
。
现已解决。