歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> CentOS磁盤擴容lvm

CentOS磁盤擴容lvm

日期:2017/3/1 15:21:46   编辑:關於Linux
CentOS磁盤擴容lvm 安裝的Centos的LVM空間減少的很快,沒多久就不夠用了,好多人使用的是Gparted擴容,命令行不好用,圖形界面的Gparted在CentOS6.4上面找不到;有人使用Gparted-Live盤,感覺非常的麻煩,其實Linux本身提供了強大而又簡單的擴容工具,非常的容易: 0:當前磁盤情況: [root@CentOS ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_centos-lv_root 5.5G 4.9G 375M 93% / tmpfs 499M 320K 498M 1% /dev/shm /dev/sda1 485M 56M 404M 13% /boot tmpfs 499M 0 499M 0% /tmp/ram 1:查看要添加的硬盤,顯示是/dev/sdb: [root@CentOS ~]# fdisk -l Disk /dev/sda: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000d0b56 Device Boot Start End Blocks Id System /dev/sda1 * 1 64 512000 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 64 1045 7875584 8e Linux LVM Disk /dev/sdb: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 .....: 2:初始化准備新增的磁盤: [root@CentOS ~]# pvcreate /dev/sdb Physical volume "/dev/sdb" successfully created 3:把新增的磁盤添加到LVM: [root@CentOS ~]# vgextend vg_centos /dev/sdb Volume group "vg_centos" successfully extended 4:查看增加磁盤後的LVM: [root@CentOS ~]# vgdisplay -v vg_centos Using volume group(s) on command line Finding volume group "vg_centos" --- Volume group --- VG Name vg_centos System ID Format lvm2 Metadata Areas 2 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 2 Act PV 2 VG Size 15.50 GiB PE Size 4.00 MiB Total PE 3969 Alloc PE / Size 1922 / 7.51 GiB Free PE / Size 2047 / 8.00 GiB //這裡顯示還有多少空間可用,就是新增的磁盤空間 VG UUID 6sYdCf-fA3g-Tyjz-lwfr-2hxP-lnFx-eVaMWj --- Logical volume --- LV Path /dev/vg_centos/lv_root LV Name lv_root VG Name vg_centos LV UUID jjByYP-BlFO-O70G-eYd9-Eupx-wqgS-AB2NNT LV Write Access read/write LV Creation host, time CentOS.Host1, 2013-08-01 11:33:27 +0800 LV Status available # open 1 LV Size 5.54 GiB Current LE 1418 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0 --- Logical volume --- LV Path /dev/vg_centos/lv_swap LV Name lv_swap VG Name vg_centos LV UUID eT8hdT-CbSj-5Kjx-1lyo-2Ru6-nB5o-fJ0HKU LV Write Access read/write LV Creation host, time CentOS.Host1, 2013-08-01 11:33:29 +0800 LV Status available # open 1 LV Size 1.97 GiB Current LE 504 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:1 --- Physical volumes --- PV Name /dev/sda2 PV UUID mEQ0cK-I0ja-45yS-fRqy-19Ds-0dr7-1CNFcx PV Status allocatable Total PE / Free PE 1922 / 0 PV Name /dev/sdb PV UUID 03e2Sl-hFVn-NrNr-eHfB-LeuY-D9P0-rSbv0P PV Status allocatable Total PE / Free PE 2047 / 2047 5:擴大邏輯卷(像windows擴大邏輯卷一樣): [root@CentOS ~]# lvextend -L +7.9G /dev/vg_centos/lv_root Rounding size to boundary between physical extents: 7.90 GiB Extending logical volume lv_root to 13.44 GiB Logical volume lv_root successfully resized 6:查看擴容後的LVM [root@CentOS ~]# vgdisplay -v vg_centos Using volume group(s) on command line Finding volume group "vg_centos" --- Volume group --- VG Name vg_centos System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 5 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 2 Act PV 2 VG Size 15.50 GiB PE Size 4.00 MiB Total PE 3969 Alloc PE / Size 3945 / 15.41 GiB Free PE / Size 24 / 96.00 MiB VG UUID 6sYdCf-fA3g-Tyjz-lwfr-2hxP-lnFx-eVaMWj --- Logical volume --- LV Path /dev/vg_centos/lv_root LV Name lv_root VG Name vg_centos LV UUID jjByYP-BlFO-O70G-eYd9-Eupx-wqgS-AB2NNT LV Write Access read/write LV Creation host, time CentOS.Host1, 2013-08-01 11:33:27 +0800 LV Status available # open 1 LV Size 13.44 GiB Current LE 3441 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0 --- Logical volume --- LV Path /dev/vg_centos/lv_swap LV Name lv_swap VG Name vg_centos LV UUID eT8hdT-CbSj-5Kjx-1lyo-2Ru6-nB5o-fJ0HKU LV Write Access read/write LV Creation host, time CentOS.Host1, 2013-08-01 11:33:29 +0800 LV Status available # open 1 LV Size 1.97 GiB Current LE 504 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:1 --- Physical volumes --- PV Name /dev/sda2 PV UUID mEQ0cK-I0ja-45yS-fRqy-19Ds-0dr7-1CNFcx PV Status allocatable Total PE / Free PE 1922 / 0 PV Name /dev/sdb PV UUID 03e2Sl-hFVn-NrNr-eHfB-LeuY-D9P0-rSbv0P PV Status allocatable Total PE / Free PE 2047 / 24 6:文件系統擴容(注意,這點必須做,因為上面只是空間擴容) [root@CentOS ~]# resize2fs /dev/vg_centos/lv_root resize2fs 1.41.12 (17-May-2010) Filesystem at /dev/vg_centos/lv_root is mounted on /; on-line resizing required old desc_blocks = 1, new_desc_blocks = 1 Performing an on-line resize of /dev/vg_centos/lv_root to 3523584 (4k) blocks. The filesystem on /dev/vg_centos/lv_root is now 3523584 blocks long. 7:查看最後磁盤情況 [root@CentOS ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_centos-lv_root 14G 5.0G 7.7G 40% / tmpfs 499M 320K 498M 1% /dev/shm /dev/sda1 485M 56M 404M 13% /boot tmpfs 499M 0 499M 0% /tmp/ram
Copyright © Linux教程網 All Rights Reserved