系统基于LVM卷组管理
1、在阿里云购买磁盘扩容后,系统重启
2、重启后lv状态不可用,无法挂在lvm
mount /dev/mapper/vgdisk-app /home mount: special device /dev/mapper/vgdisk-app does not exist
查看lv状态
--- Logical volume --- LV Name /dev/vgdisk/app VG Name vgdisk LV UUID j9GvOW-sivU-18Nq-3vfN-cmTU-49Je-nvu7rK LV Write Access read/write LV Creation host, time iZ94jg74t5xZ, 2015-08-27 19:39:19 +0800 LV Status NOT available LV Size 100.00 GiB Current LE 25600 Segments 1 Allocation inherit Read ahead sectors auto --- Logical volume --- LV Name /dev/vgdisk/data VG Name vgdisk LV UUID Y3F520-hGF2-sazF-C1Ch-kbWl-X4LE-XAta3i LV Write Access read/write LV Creation host, time iZ94jg74t5xZ, 2015-08-27 19:41:34 +0800 LV Status NOT available LV Size 350.00 GiB Current LE 89600 Segments 1 Allocation inherit Read ahead sectors auto
为啥状态不正确了呢,应该扩容导致的问题,找阿里云官方资料,要么是Window下,要么是linux非LVM管理的,感觉按照官方操作不靠谱。
遂自行查找基于LVM卷管理的磁盘扩容资料,找到了一些比较全面的参考资料,结合阿里云环境把问题解决了。
需要对lvm中的管理信息重新扫描,文档中介绍了很多命令,实际上对于扩容至需要更新pv信息,vg信息
处理方法:
---------------------------------------------
step 1:扫描和扩容PV
iZ94jg74t5xZ:~ # pvscan PV /dev/xvdc VG vgdisk lvm2 [500.00 GiB / 50.00 GiB free] Total: 1 [500.00 GiB] / in use: 1 [500.00 GiB] / in no VG: 0 [0 ] iZ94jg74t5xZ:~ # pvresize /dev/xvdc Physical volume "/dev/xvdc" changed 1 physical volume(s) resized / 0 physical volume(s) not resized
step 2:更新VG信息
iZ94jg74t5xZ:~ # vgchange -ay 2 logical volume(s) in volume group "vgdisk" now active
更新完成后查看vg信息和lv状态,一切正常
iZ94jg74t5xZ:~ # vgdisplay --- Volume group --- VG Name vgdisk 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 0 Max PV 0 Cur PV 1 Act PV 1 VG Size 1000.00 GiB PE Size 4.00 MiB Total PE 255999 Alloc PE / Size 115200 / 450.00 GiB Free PE / Size 140799 / 550.00 GiB VG UUID IcVDC2-UAKv-2Cbm-iE8c-JYjp-tupP-TXxuTC iZ94jg74t5xZ:~ # lvdisplay --- Logical volume --- LV Name /dev/vgdisk/app VG Name vgdisk LV UUID j9GvOW-sivU-18Nq-3vfN-cmTU-49Je-nvu7rK LV Write Access read/write LV Creation host, time iZ94jg74t5xZ, 2015-08-27 19:39:19 +0800 LV Status available # open 0 LV Size 100.00 GiB Current LE 25600 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 1024 Block device 252:0 --- Logical volume --- LV Name /dev/vgdisk/data VG Name vgdisk LV UUID Y3F520-hGF2-sazF-C1Ch-kbWl-X4LE-XAta3i LV Write Access read/write LV Creation host, time iZ94jg74t5xZ, 2015-08-27 19:41:34 +0800 LV Status available # open 0 LV Size 350.00 GiB Current LE 89600 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 1024 Block device 252:1
step 3:扩展LV
iZ94jg74t5xZ:/home # lvextend -L +400G /dev/vgdisk/data Extending logical volume data to 750.00 GiB Logical volume data successfully resized
step 4:扩展文件系统
iZ94jg74t5xZ:~ # resize2fs /dev/vgdisk/data resize2fs 1.41.9 (22-Aug-2009) resize2fs: Bad magic number in super-block while trying to open /dev/vgdisk/data Couldn't find valid filesystem superblock.
(插曲:由于本人使用的是XFS文件系统,所以使用resize2fs时,失败了。联想到文件系统的差异性,尝试使用了xfs文件系统的扩展命令,最终完成扩展)
针对XFS文件系统的容量扩展
iZ94jg74t5xZ:~ # xfs_growfs /dev/vgdisk/data meta-data=/dev/mapper/vgdisk-data isize=256 agcount=4, agsize=22937600 blks = sectsz=512 attr=2 data = bsize=4096 blocks=91750400, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 log =internal bsize=4096 blocks=44800, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 91750400 to 196608000
最后mount文件系统,完成任务
----------------------------------------------
从上面操作可以看出基于LVM管理磁盘优势太明显了,比阿里官方的操作方式简单安全得多