LVS_home目录缩减

实验环境
                虚拟机软件:VMware Workstation
                操作系统:Read Hat Enteprise 6.3

注意:    1、不能在线缩减,得先卸载;
              2、确保缩减后的空间大小依然能存储原有的所有数据;
              3、在缩减之前应该先强行检查文件,以确保文件系统处于一致性状态;  


1.查看home磁盘映射的位置 
[ root@template ~]# mount 
/dev/mapper/vg_template-lv_root on / type ext4 (rw) 
proc on /proc type proc (rw) 
sysfs on /sys type sysfs (rw) 
devpts on /dev/pts type devpts (rw,gid=5,mode=620) 
tmpfs on /dev/shm type tmpfs (rw) 
/dev/sda1 on /boot type ext4 (rw) 
/dev/mapper/vg_template-lv_home on /home type ext4 (rw) 
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) 
/dev/sr0 on /media type iso9660 (ro) 
2.卸载home目录 
[ root@template ~]# umount /dev/mapper/vg_template-lv_home 
3.检查home文件目录 
[ root@template ~]# e2fsck /dev/mapper/vg_template-lv_home 
e2fsck 1.41.12 (17-May-2010) 
/dev/mapper/vg_template-lv_home: clean, 11/6553600 files, 459349/26214400 blocks 
4.缩小home文件目录 
[ root@template ~]# resize2fs -f /dev/mapper/vg_template-lv_home 5G 
resize2fs 1.41.12 (17-May-2010) 
Resizing the filesystem on /dev/mapper/vg_template-lv_home to 1310720 (4k) blocks. 
The filesystem on /dev/mapper/vg_template-lv_home is now 1310720 blocks long. 
5.缩小home的lv 
[ root@template ~]# lvreduce -L 5G /dev/mapper/vg_template-lv_home 
WARNING: Reducing active logical volume to 5.00 GiB 
THIS MAY DESTROY YOUR DATA (filesystem etc.) 
Do you really want to reduce lv_home? [y/n]: y 
Reducing logical volume lv_home to 5.00 GiB 
Logical volume lv_home successfully resized 
6.查看lv 
[ root@template ~]# lvs 
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert 
lv_home vg_template -wi-a--- 5.00g 
lv_root vg_template -wi-ao-- 50.00g 
lv_swap vg_template -wi-ao-- 1.94g 
7.挂载home目录 
[ root@template ~]# mount -a 
8.检查home目录的大小 
[ root@template ~]# df -h 
Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_template-lv_root 
50G 1.4G 46G 3% / 
tmpfs 242M 0 242M 0% /dev/shm 
/dev/sda1 485M 32M 429M 7% /boot 
/dev/sr0 3.5G 3.5G 0 100% /media 
/dev/mapper/vg_template-lv_home 
5.0G 160M 4.6G 4% /home




转载于:https://my.oschina.net/Saviorsyang/blog/297598

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值