[Discuss] Running things from initramfs

grg grg-webvisible+blu at ai.mit.edu
Sat Mar 6 10:25:25 EST 2021


On Fri, Mar 05, 2021 at 09:07:56PM -0500, Dale R. Worley wrote:
> 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.
...
> Does anyone know how to get LVM working in this situation?

I don't, but if I google "xfs_repair lvm oracle" the top result is:
    https://prasadlinuxblog.wordpress.com/2017/12/26/xfs_check-and-xfs_repair-of-lvm-under-rescue-mode-on-centos-7-oraclelinux-7/
which looks like it might be your answer, if vgscan and vgchange are in
that environment?  they talk about rescue mode (is that only on CD?), you
seem to be forcing the initramfs environment to be interactive (which
surprises me that it works remotely -- do you have a way of getting to a
serial console or something?  or does it really set up sshd for you?), so
it's not clear whether it applies - but worth checking for vgscan and
vgchange and trying this out.

if that fails, plan b (or c or d, after the suggestions from others):

> 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.

what does your partition table look like?  if you have empty space, easy,
just make a new root in it and boot to that, then do whatever you like with
lvm and xfs_repair.  (not likely, but worth checking)

if there's no unused space on disk but you have /tmp in its own partition
*on disk* (not tmpfs=ramdisk), you could temporarily cannibalize that -
make a tmpfs /tmp to use temporarily (or permanently!), then set up the
normally-/tmp disk partition to be a minimal root, and boot to it.

more likely than the above, assuming you have a swap partition, you could
temporarily cannibalize it and put a root there.  as long as you have
enough ram to do what you're doing (a few gb for this temporary usage?),
things run fine without swap.

getting into the more desperate scenarios now, if none of the above apply
but there are partitions other than / (e.g. /home), you could set up a root
in a subdirectory there (e.g. /home/minimalroot/) and fiddle with your boot
process to boot root out of that subdir.  a quick google search gives this
answer for debian, inside the initramfs environment you're already using:
    https://unix.stackexchange.com/questions/39423/boot-linux-system-from-a-subdirectory-on-a-partition

or if you have enough ram (maybe even 8gb would work?) there are ways to
set up your system to move root to a tmpfs after boot.  either as part of
the boot process, or (harder) after boot in a running system, using
pivot_root -- doing that in the running system, google suggests
    https://unix.stackexchange.com/questions/226872/how-to-shrink-root-filesystem-without-booting-a-livecd/227318#227318
(which is about shrinking a partition, but applies equally to repairing)
then you can unmount your real root partition and have your way with it.

if any of these options are actually bad ideas (aside from all of this
being dangerous) or just won't work, I'm hoping others on the list will
pipe in and explain why.  I make no guarantees.  :)

--grg


More information about the Discuss mailing list