lvm下缩小根分区

一/先查看当前的 根分区 大小为21G
[root@test-disk ~]# df -h
Filesystem                                         Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00   21G  960M   19G   5% /
/dev/mapper/VolGroup00-LogVol02   7.6G  151M  7.3G   2% /home
/dev/hda1                                           99M   12M   82M  13% /boot
tmpfs                                                 189M     0  189M   0% /dev/shm

二/插入系统光盘,启动后输入linux rescue进去救援模式,不要配置网络,不要让系统根挂载到/mnt/sysimage上,所以最后的界面选择“skip”

分别为:查看物理卷             查看卷组             查看逻辑卷             激活逻辑卷

三/开始减小根文件系统大小


四/减小根lv大小


此时得出LogVol00的LE数量为682,总的PE数量为956,大小32M,所以可以减少的大小为
(956-682)*32M=8768M


五/重启进去系统,再次查看根分区情况
[root@test-disk ~]# df -h
Filesystem                            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00       13G  956M   12G   8% /
/dev/mapper/VolGroup00-LogVol02       7.6G  151M  7.3G   2% /home
/dev/hda1                             99M   12M   82M  13% /boot
tmpfs                                 189M     0  189M   0% /dev/shm

[root@test-disk ~]# vgdisplay         查看卷组情况
  --- Volume group ---
  VG Name               VolGroup00
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  10
  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               29.88 GB
  PE Size               32.00 MB
  Total PE              956
  Alloc PE / Size       682 / 21.31 GB
  Free  PE / Size       274 / 8.56 GB
  VG UUID               l6vUxv-U8KC-gVdH-RQH5-QuUC-jsdl-HjpVqN

[root@test-disk ~]# lvdisplay /dev/VolGroup00/LogVol00
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                Nbcfw3-7jG7-URyG-fRdl-5k6j-x0BC-EFpt0J
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                12.75 GB
  Current LE             408
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

六/把从根分区减出的添加到/home
[root@test-disk ~]# umount /home/
[root@test-disk ~]# e2fsck -f /dev/VolGroup00/LogVol02 
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/VolGroup00/LogVol02: 11/2064384 files (9.1% non-contiguous), 103072/2048000 blocks

[root@test-disk ~]# lvextend -l +274 /dev/VolGroup00/LogVol02 
  /dev/cdrom: open failed: Read-only file system
  Extending logical volume LogVol02 to 16.38 GB
  Logical volume LogVol02 successfully resized

[root@test-disk ~]# e2fsck -f /dev/VolGroup00/LogVol02
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/VolGroup00/LogVol02: 11/2064384 files (9.1% non-contiguous), 103072/2048000 blocks

[root@test-disk ~]# resize2fs /dev/VolGroup00/LogVol02 
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/VolGroup00/LogVol02 to 4292608 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol02 is now 4292608 blocks long.

[root@test-disk ~]# mount -a

[root@test-disk ~]# df -h       再次查看,成功
Filesystem                                 Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00            13G  956M   12G   8% /
/dev/hda1                                  99M   12M   82M  13% /boot
tmpfs                                      189M     0  189M   0% /dev/shm
/dev/mapper/VolGroup00-LogVol02            16G  155M   16G   1% /home

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值