安装centos6.5使用自动推荐分区,发现一个问题/home 分区过大,超过了1.1T。
[root@localhost ~]# df -h
文件系统 容量 已用 可用 已用%% 挂载点
/dev/mapper/VolGroup-lv_root
50G 2.9G 44G 7% /
tmpfs 5.9G 100K 5.9G 1% /dev/shm
/dev/sda1 485M 37M 423M 8% /boot
/dev/mapper/VolGroup-lv_home
1.1T 200M 988G 1% /home
目标:/home分20G,剩下添加给/目录下。
1.查看分区模式
[root@localhost ~]# df -h
文件系统 容量 已用 可用 已用%% 挂载点
/dev/mapper/VolGroup-lv_root
50G 2.9G 44G 7% /
tmpfs 5.9G 100K 5.9G 1% /dev/shm
/dev/sda1 485M 37M 423M 8% /boot
/dev/mapper/VolGroup-lv_home
1.1T 200M 988G 1% /home
2.卸载挂载分区
[root@localhost ~]# umount /home
3.检查VolGroup-lv_home文件的错误性,-f 即使文件系统没有错误迹象,仍强制地检查正确性。
[root@localhost ~]# e2fsck -f /dev/mapper/VolGroup-lv_home
e2fsck 1.41.12 (17-May-2010)
第一步: 检查inode,块,和大小
第二步: 检查目录结构
第3步: 检查目录连接性
Pass 4: Checking reference counts
第5步: 检查簇概要信息
/dev/mapper/VolGroup-lv_home: 27/69304320 files (0.0% non-contiguous), 4400705/277215232 blocks
4.调整/home为20G,
[root@localhost ~]# resize2fs -p /dev/mapper/VolGroup-lv_home 20G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/VolGroup-lv_home to 5242880 (4k) blocks.
Begin pass 2 (max = 32784)
正在重定位块 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 3 (max = 8460)
正在扫描inode表 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 4 (max = 15)
正在更新inode引用 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/mapper/VolGroup-lv_home is now 5242880 blocks long.
5.重新挂载并查看
[root@localhost ~]# mount /home
[root@localhost ~]# df -h
文件系统 容量 已用 可用 已用%% 挂载点
/dev/mapper/VolGroup-lv_root
50G 2.9G 44G 7% /
tmpfs 5.9G 100K 5.9G 1% /dev/shm
/dev/sda1 485M 37M 423M 8% /boot
/dev/mapper/VolGroup-lv_home
20G 172M 19G 1% /home
6.划分20G外面的剩余空间。使用lvreduce指令用于减少LVM逻辑卷占用的空间大小。可能会删除逻辑卷上已有的数据,所以在操作前必须进行确认。记得输入 “y”
[root@localhost ~]# lvreduce -L 20G /dev/mapper/VolGroup-lv_home
WARNING: Reducing active and open logical volume to 20.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 20.00 GiB
Logical volume lv_home successfully resized
[root@localhost ~]# df -h
文件系统 容量 已用 可用 已用%% 挂载点
/dev/mapper/VolGroup-lv_root
50G 2.9G 44G 7% /
tmpfs 5.9G 100K 5.9G 1% /dev/shm
/dev/sda1 485M 37M 423M 8% /boot
/dev/mapper/VolGroup-lv_home
20G 172M 19G 1% /home
7.查看“Free PE / Size”剩余空间
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name VolGroup
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 1.09 TiB
PE Size 4.00 MiB
Total PE 285022
Alloc PE / Size 19424 / 75.88 GiB
Free PE / Size 265598 / 1.01 TiB
VG UUID nSbflh-J7fN-xDvf-zLjL-tFcu-Y5Tm-ybnDk0
8.使用lvextend指令:扩展逻辑卷空间到/dev/mapper/VolGroup-lv_root目录下,也就是“/”目录下。
[root@localhost ~]# lvextend -L +1.01T /dev/mapper/VolGroup-lv_root
Rounding size to boundary between physical extents: 1.01 TiB
Extending logical volume lv_root to 1.06 TiB
Logical volume lv_root successfully resized
9.执行操作,使之生效,中间一定要耐心等待。
[root@localhost ~]# resize2fs -p /dev/mapper/VolGroup-lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/VolGroup-lv_root is mounted on /; on-line resizing required
old desc_blocks = 4, new_desc_blocks = 68
Performing an on-line resize of /dev/mapper/VolGroup-lv_root to 284227584 (4k) blocks.
The filesystem on /dev/mapper/VolGroup-lv_root is now 284227584 blocks long.
10.查看分区成功
[root@localhost ~]# df -h
文件系统 容量 已用 可用 已用%% 挂载点
/dev/mapper/VolGroup-lv_root
1.1T 2.9G 1011G 1% /
tmpfs 5.9G 100K 5.9G 1% /dev/shm
/dev/sda1 485M 37M 423M 8% /boot
/dev/mapper/VolGroup-lv_home
20G 172M 19G 1% /home
11.重启
[root@localhost ~]# shutdown -r now
(责任编辑:好模板) |