CentOS 7进入紧急修复模式解决

打开CentOS7页面出现:

welcome to emergency mode!after logging in ,type “journalctl -xb” to view system logs,“systemctl reboot” to reboot ,“systemctl default” to try again to boot into default mode。
give root password for maintenance
(?? Control-D???):
在这里插入图片描述

这个错误要注意一下是不是加载了外部硬盘、存储器或者是网络共享空间,在重启时没有加载上导致的。

解决方法:

1.执行 runlevel 显示unknown

2.修改默认启动级别

a. 先删除: mv /etc/systemd/system/default.target /etc/systemd/system/default.target.back #将文件重命名即可


b. 创建软连接文件: ln -sf /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
或者
ln -sf /lib/systemd/system/runlevel3.target /etc/systemd/system/default.target


也可以使用systemctl命令:
systemctl set-default graphical.target
systemctl isolate multi-user.target

执行过程中报错:Error getting authority: Error initializing authority: Could not connect: Resource temporarily unavailable (g-io-error-quark, 1)

3.查看日志 journalctl -xb
发现日志中挂载出错:
在这里插入图片描述

可以看出是挂载问题,是/home文件没有挂载上

4.编辑自动挂载的文件 vi /etc/fstab
把挂载/home的那行注释掉(先备份)

#/dev/mapper/centos-home  /home  xfs  default  0 0

5.重启服务器 reboot

6.启动成功后,页面卡在白条不动了,可以按esc键查看启动详情,是在/etc/rc.d/rc.local卡住了,重启进入单用户模式:
(1)开机时在默认项选e
在这里插入图片描述

(2)找到ro的那一行
在这里插入图片描述

(3)把ro改成 rw init=/sysroot/bin/sh ,按ctrl+x启动
在这里插入图片描述

(4)进入单用户页面后,要执行chroot /sysroot,获取root权限

7.进入单用户模式后编辑rc.local文件,把跟/home有关的启动项都注释掉,重启服务器

8.设置grub
(1)在 GRUB_CMDLINE_LINUX 中添加 net.ifnames=0 biosdevname=0

[root@localhost ~]#  cat  /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"

(2)生成菜单

[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

9.重启成功后进入正常模式,这时可以查看/home挂载的问题
(1)lvs -a -o +devices查看磁盘详细信息,可以看到home的attr参数没有a(激活)未激活状态
(2)lvchange -a y /dev/mapper/centos-home 激活home
(3)挂载home,mount /dev/mapper/centos-home /home
(4)挂载成功,把原来fstab和rc.local里注释的在改回去
在这里插入图片描述
备注:
①如果没有 lvs、lvdisplay等相关命令,需要安装

yum -y install lvm2

②用 lvsdisplay 看到 lv的状态信息
在这里插入图片描述

[root@localhost dev]# lvdisplay 
  --- Logical volume ---
  LV Path                /dev/centos/swap
  LV Name                swap
  VG Name                centos
  LV UUID                lfSF3U-wxjw-S2th-OYKz-4VOx-ld93-m9LnYk
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2016-03-30 18:29:29 +0800
  LV Status              available
  # open                 0
  LV Size                7.75 GiB
  Current LE             1984
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1
   
  --- Logical volume ---
  LV Path                /dev/centos/home
  LV Name                home
  VG Name                centos
  LV UUID                cJRCr7-vOBd-2DX9-L3p1-IeWF-PZqq-iUzrk7
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2016-03-30 18:29:30 +0800
  LV Status              NOT available
  LV Size                1.74 TiB
  Current LE             456411
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
   
  --- Logical volume ---
  LV Path                /dev/centos/root
  LV Name                root
  VG Name                centos
  LV UUID                5MSbR6-FORC-Zl2t-hIJM-2X1I-axu8-RyodIO
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2016-03-30 18:31:58 +0800
  LV Status              available
  # open                 1
  LV Size                50.00 GiB
  Current LE             12800
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
  • 10
    点赞
  • 62
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值