centos 6.4 调整home和root分区大小

调整过程中可以随时查看硬盘分区情况,命令:

lsblk

df -h

 

压缩home分区到5G:

[root@fscp-dev /]# df -h
文件系统          容量  已用  可用 已用%% 挂载点
/dev/mapper/vg_fscpdev-lv_root
                       50G  1.1G   46G   3% /
tmpfs                 1.9G     0  1.9G   0% /dev/shm
/dev/sda1             485M   32M  428M   7% /boot
/dev/mapper/vg_fscpdev-lv_home
                       45G  180M   43G   1% /home
[root@fscp-dev /]# umount /home
[root@fscp-dev /]# e2fsck -f /dev/mapper/vg_fscpdev-lv_home
e2fsck 1.41.12 (17-May-2010)
第一步: 检查inode,块,和大小
第二步: 检查目录结构
第3步: 检查目录连接性
Pass 4: Checking reference counts
第5步: 检查簇概要信息
/dev/mapper/vg_fscpdev-lv_home: 11/2992416 files (0.0% non-contiguous), 233857/11962368 blocks

[root@fscp-dev /]# resize2fs -p /dev/mapper/vg_fscpdev-lv_home 5G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/vg_fscpdev-lv_home to 1310720 (4k) blocks.
Begin pass 2 (max = 32768)
正在重定位块            XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 3 (max = 366)
正在扫描inode表          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/mapper/vg_fscpdev-lv_home is now 1310720 blocks long.

[root@fscp-dev /]# mount /home
[root@fscp-dev /]# df -h
文件系统          容量  已用  可用 已用%% 挂载点
/dev/mapper/vg_fscpdev-lv_root
                       50G  1.1G   46G   3% /
tmpfs                 1.9G     0  1.9G   0% /dev/shm
/dev/sda1             485M   32M  428M   7% /boot
/dev/mapper/vg_fscpdev-lv_home
                      5.0G  160M  4.6G   4% /home

[root@fscp-dev /]# lvreduce -L 5G /dev/mapper/vg_fscpdev-lv_home 
  WARNING: Reducing active and open 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

增加根目录40G

[root@fscp-dev /]# lvextend -L +40G /dev/mapper/vg_fscpdev-lv_root 
  Extending logical volume lv_root to 90.00 GiB
  Logical volume lv_root successfully resized
[root@fscp-dev /]# lsblk
NAME                          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0                            11:0    1 1024M  0 rom  
sda                             8:0    0  100G  0 disk 
├─sda1                          8:1    0  500M  0 part /boot
└─sda2                          8:2    0 99.5G  0 part 
  ├─vg_fscpdev-lv_root (dm-0) 253:0    0   90G  0 lvm  /
  ├─vg_fscpdev-lv_swap (dm-1) 253:1    0  3.9G  0 lvm  [SWAP]
  └─vg_fscpdev-lv_home (dm-2) 253:2    0    5G  0 lvm  /home

[root@fscp-dev /]# cat /etc/issue
CentOS release 6.4 (Final)

 

标红即是

posted @ 2018-01-18 10:10  剑握在手  阅读(422)  评论(0编辑  收藏  举报
返回顶部↑