I would like to build my own initramfs.
However, I can't type anything into the shell (enter nothing).
Even if I bring the boot process up to the getty (but systemd usually aborts in the middle)
viewtopic-t-1172303.html
I also try to get the shell to run in initramfs.
Here is the code mines initrm fs:
Code: Select all
#!/bin/busybox sh
#Importent note: ./dev contains: null nvme0n1p5 tty
rescue_shell() {
echo "resce function"
exec /bin/busybox sh || {
echo "Failed to start interactive shell"
/bin/busybox sh || {
echo "Failed to start interactive she2"
sh # Fallback to non-interactive
}
}
}
echo "Check mount points: df -h"
df -h
echo "mount /proc /sys: mount -t proc none /proc; mount -t sysfs none /sys"
mount -t proc none /proc
mount -t sysfs none /sys
#mount -t devtmpfs none /dev || rescue_shell
echo "Check mount points: df -h"
df -h
echo "second Checking and ensuring /dev/tty is accessible..."
# Check if /dev/tty is now accessible
if [ -c /dev/tty ]; then
echo "/dev/tty is available."
else
echo "Failed to create /dev/tty. Exiting rescue mode."
exit 1
fi
# Solution 2: Ensure the root filesystem is correctly mounted
echo "Mounting the root filesystem..."
# Mount the root filesystem (adjust device path as needed)
if ! mount -o ro /dev/nvme0n1p5 /mnt/root; then
echo "Failed to mount root filesystem. Exiting."
exit 1
else
echo "Root filesystem mounted successfully."
fi
# After mounting, check the filesystem status
echo "Root filesystem status: df -h"
df -h
# Debug: List mounted filesystems
echo "Mounted filesystems: mount"
mount || echo "somthing whent wrong during mount command"
# Ensure the terminal is interactive
echo "Ensure the terminal is interactive"
#if [ ! -t 1 ]; then
# echo "No controlling terminal found. Exiting."
# exit 1
#fi
# Explicitly open the terminal (tty) and exec a new shell
echo "second step: exec </dev/tty1 >/dev/tty1 2>&1"
exec </dev/tty >/dev/tty 2>&1 || rescue_shell
echo "Current terminal (tty): tty"
tty || echo "tty went wrong"
#exec setsid sh
#ls -l /dev/tty*
echo "recuse_shell"
rescue_shell || echo "Something wnt wrong. drping not to shell funktion"
echo "NOT Failed to mount root filesystem."
umount /proc
umount /sys
#umount /dev
exec switch_root /newroot /sbin/init
Code: Select all
Check mount point:df -h
Filesystem
df: /etc/mtab: No such file or directory
mount /proc /sys: mount -t proc none /proc; mount -t sysfs none /sys
Check mount points: df -h
Filsystem
second Checking and ensuring /dev/tty is accessible...
/dev/tty is available.
Mounting the root filesystem...
Root filsystem mount seccessfully.
Root filesystem status: df -h
Filsystem ...
/dev/ nvme0n1p5 ...
Mounted filesystems: mount
none on /proc (0)
none on /sys type sysfs (0)
/dev/nvme0n5 on /mnt/root type ext4 (ro)
_
however when i get to the shell i can't type as i said



