redhat linux 从/home目录扩展空间至/根目录

查看分区大小

[root@easdb01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_easdb01-lv_root 50G 3.5G 44G 8% /
tmpfs 32G 224K 32G 1% /dev/shm
/dev/sda1 485M 40M 421M 9% /boot
/dev/mapper/vg_easdb01-lv_home 217G 188M 205G 1% /home

卸载/home分区
[root@easdb01 ~]# umount /home

可以看到/home分区不见了
[root@easdb01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_easdb01-lv_root 50G 3.5G 44G 8% /
tmpfs 32G 224K 32G 1% /dev/shm
/dev/sda1 485M 40M 421M 9% /boot

重置/home分区大小
[root@easdb01 ~]# resize2fs -p /dev/mapper/vg_easdb01-lv_home 117G
resize2fs 1.41.12 (17-May-2010)
请先运行 'e2fsck -f /dev/mapper/vg_easdb01-lv_home'.

提示需要先运行:

[root@easdb01 ~]# e2fsck -f /dev/mapper/vg_easdb01-lv_home 

e2fsck 1.41.12 (17-May-2010)
第一步: 检查inode,块,和大小
第二步: 检查目录结构
第3步: 检查目录连接性
Pass 4: Checking reference counts
第5步: 检查簇概要信息
/dev/mapper/vg_easdb01-lv_home: 11/14393344 files (0.0% non-contiguous), 951247/57542656 blocks

再运行重置分区大小:
[root@easdb01 ~]# resize2fs -p /dev/mapper/vg_easdb01-lv_home 117G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/vg_easdb01-lv_home to 30670848 (4k) blocks.
Begin pass 3 (max = 1757)
正在扫描inode表 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/mapper/vg_easdb01-lv_home is now 30670848 blocks long.

加载/home分区

[root@easdb01 ~]# mount /home/
[root@easdb01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_easdb01-lv_root 50G 3.5G 44G 8% /
tmpfs 32G 224K 32G 1% /dev/shm
/dev/sda1 485M 40M 421M 9% /boot
/dev/mapper/vg_easdb01-lv_home 116G 188M 110G 1% /home

将lv_home逻辑分区减小到指定大小
[root@easdb01 ~]# lvre
lvreduce lvremove lvrename lvresize
[root@easdb01 ~]# lvreduce -L 117G /dev/mapper/vg_easdb01-lv_home
WARNING: Reducing active and open logical volume to 117.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 117.00 GiB
Logical volume lv_home successfully resized

查看卷组信息:
[root@easdb01 ~]# vgdisplay
--- Volume group ---
VG Name vg_easdb01
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size 299.51 GiB
PE Size 4.00 MiB
Total PE 76674
Alloc PE / Size 50432 / 197.00 GiB
Free PE / Size 26242 / 102.51 GiB
VG UUID Kopjdv-GfET-USVw-F1bK-1Qdn-Bf80-uUmTGg

扩展lv_root卷大小
[root@easdb01 ~]# lvextend -L +100G /dev/mapper/vg_easdb01-lv_root
Extending logical volume lv_root to 150.00 GiB
Logical volume lv_root successfully resized

重新设定lv_root卷大小
[root@easdb01 ~]# resize2fs -p /dev/mapper/vg_easdb01-lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/vg_easdb01-lv_root is mounted on /; on-line resizing required
old desc_blocks = 4, new_desc_blocks = 10
Performing an on-line resize of /dev/mapper/vg_easdb01-lv_root to 39321600 (4k) blocks.
The filesystem on /dev/mapper/vg_easdb01-lv_root is now 39321600 blocks long.

查看分区,已将空间扩展至/根目录

[root@easdb01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_easdb01-lv_root 148G 3.5G 137G 3% /
tmpfs 32G 224K 32G 1% /dev/shm
/dev/sda1 485M 40M 421M 9% /boot
/dev/mapper/vg_easdb01-lv_home 116G 188M 110G 1% /home
[root@easdb01 ~]#

posted @ 2017-06-08 10:12  Anan_Zou  阅读(2162)  评论(0编辑  收藏  举报