Linux

Lvextend 找不到可用空間

  • January 9, 2022

我正在嘗試在 Ubuntu 16.04 上擴展我的 lvm 分區,但是

lvextend -l +100%FREE /dev/Server0-vg/root 

節目

New size (3861 extents) matches existing size (3861 extents)
Run `lvextend --help' for more information.

我的 lvm 分區是 /dev/sda5,它位於 /dev/sda2 - 兩者都是 159GB。lvdisplay 顯示:

--- Logical volume ---
LV Path                /dev/Server0-vg/root
LV Name                root
VG Name                Server0-vg
LV UUID                fxh0JM-oKQM-nIrj-c5S0-Tlw6-GGKX-2vcZY8
LV Write Access        read/write
LV Creation host, time Server0, 2004-11-29 01:15:23 +0100
LV Status              available
# open                 1
LV Size                15,08 GiB
Current LE             3861
Segments               2
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           252:0

--- Logical volume ---
LV Path                /dev/Server0-vg/swap_1
LV Name                swap_1
VG Name                Server0-vg
LV UUID                ZxV31F-BLza-3QaB-awXX-3IBt-SvzA-Lo2RAj
LV Write Access        read/write
LV Creation host, time Server0, 2004-11-29 01:15:24 +0100
LV Status              available
# open                 2
LV Size                508,00 MiB
Current LE             127
Segments               1
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           252:1

(如果有人沒有得到,我想將 /dev/Server0-vg/root 擴展至 159gb)

df -h 顯示:

Filesystem                    Size  Used Avail Use% Mounted on
udev                          737M     0  737M   0% /dev
tmpfs                         151M  5,1M  146M   4% /run
/dev/mapper/Server0--vg-root   15G  6,7G  7,3G  48% /  
tmpfs                         754M     0  754M   0% /dev/shm
tmpfs                         5,0M     0  5,0M   0% /run/lock
tmpfs                         754M     0  754M   0% /sys/fs/cgroup
/dev/sda1                     472M  453M     0 100% /boot
tmpfs                         100K     0  100K   0% /run/lxcfs/controllers
tmpfs                         151M     0  151M   0% /run/user/1000

“列印”在分開的節目中:

Model: ATA WDC WD1600BB-56R (scsi)
Disk /dev/sda: 160GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End    Size   Type      File system  Flags
1      1049kB  512MB  511MB  primary   ext2         boot
2      513MB   160GB  159GB  extended
5      513MB   160GB  159GB  logical                lvm

sudo vgdisplay 的結果:

--- Volume group ---

VG Name               Server0-vg
System ID             
Format                lvm2
Metadata Areas        1
Metadata Sequence No  4
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               15,58 GiB
PE Size               4,00 MiB
Total PE              3988
Alloc PE / Size       3988 / 15,58 GiB
Free  PE / Size       0 / 0   
VG UUID               302ela-v51W-hM2T-zjdv-8QtK-ZFBc-SW1D5Y

sudo pvdisplay 的結果:

--- Physical volume ---
PV Name               /dev/sda5
VG Name               Server0-vg
PV Size               15,58 GiB / not usable 4,00 MiB
Allocatable           yes (but full)
PE Size               4,00 MiB
Total PE              3988
Free PE               0
Allocated PE          3988
PV UUID               6j391r-dL9l-8Rw8-kGt4-Ewxg-NiyM-rjzggr

由於您Physical volume唯一的大小為 15,58 GiB,Volume group因此Logical Volume不能更大。

首先,您必須調整物理卷的大小:

sudo pvresize /dev/sda5

(請參閱man pvresize選項)。如果您不希望它調整到最大值,請使用 option --setphysicalvolumesize

現在再次查看vgdisplay卷組是否也已擴展。

引用自:https://unix.stackexchange.com/questions/343474