LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 09-15-2023, 11:00 PM   #1
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Does rescue mode with an initrd work for you in Slackware64-15.0?


Needless to say, I did something very stupid with my root filesystem's /etc/fstab entry; the end result is that filesystem is now read-only on full boot and any attempts to modify that state require writing something into the root filesystem.

OK, no problem; I should be able to modify (I'm using grub.) the command line passed on as boot by adding rescue. That should give me a command-line to mount directories and fix stuff as part of the initrd portion of the boot.

The problem is that I don't really get an interactive shell. I get the message...

Code:
/bin/sh: can't access tty; job control turned off
...followed by a
Code:
/ #
prompt that accepts no input from the device that I used to interactively modify the grub boot entry to add rescue to the kernel command line.

I fully realize that if there is an underlying problem here that would require some initrd changes to get this to work for later initrd images that it won't help with the problem that I have at the moment. (Yes, I know that I can get a live slack image and use that to fix my problem but where I live now uses ViaSat and going over your data limit puts you back into the 56k modem days.)

EDIT: OTOH, my /boot partition is on a different filesystem than /, so maybe I can fix it if it's a simple case of changing something in the initrd init script.

Last edited by Richard Cranium; 09-15-2023 at 11:13 PM. Reason: background mental processing
 
Old 09-15-2023, 11:10 PM   #2
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,065

Rep: Reputation: Disabled
1. When the GRUB boot menu appears, highlight the relevant boot entry.
2. Press e to edit this boot entry.
3. Modify the line beginning with "linux":
- replace ro by rw
- append to the line a space then: init=/bin/bash
- press Ctrl+X of F10 to boot
4. After booting you be dropped to a bash shell as root, without needing to log in first. From there you can fix your /etc/fstab, then reboot.
 
2 members found this post helpful.
Old 09-15-2023, 11:12 PM   #3
LuckyCyborg
Senior Member
 
Registered: Mar 2010
Posts: 3,550

Rep: Reputation: 3404Reputation: 3404Reputation: 3404Reputation: 3404Reputation: 3404Reputation: 3404Reputation: 3404Reputation: 3404Reputation: 3404Reputation: 3404Reputation: 3404
Quote:
Originally Posted by Richard Cranium View Post
Needless to say, I did something very stupid with my root filesystem's /etc/fstab entry; the end result is that filesystem is now read-only on full boot and any attempts to modify that state require writing something into the root filesystem.

OK, no problem; I should be able to modify (I'm using grub.) the command line passed on as boot by adding rescue. That should give me a command-line to mount directories and fix stuff as part of the initrd portion of the boot.

The problem is that I don't really get an interactive shell. I get the message...

Code:
/bin/sh: can't access tty; job control turned off
...followed by a
Code:
/ #
prompt that accepts no input from the device that I used to interactively modify the grub boot entry to add rescue to the kernel command line.

I fully realize that if there is an underlying problem here that would require some initrd changes to get this to work for later initrd images that it won't help with the problem that I have at the moment. (Yes, I know that I can get a live slack image and use that to fix my problem but where I live now uses ViaSat and going over your data limit puts you back into the 56k modem days.)
Well, the "rescue" mode of Slackware's initrd is not what you (and also me) expects...

In fact, on this "rescue" mode almost entire init script is bypassed and you will be put in a console from where you should execute manually every command done by that init script from initrd, including loading the modules by hand.

What probably you want is initrd to stop processing just before switching root to real system, then to do your things.

BUT, it's rather simple to end this way, by giving in kernel command like as root an imaginary root device, i.e. "root=/dev/sdg1" so initrd will fail to mount it, sending you in the built-in shell. I for one, this thing I do when I want to be sent in shell at the end of initrd's init script.

Last edited by LuckyCyborg; 09-15-2023 at 11:18 PM.
 
1 members found this post helpful.
Old 09-16-2023, 12:27 AM   #4
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Original Poster
Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
I thank both (in chronological order) Mr. Spaier and Mr. (I assume) LuckyCyborg for your input. I tried both methods and neither of them worked.

Those tests did, however, trigger a couple of normally unused brain cells. The machine that I effed up doesn't really need keyboard input during boot. I have a laptop nearby that needs me to type in a LUKS passphrase as part of the boot process.

Low and behold, the effed up machine's /boot/initrd-tree/load_kernel_modules file contains...
Code:
# This is a script used to load the kernel modules.
# To use it, chmod it 755, and then add the insmod
# lines needed to load your modules, like this:

modprobe -v jfs
modprobe -v dm-bufio
modprobe -v dm-snapshot
...while the laptop that knows I'll need to type in data has this content for the same file:

Code:
# This is a script used to load the kernel modules.
# To use it, chmod it 755, and then add the insmod
# lines needed to load your modules, like this:

modprobe -v xhci-hcd
modprobe -v xhci-pci-renesas
modprobe -v xhci-pci
modprobe -v ehci-hcd
modprobe -v ohci-hcd
modprobe -v ohci-pci
modprobe -v ehci-pci
modprobe -v uhci-hcd
modprobe -v hid
modprobe -v usbhid
modprobe -v i2c-core
modprobe -v i2c-hid
modprobe -v hid-generic
modprobe -v video
modprobe -v wmi
modprobe -v rfkill
modprobe -v sparse-keymap
modprobe -v platform_profile
modprobe -v battery
modprobe -v asus-wmi
modprobe -v hid-asus
modprobe -v hid-cherry
modprobe -v hid-logitech
modprobe -v hid-logitech-dj
modprobe -v hid-logitech-hidpp
modprobe -v hid-lenovo
modprobe -v hid-microsoft
modprobe -v hid-multitouch
modprobe -v jbd2
modprobe -v mbcache
modprobe -v ext4
modprobe -v af_alg
modprobe -v algif_skcipher
modprobe -v dm-bufio
modprobe -v dm-snapshot
...with the important (in this case) information is that the screwed up machine doesn't have any hid* modules (and their dependencies) loaded. I can't type anything in because the kernel modules that would let me do that aren't loaded.
 
Old 09-16-2023, 05:01 AM   #5
henca
Member
 
Registered: Aug 2007
Location: Linköping, Sweden
Distribution: Slackware
Posts: 992

Rep: Reputation: 674Reputation: 674Reputation: 674Reputation: 674Reputation: 674Reputation: 674
Quote:
Originally Posted by Richard Cranium View Post
screwed up machine doesn't have any hid* modules (and their dependencies) loaded. I can't type anything in because the kernel modules that would let me do that aren't loaded.
Unless you have some boot entry in your boot loader allowing you to load a functional initrd or a huge kernel you will have to resort to boot some other kind of rescue media.

The Slackware installation media might be useful, the boot menu tells you how to boot its huge kernel together with your existing root partition. However, once the slackware installation huge kernel is booted it will expect to find its modules on your root partition. If you have applied the security kernel updated packages you might only have the newer kernel modules there and be back at a system with no HID modules for your kernel. If so, you migth be better off booting the Slackware installation media like normal, but instead of starting an installation mount partitions and chroot to then start to fix things.

Other good choices for situations like this might be a live CD/DVD like knoppix or SystemRescueCD.

regards Henrik
 
Old 09-16-2023, 06:34 AM   #6
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Original Poster
Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
The machine with the problem (I'll refer to it as testbed from now on) was able to more-or-less boot up, at least well enough to connect to the local network. I have other Slackware machines nearby that I could (and did) use to compare environments. The only things complicating matters were:
  1. The root filesystem is jfs (don't judge me)
  2. The root filesystem is based off a logical volume.
  3. The logical volume the root filesystem uses has RAID1 physical volumes
  4. The initrd used didn't have any hid modules loaded, so you couldn't do anything interactive during early boot

The saving grace in this issue was that testbed's /boot directory was on a different filesystem that was rw; that allowed me to update the initrd. If /boot was on the same filesystem as /, I would have absolutely needed to boot into a live system to fix the problem.

Since testbed could allow local access via ssh, I could use one fully operational system to check things while modifying testbed. That wasn't necessary, but it made things easier.

Within /usr/share/mkinitrd/mkinitrd_command_generator.sh, there are a couple of functions that are quite useful:

Code:
# Search for USB keyboards:
function add_usb_keyboard() {
  local USBMOD
  if cat /proc/bus/input/devices | sed -e 's/^$/\$/g' | \
     tr "\n$" " \n" | grep -q " Phys=.*usb.* .*Handlers=.*kbd.*B:"; then
     USBMOD="xhci-pci:ohci-pci:ehci-pci:xhci-hcd:uhci-hcd:ehci-hcd:hid:usbhid:i2c-hid:hid_generic:hid-asus:hid-cherry:hid-logitech:hid-logitech-dj:hid-logitech-hidpp:hid-lenovo:hid-microsoft:hid_multitouch"
     [ -n "$MLIST" ] && MLIST="$MLIST:$USBMOD" \
                     || MLIST="$USBMOD"
  fi
  echo $MLIST
}

# Determine what USB Host Controller is in use
function add_usb_hcd() {
  local USBMOD
  for i in $(ls -Ld /sys/module/*_hcd/drivers/* 2> /dev/null); do 
    if ls -L $i | grep -q "[0-9a-f]*:" ; then
      USBMOD=$( echo $i | cut -f4 -d/ | tr "_" "-")
      [ -n "$MLIST" ] && MLIST="$MLIST:$USBMOD" \
                      || MLIST="$USBMOD"
    fi
  done
  echo $MLIST
}
I used the USBMOD value of the first function to get the list of usb keyboard modules and then simply ran
Code:
ls -Ld /sys/module/*_hcd/drivers/*
to see which host controller I needed. I ended up with
Code:
root@testbed:~# $( /usr/share/mkinitrd/mkinitrd_command_generator.sh -k 5.15.117 -a "-F -o /boot/initrd-5.15.117.gz" -m "xhci-pci:ohci-pci:ehci-pci:xhci-hcd:uhci-hcd:ehci-hcd:hid:usbhid:i2c-hid:hid_generic:hid-asus:hid-cherry:hid-logitech:hid-logitech-dj:hid-logitech-hidpp:hid-lenovo:hid-microsoft:hid_multitouch:uhci_hcd" -r )
So, rescue mode on boot gives you a minimal environment when you get the shell prompt, which makes sense. A generic rescue mode should bring the system up enough so you can interact with it so you can find out exactly what failed and interactively fix it.

In this case, I know what's wrong and I'd like to not have to remember how to start my raid devices and then bring up my logical volumes to the state where I can mount them. @LuckyCyborg's suggestion of providing a BS root device worked quite well in this case.

When I rebooted testbed with the new initrd, I interactively modified the grub entry to give it a root device of /dev/sdg55 (which doesn't exist on that machine, or anything else that I have). The initrd init script dropped me into a shell with an environment that easily allowed me to mount the root logical volume rw and fix the /etc/fstab entry that was causing the issue. On the subsequent reboot, the testbed system came up with a rw / filesystem.

Many thanks to all of you who commented on this thread. I believe that it would be nice if the default initrd generated by the /usr/share/mkinitrd/mkinitrd_command_generator.sh script loaded keyboard modules or provided a flag that would do that for you.

Last edited by Richard Cranium; 09-16-2023 at 06:36 AM. Reason: spelling errors that you never see until after you post
 
Old 09-16-2023, 11:13 AM   #7
JayByrd
Member
 
Registered: Aug 2021
Location: Seattle, WA
Distribution: Slackware
Posts: 302

Rep: Reputation: 310Reputation: 310Reputation: 310Reputation: 310
Quote:
Originally Posted by Richard Cranium View Post
... I believe that it would be nice if the default initrd generated by the /usr/share/mkinitrd/mkinitrd_command_generator.sh script loaded keyboard modules or provided a flag that would do that for you.
Agreed. However, I find it a little more than ridiculous that one should need so many friggin' kernel modules just for the keyboard. Like you, only after I needed a "rescue" boot (on my wife's desktop) did I realize it. One more reason all of my boxes have PS/2 mouse and keyboard.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Rescue mode and grub rescue beyond my understanding A Novice Linux Mint 9 06-15-2019 11:10 AM
error: unknown filesystem. entering rescue mode. ..grub rescue> Celsiusrising Linux - Newbie 7 06-29-2018 11:51 AM
How to Rescue a System with Automation Script in Rescue Mode Neron.L Linux - Server 1 12-13-2012 12:12 PM
initrd and rescue mode Centos quinox10 Linux - General 2 03-11-2009 03:22 AM
Linux Rescue script question, in rescue mode vijay_aras Linux - General 1 01-09-2008 05:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration