Lvm

在 linux 中增加本地 usr 容量的方法有哪些?

  • October 3, 2018

我有一個 linux 生產虛擬機,我需要增加/usr/local文件夾中的空間。我已經附加了一個容量為 300 GB 的分區和格式化磁碟,如下所示。

[root@CentOS6-4SVR ~]# df -hT
Filesystem           Type   Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                    ext4   433G  373G   39G  91% /
tmpfs                tmpfs  3.9G     0  3.9G   0% /dev/shm
/dev/xvda1           ext4   477M   46M  406M  11% /boot
/dev/mapper/VolGroup-lv_home
                    ext4    41G   10G   29G  26% /home

[root@CentOS6-4SVR ~]# lsblk              
NAME                        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
xvdb                        202:16   0  400G  0 disk 
└─VolGroup-lv_root (dm-0)   253:0    0  440G  0 lvm  /
xvda                        202:0    0  100G  0 disk 
├─xvda1                     202:1    0  500M  0 part /boot
└─xvda2                     202:2    0 99.5G  0 part 
 ├─VolGroup-lv_root (dm-0) 253:0    0  440G  0 lvm  /
 ├─VolGroup-lv_swap (dm-1) 253:1    0  7.8G  0 lvm  [SWAP]
 └─VolGroup-lv_home (dm-2) 253:2    0 41.7G  0 lvm  /home
xvdc                        202:32   0  300G  0 disk 

[root@CentOS6-4SVR ~]# vgdisplay          
 --- Volume group ---
 VG Name               VolGroup
 System ID             
 Format                lvm2
 Metadata Areas        2
 Metadata Sequence No  7
 VG Access             read/write
 VG Status             resizable
 MAX LV                0
 Cur LV                3
 Open LV               3
 Max PV                0
 Cur PV                2
 Act PV                2
 VG Size               499.50 GiB
 PE Size               4.00 MiB
 Total PE              127873
 Alloc PE / Size       125314 / 489.51 GiB
 Free  PE / Size       2559 / 10.00 GiB
 VG UUID               jH8M8M-P8ey-apiK-888r-OhDj-ERSf-bn13N9

請提及可用的方法來做到這一點?

編輯 01

我嘗試如下擴展,但出現以下錯誤。請指教。

[root@csc-akaza-test-01 ~]# pvcreate /dev/xvdc
 Couldn't find device with uuid gBPzEJ-Ir84-Q8pw-IJ8J-Bh10-ISIy-1snfWG.
 Couldn't find device with uuid d4eTfV-HR7R-TLeH-tYgy-e2JC-B6sl-d5ysHa.
 Physical volume "/dev/xvdc" successfully created

[root@csc-akaza-test-01 ~]# vgextend VolGroup /dev/xvdc
 Couldn't find device with uuid gBPzEJ-Ir84-Q8pw-IJ8J-Bh10-ISIy-1snfWG.
 Couldn't find device with uuid d4eTfV-HR7R-TLeH-tYgy-e2JC-B6sl-d5ysHa.
 Volume group "VolGroup" successfully extended

[root@csc-akaza-test-01 ~]# lvresize -r -l 100%FREE VolGroup/lv_root
 Couldn't find device with uuid gBPzEJ-Ir84-Q8pw-IJ8J-Bh10-ISIy-1snfWG.
 Couldn't find device with uuid d4eTfV-HR7R-TLeH-tYgy-e2JC-B6sl-d5ysHa.
 Cannot change VG VolGroup while PVs are missing.
 Consider vgreduce --removemissing.
 Cannot process volume group VolGroup

由於您已經在使用 LVM 並且沒有安裝文件系統/usr/local,您可以簡單地將新磁碟(實際上是分區)添加到卷組,然後增加根邏輯捲和文件系統的大小:

pvcreate /dev/xvdc1
vgextend VolGroup /dev/xvdc1
lvresize -r -l 100%FREE VolGroup/lv_root

警告

你正在處理一個生產系統。在使用它們之前,請確保您了解上面顯示的命令。聽從我的建議,您將對可能發生的任何事情承擔全部責任。

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