RHEL9进入rd.break修改密码提示”Give Password For Maintenance”解决方法

在我备考RHCE的时候遇到了个很奇怪的问题,RHCSA考试时开篇就要求进入救援模式破解ROOT密码,按书上介绍的方法,需要在gurb里修改linux行添加rd.break进入救援模式,但是我手上的RHEL9进入后竟然要求输入root密码才能继续。

四处谷歌了一下,原来RHEL9修改了救援模式的用户登录方式,具体体现在systemd下的dracut-emergency.sh文件中

 exec sulogin -e

在RHEL8或更早版本之前是这样的

exec sh -i -l

虽然现在的考证系统还是RHEL8,但总有一天会更新到RHEL9,我决定还是记录下比较好。

解决方法

在进入Grub引导后选择第二个自带的rescue,但是直接会弹回到系统,需要按E进入编辑模式

然后就是常规操作,在linux后面添加rd.break才能真正引导至救援模式,如果是真机推荐添加一句console=tty0 最后按Ctrl-X进入

这样就不会提示输入ROOT密码,按回车即可操作shell

然后就是常规操作,挂载/sysroot,chroot进去后passwd修改密码。但是我很好奇mount后为什么要借个remount,于是我查了下。

remount
          Attempt to remount an already-mounted filesystem.  This is commonly used to change the mount flags for a filesystem,  especially  to  make  a
          readonly filesystem writable.  It does not change device or mount point.

          The  remount  functionality follows the standard way the mount command works with options from fstab.  This means that the mount command only
          doesn't read fstab (or mtab) when both the device and dir are specified.

          mount -o remount,rw /dev/foo /dir

          After this call all old mount options are replaced and arbitrary stuff from fstab (or mtab) is ignored, except  the  loop=  option  which  is
          internally generated and maintained by the mount command.

          mount -o remount,rw  /dir

          After  this call mount reads fstab and merges these options with the options from the command line (-o). If no mountpoint found in fstab than
          remount with unspecified source is allowed.

以下是完整流程

mount -o remount,rw /sysroot
chroot /sysroot #用来将root的根目录/转换成目标目录
passwd #修改root密码
touch /.autorelabel #创建SElinux 标记文件
exit
exit #重启系统

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇