centos7 /home分区转移空间到 /根分区,结果,/分区已增加大,/home分区却未减小,重启系统后,未正常启动操作系统(实验失败)

环境:

home    /dev/mapper/centos-home     71.1G   71127007232字节       138919936个扇区
root    /dev/mapper/centos-root     52,7G   53687091200         104857600个扇区

目的:
将home分区转移动20G至根分区

过程
1、将/dev/mapper/centos-home缩小21G

[root@localhost ~]# lvreduce -L -21G /dev/mapper/centos-home 
  WARNING: Reducing active and open logical volume to 45.24 GiB.
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce centos/home? [y/n]: y
  Size of logical volume centos/home changed from 66.24 GiB (16958 extents) to 45.24 GiB (11582 extents).
  Logical volume centos/home successfully resized.

2、将多出来的空间给root分区

[root@localhost ~]# lvextend -l +92%FREE /dev/mapper/centos-root   
  Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to 69.32 GiB (17747 extents).
  Logical volume centos/root successfully resized.

3、使用xfs_growfs命令刷新文件系统使用空间转移生效

[root@localhost ~]# xfs_growfs /dev/mapper/centos-home 
meta-data=/dev/mapper/centos-home isize=512    agcount=4, agsize=4341248 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=17364992, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=8479, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data size 11859968 too small, old size is 17364992

[root@localhost ~]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512    agcount=4, agsize=3276800 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=13107200, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=6400, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 13107200 to 18172928

查看结果,发现根目录已增加,但/home未减少

[root@localhost ~]# df  -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 657M     0  657M   0% /dev
tmpfs                    668M     0  668M   0% /dev/shm
tmpfs                    668M  9.4M  659M   2% /run
tmpfs                    668M     0  668M   0% /sys/fs/cgroup
/dev/mapper/centos-root   70G  2.0G   68G   3% /
/dev/sda1               1014M  137M  878M  14% /boot
/dev/mapper/centos-home   67G   33M   67G   1% /home
tmpfs                    134M     0  134M   0% /run/user/0

重启系统看看
结果:
1、未正常启动系统
图片说明
2、df -h,未发现home
图片说明
3、mount home失败,提示超级块不可读
图片说明

求教,centos 7动态扩容,将home分区部分空间转移至/根分区,lvm分区系统,不删除home分区的lv

2个回答

分好的区,每个区都有起止的编码,而且扩容只能针对最后一个分区扩容,因为只有最后的这个分区的编码改动而不影响其他分区。你用fdisk -l这条命令可以查看分区编码起止。你想要将home下的空间给根分区点,你可以重新分区分配大小,如果有数据,不能重新分区,就数据迁移。

由上可以看见缩小后,home分区提示没有成功:
data size 11859968 too small, old size is 17364992
详细原因可以远程帮忙一起看看

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问