![linux下增加usr本地容量的方法有哪些?](https://linux22.com/image/12108/linux%E4%B8%8B%E5%A2%9E%E5%8A%A0usr%E6%9C%AC%E5%9C%B0%E5%AE%B9%E9%87%8F%E7%9A%84%E6%96%B9%E6%B3%95%E6%9C%89%E5%93%AA%E4%BA%9B%EF%BC%9F%20.png)
我有一个 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
答案1
由于您已经使用 LVM 并且没有安装文件系统/usr/local
,因此您可以简单地将新磁盘(实际上是分区)添加到卷组,然后增加根逻辑卷和文件系统的大小:
pvcreate /dev/xvdc1
vgextend VolGroup /dev/xvdc1
lvresize -r -l 100%FREE VolGroup/lv_root
警告
您正在处理一个生产系统。确保您理解上面显示的命令前你使用它们。遵循我的建议,您对可能发生的任何事情承担全部责任。