[Discuss] Running things from initramfs
Matthew Gillen
me at mattgillen.net
Sat Mar 6 00:46:09 EST 2021
On 3/5/2021 9:07 PM, Dale R. Worley wrote:
> Here's a messy problem. I suspect the answer is simple, but obscure:
>
> I have an Oracle Linux (a Red Hat derivative) computer and I'd like to
> run "xfs_repair /dev/mapper/ol-root". The problem of course
> is that partition is the root partition and xfs_repair can't operate
> on a partition that's mounted. If I could boot off a CD, it would be
> simple, but since this computer is remote, that's hard to do. I've recently
> found that you can edit the "kernel boot line" to include
> "rdinit=/bin/bash", and that causes the boot process to stop early,
> with only the initramfs mounted and you talking to a Bash shell.
>
> The problem is that this environment is not at all set up, and even
> /dev is nearly empty. There is an xfs_repair binary, so I figure if I
> could just get /dev/mapper/ol-root set up correctly, I could
> repair it. There is an "lvm" binary, and it seems to support the
> usual commands, but I can't get it to set up /dev/mapper.
>
> When I run "lvm" it complains about (IIRC) /proc and /sys not
> containing what it wants. I've discovered that I can do "mount -t
> proc non /proc" and similarly for /sys and those seem to work. That
> stops "lvm" from complaining but it doesn't cause it to populate
> /dev/mapper.
>
Dale,
You could try the rescue target by adding this to your kernel command
line instead of changing the rdinit:
systemd.unit=rescue.target
or if that mounts your root fs and does the chroot, try emergency mode:
systemd.unit=emergency.target
If your initramfs contains systemd, then try just starting the
local-fs.target (try "systemctl start local-fs.target"). That might set
everything up that you need. With luck it doesn't do the chroot to your
LVM/XFS root filesystem.
If that doesn't work, this might give you some hints about using systemd
to mount the right stuff:
https://www.golinuxcloud.com/mount-filesystem-without-fstab-systemd-rhel-8/
Finally, if you get frustrated and feel like you trust your backups, the
option is called dangerous, but one thing you could try is boot to
single-user mode, then remount the root filesystem read-only:
mount -o remount,ro /
Then do the dangerous repair on a mounted filesystem:
xfs_repair -d /dev/mapper/ol-root
Then reboot.
HTH,
Matt
More information about the Discuss
mailing list