根目录今天满盘后导致系统停机, 梳理发现当初分区不合理, 于是想调整/home与/的分配
# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 32G 0 32G 0% /dev
tmpfs 32G 893M 31G 3% /dev/shm
tmpfs 32G 8.9M 32G 1% /run
tmpfs 32G 0 32G 0% /sys/fs/cgroup
/dev/mapper/centos-root 50G 39G 12G 77% /
/dev/sda2 1014M 179M 836M 18% /boot
/dev/sda1 200M 12M 189M 6% /boot/efi
/dev/mapper/centos-home 72G 33M 72G 1% /home
tmpfs 6.3G 0 6.3G 0% /run/user/11012
tmpfs 6.3G 0 6.3G 0% /run/user/0
# lvresize -L 10G /dev/mapper/centos-home
WARNING: Reducing active and open logical volume to 10.00 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 71.92 GiB (18412 extents) to 10.00 GiB (2560 extents).
Logical volume centos/home successfully resized.
# mount -a
mount: /dev/mapper/centos-home: can't read superblock
这时候发现不对劲
# xfs_repair /dev/mapper/centos-home
Phase 1 - find and verify superblock...
error reading superblock 1 -- seek to offset 19306381312 failed
couldn't verify primary superblock - attempted to perform I/O beyond EOF !!!
attempting to find secondary superblock...
Sorry, could not find valid secondary superblock
Exiting now.
赶紧恢复原样
# lvresize -L 72G /dev/mapper/centos-home
Size of logical volume centos/home changed from 10.00 GiB (2560 extents) to 72.00 GiB (18432 extents).
Logical volume centos/home successfully resized.
# xfs_repair /dev/mapper/centos-home
Phase 1 - find and verify superblock...
Phase 2 - using internal log
- zero log...
ERROR: The filesystem has valuable metadata changes in a log which needs to
be replayed. Mount the filesystem to replay the log, and unmount it before
re-running xfs_repair. If you are unable to mount the filesystem, then use
the -L option to destroy the log and attempt a repair.
Note that destroying the log may cause corruption -- please attempt a mount
of the filesystem before doing this.
# mount /dev/mapper/centos-home /home
# ls /home
grid oracle
这次改用稳妥点的方式
先备份!
# tar cvf /root/home_backup.tar -C /home .
缩小容量并重新格式化
# umount /home
# lvresize -L 10G /dev/mapper/centos-home
WARNING: Reducing active logical volume to 10.00 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 72.00 GiB (18432 extents) to 10.00 GiB (2560 extents).
Logical volume centos/home successfully resized.
# mkfs.xfs /dev/mapper/centos-home -f
Discarding blocks...Done.
meta-data=/dev/mapper/centos-home isize=512 agcount=4, agsize=655360 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=2621440, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
挂盘与还原数据
# mount /dev/mapper/centos-home /home
# tar xvf /root/home_backup.tar -C /home
检查数据后正常
现在要增加 / 的空间
# lvresize -l +100%FREE /dev/mapper/centos-root
Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to 234.92 GiB (60140 extents).
Logical volume centos/root successfully resized.
# xfs_growfs /
meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=3276800 blks
= sectsz=4096 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=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 13107200 to 61583360
操作成功!
再次检查
# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 32G 0 32G 0% /dev
tmpfs 32G 893M 31G 3% /dev/shm
tmpfs 32G 8.9M 32G 1% /run
tmpfs 32G 0 32G 0% /sys/fs/cgroup
/dev/mapper/centos-root 235G 39G 197G 17% /
/dev/sda2 1014M 179M 836M 18% /boot
/dev/sda1 200M 12M 189M 6% /boot/efi
tmpfs 6.3G 0 6.3G 0% /run/user/11012
tmpfs 6.3G 0 6.3G 0% /run/user/0
/dev/mapper/centos-home 10G 33M 10G 1% /home
完工!

5万+

被折叠的 条评论
为什么被折叠?



