求教,centos7 将home分区空间转移部分至根分区,不删除home分区的lv,不删除home分区的lv,不删除home分区的lv,重要事情说三遍

centos7 将home分区空间转移部分至根分区,不删除home分区的lv.

[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   50G  2.0G   48G   4% /
/dev/sda1               1014M  137M  878M  14% /boot
tmpfs                    134M     0  134M   0% /run/user/0
/dev/mapper/centos-home   67G   33M   67G   1% /home

想转20G过去

umout后,按照大佬的思路,提示black块有问题

[root@localhost ~]# e2fsck -f /dev/mapper/centos-home 
e2fsck 1.42.9 (28-Dec-2013)
ext2fs_open2: Bad magic number in super-block
e2fsck: Superblock invalid, trying backup blocks...
e2fsck: Bad magic number in super-block while trying to open /dev/mapper/centos-home

The superblock could not be read or does not describe a correct ext2
filesystem.  If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>

[root@localhost ~]# echo $?
8
[root@localhost ~]# resize2fs /dev/mapper/centos-home 47G
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/mapper/centos-home
Couldn't find valid filesystem superblock.
[root@localhost ~]# resize2fs -f /dev/mapper/centos-home 47G
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/mapper/centos-home
Couldn't find valid filesystem superblock.

1个回答

linux系统下只有逻辑卷lv空间才能扩充和缩减
umount /dev/mapper/centos-home <‐‐‐ 裁剪容量必须先卸载文件系统
e2fsck ‐f home目录的lv路径 <‐‐‐ 裁剪前必须检测文件系统,以免把文件系统的错误扩大
resize2fs home目录的lv路径 47G <‐‐ 必须先刷新文件系统的容量信息,这是与扩容相反的,顺序错了就会损坏
//执行上述命令有提示 Please run 'e2fsck ‐f /dev/vg0/lv0'first. <‐‐‐‐ 如果已经检测过,但执行多次还是这个提示,再次执行的时候添加参数 ‐f
resize2fs ‐f /home目录的lv路径 47G <‐‐‐‐ 添加参数 ‐f 强制调整
lvreduce ‐L 47G home目录的lv路径 <‐‐‐‐ 再裁剪逻辑卷设备的容量
mount /dev/mapper/centos-home <‐‐‐ 如无意外,正常挂载

扩展:
lvextend ‐l 100%FREE 根目录的LV卷路径
resize2fs /dev/vg0/lv0 <‐‐‐ 最后记得刷新文件系统的容量信息

weixin_39896728
weixin_39896728 回复归$兮: 查下文件格式是ext 还是xfs ,xfs格式的文件扩充需要使用 xfs_growfs
4 个月之前 回复
oToyix
归$兮 [root@localhost ~]# e2fsck -f /dev/mapper/centos-home e2fsck 1.42.9 (28-Dec-2013) ext2fs_open2: Bad magic number in super-block e2fsck: Superblock invalid, trying backup blocks... e2fsck: Bad magic number in super-block while trying to open /dev/mapper/centos-home The superblock could not be read or does not describe a correct ext2 filesystem. If the device is valid and it really contains an ext2 filesystem (and not swap or ufs or something else), then the superblock is corrupt, and you might try running e2fsck with an alternate superblock: e2fsck -b 8193 <device> [root@localhost ~]# echo $? 8 [root@localhost ~]# resize2fs /dev/mapper/centos-home 47G resize2fs 1.42.9 (28-Dec-2013) resize2fs: Bad magic number in super-block while trying to open /dev/mapper/centos-home Couldn't find valid filesystem superblock. [root@localhost ~]# resize2fs -f /dev/mapper/centos-home 47G resize2fs 1.42.9 (28-Dec-2013) resize2fs: Bad magic number in super-block while trying to open /dev/mapper/centos-home Couldn't find valid filesystem superblock.
4 个月之前 回复
oToyix
归$兮 大佬,按照你的操作,提示block块有问题
4 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问