Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Custom initramfs
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2, 3  Next  
Reply to topic    Gentoo Forums Forum Index Unsupported Software
View previous topic :: View next topic  
Author Message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54397
Location: 56N 3W

PostPosted: Fri Apr 02, 2021 9:47 am    Post subject: Reply with quote

kucklehead,

I don't understand how
Code:
exec switch_root /newroot /sbin/init
can work.

The /newroot is wherever you mounted your gentoo-root. The function uuidlabel_root() says
Code:
            if [ $type == "LABEL" ] || [ $type == "UUID" ] ; then
                uuid=$(echo $cmd | cut -d= -f3)
                mount -o ro $(findfs "$type"="$uuid") /mnt/root
            else
                mount -o ro $(echo $cmd | cut -d= -f2) /mnt/root
so its mounted on /mnt/root.

As a result,
Code:
# switch to the real root and execute init
exec switch_root -c /dev/console /newroot /sbin/init
fails and you fall off the end of the init script.
The kernel runs out of instructions, something that mush never happen, so it shows you
Code:
end of kernel panic -- not syncing Attempted to kill the init! exitcode=0x00000100]


If you do the break, just before the cleanup, where is gentoo-root mounted.
/newroot or /mnt/root or not at all?

As long as the names are consistent throughout the script, the names don't matter.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
kucklehead
Tux's lil' helper
Tux's lil' helper


Joined: 13 Oct 2020
Posts: 108

PostPosted: Fri Apr 02, 2021 10:23 pm    Post subject: Reply with quote

Why does this pop up? it doesn't anymore after I got the session loader from here: https://www.busybox.net/FAQ.html#job_control
Code:

Free initramfs and switched to another rootfs:
chroot to NEW_ROOT, delete all in /, move to NEW_ROOT /, execute NEW_INIT PID must be 1. NEW_ROOT must be on mountpoint

usage: switch_root [-c CONSOLE_DEV] NEW_ROOT NEW_ROOT NEW_INIT [ARGS]


Is it looking for newroot? and does it want a new_init?

I changed it back to /mnt/root and made sure that everything is consistent with /mnt/root, and it still gives me the kernel panic error.
Here are some errors that seemed suspicious
Code:

CPU: 2 PID: 1 Comm: busybox Not tainted <my kernel> +1
/init: line 6: can't open /dev/tty1 no such file
Memory limit: None
mmc1: queing unknown CIS tuple 0x800 (2 bytes)
mmc2835 fe300000.mmcnr: could not get clk, deferring probe


Here is my init:
Code:

#!/bin/busybox sh



# Create the session loader
exec setsid sh -c exec sh </dev/tty1 >/dev/tty1 2>&1

rescue_shell() {
    echo "$@"
    echo "Something went wrong. Dropping you to a shell."
    /bin/busybox --install -s
    exec /bin/sh
}


# allow the use of UUIDs or filesystem lables
uuidlabel_root() {
    for cmd in $(cat /proc/cmdline) ; do
        case $cmd in
        root=*)
            type=$(echo $cmd | cut -d= -f2)
            echo "Mounting rootfs"
            if [ $type == "LABEL" ] || [ $type == "UUID" ] ; then
                uuid=$(echo $cmd | cut -d= -f3)
                mount -o ro $(findfs "$type"="$uuid") /mnt/root
            else
                mount -o ro $(echo $cmd | cut -d= -f2) /mnt/root
            fi
            ;;
        esac
    done
}

check_filesystem() {
    # most of code coming from /etc/init.d/fsck

    local fsck_opts= check_extra= RC_UNAME=$(uname -s)

    # FIXME : get_bootparam forcefsck
    if [ -e /forcefsck ]; then
        fsck_opts="$fsck_opts -f"
        check_extra="(check forced)"
    fi

    echo "Checking local filesystem $check_extra : $1"

    if [ "$RC_UNAME" = Linux ]; then
        fsck_opts="$fsck_opts -C0 -T"
    fi

    trap : INT QUIT
    # using our own fsck, not the builtin one from busybox
    /sbin/fsck -p $fsck_opts $1

    ret_val=$?
    case $ret_val in
        0)      return 0;;
        1)      echo "Filesystem repaired"; return 0;;
        2|3)    if [ "$RC_UNAME" = Linux ]; then
                        echo "Filesystem repaired, but reboot needed"
                        reboot -f
                else
                        rescue_shell "Filesystem still have errors; manual fsck required"
                fi;;
        4)      if [ "$RC_UNAME" = Linux ]; then
                        rescue_shell "Fileystem errors left uncorrected, aborting"
                else
                        echo "Filesystem repaired, but reboot needed"
                        reboot
                fi;;
        8)      echo "Operational error"; return 0;;
        16)     echo "Use or Syntax Error"; return 16;;
        32)     echo "fsck interrupted";;
        127)    echo "Shared Library Error"; sleep 20; return 0;;
        *)      echo $ret_val; echo "Some random fsck error - continuing anyway"; sleep 20; return 0;;
    esac

# rescue_shell can't find tty so its broken
    rescue_shell
}

# start for real here
mount -t devtmpfs none /dev
mount -t proc none /proc
mount -t sysfs none /sys


# lvm runs as whatever its called as
ln -s /sbin/lvm.static /sbin/vgchange

lvm vgscan --mknodes # creates /dev/mapper/control
lvm lvchange -a ly gentoo/root
lvm vgscan --mknodes # creates /dev/mapper/VG-root and /dev/VG/root
# Change VG into the Volume Group which mine is gentoo. Physical Volume PV is created first then the VG


# start the vg volume group - /home and everything for portage - need not die here
/sbin/vgchange -ay gentoo || rescue_shell

# get here with raid sets assembled and logical volumes available
# mounting rootfs on /mnt/root
uuidlabel_root || rescue_shell "Error with uuidlabel_root"



# ... we want to find in /etc/fstab ...
ln -s /mnt/root/etc/fstab /etc/fstab



echo "All done. Switching to real root."

break_requested() {
    local want_break
    for o in $(cat /proc/cmdline) ; do
        case "$o" in
            rd.break|rdbreak)                                        want_break="yes" ;;
            init=/bin/sh|init=/bin/bb|init=/bin/bash|init=/bin/dash) want_break="yes" ;;
        esac
    done
    echo "${want_break}"
}

if [[ -n "$(break_requested)" ]] ; then
    rescue_shell
fi




# clean up. The init process will remount proc sys and dev later
mount --move /proc /mnt/root/proc
mount --move /sys /mmt/root/sys
mount --move /dev /mnt/root/dev

# switch to the real root and execute init
exec switch_root -c /dev/console /mnt/root /sbin/init


And again I still get the kernel panic, and I don't know why. And I don't know if gentoo-root is mounted or not. I can't get into my shell anymore, so I have to turn off the power. I think it is not mounted as now it doesn't show
Code:

4 logcial volumes detected and now active
mount: failed to mount /dev/mmcblk0p2 on /mnt/root
Back to top
View user's profile Send private message
kucklehead
Tux's lil' helper
Tux's lil' helper


Joined: 13 Oct 2020
Posts: 108

PostPosted: Sat Apr 03, 2021 7:47 am    Post subject: Reply with quote

I fixed the /init: /dev/tty1 no such file by creating the tty node inside the init script.
I have been looking at this layout here:
Code:

#!/bin/sh

#Mount things needed by this script
mount -t proc proc /proc
mount -t sysfs sysfs /sys

#Disable kernel messages from popping onto the screen
echo 0 > /proc/sys/kernel/printk

#Clear the screen
clear

#Create all the symlinks to /bin/busybox
busybox --install -s

#Create device nodes
mknod /dev/null c 1 3
mknod /dev/tty c 5 0
mdev -s

#Function for parsing command line options with "=" in them
# get_opt("init=/sbin/init") will return "/sbin/init"
get_opt() {
   echo "$@" | cut -d "=" -f 2
}

#Defaults
init="/sbin/init"
root="/dev/hda1"

#Process command line options
for i in $(cat /proc/cmdline); do
   case $i in
      root\=*)
         root=$(get_opt $i)
         ;;
      init\=*)
         init=$(get_opt $i)
         ;;
   esac
done

#Mount the root device
mount "${root}" /newroot

#Check if $init exists and is executable
if [[ -x "/newroot/${init}" ]] ; then
   #Unmount all other mounts so that the ram used by
   #the initramfs can be cleared after switch_root
   umount /sys /proc
       

        #Switch to the new root and execute init
   exec switch_root /newroot "${init}"
fi

#This will only be run if the exec above failed
echo "Failed to switch_root, dropping to a shell"
exec sh


I am not getting my shell because tty is found and works. I tried merging that script with mine and it gave me errors about /sbin/init not found and what not.[/code]
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54397
Location: 56N 3W

PostPosted: Sat Apr 03, 2021 8:20 am    Post subject: Reply with quote

kucklehead,

Code:
root="/dev/hda1"
Thats the old IDE hard drive interface.
Its been depreciated since about kernel 2.6.30. Linux userland no longer supports it but its still in the kernel.

That script is very minimal. It does no filesystem checking after an unclean shutdown, so its not robust.

As you are using DEVTMPFS from the kernel, your /dev nodes should be generated by the kernel as it discovers the hardware.
Needing to making /dev entries suggests that there is a driver missing from your kernel.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
kucklehead
Tux's lil' helper
Tux's lil' helper


Joined: 13 Oct 2020
Posts: 108

PostPosted: Sat Apr 03, 2021 9:00 am    Post subject: Reply with quote

Yes I am using DEVTMPFS as I have it built-in. And the mknod inside my init script seems to work find and avoids the /init: /dev/tty1 no such file. Also, my shell just vanished and I can't get into it because of the kernel panic so I can't look around anymore...
And if there is a way to show you my config file, I would happy to do so.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54397
Location: 56N 3W

PostPosted: Sat Apr 03, 2021 9:22 am    Post subject: Reply with quote

kucklehead,

Use wgetpaste to files and command outputs onto the web, then post a link.
The web link is only good for a few days but helpers here know that and will quote the useful bits so that others may use it later.

dev/ entres are links to the kernel drivers.
If you create one one with no kernel driver behind it, it acts a lot like /dev/null.

The error /dev/... will go away but it won't work.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 21789

PostPosted: Sat Apr 03, 2021 4:23 pm    Post subject: Reply with quote

An earlier iteration of the init script explicitly mounted devtmpfs. The latest one appears not to. As I read the kernel source, when an initramfs is used, devtmpfs is not automatically mounted by the kernel; you must mount it if you need it.

The symbol to enable automatic mounting:
drivers/base/Kconfig:
config DEVTMPFS_MOUNT
   bool "Automount devtmpfs at /dev, after the kernel mounted the rootfs"
The place it is converted into a C variable:
drivers/base/devtmpfs.c:
static int __initdata mount_dev = IS_ENABLED(CONFIG_DEVTMPFS_MOUNT);
Where it is read:
drivers/base/devtmpfs.c:
/*
 * If configured, or requested by the commandline, devtmpfs will be
 * auto-mounted after the kernel mounted the root filesystem.
 */
int __init devtmpfs_mount(void)
{
   int err;

   if (!mount_dev)
      return 0;
Where devtmpfs_mount is called:
init/do_mounts.c:
void __init prepare_namespace(void)
{
...
   devtmpfs_mount();
About when prepare_namespace is used:
Documentation/driver-api/early-userspace/early_userspace_support.rst:
The kernel has currently 3 ways to mount the root filesystem:

c) using initramfs.  The call to prepare_namespace() must be skipped.
Apparent confirmation that if an initramfs is used, then prepare_namespace is not used. If prepare_namespace is not used, then devtmpfs_mount is not used. If devtmpfs_mount is not used, then devtmpfs is not automatically mounted.
init/main.c:
static noinline void __init kernel_init_freeable(void)
{
...
   /*
    * check if there is an early userspace init.  If yes, let it do all
    * the work
    */
   if (init_eaccess(ramdisk_execute_command) != 0) {
      ramdisk_execute_command = NULL;
      prepare_namespace();
   }


In my opinion, the right approach is not to make those nodes, but instead to mount devtmpfs as soon as possible, then rely on its tty node for the redirection.
Back to top
View user's profile Send private message
kucklehead
Tux's lil' helper
Tux's lil' helper


Joined: 13 Oct 2020
Posts: 108

PostPosted: Sat Apr 03, 2021 11:31 pm    Post subject: Reply with quote

Neddy here is my kernel configuration file: https://pastebin.com/qaXnC97K


And hu, are you wanting me to create /dev/devtmpfs.c as a static library? It is possible? As I am reading this guide right here: http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html
Or do you want me to add something into the init? I don't know that much about creating my own init and I am struggling to keep up with it; I am chrooting this system, if you need to know that is. If I comment out the mknod tty, I will get this:
Code:

Free initramfs and switched to another rootfs:
chroot to NEW_ROOT, delete all in /, move to NEW_ROOT /, execute NEW_INIT PID must be 1. NEW_ROOT must be on mountpoint

usage: switch_root [-c CONSOLE_DEV] NEW_ROOT NEW_ROOT NEW_INIT [ARGS]


followed by kernel panic

I believe that devtmpfs is mount as I have the command mount -t devtmpfs in my init, but right now I am viewing and processing that documentation. My init layout or anything in it's directories doesn't contain a main.c at all. And it is running off a script.
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 21789

PostPosted: Sun Apr 04, 2021 12:24 am    Post subject: Reply with quote

I was showing my work, for the benefit of anyone who wanted to better understand why I made the claims that I did.

I was reacting to your then-latest post, where it appeared you had completely removed the mounting of devtmpfs.
Back to top
View user's profile Send private message
kucklehead
Tux's lil' helper
Tux's lil' helper


Joined: 13 Oct 2020
Posts: 108

PostPosted: Sun Apr 04, 2021 12:37 am    Post subject: Reply with quote

Yeah, I didn't mean to remove it. I added it back in by the way. I did some digging around, and I believe exec /bin/busybox switched_root might be needed?
As this error pops up:
Code:

CPU 2: PID: 1 Comm: busybox Not tainted 5.12.0-rc3-v8 +1

The reason why i say that it might exec /bin/busybox switch_root might need to be on the same line is because of this: https://stackoverflow.com/questions/30813572/switch-root-busybox-init-problems
And you said I shouldn't create the node there and should redirect it? How can I do that exactly?

And do I change the top of the script from this #!/bin/busybox sh to #!/bin/sh, and my shell isn't showing up. Here is my current init:
Code:

#!/bin/busybox sh

rescue_shell() {
    echo "$@"
    echo "Something went wrong. Dropping you to a shell."
    /bin/busybox --install -s
    exec setid ctty /bin/sh
}

# allow the use of UUIDs or filesystem lables
uuidlabel_root() {
    for cmd in $(cat /proc/cmdline) ; do
        case $cmd in
        root=*)
            type=$(echo $cmd | cut -d= -f2)
            echo "Mounting rootfs"
            if [ $type == "LABEL" ] || [ $type == "UUID" ] ; then
                uuid=$(echo $cmd | cut -d= -f3)
                mount -o ro $(findfs "$type"="$uuid") /mnt/root
            else
                mount -o ro $(echo $cmd | cut -d= -f2) /mnt/root
            fi
            ;;
        esac
    done
}

check_filesystem() {
    # most of code coming from /etc/init.d/fsck

    local fsck_opts= check_extra= RC_UNAME=$(uname -s)

    # FIXME : get_bootparam forcefsck
    if [ -e /forcefsck ]; then
        fsck_opts="$fsck_opts -f"
        check_extra="(check forced)"
    fi

    echo "Checking local filesystem $check_extra : $1"

    if [ "$RC_UNAME" = Linux ]; then
        fsck_opts="$fsck_opts -C0 -T"
    fi

    trap : INT QUIT
    # using our own fsck, not the builtin one from busybox
    /sbin/fsck -p $fsck_opts $1

    ret_val=$?
    case $ret_val in
        0)      return 0;;
        1)      echo "Filesystem repaired"; return 0;;
        2|3)    if [ "$RC_UNAME" = Linux ]; then
                        echo "Filesystem repaired, but reboot needed"
                        reboot -f
                else
                        rescue_shell "Filesystem still have errors; manual fsck required"
                fi;;
        4)      if [ "$RC_UNAME" = Linux ]; then
                        rescue_shell "Fileystem errors left uncorrected, aborting"
                else
                        echo "Filesystem repaired, but reboot needed"
                        reboot
                fi;;
        8)      echo "Operational error"; return 0;;
        16)     echo "Use or Syntax Error"; return 16;;
        32)     echo "fsck interrupted";;
        127)    echo "Shared Library Error"; sleep 20; return 0;;
        *)      echo $ret_val; echo "Some random fsck error - continuing anyway"; sleep 20; return 0;;
    esac

# rescue_shell can't find tty so its broken
    rescue_shell
}

# start for real here
mount -t devtmpfs none /dev || rescue_shell "mount /proc failed"
mount -t proc none /proc    || rescue_shell "mount /sys failed"
mount -t sysfs none /sys    || rescure_shell "mount /dev failed"

#Disable kernel messages from popping onto the screen
echo 0 > /proc/sys/kernel/printk

#Clear the screen
clear

# lvm runs as whatever its called as
ln -s /sbin/lvm.static /sbin/vgchange

lvm vgscan --mknodes # creates /dev/mapper/control
lvm lvchange -a ly gentoo/root
lvm vgscan --mknodes # creates /dev/mapper/VG-root and /dev/VG/root
# Change VG into the Volume Group which mine is gentoo. Physical Volume PV is created first then the VG

# start the vg volume group - /home and everything for portage - need not die here
/sbin/vgchange -ay gentoo || rescue_shell

# get here with raid sets assembled and logical volumes available
# mounting rootfs on /mnt/root
uuidlabel_root || rescue_shell "Error with uuidlabel_root"

# ... we want to find in /etc/fstab ...
ln -s /mnt/root/etc/fstab /etc/fstab

echo "All done. Switching to real root."

break_requested() {
    local want_break
    for o in $(cat /proc/cmdline) ; do
        case "$o" in
            rd.break|rdbreak)                                        want_break="yes" ;;
            init=/bin/sh|init=/bin/bb|init=/bin/bash|init=/bin/dash) want_break="yes" ;;
        esac
    done
    echo "${want_break}"
}

if [[ -n "$(break_requested)" ]] ; then
    rescue_shell
fi


# clean up. The init process will remount proc sys and dev later
umount /proc /sys /dev

# switch to the real root and execute init
exec switch_root /mnt/root /sbin/init


Once again, I can't get into my shell as it will either hang on kernel panic or it hang on this:
Code:

 usage: switch_root [-c CONSOLE_DEV] NEW_ROOT NEW_ROOT NEW_INIT [ARGS]

I want my shell back and I don't know how to get it back...
Here is my initramfs.list:
Code:

# This is my initramfs layout. Everything here that has file needs to be archived in the /usr/src/initramfs
dir /proc       755 0 0
dir /usr        755 0 0
dir /bin        755 0 0
dir /sys        755 0 0
dir /var        755 0 0
dir /lib        755 0 0
dir /lib64      755 0 0
dir /sbin       755 0 0
dir /mnt        755 0 0
dir /mnt/root   755 0 0
dir /etc        755 0 0
dir /root       700 0 0
dir /dev        755 0 0
dir /dev/mapper 755 0 0


# Note: cp --archive is used when you're coping over a ebuild which has the static and or static-libs enabled.
# Archiving dynamic library is not needed and using lddtree --copy-to-tree /usr/src/initramfs /sbin/<binary name>


# we don't have a static /dev and mounting devtmpfs is needed.
# I will mount the devtmpfs in the init so this will work
# e.g. /dev/console below
nod /dev/console        0600 0 0 c 5 1
nod /dev/null           0666 0 0 c 1 5

# dev/sda and partitions
nod /dev/mmcblk0            0660 0 0 b 179 0
nod /dev/mmcblk0p1          0660 0 0 b 179 1
nod /dev/mmcblk0p2          0660 0 0 b 179 2


# busybox
file /bin/busybox /bin/busybox  755 0 0


# all the lvm nodes I need and dm stands for device-mapper
nod /dev/dm-0            0660 0 0 b 253 0
nod /dev/dm-1            0660 0 0 b 253 1
nod /dev/dm-2            0660 0 0 b 254 2
nod /dev/dm-3            0660 0 0 b 254 3
# ...

slink /dev/stderr                       /proc/self/fd/2                 777 0 0
slink /dev/stdin                        /proc/self/fd/0                 777 0 0
slink /dev/std/out                      /proc/self/fd/1                 777 0 0


# libraries required by /sbin/fsck.ext4 and /sbin/fsck
# This section where it has /lib64 is the libraries. You can keep adding more libraries into here.
# Do not alter file /init /usr/src/initramfs/init 0755 0 0
# Libaries I added are consoletype,dhcpcd,fdisk,insmod,modprobe,switch_root,reboot,shutdown,halt,depmod,swapon,cfdisk

slink   /lib                            /lib64                          777 0 0
file   /lib64/ld-linux-aarch64.so.1    /lib64/ld-linux-aarch64.so.1    755 0 0
file   /lib64/libblkid.so.1            /lib64/libblkid.so.1            755 0 0
file    /lib64/libmount.so.1            /lib64/libmount.so.1            755 0 0
file    /lib64/libc.so.6                /lib64/libc.so.6                755 0 0
file    /lib64/libext2fs.so.2           /lib64/libext2fs.so.2           755 0 0
file   /lib64/libcom_err.so.2          /lib64/libcom_err.so.2          755 0 0
file    /lib64/libdl.so.2               /lib64/libdl.so.2               755 0 0
file    /lib64/libpthread.so.0          /lib64/libpthread.so.0          755 0 0
file    /lib64/libfdisk.so.1            /lib64/libfdisk.so.1            755 0 0
file    /lib64/libsmartcols.so.1        /lib64/libsmartcols.so.1        755 0 0
file    /lib64/libtinfow.so.6           /lib64/libtinfow.so.6           755 0 0
file    /lib64/libreadline.so.8         /lib64/libreadline.so.8         755 0 0
file    /lib64/liblzma.so.5             /lib64/liblzma.so.5             755 0 0
file    /lib64/libz.so.1                /lib64/libz.so.1                755 0 0
file    /lib64/libacl.so.1              /lib64/libacl.so.1              755 0 0
file    /lib64/libcap.so.2              /lib64/libcap.so.2              755 0 0
file    /lib64/libcrypt.so.1            /lib64/libcrypt.so.1            755 0 0
file    /usr/lib64/libgcrypt.so.20      /usr/lib64/libgcrypt.so.20      755 0 0
file    /lib64/libkmod.so.2             /lib64/libkmod.so.2             755 0 0
file    /lib64/libpam.so.0              /lib64/libpam.so.0              755 0 0
file    /lib64/librt.so.1               /lib64/librt.so.1               755 0 0
file    /usr/lib64/libseccomp.so.2      /usr/lib64/libseccomp.so.2      755 0 0
file    /usr/lib64/libzstd.so.1         /usr/lib64/libzstd.so.1         755 0 0
file    /lib64/libm.so.6                /lib64/libm.so.6                755 0 0
file    /usr/lib64/libgpg-error.so.0    /usr/lib64/libgpg-error.so.0    755 0 0
file    /lib64/libncursesw.so.6         /lib64/libncursesw.so.6         755 0 0
file    /lib64/libe2p.so.2              /lib64/libe2p.so.2              755 0 0
file    /lib64/libext2fs.so.2           /lib64/libext2fs.so.2           755 0 0
file    /lib64/libdevmapper.so.1.02     /lib64/libdevmapper.so.1.02     755 0 0
file    /lib64/libdevmapper-event.so.1.02 /lib64/libdevmapper-event.so.1.02 755 0 0 
file    /lib64/libaio.so.1                /lib64/libaio.so.1            755 0 0 

# Anything you archive it must be added to the init_list. You do not need to add it into the layout as you're not using it.
# For example, device-mapper known as dm is being used. I don't know anything about lvm, I archived it so it has to be defined
# lvm is located in the /sbin and the libaries I already have called in. If you get an error when booting the initramfs involving lvm libraries, remove it.

file    /sbin/lvm               /sbin/lvm                       755 0 0
file    /sbin/fsck              /sbin/fsck                      755 0 0
file    /sbin/fsck.ext4         /sbin/fsck.ext4                 755 0 0
file    /sbin/lvm.static        /sbin/lvm.static                755 0 0
file    /sbin/dmsetup.static    /sbin/dmsetup.static            755 0 0
file    /sbin/ldconfig          /sbin/ldconfig                  755 0 0

# our init script
#dir /dev 0755 0 0
file    /init                           /usr/src/initramfs/init           755 0 0

Maybe I have to remove some stuff from here? This is my initramfs /sbin:
Code:

consoletype  fsck   halt     lvmetad    mkfs.ext4   rmmod     swapon
depmod        fsck.ext2   insmod     mkfs        modprobe   shutdown  switch_root
dhcpcd        fsck.ext3   ldconfig  mkfs.ext2  poweroff   sulogin
fdisk        fsck.ext4   lvm     mkfs.ext3  reboot   swapoff

All those libraries are dynammically linked into my initramfs.list. Most of the stuff in there busybox already has that, and that I did not know
Back to top
View user's profile Send private message
kucklehead
Tux's lil' helper
Tux's lil' helper


Joined: 13 Oct 2020
Posts: 108

PostPosted: Sun Apr 04, 2021 4:49 am    Post subject: Reply with quote

Good news, I did something that finally got it so I can get into my shell. Bad news is if I run /dev/mapper it says permission denied
and I get this error now:
Code:

stack smashing detected **** terminated Aborted

I am looking through the script and going to see if I can fix that
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54397
Location: 56N 3W

PostPosted: Sun Apr 04, 2021 9:01 am    Post subject: Reply with quote

kucklehead,

When you use an initrd the kernel gets completely out of you way. There is no 'hand holding'.
You can do whatever you like as long as you are consistent about it.

The real root filesystem can be mounted at any empty mount point.
Wherever that is, you must switch/piviot root to that to exit the initrd.

If you want to make your own /dev nodes, that works. If you want to use the kernel provided devtmpfs, you must mount. it.
Do not do both or you will get confused. When you use devtmpfs and you find that you need a /dev node that is missing, its usually because the kernel code that makes that node work is missing.

Code:
stack smashing detected **** terminated Aborted

Something overwrote a return address on the stack, the kernel detected it and killed the offending process.
More exactly, the kernel detected the canary value on the stack, protecting the return address, had changed.
Its a software problem rather than the script.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 21789

PostPosted: Sun Apr 04, 2021 4:26 pm    Post subject: Reply with quote

kucklehead wrote:
I did some digging around, and I believe exec /bin/busybox switched_root might be needed?
Maybe. In at least some cases, exec switch_root args is sufficient; no need for /bin/busybox.
kucklehead wrote:
And you said I shouldn't create the node there and should redirect it? How can I do that exactly?
devtmpfs will provide the node; you only need to exec >/dev/tty1 etc., and then only when you actually need the redirection. For basic early use, no redirection should be needed. Interactive mode will probably be nicer with the redirection though.
kucklehead wrote:
And do I change the top of the script from this #!/bin/busybox sh to #!/bin/sh, and my shell isn't showing up.
This sentence is a bit confusing. It starts like a question and ends as a statement. I use bash to interpret my /init, because I wanted to use bash-isms in text processing. The extra overhead is negligible to me.
kucklehead wrote:
Code:
rescue_shell() {
    echo "$@"
    echo "Something went wrong. Dropping you to a shell."
    /bin/busybox --install -s
    exec setid ctty /bin/sh
I don't see a setid in my environment after a busybox install. Did you mean setsid? Likewise, I don't see a ctty. Did you mean cttyhack? Assuming you also lack the names shown, each of those individually would be fatal if you ever ran this function.
kucklehead wrote:
Code:

            type=$(echo $cmd | cut -d= -f2)
            echo "Mounting rootfs"
For ease of debugging, I would move this echo into the if, then show $type and $uuid, so you can know what was found. You may want to duplicate the echo into the else branch for a similar reason.
kucklehead wrote:
Code:

                mount -o ro $(echo $cmd | cut -d= -f2) /mnt/root
This echo|cut is redundant. You already have its value in $type.
kucklehead wrote:
Code:

# rescue_shell can't find tty so its broken
What is the exact error that rescue_shell shows?
kucklehead wrote:
Code:
mount -t sysfs none /sys    || rescure_shell "mount /dev failed"
I do not see a definition for rescure_shell shell. Additionally, all three of your error messages in this area are wrong. dev blames proc. proc blames sys. sys blames dev.
kucklehead wrote:
Code:
#Disable kernel messages from popping onto the screen
echo 0 > /proc/sys/kernel/printk
Personally, I would not silence the kernel until you have this all working. Some of those messages might be diagnostically useful.
kucklehead wrote:
Code:
#Clear the screen
clear
For the same reason, I would not do this.
kucklehead wrote:
Code:
# lvm runs as whatever its called as
ln -s /sbin/lvm.static /sbin/vgchange
LVM can also be run as whatever argv[1] is:
Code:
# lvm lvs --help | head -n1
  lvs - Display information about logical volumes
# lvm vgs --help | head -n2
  vgs - Display information about volume groups
You even take advantage of this, inconsistently, later on.
kucklehead wrote:
Code:
# get here with raid sets assembled and logical volumes available
I do not see anything else in your post that pertains to RAID. Is this comment stale?
kucklehead wrote:
Code:
# mounting rootfs on /mnt/root
uuidlabel_root || rescue_shell "Error with uuidlabel_root"
I do not see anything in uuidlabel_root to return an error if root= is unset. I think that if the kernel command line lacks root=, then this line will do nothing, successfully.

You mount root without ever using check_filesystem. Was that intended?
kucklehead wrote:
Code:
 usage: switch_root [-c CONSOLE_DEV] NEW_ROOT NEW_ROOT NEW_INIT [ARGS]
Are you sure about this? Duplicate NEW_ROOT looks wrong to me.
Back to top
View user's profile Send private message
kucklehead
Tux's lil' helper
Tux's lil' helper


Joined: 13 Oct 2020
Posts: 108

PostPosted: Sun Apr 04, 2021 8:16 pm    Post subject: Reply with quote

No It wasn't. Again, I don't know how to create a custom initramfs and this is my first time ever creating it. I added that in because of this: https://wiki.gentoo.org/wiki/Custom_Initramfs/Examples I grabbed most of the script from here: https://wiki.gentoo.org/wiki/Old_Fashioned_Gentoo_Install#Making_the_initrd And yeah, you're probably right about NEW_ROOT being wrong, again I don't know what is going on and I am trying my best to absorb this material as best as I can. /dev/mmcblk0p2 keeps trying to mount itself on /mnt/root and I still cannot find why it is doing that.

Whoever made the old fashioned making initrd already made three functions:
Code:

rescue shell()
uuidlabel_root()
check_filesystem()

The rescue shell is at the top of this script, I was considering moving it below the exec switch root, but then again I would have to remove all the rescueshell stuff and it would just be a pain.
Code:

rescue_shell() {
    echo "$@"
    echo "Something went wrong. Dropping you to a shell."
    /bin/busybox --install -s
    exec /bin/sh
}

I don't know if that's what you're implying too?

I added this:
Code:

break_requested()

And only that

Neddy told me to remove this block of code:
Code:

# ... to check filesystems and mount our devices.
for m in $mountpoints ; do

#echo $m

    check_filesystem $m

    echo "Mounting $m"
    # mount the device and ...
    mount $m || rescue_shell "Error while mounting $m"

    # ... move the tree to its final location
    mount --move $m "/mnt/root"$m || rescue_shell "Error while moving $m"
done

As Neddy said it only needs to be executed once.

The rescueshell, uuidlabel_root, and checkfilesystem are just the basics from what I understand. I didn't pay attention to the custom initramfs guide as it is flagged dirty, so I was guessing that the information provided there was not accurate.
I was considering to make a new init script based off of custom initramfs without combining all these guides together: https://wiki.gentoo.org/wiki/Old_Fashioned_Gentoo_Install#Making_the_initrd https://wiki.gentoo.org/wiki/Custom_Initramfs#Dynamic_devices https://wiki.gentoo.org/wiki/Early_Userspace_Mounting

My kernel command line does indeed hold root= UUID= gentoo-root

Why do I need to remove this from my init:
Code:

# lvm runs as whatever its called as
ln -s /sbin/lvm.static /sbin/vgchange


Is it because I already have it in my initramfs.list. I'll comment it out if I might need it later on. I am guessing I should add this into my script:
Code:

lvm lvs --help | head -n1
lvs - Display information about logical volumes
lvm vgs --help | head -n2
vgs - Display information about volume groups


Which is near this:
Code:

lvm vgscan --mknodes # creates /dev/mapper/control
lvm lvchange -a ly gentoo/root
lvm vgscan --mknodes # creates /dev/mapper/VG-root and /dev/VG/root
# Change VG into the Volume Group which mine is gentoo. Physical Volume PV is c>

lvm lvs --help | head -n1
lvs - Display information about logical volumes
lvm vgs --help | head -n2
vgs - Display information about volume groups



And isn't this already in the if branch:
Code:

mount -o ro $(echo $cmd | cut -d= -f2) /mnt/root


The ctty and setsid is from here: https://www.busybox.net/FAQ.html#job_control

This code that I keep looking at is confusing and not something that I am familiar with such as python. I can see that the if elif and else branches are used in this code and same with the return statement. I am getting that software error in which Neddy described is. It might be something to do with my kernel? I did recompile it again and added things that I thought might be useful. I am going to recompile it again, remove the stuff you mentioned add those two lines of code in you suggested, and hopefully it works..


I forgot that when I am compiling it, I need to copy over the Image to my boot. I was considering on using dracut again, but I had issues with it when chrooting I think. I made a post not too long ago in the arm64 section in which Neddy helped me out and so did Govenr I think is his username.

And what about this stuff here:
Code:

consoletype  fsck   halt     lvmetad    mkfs.ext4   rmmod     swapon
depmod        fsck.ext2   insmod     mkfs        modprobe   shutdown  switch_root
dhcpcd        fsck.ext3   ldconfig  mkfs.ext2  poweroff   sulogin
fdisk        fsck.ext4   lvm     mkfs.ext3  reboot   swapoff


I thought that stuff would be useful as at the time I didn't know that busybox already has that stuff with it; Assuming that I am loading into a busybox shell, then those commands should be already In there. Which makes me think that I should remove some of those libraries from my initramfs.list. I need to keep lvm, and I was thinking on commenting out this section:

Code:

trap : INT QUIT
    # using our own fsck, not the builtin one from busybox
    /sbin/fsck -p $fsck_opts $1


Because I'll be using everything from busybox.
And this is the stuff I am referencing too in my initramfs.list:
Code:

slink   /lib                            /lib64                          777 0 0
file   /lib64/ld-linux-aarch64.so.1    /lib64/ld-linux-aarch64.so.1    755 0 0
file   /lib64/libblkid.so.1            /lib64/libblkid.so.1            755 0 0
file    /lib64/libmount.so.1            /lib64/libmount.so.1            755 0 0
file    /lib64/libc.so.6                /lib64/libc.so.6                755 0 0
file    /lib64/libext2fs.so.2           /lib64/libext2fs.so.2           755 0 0
file   /lib64/libcom_err.so.2          /lib64/libcom_err.so.2          755 0 0
file    /lib64/libdl.so.2               /lib64/libdl.so.2               755 0 0
file    /lib64/libpthread.so.0          /lib64/libpthread.so.0          755 0 0
file    /lib64/libfdisk.so.1            /lib64/libfdisk.so.1            755 0 0
file    /lib64/libsmartcols.so.1        /lib64/libsmartcols.so.1        755 0 0
file    /lib64/libtinfow.so.6           /lib64/libtinfow.so.6           755 0 0
file    /lib64/libreadline.so.8         /lib64/libreadline.so.8         755 0 0
file    /lib64/liblzma.so.5             /lib64/liblzma.so.5             755 0 0
file    /lib64/libz.so.1                /lib64/libz.so.1                755 0 0
file    /lib64/libacl.so.1              /lib64/libacl.so.1              755 0 0
file    /lib64/libcap.so.2              /lib64/libcap.so.2              755 0 0
file    /lib64/libcrypt.so.1            /lib64/libcrypt.so.1            755 0 0
file    /usr/lib64/libgcrypt.so.20      /usr/lib64/libgcrypt.so.20      755 0 0
file    /lib64/libkmod.so.2             /lib64/libkmod.so.2             755 0 0
file    /lib64/libpam.so.0              /lib64/libpam.so.0              755 0 0
file    /lib64/librt.so.1               /lib64/librt.so.1               755 0 0
file    /usr/lib64/libseccomp.so.2      /usr/lib64/libseccomp.so.2      755 0 0
file    /usr/lib64/libzstd.so.1         /usr/lib64/libzstd.so.1         755 0 0
file    /lib64/libm.so.6                /lib64/libm.so.6                755 0 0
file    /usr/lib64/libgpg-error.so.0    /usr/lib64/libgpg-error.so.0    755 0 0
file    /lib64/libncursesw.so.6         /lib64/libncursesw.so.6         755 0 0
file    /lib64/libe2p.so.2              /lib64/libe2p.so.2              755 0 0
file    /lib64/libext2fs.so.2           /lib64/libext2fs.so.2           755 0 0
file    /lib64/libdevmapper.so.1.02     /lib64/libdevmapper.so.1.02     755 0 0
file    /lib64/libdevmapper-event.so.1.02 /lib64/libdevmapper-event.so.1.02 755 0 0 
file    /lib64/libaio.so.1                /lib64/libaio.so.1            755 0 0 

I am thinking removing some stuff from here, adding nano into my initramfs.
This section right here is kind of worrying me:
Code:

file    /sbin/lvm               /sbin/lvm                       755 0 0
file    /sbin/fsck              /sbin/fsck                      755 0 0
file    /sbin/fsck.ext4         /sbin/fsck.ext4                 755 0 0
file    /sbin/lvm.static        /sbin/lvm.static                755 0 0
file    /sbin/dmsetup.static    /sbin/dmsetup.static            755 0 0
file    /sbin/ldconfig          /sbin/ldconfig                  755 0 0

And should I change this:
Code:

#dir /dev 0755 0 0
file /init /usr/src/initramfs/init   755 0 0


Back to this:
Code:

dir /dev 0755 0 0
file /init /usr/src/initramfs/init 0755 0 0


Because when I load into the shell I can't execute anything really.


Also, happy Easter to you guys and thank you for helping me out with this. I'll post up the result later on tonight my timezone.
Back to top
View user's profile Send private message
kucklehead
Tux's lil' helper
Tux's lil' helper


Joined: 13 Oct 2020
Posts: 108

PostPosted: Mon Apr 05, 2021 3:24 pm    Post subject: Reply with quote

Got rid of the software issue and I am back to this:
Code:

Free initramfs and switched to another rootfs:
chroot to NEW_ROOT, delete all in /, move to NEW_ROOT /, execute NEW_INIT PID must be 1. NEW_ROOT must be on mountpoint

usage: switch_root [-c CONSOLE_DEV] NEW_ROOT NEW_ROOT NEW_INIT [ARGS]


Along with the kernel panic. And how do I even get the init script to run the checkfilesystem() function? Do I have to call it?
Back to top
View user's profile Send private message
kucklehead
Tux's lil' helper
Tux's lil' helper


Joined: 13 Oct 2020
Posts: 108

PostPosted: Tue Apr 20, 2021 12:38 am    Post subject: Reply with quote

I rebuilt my kernel and have init=/usr/src/initramfs/init in my kernel command line, and now when I boot up it says this:
Code:

cat: (/proc/cmdline) error: no file or directory


Followed by hanging and yes I can't get into busybox shell..

Here is my current init script right now:
Code:

#!/bin/busybox sh

# Load up the session loader
exec >/dev/tty1


rescue_shell() {
    echo "$@"
    echo "Something went wrong. Dropping you to a shell."
    /bin/busybox --install -s
    exec /bin/sh
}

# allow the use of UUIDs or filesystem lables
uuidlabel_root() {
    for cmd in $(cat /proc/cmdline) ; do
        case $cmd in
        root=*)
            type=$(echo $cmd | cut -d= -f2)
            echo "Mounting rootfs"
            if [ $type == "LABEL" ] || [ $type == "UUID" ] ; then
                uuid=$(echo $cmd | cut -d= -f3)
                mount -o ro $(findfs "$type"="$uuid") /mnt/root
            else
                mount -o ro $(echo $cmd | cut -d= -f2) /mnt/root
                mount -o ro $(findfs "$type"="$uuid") /mnt/root
            fi
            ;;
        esac
    done
}

check_filesystem() {
    # most of code coming from /etc/init.d/fsck

    local fsck_opts= check_extra= RC_UNAME=$(uname -s)

    # FIXME : get_bootparam forcefsck
    if [ -e /forcefsck ]; then
        fsck_opts="$fsck_opts -f"
        check_extra="(check forced)"
    fi

    echo "Checking local filesystem $check_extra : $1"

    if [ "$RC_UNAME" = Linux ]; then
        fsck_opts="$fsck_opts -C0 -T"
    fi

    trap : INT QUIT
    # using our own fsck, not the builtin one from busybox
    #/sbin/fsck -p $fsck_opts $1

    ret_val=$?
    case $ret_val in
        0)      return 0;;
        1)      echo "Filesystem repaired"; return 0;;
        2|3)    if [ "$RC_UNAME" = Linux ]; then
                        echo "Filesystem repaired, but reboot needed"
                        reboot -f
                else
                        rescue_shell "Filesystem still have errors; manual fsck required"
                fi;;
        4)      if [ "$RC_UNAME" = Linux ]; then
                        rescue_shell "Fileystem errors left uncorrected, aborting"
                else
                        echo "Filesystem repaired, but reboot needed"
                        reboot
                fi;;
        8)      echo "Operational error"; return 0;;
        16)     echo "Use or Syntax Error"; return 16;;
        32)     echo "fsck interrupted";;
        127)    echo "Shared Library Error"; sleep 20; return 0;;
        *)      echo $ret_val; echo "Some random fsck error - continuing anyway"; sleep 20; return 0;;
    esac
}



break_requested() {
    local want_break
    for o in $(cat /proc/cmdline) ; do
        case "$o" in
            rd.break|rdbreak)                                        want_break="yes" ;;
            init=/bin/sh|init=/bin/bb|init=/bin/bash|init=/bin/dash) want_break="yes" ;;
        esac
    done
    echo "${want_break}"
}

if [[ -n "$(break_requested)" ]] ; then
    rescue_shell
fi


# start for real here
mount -t devtmpfs none /dev
mount -t proc none /proc
mount -t sysfs none /sys

# lvm runs as whatever its called as
ln -s /sbin/lvm.static /sbin/vgchange

lvm vgscan --mknodes # creates /dev/mapper/control
lvm lvchange -a ly gentoo/root
lvm vgscan --mknodes # creates /dev/mapper/VG-root and /dev/VG/root
# Change VG into the Volume Group which mine is gentoo. Physical Volume PV is created first then the VG


# start the vg volume group - /home and everything for portage - need not die here
/sbin/vgchange -ay gentoo || rescue_shell

# get here with raid sets assembled and logical volumes available
# mounting rootfs on /mnt/root
#uuidlabel_root || rescue_shell #Error with uuidlabel_root#

# ... we want to find in /etc/fstab ...
ln -s /mnt/root/etc/fstab /etc/fstab

echo "All done. Switching to real root."

rescue_shell "All done ... maybe"
# clean up. The init process will remount proc sys and dev later
umount /proc
umount /sys
umount /dev

# switch to the real root and execute init
exec switch_root /mnt/root /sbin/init


This is my fstab:
Code:

# /etc/fstab: static file system information.
#
# noatime turns off atimes for increased performance (atimes normally aren't
# needed); notail increases performance of ReiserFS (at the expense of storage
# efficiency).  It's safe to drop the noatime options if you want and to
# switch between notail / tail freely.
#
# The root filesystem should have a pass number of either 0 or 1.
# All other filesystems should have a pass number of 0 or greater than 1.
#
# See the manpage fstab(5) for more information.
#

# <fs>                  <mountpoint>    <type>          <opts>          <dump/pass>

# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.
#
# NOTE: Even though we list ext4 as the type here, it will work with ext2/ext3
#       filesystems.  This just tells the kernel to use the ext4 driver.
#
# NOTE: You can use full paths to devices like /dev/sda3, but it is often
#       more reliable to use filesystem labels or UUIDs. See your filesystem
#       documentation for details on setting a label. To obtain the UUID, use
#       the blkid(8) command.

UUID="myuuid"        /boot           vfat            noatime  1 2
UUID="myuuid"         /               ext4            noatime         0 1
UUID="my uuid"     /var/log        ext4            noatime         0 2
UUID="myuuid"         /tmp            ext4            noatime         0 2
UUID="myuuid"        none            swap            sw              0 0

#/dev/cdrom             /mnt/cdrom      auto            noauto,ro       0 0

# First UUID is my boot
# Second UUID is my root
# Third UUID is my /var/log
# Fourth UUID is my /tmp
# Fifth UUIS is my swap




I am very aware what noauto does, which I will be removing shortly
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54397
Location: 56N 3W

PostPosted: Tue Apr 20, 2021 10:21 am    Post subject: Reply with quote

kucklehead,

Please post the /boot/config.txt from your Pi.

This stackexchange topic says
Code:
As you see you will get a warning (it's not an error) from ln. The boot partition has a fat filesystem that does not support links but it doesn't matter. The only problem is that it needs an entry in /boot/config.txt like

initramfs initrd.img-4.14.71-v7+ (without equal sign)

Without the /boot/config.txt entry to toad the initrd, your initrd won't be loaded.

The authorative page is on the Pi site.
See the boot section.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
kucklehead
Tux's lil' helper
Tux's lil' helper


Joined: 13 Oct 2020
Posts: 108

PostPosted: Tue Apr 20, 2021 7:36 pm    Post subject: Reply with quote

This is my config.txt
Code:

# set 64 bit mode
arm_64bit=1
enable_gic=1
device_tree=bcm2711-rpi-4-b.dtb

# This is how I have it set for the pi to boot off of the initramfs
kernel=rpi-5.12.img
initramfs rpi-5.12-v8-custom_initramfs.cpio.gz followkernel

# have a properly sized image
disable_overscan=1

# for sound over HDMI
hdmi_drive=2

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

# Enable autoprobing of Bluetooth driver without the need of hciattach/btattach files
dtparam=krnbt=on

# Enable the SPI interface on your RPI
dtparam=spi=on

# gpu_mem is for closed-source driver only; since we are only using the
# open-source driver here, set low
gpu_mem=16

# Overclocking the pi
arm_freq=900
core_freq=333
sdram_freq=450
over_voltage=2

It already has what you specifying as you told me before in my other post, the init keeps saying that /proc/cmdline error no file or directory
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54397
Location: 56N 3W

PostPosted: Tue Apr 20, 2021 11:00 pm    Post subject: Reply with quote

kucklehead,

/proc/cmdline comes from the Pis /boot/cmdline.txt
You get the /proc/cmdline error no file or directory if you don't provide a /boot/cmdline.txt.
Your init script tries to read it.

The kernel can use an internal command line but I don't know if it puts the internal command line at /proc/cmdline for you to use.
It appears not.

Code:
# gpu_mem is for closed-source driver only; since we are only using the
# open-source driver here, set low
gpu_mem=16
you need to load a device tree overlay for the open source driver.
The Pi 4 has hardware video decoding but it wants 128 or even 256M of GPU RAM to work.

Code:
# Overclocking the pi
arm_freq=900
core_freq=333
sdram_freq=450
over_voltage=2
is for overclocking a Pi 1, not a Pi 4.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
kucklehead
Tux's lil' helper
Tux's lil' helper


Joined: 13 Oct 2020
Posts: 108

PostPosted: Wed Apr 21, 2021 12:32 am    Post subject: Reply with quote

I erased the kernel command string and added the cmdline.txt into boot. I wanted to use the kernel command line which is provided in the kernel itself. Which seems impossible to do or not recommended. I added the dtoverlay=vc4-driver from the guide into my config.txt.
I kept gpu_mem=16 in order to configure redshift for the pi. If gpu_mem needs to be 128 or 256 then could I perhaps use another module such as VC3 or fbdev. I will edit this post if something pops up and to limit the double posting
Back to top
View user's profile Send private message
Goverp
Advocate
Advocate


Joined: 07 Mar 2007
Posts: 2022

PostPosted: Wed Apr 21, 2021 9:51 am    Post subject: Reply with quote

NeddySeagoon wrote:
...
The kernel can use an internal command line but I don't know if it puts the internal command line at /proc/cmdline for you to use.
It appears not.
....

/proc/cmdline contains the kernel's internal command string catenated with the boot-time command string when I use it in my AMD64 initramfs.
_________________
Greybeard
Back to top
View user's profile Send private message
kucklehead
Tux's lil' helper
Tux's lil' helper


Joined: 13 Oct 2020
Posts: 108

PostPosted: Wed Apr 21, 2021 5:46 pm    Post subject: Reply with quote

I moved all the kernel commands into the cmdline.txt, and tried booting off bleeding-edge kernel, and it shows three raspberries and no output. I installed 5.10.11 and all I get is a black screen...
These are the commands that I tried without no issues and now I am getting issues with them
Code:

 make menuconfig; make -j4 Image modules dtbs; make modules_install dtbs_install; rm -r /boot/overlays/* cp /boot/dtbs/5.12.0-rc8-v8/overlays/* /boot/overlays/; rm -r /boot/dtbs; rm -r /boot/rpi-5.12.0-v8.img; cp /usr/src/linux/arch/arm64/boot/Image /boot/rpi-5.10.11-v8.img


Here's my kernel configurations for 5.10.11: http://dpaste.com/6D8HNX8G7

And I will grab my configurations for 5.12.0-rc8-v8 after downloading it, re configuring it, and boot off of it again which seems to work for some reason. I follow these steps to install it from here https://github.com/mcpcpc/gentoo-arm64-rpi4-install

This is my cmdline.txt data:
Code:

root=UUID=my root uuid zswap.enabled=1 zswap.compressor=lz4 dolvm

I had console= something something can't remember what exactly, I removed it cause my script already holds a console. I also notice something when booting 5.10.11 with openrc, it goes black and then it flickers and loads up the kernel, I don't know if that's good or not or something important to say?
this is my config.txt:
Code:

# set 64 bit mode
arm_64bit=1
enable_gic=1
device_tree=bcm2711-rpi-4-b.dtb

# This is how I have it set for the pi to boot off of the initramfs
kernel=5.10.11.img
initramfs initramfs.cpio.gz followkernel

# have a properly sized image
disable_overscan=1

# for sound over HDMI
hdmi_drive=2

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

# Enable autoprobing of Bluetooth driver without the need of hciattach/btattach files
dtparam=krnbt=on

# Enable the SPI interface on your RPI and video card module
dtparam=spi=on
dtoverlay=vc4-kms-v3d

# gpu_mem is for closed-source driver only; since we are only using the
# open-source driver here, set low
gpu_mem=128


This is what I removed from the cmdline.txt:
Code:

console=ttyAMA0,115200 kgdboc=ttyAMA0,115200
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54397
Location: 56N 3W

PostPosted: Wed Apr 21, 2021 10:50 pm    Post subject: Reply with quote

kucklehead,

It all looks OK. console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 sets the serial port console. You don't need that if you never intend to use the serial port console.
It normally drives the bluetooth, so there is some config.txt work to do to have both serial port console and bluetooth at the same time.

You do need
Code:
console=tty
. That puts the console output onto a virtual terminal, which is the video output on the Pi.
The kernel command line only sets the console locations (have several if you want) until /etc/inittab is processed.

You should get one or four logos. Three is an odd number.

Go with the LTS Foundation kernel and the Foundation default Pi4 kernel config. Make only the minimum changes to it to ensure that all the things you need to boot are built in.
Test it with two root filesystems. One on a partition, one in LVM.

Once it boots to the partition root filesystem you are pretty sure the kernel is good. You may have missed out LVM support be that will become clear.
With a working kernel, change /boot/cmdline.txt to point to root in LVM and and the initrd to config.txt
When it breaks now, you can be fairly sure its the initrd.

Small steps, building on what you know works. That keeps the problem space small.
Once it works, you can get more adventurous. Minimise the number of variables you are dealing with at any one time.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
kucklehead
Tux's lil' helper
Tux's lil' helper


Joined: 13 Oct 2020
Posts: 108

PostPosted: Wed Apr 21, 2021 11:04 pm    Post subject: Reply with quote

I reconfigured the bleeding-edge 5.12.y from here: https://github.com/raspberrypi/linux
Got it to boot, and it still says /proc/cmdline no file or directory, and also this as well:
Code:

can not allocate SWIOTLB buffer earlier and can't provide you with the DMA bouncer buffer

And I am guessing you meant this: https://www.acmesystems.it/roadrunner_compile_kernel_4_19 And all I have been applying was zswap, and systemd support to my kernel.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54397
Location: 56N 3W

PostPosted: Wed Apr 21, 2021 11:35 pm    Post subject: Reply with quote

kucklehead,

I meant the Pi 5.10.y kernel. That's their stable kernel.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Unsupported Software All times are GMT
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum