先看挂载点:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
root@confluence:/var/atlassian/application-data/confluence/backups# df -h Filesystem Size Used Avail Use% Mounted on udev 4.9G 0 4.9G 0% /dev tmpfs 997M 1.3M 995M 1% /run /dev/mapper/ubuntu--vg-ubuntu--lv 19G 18G 375M 98% / tmpfs 4.9G 0 4.9G 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 4.9G 0 4.9G 0% /sys/fs/cgroup /dev/loop1 56M 56M 0 100% /snap/core18/2538 /dev/loop2 62M 62M 0 100% /snap/core20/1587 /dev/loop0 56M 56M 0 100% /snap/core18/2409 /dev/loop3 68M 68M 0 100% /snap/lxd/22753 /dev/sda2 974M 303M 604M 34% /boot /dev/loop6 47M 47M 0 100% /snap/snapd/16292 /dev/loop5 62M 62M 0 100% /snap/core20/1611 /dev/loop4 47M 47M 0 100% /snap/snapd/16010 /dev/loop7 68M 68M 0 100% /snap/lxd/22526 tmpfs 997M 0 997M 0% /run/user/1003 tmpfs 997M 0 997M 0% /run/user/1000 |
分区表:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
root@confluence:/var/atlassian/application-data/confluence/backups# fdisk -l Disk /dev/loop0: 55.55 MiB, 58232832 bytes, 113736 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/loop1: 55.58 MiB, 58261504 bytes, 113792 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/loop2: 61.98 MiB, 64970752 bytes, 126896 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/loop3: 67.83 MiB, 71106560 bytes, 138880 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/loop4: 46.98 MiB, 49233920 bytes, 96160 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/loop5: 61.98 MiB, 64966656 bytes, 126888 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/loop6: 46.98 MiB, 49242112 bytes, 96176 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/loop7: 67.94 MiB, 71221248 bytes, 139104 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 GPT PMBR size mismatch (41943039 != 104857599) will be corrected by write. The backup GPT table is not on the end of the device. This problem will be corrected by write. Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 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: gpt Disk identifier: A5BFC3DF-0E92-4D44-A804-501AA38922A8 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 41940991 39839744 19G Linux filesystem Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 18.102 GiB, 20396900352 bytes, 39837696 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 |
其中可以看到磁盘/dev/sda的大小为50GB,但/dev/sda3大小只有19GB。
按照笔者《阿里云ECS Linux根分区扩容(数据盘也可以)》一文中的说法,先分区扩容:
1 2 |
root@confluence:/var/atlassian/application-data/confluence/backups# growpart /dev/sda 3 CHANGED: partition=3 start=2101248 old: size=39839744 end=41940992 new: size=102756319 end=104857567 |
其中,growpart <DeviceName> <PartionNumber>命令调用growpart为需要扩容的磁盘和对应的第几个分区,上述命令表示为/dev/sda的第3个分区扩容。
可以看到分区大小正确了:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
root@confluence:/var/atlassian/application-data/confluence/backups# fdisk -l Disk /dev/loop0: 55.55 MiB, 58232832 bytes, 113736 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/loop1: 55.58 MiB, 58261504 bytes, 113792 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/loop2: 61.98 MiB, 64970752 bytes, 126896 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/loop3: 67.83 MiB, 71106560 bytes, 138880 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/loop4: 46.98 MiB, 49233920 bytes, 96160 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/loop5: 61.98 MiB, 64966656 bytes, 126888 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/loop6: 46.98 MiB, 49242112 bytes, 96176 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/loop7: 67.94 MiB, 71221248 bytes, 139104 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/sda: 50 GiB, 53687091200 bytes, 104857600 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: gpt Disk identifier: A5BFC3DF-0E92-4D44-A804-501AA38922A8 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 104857566 102756319 49G Linux filesystem Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 18.102 GiB, 20396900352 bytes, 39837696 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 |
显然,此时挂载点及对应的文件系统大小是没有变化的:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
root@confluence:/var/atlassian/application-data/confluence/backups# df -h Filesystem Size Used Avail Use% Mounted on udev 4.9G 0 4.9G 0% /dev tmpfs 997M 1.3M 995M 1% /run /dev/mapper/ubuntu--vg-ubuntu--lv 19G 18G 375M 98% / tmpfs 4.9G 0 4.9G 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 4.9G 0 4.9G 0% /sys/fs/cgroup /dev/loop1 56M 56M 0 100% /snap/core18/2538 /dev/loop2 62M 62M 0 100% /snap/core20/1587 /dev/loop0 56M 56M 0 100% /snap/core18/2409 /dev/loop3 68M 68M 0 100% /snap/lxd/22753 /dev/sda2 974M 303M 604M 34% /boot /dev/loop6 47M 47M 0 100% /snap/snapd/16292 /dev/loop5 62M 62M 0 100% /snap/core20/1611 /dev/loop4 47M 47M 0 100% /snap/snapd/16010 /dev/loop7 68M 68M 0 100% /snap/lxd/22526 tmpfs 997M 0 997M 0% /run/user/1003 tmpfs 997M 0 997M 0% /run/user/1000 |
《阿里云ECS Linux根分区扩容(数据盘也可以)》一文中没有使用LVM,由于这台服务器使用了LVM因此需要对VG扩容。
查看VG和LV:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
root@confluence:/var/atlassian/application-data/confluence/backups# vgdisplay --- Volume group --- VG Name ubuntu-vg System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 2 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 <19.00 GiB PE Size 4.00 MiB Total PE 4863 Alloc PE / Size 4863 / <19.00 GiB Free PE / Size 0 / 0 VG UUID Fdmmm2-22uK-JqSq-vHRR-Df57-5SaG-QB08AZ root@confluence:/var/atlassian/application-data/confluence/backups# lvdisplay --- Logical volume --- LV Path /dev/ubuntu-vg/ubuntu-lv LV Name ubuntu-lv VG Name ubuntu-vg LV UUID 1sDjEs-tN1f-C3Zo-P6Ow-peEc-u0zP-JiTrgq LV Write Access read/write LV Creation host, time ubuntu-server, 2021-11-08 23:14:31 +0800 LV Status available # open 1 LV Size <19.00 GiB Current LE 4863 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0 |
可以看到PV没有Free。
vgextend是用来增加pv的,因此这里不能使用vgextend:
1 2 3 4 5 6 |
root@confluence:/var/atlassian/application-data/confluence/backups# vgextend ubuntu-vg /dev/sda3 Physical volume '/dev/sda3' is already in volume group 'ubuntu-vg' Unable to add physical volume '/dev/sda3' to volume group 'ubuntu-vg' /dev/sda3: physical volume not initialized. root@confluence:/var/atlassian/application-data/confluence/backups# lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv New size (4863 extents) matches existing size (4863 extents). |
而是需要使用pvresize:
1 2 3 4 5 6 7 8 9 |
root@confluence:/var/atlassian/application-data/confluence/backups# pvscan PV /dev/sda3 VG ubuntu-vg lvm2 [<19.00 GiB / 0 free] Total: 1 [<19.00 GiB] / in use: 1 [<19.00 GiB] / in no VG: 0 [0 ] root@confluence:/var/atlassian/application-data/confluence/backups# pvs PV VG Fmt Attr PSize PFree /dev/sda3 ubuntu-vg lvm2 a-- <19.00g 0 root@confluence:/var/atlassian/application-data/confluence/backups# pvresize /dev/sda3 Physical volume "/dev/sda3" changed 1 physical volume(s) resized or updated / 0 physical volume(s) not resized |
此时可以看到PV的大小变为了49GB:
1 2 3 4 5 6 7 8 9 10 11 |
root@confluence:/var/atlassian/application-data/confluence/backups# pvdisplay --- Physical volume --- PV Name /dev/sda3 VG Name ubuntu-vg PV Size <49.00 GiB / not usable 16.50 KiB Allocatable yes PE Size 4.00 MiB Total PE 12543 Free PE 7680 Allocated PE 4863 PV UUID mVyruf-T2W0-xF3u-ASG9-YPSx-z2d9-phUXmK |
接下来扩容LV:
1 2 3 |
root@confluence:/var/atlassian/application-data/confluence/backups# lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv Size of logical volume ubuntu-vg/ubuntu-lv changed from <19.00 GiB (4863 extents) to <49.00 GiB (12543 extents). Logical volume ubuntu-vg/ubuntu-lv successfully resized. |
此时PV、VG、LV大小都正确了:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
root@confluence:/var/atlassian/application-data/confluence/backups# pvdisplay --- Physical volume --- PV Name /dev/sda3 VG Name ubuntu-vg PV Size <49.00 GiB / not usable 16.50 KiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 12543 Free PE 0 Allocated PE 12543 PV UUID mVyruf-T2W0-xF3u-ASG9-YPSx-z2d9-phUXmK root@confluence:/var/atlassian/application-data/confluence/backups# 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 <49.00 GiB PE Size 4.00 MiB Total PE 12543 Alloc PE / Size 12543 / <49.00 GiB Free PE / Size 0 / 0 VG UUID Fdmmm2-22uK-JqSq-vHRR-Df57-5SaG-QB08AZ root@confluence:/var/atlassian/application-data/confluence/backups# lvdisplay --- Logical volume --- LV Path /dev/ubuntu-vg/ubuntu-lv LV Name ubuntu-lv VG Name ubuntu-vg LV UUID 1sDjEs-tN1f-C3Zo-P6Ow-peEc-u0zP-JiTrgq LV Write Access read/write LV Creation host, time ubuntu-server, 2021-11-08 23:14:31 +0800 LV Status available # open 1 LV Size <49.00 GiB Current LE 12543 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0 |
不过,文件系统还需要扩容:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
root@confluence:/var/atlassian/application-data/confluence/backups# df -h Filesystem Size Used Avail Use% Mounted on udev 4.9G 0 4.9G 0% /dev tmpfs 997M 1.3M 995M 1% /run /dev/mapper/ubuntu--vg-ubuntu--lv 19G 18G 374M 98% / tmpfs 4.9G 0 4.9G 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 4.9G 0 4.9G 0% /sys/fs/cgroup /dev/loop1 56M 56M 0 100% /snap/core18/2538 /dev/loop2 62M 62M 0 100% /snap/core20/1587 /dev/loop0 56M 56M 0 100% /snap/core18/2409 /dev/loop3 68M 68M 0 100% /snap/lxd/22753 /dev/sda2 974M 303M 604M 34% /boot /dev/loop6 47M 47M 0 100% /snap/snapd/16292 /dev/loop5 62M 62M 0 100% /snap/core20/1611 /dev/loop4 47M 47M 0 100% /snap/snapd/16010 /dev/loop7 68M 68M 0 100% /snap/lxd/22526 tmpfs 997M 0 997M 0% /run/user/1003 tmpfs 997M 0 997M 0% /run/user/1000 |
执行:
1 2 3 4 5 |
root@confluence:/var/atlassian/application-data/confluence/backups# 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 = 7 The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 12844032 (4k) blocks long. |
此时挂载点及文件系统的大小就正确了:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
root@confluence:/var/atlassian/application-data/confluence/backups# df -h Filesystem Size Used Avail Use% Mounted on udev 4.9G 0 4.9G 0% /dev tmpfs 997M 1.3M 995M 1% /run /dev/mapper/ubuntu--vg-ubuntu--lv 49G 18G 29G 38% / tmpfs 4.9G 0 4.9G 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 4.9G 0 4.9G 0% /sys/fs/cgroup /dev/loop1 56M 56M 0 100% /snap/core18/2538 /dev/loop2 62M 62M 0 100% /snap/core20/1587 /dev/loop0 56M 56M 0 100% /snap/core18/2409 /dev/loop3 68M 68M 0 100% /snap/lxd/22753 /dev/sda2 974M 303M 604M 34% /boot /dev/loop6 47M 47M 0 100% /snap/snapd/16292 /dev/loop5 62M 62M 0 100% /snap/core20/1611 /dev/loop4 47M 47M 0 100% /snap/snapd/16010 /dev/loop7 68M 68M 0 100% /snap/lxd/22526 tmpfs 997M 0 997M 0% /run/user/1003 tmpfs 997M 0 997M 0% /run/user/1000 |
转载时请保留出处,违法转载追究到底:进城务工人员小梅 » Ubuntu 20.04 vg扩容(不增加新磁盘,单纯PV扩容)