免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1213 | 回复: 0
打印 上一主题 下一主题

Splitting a Volume Group [复制链接]

招聘 : 技术支持/维
论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-08-16 17:29 |只看该作者 |倒序浏览
Splitting a Volume Group

Author: Jaylin Zhou

Create PVs:
# pvcreate /dev/sdb[567]
  Physical volume "/dev/sdb5" successfully created
  Physical volume "/dev/sdb6" successfully created
  Physical volume "/dev/sdb7" successfully created

Create VG:
# vgcreate myvg /dev/sdb[567]
  Volume group "myvg" successfully created

Create LV:
# # lvcreate -l 50 /dev/myvg -n mylv
  Logical volume "mylv" created

Create filesystem on LV:
# mkfs.ext3 /dev/myvg/mylv

Mount LV and Write data on LV

Determining Free Space:
Use "pvscan" command to determine how much free space is currently available in the VG
# pvscan
  PV /dev/sdb5   VG myvg   lvm2 [100.00 MB / 0    free]
  PV /dev/sdb6   VG myvg   lvm2 [100.00 MB / 0    free]
  PV /dev/sdb7   VG myvg   lvm2 [100.00 MB / 100.00 MB free]
  Total: 3 [300.00 MB] / in use: 3 [300.00 MB] / in no VG: 0 [0   ]

Moving the Data:
Move all the used PE in /dev/sdb5 to /dev/sdb7 with the "pvmove" command
The "pvmove" command can take a long time to execute
# pvmove /dev/sdb5 /dev/sdb7
  /dev/sdb5: Moved: 100.0%
After moving the data, all of the space on /dev/sdb5 is free
# pvscan
  PV /dev/sdb5   VG myvg   lvm2 [100.00 MB / 100.00 MB free]
  PV /dev/sdb6   VG myvg   lvm2 [100.00 MB / 0    free]
  PV /dev/sdb7   VG myvg   lvm2 [100.00 MB / 0    free]
  Total: 3 [300.00 MB] / in use: 3 [300.00 MB] / in no VG: 0 [0   ]

Splitting the VG:
Before splitting the VG, the LV must be inactive.
If the file system is mounted, it must be unmounted before deactivating the LV.
Deactivate the LV with the "lvchange" command or "pvchange" command
# lvchange -an /dev/myvg/mylv
Split the VG "yourvg" from the VG "myvg" with moving PV "/dev/sdb5" into the new VG "yourvg"
# vgsplit myvg yourvg /dev/sdb5
  New volume group "yourvg" successfully split from "myvg"
Use the "vgs" command to see the attributes of the two VGs
# vgs
  VG     #PV #LV #SN Attr   VSize   VFree  
  myvg     2   1   0 wz--n- 200.00M      0
  yourvg   1   0   0 wz--n- 100.00M 100.00M

Creating the New LV:
Create the new LV "yourlv"
# lvcreate -l 100%FREE /dev/yourvg -n yourlv
  Logical volume "yourlv" created
Making a File System and Mounting the New LV:
# mkfs.ext3 /dev/yourvg/yourlv
# mount /dev/yourvg/yourlv  /mnt/

Activating and Mounting the Original LV:
Check the state of the original LV
# lvscan
  inactive          '/dev/myvg/mylv' [200.00 MB] inherit
  ACTIVE            '/dev/yourvg/yourlv' [100.00 MB] inherit
Activate the original LV
# lvchange -ay /dev/myvg/mylv
Check the new state of the original LV
# lvscan
  ACTIVE            '/dev/myvg/mylv' [200.00 MB] inherit
  ACTIVE            '/dev/yourvg/yourlv' [100.00 MB] inherit
# mount /dev/myvg/mylv /mnt/


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/103385/showart_2029257.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP