VMware主机 几次断电后,挂载的磁盘报错了,系统无法启动
由于断电,挂载的磁盘出错:
task mount:1153 blocked for more than 120 seconds
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message
task mount:9943 blocked for more than 120 seconds
磁盘挂载位置: /dev/mapper/centos-home /home
解决方法:
1.进入单用户模式:
按 e 把ro改成 rw init=/sysroot/bin/sh ,按ctrl+x启动
进入单用户页面后,要执行
chroot /sysroot,获取root权限
设置grub
(1)在 GRUB_CMDLINE_LINUX 中添加 net.ifnames=0 biosdevname=0
[root@localhost ~]# vi /etc/sysconfig/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed ‘s, release .*$,,g‘ /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=128M rd.lvm.lv=centos/root rhgb quiet net.ifnames=0 biosdevname=0"
GRUB_DISABLE_RECOVERY="true"
生成菜单
[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-327.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-327.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-8058723e5e754d3aabc51842d9108e3b
Found initrd image: /boot/initramfs-0-rescue-8058723e5e754d3aabc51842d9108e3b.img
done
vi /etc/fstab
#/dev/mapper/centos-home /home xfs default 0 0
重启系统。
重启成功后进入正常模式,这时可以查看/home挂载的问题
(1) lvs -a -o +devices查看磁盘详细信息,可以看到home的attr参数没有a(激活)未激活状态
(2) lvchange -a y /dev/mapper/centos-home 激活home
lvsdisplay
使用xfs_repair来修复,但是要注意xfs_repair修复的分区中的文件都会丢失,即使是du能正常显示的文件也会丢失。
处理步骤:
1、umount /dev/mapper/centos-home
2、xfs_repair /dev/mapper/centos-home 或者xfs_repair /dev/mapper/centos-home -L
3、执行:mount /dev/mapper/centos-home /home
4、取消已挂载:umount /dev/mapper/centos-home
vi /etc/fstab #去掉之前的注释
/dev/mapper/centos-home /home xfs default 0 0
5、关闭linux虚拟机,再重启,这时linux虚拟机就可以正常启动了
————————————————
原文链接:https://blog.csdn.net/glongljl/article/details/80157162
其他设置:
journalctl -xb
sysctl -a |grep dirty
vi /etc/sysctl.conf
vm.dirty_background_ratio = 5
vm.dirty_ratio = 10
vi /etc/init.d/rcS
vm.dirty_ratio = 10
vm.dirty_background_ratio = 5
sysctl -p
sysctl -a | grep hung_task_timeout_secs
sysctl -w kernel.hung_task_timeout_secs=0
cat /sys/block/sda/queue/scheduler
echo noop >/sys/block/sda/queue/scheduler