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

磁盘管理之LVM

[日期:2014-08-10] 来源:Linux社区  作者:dddbk [字体:大 中 小]

7.当我们使用完一段时间后,可能4G的空间不够用了,这种时候,我们可以对test1进行扩展.LVM的灵活性就展现出来了.例如我们想扩展到7G,但是经过查看,卷组中的空间已经不够使用,需要先对卷组进行扩展

[root@localhost test]# vgs test

VG #PV #LV #SN Attr VSize VFree

test 1 1 0 wz--n- 5.01g 1.01g

[root@localhost test]# vgextend test /dev/sdb2

Volume group "test" successfully extended

[root@localhost test]# vgs test

VG #PV #LV #SN Attr VSize VFree

test 2 1 0 wz--n- 10.02g 6.02g


8.扩展逻辑卷test1(首先扩展物理边界,再扩展文件系统边界)

[root@localhost test]# vgextend test /dev/sdb2

Volume group "test" successfully extended

[root@localhost test]# vgs test

VG #PV #LV #SN Attr VSize VFree

test 2 1 0 wz--n- 10.02g 6.02g

[root@localhost test]# lvextend -L 7G /dev/test/test1 #扩展物理边界

Extending logical volume test1 to 7.00 GiB

Logical volume test1 successfully resized

[root@localhost test]# resize2fs /dev/test/test1 #扩展文件系统边界

resize2fs 1.41.12 (17-May-2010)

Filesystem at /dev/test/test1 is mounted on /test; on-line resizing required

old desc_blocks = 1, new_desc_blocks = 1

Performing an on-line resize of /dev/test/test1 to 1835008 (4k) blocks.

The filesystem on /dev/test/test1 is now 1835008 blocks long.

[root@localhost test]# df -h #test1成功扩展到7G大小

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/vg0-root 20G 428M 19G 3% /

tmpfs 246M 0 246M 0% /dev/shm

/dev/sda1 194M 30M 155M 16% /boot

/dev/mapper/vg0-usr 9.9G 2.3G 7.2G 24% /usr

/dev/mapper/vg0-var 20G 361M 19G 2% /var

/dev/mapper/test-test1 6.9G 137M 6.5G 3% /test


9.对测试后的test1访问,查看文件是否被破坏

[root@localhost test]# cat a.txt #文件未被破坏

lv test


10.快照卷创建(用于文件系统备份等场景使用)

[root@localhost test]# lvcreate -n snap-test1 -L 2G -s /dev/test/test1 -p r

Logical volume "snap-test1" created

[root@localhost test]# mkdir /test.bak

[root@localhost test]# mount /dev/test/snap-test1 /test.bak/

mount: block device /dev/mapper/test-snap--test1 is write-protected, mounting read-only


11.查看test1及其快照卷的文件列表及a.txt的文件内容

[root@localhost /]# ls /test

a.txt lost+found

[root@localhost /]# ls /test.bak/

a.txt lost+found

[root@localhost test]# cat /test/a.txt /test.bak/a.txt

lv test

lv test


12.修改test1中的文件,查看在其快照卷中是否发生了改动

[root@localhost test]# echo "This is a new line" >>/test/a.txt

[root@localhost test]# cat /test/a.txt

lv test

This is a new line

[root@localhost test]# cat /test.bak/a.txt #快照卷的文件内容未发生改变

lv test

本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-08/105381.htm

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

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