Ubuntu

增加音量

  • August 21, 2018

當我重新啟動並嘗試使用時,我使用 Gparted Live cd 來調整捲組和邏輯分區的大小,lvextend –l +100%FREE /dev/vda5我收到以下消息:

 Path required for Logical Volume "–l"
 Please provide a volume group name
 Run `lvextend --help' for more information.

這是我的pvs, lvs,vgs輸出:

 VG       #PV #LV #SN Attr   VSize VFree
 d8dev-vg   1   2   0 wz--n- 9.76g 5.01g

 PV         VG       Fmt  Attr PSize PFree
 /dev/vda5  d8dev-vg lvm2 a--  9.76g 5.01g

 LV     VG       Attr      LSize    Pool Origin Data%  Move Log Copy%  Convert
 root   d8dev-vg -wi-ao---    3.75g
 swap_1 d8dev-vg -wi-ao--- 1020.00m

這是df -h輸出

Filesystem      Size  Used Avail Use% Mounted on
udev            487M  4.0K  487M   1% /dev
tmpfs           100M  632K   99M   1% /run
/dev/dm-0       3.7G  3.2G  325M  91% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
none            5.0M     0  5.0M   0% /run/lock
none            498M  184K  497M   1% /run/shm
none            100M     0  100M   0% /run/user
/dev/vda1       236M   37M  188M  17% /boot
none            3.7G  3.2G  325M  91% /var/lib/docker/aufs/mnt/a5516e7a4136a510a3b6b388a57b266067cce4b2240db77a859910d3c741f988
shm              64M     0   64M   0% /var/lib/docker/containers/f5c852ead8bd3578b63fd5a259586c5a9c4b375b8505bb339e9f3c27cabc130f/shm
none            3.7G  3.2G  325M  91% /var/lib/docker/aufs/mnt/074360c189d2dae1477d9eeed419a86880355cab68c266155eb649aaee9e80ff
none            3.7G  3.2G  325M  91% /var/lib/docker/aufs/mnt/921ae5230e127989f8f12ecbd52a454965ed385531397fc46cfc5a82392ec876
none            3.7G  3.2G  325M  91% /var/lib/docker/aufs/mnt/eda6cf31040113c7216c4e07071596c724288071a94869b3606e90ea9fdc6034
shm              64M     0   64M   0% /var/lib/docker/containers/27d44748763ef03fea24464e11dde5498329ce438002812cc5168379825c5003/shm
shm              64M     0   64M   0% /var/lib/docker/containers/7a79506bb707843b3eea9d062f934e5f53a8ca72326a497559b0cd391f5f271b/shm
shm              64M     0   64M   0% /var/lib/docker/containers/78fbe6d2bccc7d29f08051a9ab4d2f02b0794fd7a95e28446e208184fa84b149/shm
none            3.7G  3.2G  325M  91% /var/lib/docker/aufs/mnt/d06efbeda0bcf8352e88aa078d23caf3855ae14dbd9100980c3431dfce5870a7
none            3.7G  3.2G  325M  91% /var/lib/docker/aufs/mnt/10dd1eb657163fb314d1fd5e7951645e957365b9760b46846491c8374e106039
shm              64M     0   64M   0% /var/lib/docker/containers/90a5ef4a9a761778fbad4bd052426263f5fe14d5248aaf7cdecd87013fb2c706/shm
shm              64M     0   64M   0% /var/lib/docker/containers/dd20465dc2764916efb2d29887dfe76d3bf8cf823b9e032d7ec399aa40dc083f/shm
none            3.7G  3.2G  325M  91% /var/lib/docker/aufs/mnt/966dc571c622e09757ceebbfefd540a6ab4b27922b2fbab8615277e343a67357
shm              64M     0   64M   0% /var/lib/docker/containers/312cceb4eb20613ad493df37097ab47a204da19669c3aa065feb7fc9818c126c/shm

我試過這個命令

 lvextend –l +100%FREE /dev/vda5
 lvextend –l +100%FREE d8dev-vg
 lvextend –l +100%FREE /dev/root

但所有相同的輸出

 Path required for Logical Volume "–l"
 Please provide a volume group name

**編輯:**我lvextend /dev/dm-0 /dev/vda5現在做了我的lvs輸出是:

 LV     VG       Attr      LSize    Pool Origin Data%  Move Log Copy%  Convert
 root   d8dev-vg -wi-ao---    8.76g
 swap_1 d8dev-vg -wi-ao--- 1020.00m

/dev/dm-0仍然很低:

Filesystem      Size  Used Avail Use% Mounted on
udev            487M  4.0K  487M   1% /dev
tmpfs           100M  632K   99M   1% /run
/dev/dm-0       3.7G  3.2G  325M  91% /

編輯2vgdisplaylvdisplay

 --- Volume group ---
 VG Name               d8dev-vg
 System ID
 Format                lvm2
 Metadata Areas        1
 Metadata Sequence No  6
 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               9.76 GiB
 PE Size               4.00 MiB
 Total PE              2498
 Alloc PE / Size       2498 / 9.76 GiB
 Free  PE / Size       0 / 0
 VG UUID               AGVHqT-IO1R-l3uB-AeN4-q62b-z33r-b4NwS7

 --- Logical volume ---
 LV Path                /dev/d8dev-vg/root
 LV Name                root
 VG Name                d8dev-vg
 LV UUID                qet8dK-Izh1-uJul-2T0R-rDyy-ONNH-Xwvs2h
 LV Write Access        read/write
 LV Creation host, time d8dev, 2016-05-19 08:17:01 -0700
 LV Status              available
 # open                 1
 LV Size                8.76 GiB
 Current LE             2243
 Segments               2
 Allocation             inherit
 Read ahead sectors     auto
 - currently set to     256
 Block device           252:0

 --- Logical volume ---
 LV Path                /dev/d8dev-vg/swap_1
 LV Name                swap_1
 VG Name                d8dev-vg
 LV UUID                4mbhDG-PmAN-Fym3-yXSI-gRkd-owki-eYqWqj
 LV Write Access        read/write
 LV Creation host, time d8dev, 2016-05-19 08:17:01 -0700
 LV Status              available
 # open                 2
 LV Size                1020.00 MiB
 Current LE             255
 Segments               1
 Allocation             inherit
 Read ahead sectors     auto
 - currently set to     256
 Block device           252:1

DF -Th

Filesystem     Type      Size  Used Avail Use% Mounted on
udev           devtmpfs  487M  4.0K  487M   1% /dev
tmpfs          tmpfs     100M  632K   99M   1% /run
/dev/dm-0      ext4      3.7G  3.2G  325M  91% /
none           tmpfs     4.0K     0  4.0K   0% /sys/fs/cgroup
none           tmpfs     5.0M     0  5.0M   0% /run/lock
none           tmpfs     498M  184K  497M   1% /run/shm
none           tmpfs     100M     0  100M   0% /run/user
/dev/vda1      ext2      236M   37M  188M  17% /boot
none           aufs      3.7G  3.2G  325M  91% /var/lib/docker/aufs/mnt/a5516e7a4136a510a3b6b388a57b266067cce4b2240db77a859910d3c741f988
shm            tmpfs      64M     0   64M   0% /var/lib/docker/containers/f5c852ead8bd3578b63fd5a259586c5a9c4b375b8505bb339e9f3c27cabc130f/shm
none           aufs      3.7G  3.2G  325M  91% /var/lib/docker/aufs/mnt/074360c189d2dae1477d9eeed419a86880355cab68c266155eb649aaee9e80ff
none           aufs      3.7G  3.2G  325M  91% /var/lib/docker/aufs/mnt/921ae5230e127989f8f12ecbd52a454965ed385531397fc46cfc5a82392ec876
none           aufs      3.7G  3.2G  325M  91% /var/lib/docker/aufs/mnt/eda6cf31040113c7216c4e07071596c724288071a94869b3606e90ea9fdc6034
shm            tmpfs      64M     0   64M   0% /var/lib/docker/containers/27d44748763ef03fea24464e11dde5498329ce438002812cc5168379825c5003/shm
shm            tmpfs      64M     0   64M   0% /var/lib/docker/containers/7a79506bb707843b3eea9d062f934e5f53a8ca72326a497559b0cd391f5f271b/shm
shm            tmpfs      64M     0   64M   0% /var/lib/docker/containers/78fbe6d2bccc7d29f08051a9ab4d2f02b0794fd7a95e28446e208184fa84b149/shm
none           aufs      3.7G  3.2G  325M  91% /var/lib/docker/aufs/mnt/d06efbeda0bcf8352e88aa078d23caf3855ae14dbd9100980c3431dfce5870a7
none           aufs      3.7G  3.2G  325M  91% /var/lib/docker/aufs/mnt/10dd1eb657163fb314d1fd5e7951645e957365b9760b46846491c8374e106039
shm            tmpfs      64M     0   64M   0% /var/lib/docker/containers/90a5ef4a9a761778fbad4bd052426263f5fe14d5248aaf7cdecd87013fb2c706/shm
shm            tmpfs      64M     0   64M   0% /var/lib/docker/containers/dd20465dc2764916efb2d29887dfe76d3bf8cf823b9e032d7ec399aa40dc083f/shm
none           aufs      3.7G  3.2G  325M  91% /var/lib/docker/aufs/mnt/966dc571c622e09757ceebbfefd540a6ab4b27922b2fbab8615277e343a67357
shm            tmpfs      64M     0   64M   0% /var/lib/docker/containers/312cceb4eb20613ad493df37097ab47a204da19669c3aa065feb7fc9818c126c/shm

使用 LVM(邏輯捲管理器)時,您應該記住操作順序是必不可少的。如果您不遵守順序,您可能會失去數據。

如果您已經有一個PV(物理卷)和一個VG(卷組),則通過添加其他設備來擴展卷組會更容易。

要擴展卷組,例如vg1,您可以執行以下操作:

vgextend vg1 /dev/vda5

擴展卷組後,我們需要調整我們的LV(邏輯卷)

要擴展LV您可以使用以下內容

lvextend /dev/vg1/your_lv /dev/vda5 

在這個階段,只擴展了邏輯卷,沒有擴展文件系統。

要擴展文件系統,您可以使用resize2fs後跟LV. 例如:

resize2fs /dev/vg1/your_lv

注意:lvextend具有在後台呼叫並自動執行此操作的-r標誌。resize2fs

總結以上內容:

  1. 擴展卷組
  2. 擴展邏輯卷
  3. 調整文件系統大小

要縮小文件系統(不能使用xfs),請遵循以下過程:

  1. 收縮文件系統
  2. 減小邏輯卷的大小
  3. /dev/vda5從卷組中刪除設備

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