手机版
你好,游客 登录 注册
背景:
阅读新闻

Linux逻辑卷管理LVM

[日期:2013-03-25] 来源:Linux社区  作者:missedyou [字体:大 中 小]
  • 在线扩展LV的大小
  1. LVM最主要的功能就是能动态的调整分区的大小,其实也就是修改逻辑卷的大小
  2. lvresize [-L (+size) –l (+PE数)] 逻辑卷名称
  3. 扩展逻辑卷sharedisk的大小到5G,执行以下命令:
  4. [root@rhel5 ~]# lvresize -L 5G /dev/iscsi/sharedisk
  5. [root@rhel5 ~]# resize2fs /dev/iscsi/sharedisk
  6. resize2fs 1.39 (29-May-2006)
  7. resize2fs: Bad magic number in super-block while trying toopen /dev/iscsi/sharedisk
  8. Couldn't find valid filesystem superblock.
  • 缩小LV的大小
  1. 缩小LV必须先缩小LV所在的文件系统(resize2fs)才能进一步缩小LV(lvresize)
  2. 缩小逻辑卷sharediak的大小为3G
  3. [root@rhel5 ~]# umount /dev/iscsi/sharedisk
  4. [root@rhel5 ~]# e2fsck -f /dev/iscsi/sharedisk //检查文件系统的准确性
  5. e2fsck 1.39 (29-May-2006)
  6. Couldn't find ext2 superblock, trying backup blocks...
  7. Pass 1: Checking inodes, blocks, and sizes
  8. Pass 2: Checking directory structure
  9. Pass 3: Checking directory connectivity
  10. Pass 4: Checking reference counts
  11. Pass 5: Checking group summary information
  12. /dev/iscsi/sharedisk: ***** FILE SYSTEM WAS MODIFIED *****
  13. /dev/iscsi/sharedisk: 11/262144 files (9.1% non-contiguous), 25406/524288 blocks
  14. [root@rhel5 ~]# resize2fs /dev/iscsi/sharedisk 3G //缩小文件系统的大小为3G
  15. resize2fs 1.39 (29-May-2006)
  16. Resizing the filesystem on /dev/iscsi/sharedisk to 786432 (4k) blocks.
  17. The filesystem on /dev/iscsi/sharedisk is now 786432 blocks long.
  18. [root@rhel5 ~]# lvresize -L 3G /dev/iscsi/sharedisk //缩小逻辑卷sharedisk的大小为3G
  19. WARNING: Reducing active logical volume to 3.00 GB
  20. THIS MAY DESTROY YOUR DATA (filesystem etc.)
  21. Do you really want to reduce sharedisk? [y/n]: y
  22. Reducing logical volume sharedisk to 3.00 GB
  23. Logical volume sharedisk successfully resized
  24. [root@rhel5 ~]# mount /dev/iscsi/sharedisk /data/
  • 删除LV、VG、PV
  1. 删除物理卷的命令是pvremove,将物理卷从卷组移除的命令是vgreduce,删除卷组的命令是vgremove,同理,删除逻辑卷的命令是lvremove。
  2. 删除一个卷组的顺序是:卸载逻辑卷分区-->删除卷组上所有逻辑卷-->删除卷组
  3. [root@rhel5 ~]# umount /dev/iscsi/sharedisk
  4. [root@rhel5 ~]# lvremove /dev/iscsi/sharedisk
  5. Do you really want to remove active logical volume sharedisk? [y/n]: y
  6. Logical volume "sharedisk" successfully removed
  7. [root@rhel5 ~]# vgchange -a n iscsi //停用卷组iscsi
  8. 0 logical volume(s) in volume group"iscsi" now active
  9. [root@rhel5 ~]# vgreduce iscsi /dev/sda6 //从卷组iscsi 中移除一个/dev/sda6的物理卷
  10. Removed "/dev/sda6"from volume group"iscsi"
  11. [root@rhel5 ~]# vgs iscsi
  12. VG #PV #LV #SN Attr VSize VFree
  13. iscsi 1 0 0 wz--n- 4.68G 4.68G
  14. [root@rhel5 ~]# vgremove iscsi /dev/sda5
  15. Volume group"iscsi" successfully removed
  16. [root@rhel5 ~]# pvremove /dev/sda5
  17. Labels on physical volume "/dev/sda5" successfully wiped
  18. [root@rhel5 ~]# pvremove /dev/sda6
  19. Labels on physical volume "/dev/sda6" successfully wiped
linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转���或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款