组团学

逻辑卷实战案例-逻辑卷裁剪

阅读 (226753)

案例需求

将lv1逻辑卷由原来的3G缩小为2G

案例思路

1、卸载逻辑卷
2、扫描逻辑卷
3、裁剪率lv1文件系统
4、裁剪逻辑卷lv1
5、挂载使用

案例实现

ext分区逻辑卷裁剪

[root@zutuanxue /]# umount /lv1 [root@zutuanxue /]# e2fsck -f /dev/vg1/lv1 检验文件系统 [root@zutuanxue /]# resize2fs /dev/vg1/lv1 2G 裁剪文件系统到2G [root@zutuanxue /]# lvreduce /dev/vg1/lv1 -L 2G 裁剪逻辑卷 [root@zutuanxue /]# mount /dev/vg1/lv1 /lv1/ 挂载使用 [root@zutuanxue /]# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/mapper/vg1-lv1 2.0G 9.0M 1.8G 1% /lv1

xfs分区逻辑卷裁剪

案例思路:
1、将lv2的文件系统格式化为xfs
2、将/dev/vg1/lv2挂载到/lv2
3、在/lv2中建立一个文件,写入内容
4、备份数据
5、卸载分区并裁剪逻辑卷
6、格式化裁剪后的逻辑卷
7、导入数据

1)备份数据命令 xfsdump 2)备份数据 [root@zutuanxue /]# xfsdump -f /root/lv2.img /lv2 #挂载点目录后面不要加"/" xfsdump: using file dump (drive_simple) strategy xfsdump: version 3.1.8 (dump format 3.0) - type ^C for status and control ============================= dump label dialog ============================== please enter label for this dump session (timeout in 300 sec) -> lv2 session label entered: "lv2" --------------------------------- end dialog --------------------------------- xfsdump: level 0 dump of localhost.localdomain:/lv2 xfsdump: dump date: Tue Dec 10 06:33:44 2019 xfsdump: session id: 15936371-b967-4c2c-8995-49eb702792fe xfsdump: session label: "lv2" xfsdump: ino map phase 1: constructing initial dump list xfsdump: ino map phase 2: skipping (no pruning necessary) xfsdump: ino map phase 3: skipping (only one dump stream) xfsdump: ino map construction complete xfsdump: estimated dump size: 20800 bytes ============================= media label dialog ============================= please enter label for media in drive 0 (timeout in 300 sec) -> lv2 media label entered: "lv2" --------------------------------- end dialog --------------------------------- xfsdump: creating dump session media file 0 (media 0, file 0) xfsdump: dumping ino map xfsdump: dumping directories xfsdump: dumping non-directory files xfsdump: ending media file xfsdump: media file size 21016 bytes xfsdump: dump size (non-dir files) : 0 bytes xfsdump: dump complete: 14 seconds elapsed xfsdump: Dump Summary: xfsdump: stream 0 /root/lv2.img OK (success) xfsdump: Dump Status: SUCCESS 3)裁剪 [root@zutuanxue ~]# umount /lv2 [root@zutuanxue ~]# lvreduce /dev/vg1/lv2 -L 100M WARNING: Reducing active logical volume to 2.00 GiB. THIS MAY DESTROY YOUR DATA (filesystem etc.) Do you really want to reduce vg01/lv01? [y/n]: y Size of logical volume vg01/lv01 changed from 7.00 GiB (1792 extents) to 2.00 GiB (512 extents). Logical volume vg01/lv01 successfully resized. 4)格式化 [root@zutuanxue ~]# mkfs.xfs -f /dev/vg1/lv2 [root@zutuanxue ~]# mount /dev/vg1/lv2 /lv2 5)恢复数据 -f source [root@zutuanxue ~]# xfsrestore -f /root/lv2.img /lv2 . . . xfsrestore: Restore Status: SUCCESS root@zutuanxue ~]# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/mapper/vg1-lv2 95M 6.0M 89M 7% /lv2 [root@zutuanxue ~]# cat /lv2/filea hahaha
需要 登录 才可以提问哦