View previous topic :: View next topic |
Author |
Message |
hjkl Apprentice
Joined: 22 Apr 2021 Posts: 198 Location: Somewhere in Europe
|
Posted: Tue Jul 20, 2021 12:13 pm Post subject: How to include programs in "rescue mode" |
|
|
Hi,
Is there any way to include programs (i.e. vim instead of vi) in the "rescue mod" (as in, when you get dropped into a root shell when something goes wrong) because I find it a pain to do anything there when vim isn't there.
Same with other software I use which isn't included in it. _________________ Having problems compiling since 2021 |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54237 Location: 56N 3W
|
Posted: Tue Jul 20, 2021 1:03 pm Post subject: |
|
|
hjkl,
What you put in the the initrd, or initrds, is up to you. Its just a cpio archive of other cpio archives.
How you do it do depends on how you build the initrd.
You may have several initrds and grub will load them all.
To add an initrd, determine the files you need with lddtree.
e.g. Code: | $ lddtree /bin/bash
/bin/bash (interpreter => /lib64/ld-linux-x86-64.so.2)
libreadline.so.8 => /lib64/libreadline.so.8
libtinfow.so.6 => /lib64/libtinfow.so.6
libc.so.6 => /lib64/libc.so.6
|
Make a cpio archive containing those files in those exact paths.
You can unpack the initrd you already have, add to it, and repack it but that's not something you want to do every kernel build because the modules change.
You can also make your own initrd, from scratch. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
hjkl Apprentice
Joined: 22 Apr 2021 Posts: 198 Location: Somewhere in Europe
|
Posted: Tue Jul 20, 2021 2:42 pm Post subject: |
|
|
NeddySeagoon wrote: | hjkl,
What you put in the the initrd, or initrds, is up to you. Its just a cpio archive of other cpio archives.
How you do it do depends on how you build the initrd.
You may have several initrds and grub will load them all.
To add an initrd, determine the files you need with lddtree.
e.g. Code: | $ lddtree /bin/bash
/bin/bash (interpreter => /lib64/ld-linux-x86-64.so.2)
libreadline.so.8 => /lib64/libreadline.so.8
libtinfow.so.6 => /lib64/libtinfow.so.6
libc.so.6 => /lib64/libc.so.6
|
Make a cpio archive containing those files in those exact paths.
You can unpack the initrd you already have, add to it, and repack it but that's not something you want to do every kernel build because the modules change.
You can also make your own initrd, from scratch. |
That sound's quite complicated.
Would I be able to do this with genkernel? _________________ Having problems compiling since 2021 |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54237 Location: 56N 3W
|
Posted: Tue Jul 20, 2021 3:02 pm Post subject: |
|
|
hjkl,
I've never used genkernel, so I can't help there.
You would need to look at how the initrd is defined and add to it. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3136
|
Posted: Tue Jul 20, 2021 8:12 pm Post subject: |
|
|
Quote: | Would I be able to do this with genkernel? | Yes, I think so.
AFAIR genkernel allows you to include contents of some particular directory in your initramfs. Haven't used it, it just caught my eye (and now I look like a pirate )
Have a look at /etc/genkernel.conf:
Code: | # Directory structure to include in the initramfs,
# only available on >=2.6 kernels
#INITRAMFS_OVERLAY=""
|
|
|
Back to top |
|
|
Goverp Advocate
Joined: 07 Mar 2007 Posts: 2006
|
Posted: Wed Jul 21, 2021 8:27 am Post subject: |
|
|
I've never used genkernel, so this may be irrelevant, but most initramfs setups I've met use busybox, especially for rescue mode. AFAIK, by default busybox contains a vi editor. If yours doesn't, perhaps genkernel is disabling it in the initramfs build, in which case it ought to be possible to change its busybox config to put it back.
Whoops, sorry, skimmed the original article too fast. You want vim instead of vi. Ignore me. _________________ Greybeard |
|
Back to top |
|
|
Goverp Advocate
Joined: 07 Mar 2007 Posts: 2006
|
Posted: Wed Jul 21, 2021 8:35 am Post subject: |
|
|
You might be able to use the initramfs file list generated by my script; not sure how that fits into genkernel.
However, from experience without genkernel, I can say you may well trip over vim's prereqs and their config files. Without checking, I expect you might need to get ncurses working in the initramfs environment. AFAIR there's a thread somewhere in the forums that calls out a couple of config files it needs that you'd otherwise miss. _________________ Greybeard |
|
Back to top |
|
|
hjkl Apprentice
Joined: 22 Apr 2021 Posts: 198 Location: Somewhere in Europe
|
Posted: Wed Jul 21, 2021 9:41 am Post subject: |
|
|
Goverp wrote: | You might be able to use the initramfs file list generated by my script; not sure how that fits into genkernel.
However, from experience without genkernel, I can say you may well trip over vim's prereqs and their config files. Without checking, I expect you might need to get ncurses working in the initramfs environment. AFAIR there's a thread somewhere in the forums that calls out a couple of config files it needs that you'd otherwise miss. |
I will make sure to check it out.
I hope I won't brick my system. _________________ Having problems compiling since 2021 |
|
Back to top |
|
|
Goverp Advocate
Joined: 07 Mar 2007 Posts: 2006
|
Posted: Wed Jul 21, 2021 12:39 pm Post subject: |
|
|
hjkl wrote: | ...
I hope I won't brick my system. |
Which bootmanager are you using? Grub, rEFInd, kernel EFI stub, something else, something non-EFI? Most of them will let you keep a previous working kernel/initramfs around for fallback. _________________ Greybeard |
|
Back to top |
|
|
|