您的位置:首页 > 运维架构 > Linux

Linux服务器默认建立的LVM逻辑卷磁盘空间分配不合理,根目录不够用,如何缩减和扩展逻辑卷?

2016-06-22 13:22 861 查看


把home目录缩减到50G,把根目录扩容到400G
[b]第一步:逻辑卷的缩减,有风险,先缩减逻辑边界——再缩减物理边界[/b]注意:1、不能在线缩减,得先卸载; 2、确保缩减后的空间大小依然能存储原有的所有数据; 3、在缩减之前应该强行检查文件,确保文件系统处于一致性状态
df –lhumount 卸载e2fsck -f /PATH/TO/PV 强行文件系统检查,看是否有问题 开始缩减用lvdisplay命令查看逻辑卷消息resize2fs /PATH/TO/PV 50G
缩减(逻辑边界)为50G (缩减后的总共大小为50G)

lvreduce -L [-]# /PATH/TO/LV缩减(物理边界)为50Gmount -a
重新挂在

下面为实际操作过程及结果:
[root@wlm ~]# umount /dev/vg_wlm2/lv_home
[root@wlm ~]# resize2fs /dev/vg_wlm2/lv_home 50G
resize2fs 1.41.12 (17-May-2010)
The filesystem is already 13107200 blocks long. Nothing to do!

[root@wlm ~]# lvreduce -L 50G /dev/vg_wlm2/lv_home
WARNING: Reducing active logical volume to 50.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 50.00 GiB
Logical volume lv_home successfully resized
[root@wlm ~]# mount -a
[root@wlm ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_wlm2-lv_root 50G 38G 8.8G 82% /
tmpfs 1.4G 144K 1.4G 1% /dev/shm
/dev/sda1 485M 40M 420M 9% /boot
/dev/mapper/vg_wlm2-lv_home 50G 23G 25G 49% /home

注意:lv的物理路径要用lvdisplay查看,用df查看的只是挂载点

[b]第二步:逻辑卷的扩张:先扩张物理边界———再扩张逻辑边界[/b][b]把根目录扩张到400G[/b]扩张物理边界命令:lvextend -L [+]# /PATH/TO/LV扩展逻辑边界resize2fs resize2fs -p /PATH/TO/LV注意:过程有点长,正常现象
下面为实际操作过程及结果:
[root@wlm ~]# lvextend -L 400G /dev/vg_wlm2/lv_root
Extending logical volume lv_root to 400.00 GiB
Logical volume lv_root successfully resized
You have new mail in /var/spool/mail/root
[root@wlm ~]# resize2fs -p /dev/vg_wlm2/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg_wlm2/lv_root is mounted on /; on-line resizing required
old desc_blocks = 4, new_desc_blocks = 25
Performing an on-line resize of /dev/vg_wlm2/lv_root to 104857600 (4k) blocks.
The filesystem on /dev/vg_wlm2/lv_root is now 104857600 blocks long.
You have new mail in /var/spool/mail/root

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  LVM 简易配置