sfjro / aufs-standalone

27 stars 14 forks source link

Version 6.6: Kernel panic - not syncing: Can't create rootfs #31

Open fulalas opened 10 months ago

fulalas commented 10 months ago

I'm not sure if this is related to aufs, but I'm failing to boot on PorteuX 0.7 and Porteus 5.01 with the new kernel 6.6 + aufs 6.6 branch:

kernel panic - not syncing: Can't create rootfs

photo_2023-11-06_10-11-42

sfjro commented 10 months ago

Hello fulalas,

fulalas:

I'm not sure if this is related to aufs, but I'm failing to boot on PorteuX 0.7 and Porteus 5.01 with the new kernel 6.6 + aufs 6.6 branch:

kernel panic - not syncing: Can't create rootfs

What parameters did you give to kernel cmdline?

J. R. Okajima

fulalas commented 10 months ago

I just tried to build kernel 6.6 without aufs and the same error occurs.

I'm closing this because although I don't know how to fix it, it's clear not aufs's fault.

Sorry for bothering you and thanks for the help :)

fulalas commented 10 months ago

@sfjro, I'm re-opening this because it seems the problem is really related to your code, specifically this file tmpfs-idr.patch.

If I build kernel 6.6.x with all patches but without tmpfs-idr.patch, it works, otherwise it doesn't (kernel panic as seen in the first post of this thread).

I haven't tried to use tmpfs-idr.patch from 6.5.x on 6.6.x -- most likely it will fail to build. But I checked and there are a bunch of changes made to this file in your 6.6 branch when compared to 6.5 branch.

What parameters did you give to kernel cmdline?

BOOT_IMAGE=/boot/syslinux/vmlinuz mitigations=off initrd=/boot/syslinux/initrd.zst

Do you mind taking a look at this issue?

Thanks once again for the hard work! :)

sfjro commented 10 months ago

Hello,

fulalas:

@sfjro, I'm re-opening this because it seems the problem is really related to your code, specifically this file tmpfs-idr.patch. ::: BOOT_IMAGE=/boot/syslinux/vmlinuz mitigations=off initrd=/boot/syslinux/initrd.zst

tmpfs-idr.patch? That is unexpected.

J. R. Okajima

fulalas commented 10 months ago
  • Are there any logs left? If there is, post please.

Not sure what kind of logs you're expecting.

  • Without tmpfs-idr.patch, what will /proc/mounts look like just after the boot?

Without tmpfs-idr.patch (kernel 6.6.1):

tmpfs /mnt/live tmpfs rw,relatime,mode=755,inode64 0 0
proc /mnt/live/proc proc rw,relatime 0 0
sysfs /mnt/live/sys sysfs rw,relatime 0 0
none /mnt/live/dev devtmpfs rw,relatime,size=16382364k,nr_inodes=4095591,mode=755,inode64 0 0
/dev/nvme0n1p1 /mnt/nvme0n1p1 fuseblk rw,noatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096 0 0
/dev/nvme0n1p2 /mnt/nvme0n1p2 fuseblk rw,noatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096 0 0
/dev/sda1 /mnt/sda1 vfat rw,noatime,nodiratime,uid=1000,fmask=0000,dmask=0000,allow_utime=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,check=s,utf8,errors=remount-ro 0 0
/dev/sda3 /mnt/sda3 fuseblk rw,noatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096 0 0
/dev/sdb1 /mnt/sdb1 fuseblk rw,noatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096 0 0
/dev/sdb2 /mnt/sdb2 vfat rw,noatime,nodiratime,uid=1000,fmask=0000,dmask=0000,allow_utime=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,check=s,utf8,errors=remount-ro 0 0
/dev/sdb3 /mnt/sdb3 btrfs rw,noatime,nodiratime,ssd,discard=async,space_cache=v2,subvolid=5,subvol=/ 0 0
tmpfs /mnt/live/memory/changes tmpfs rw,relatime,size=27854312k,inode64 0 0
aufs / aufs rw,relatime,si=11f9dff4f5c9c1c0,nowarn_perm 0 0
/dev/loop0 /mnt/live/memory/images/000-kernel-6.6.1.xzm squashfs ro,relatime,errors=continue 0 0
/dev/loop1 /mnt/live/memory/images/001-core-stable-20231013.xzm squashfs ro,relatime,errors=continue 0 0
/dev/loop2 /mnt/live/memory/images/002-xorg-stable-20231013.xzm squashfs ro,relatime,errors=continue 0 0
/dev/loop3 /mnt/live/memory/images/002-xtra-stable-20231013.xzm squashfs ro,relatime,errors=continue 0 0
/dev/loop4 /mnt/live/memory/images/003-xfce-4.12-stable-20231013.xzm squashfs ro,relatime,errors=continue 0 0
devtmpfs /dev devtmpfs rw,relatime,size=16382364k,nr_inodes=4095591,mode=755,inode64 0 0
proc /proc proc rw,relatime 0 0
sysfs /sys sysfs rw,relatime 0 0
tmpfs /dev/shm tmpfs rw,relatime,inode64 0 0
devpts /dev/pts devpts rw,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /run tmpfs rw,relatime,mode=755,inode64 0 0
fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0
tmpfs /sys/fs/cgroup tmpfs rw,nosuid,nodev,noexec,size=4096k,nr_inodes=1024,mode=755,inode64 0 0
cgroup /sys/fs/cgroup/elogind cgroup rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib64/elogind/elogind-cgroups-agent,name=elogind 0 0
tmpfs /run/user/1000 tmpfs rw,nosuid,nodev,relatime,size=3276976k,nr_inodes=819244,mode=700,uid=1000,gid=100,inode64 0 0
gvfsd-fuse /run/user/1000/gvfs fuse.gvfsd-fuse rw,nosuid,nodev,relatime,user_id=1000,group_id=100 0 0

With tmpfs-idr.patch (kernel 6.5.7):

tmpfs /mnt/live tmpfs rw,relatime,mode=755,inode64 0 0
proc /mnt/live/proc proc rw,relatime 0 0
sysfs /mnt/live/sys sysfs rw,relatime 0 0
none /mnt/live/dev devtmpfs rw,relatime,size=16382364k,nr_inodes=4095591,mode=755,inode64 0 0
/dev/nvme0n1p1 /mnt/nvme0n1p1 fuseblk rw,noatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096 0 0
/dev/nvme0n1p2 /mnt/nvme0n1p2 fuseblk rw,noatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096 0 0
/dev/sda1 /mnt/sda1 vfat rw,noatime,nodiratime,uid=1000,fmask=0000,dmask=0000,allow_utime=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,check=s,utf8,errors=remount-ro 0 0
/dev/sda3 /mnt/sda3 fuseblk rw,noatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096 0 0
/dev/sdb1 /mnt/sdb1 fuseblk rw,noatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096 0 0
/dev/sdb2 /mnt/sdb2 vfat rw,noatime,nodiratime,uid=1000,fmask=0000,dmask=0000,allow_utime=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,check=s,utf8,errors=remount-ro 0 0
/dev/sdb3 /mnt/sdb3 btrfs rw,noatime,nodiratime,ssd,discard=async,space_cache=v2,subvolid=5,subvol=/ 0 0
tmpfs /mnt/live/memory/changes tmpfs rw,relatime,size=27854368k,inode64 0 0
aufs / aufs rw,relatime,si=4dc91af0f407bcf4,nowarn_perm 0 0
/dev/loop0 /mnt/live/memory/images/000-kernel-6.5.7.xzm squashfs ro,relatime,errors=continue 0 0
/dev/loop1 /mnt/live/memory/images/001-core-stable-20231013.xzm squashfs ro,relatime,errors=continue 0 0
/dev/loop2 /mnt/live/memory/images/002-xorg-stable-20231013.xzm squashfs ro,relatime,errors=continue 0 0
/dev/loop3 /mnt/live/memory/images/002-xtra-stable-20231013.xzm squashfs ro,relatime,errors=continue 0 0
/dev/loop4 /mnt/live/memory/images/003-xfce-4.12-stable-20231013.xzm squashfs ro,relatime,errors=continue 0 0
devtmpfs /dev devtmpfs rw,relatime,size=16382364k,nr_inodes=4095591,mode=755,inode64 0 0
sysfs /sys sysfs rw,relatime 0 0
proc /proc proc rw,relatime 0 0
tmpfs /dev/shm tmpfs rw,relatime,inode64 0 0
devpts /dev/pts devpts rw,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /run tmpfs rw,relatime,mode=755,inode64 0 0
fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0
tmpfs /sys/fs/cgroup tmpfs rw,nosuid,nodev,noexec,size=4096k,nr_inodes=1024,mode=755,inode64 0 0
cgroup /sys/fs/cgroup/elogind cgroup rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib64/elogind/elogind-cgroups-agent,name=elogind 0 0
tmpfs /run/user/1000 tmpfs rw,nosuid,nodev,relatime,size=3276984k,nr_inodes=819246,mode=700,uid=1000,gid=100,inode64 0 0
gvfsd-fuse /run/user/1000/gvfs fuse.gvfsd-fuse rw,nosuid,nodev,relatime,user_id=1000,group_id=100 0 0
  • Does your distribution 'Porteus' make change about tmpfs or something? Where can I found their source files?

I'm actually using PorteuX. The initrd has this script which is responsible for mounting everything in the boot time:

#!/bin/sh
export PATH=/bin:/usr/bin:./

# Source functions
. ./finit

# Enable pivot_root in initramfs to let it behave like initrd:
if [ -d /m ]; then
    mount -nt tmpfs tmpfs -o mode=0755 /m
    cp -a ??* /m 2>/dev/null
    exec switch_root /m linuxrc "$@"
fi

mount -nt proc proc /proc
mount -nt sysfs sysfs /sys
echo 0 >/proc/sys/kernel/printk

clear
echo -e "${BOLD}PorteuX - The Next Experience${RST}"
echo

# Variables:
i=$(echo -e "${X_BLUE}^ ${RST}")
m=$(echo -e "${X_BLUE}>${RST}")
m_warning=$(echo -e "${YELLOW}>${RST}")
arch=`uname -m`; [ $arch = x86_64 ] || arch=i586
CFG=`value cfgfile`; [ $CFG ] || CFG=porteux.cfg
FROM=`value from`; ISO=`echo $FROM | egrep ".*\.iso( |\$)"`
MOPT=`value mopt`; [ $MOPT ] || MOPT="noatime,nodiratime,suid,dev,exec,async"
CHANGES=`value changes`
RAMSIZE=`value ramsize`; [ $RAMSIZE ] || RAMSIZE=85%
LOAD=`value load | sed 's/;/|/g'`; [ $LOAD ] || LOAD=._null
NOLOAD=`value noload | sed 's/;/|/g'`; [ $NOLOAD ] || NOLOAD=._null
EXTRAMOD=`value extramod | sed 's/;/ /g'`
RAMMOD=`value rammod | sed 's/;/|/g'`
ROOTCOPY=`value rootcopy`
FOLDER=porteux
livedbg=/var/log/livedbg
LOGFILE=/var/log/boot.log

FindPorteuxUnit() {
    lazySearchUuid porteux/$CFG
    [ ! $FOUNDPORTEUXUNIT ] && lazySearch porteux/$CFG
}

## Let's start!
mount -nt devtmpfs none /dev

DELAY=`value delay`; [ $DELAY ] && { echo $i"delaying $DELAY sec (waiting for slow devices to settle)"; sleep $DELAY; }

# Perform filesystem check:
if param fsck || param fscknolog; then
    echo $i"performing filesystem check on all available devices..."
    [ ! $DELAY ] || [ $DELAY -lt 3 ] && sleep 3
    blkidValue=$(blkid)
    log=/tmp/fsck.log
    for x in ${blkidValue// /}; do
        fs=$(echo $x | egrep -o 'TYPE="[^"]+' | cut -d\" -f2)
        case $fs in ext|ext2|ext3|ext4|vfat|exfat|ntfs)
            partition=$(echo $x | cut -d: -f1)
            echo "Partition $partition scan result:" >> $log
            case $fs in
                ext|ext2|ext3|ext4) e2fsck -C 0 -p $partition >> $log 2>&1 ;;
                vfat) fsck.fat -a $partition >> $log 2>&1 ;;
                exfat) exfatfsck -p $partition >> $log 2>&1 ;;
                ntfs) ntfsfix -bd $partition >> $log 2>&1 ;;
            esac
            echo "----------" >> $log
        esac
    done
    wait
fi

# Create /etc/fstab and mount devices:
fstab

# Find porteux.cfg file:
echo $i"checking PorteuX data"
if [ $ISO ]; then
    CFGDEV=/mnt/isoloop
    locate $FROM && {
        BOOTDEV=/mnt/$DEV
        mkdir /mnt/isoloop
        mount -o loop /mnt/$DEV/$LPTH /mnt/isoloop
        ISOSRC=/mnt/$DEV/$LPTH
    }
else
    if [ $FROM ]; then
        locate $FROM/porteux/$CFG
        if [ $? -eq 0 ]; then
            DIR=`echo $LPTH | rev | cut -d/ -f3- | rev`; [ $DIR ] && FOLDER=$DIR/porteux
        else
            echo -e "${YELLOW}from= cheatcode is incorrect; searching through all devices${RST}"
            FindPorteuxUnit
        fi
    else
        FindPorteuxUnit
    fi

    CFGDEV=/mnt/$DEV
fi

[ -e $CFGDEV/$FOLDER/$CFG ] && PTH=$CFGDEV/$FOLDER || . fatal

# Set some variables to export as environment variables
BOOTDEV=$CFGDEV
MODDIR=$PTH/modules
BASEDIR=${PTH%/*}
PORTDIR=$PTH
PORTCFG=$CFGDEV/$FOLDER/$CFG
echo $i"using PorteuX data from $PTH"

# Make all drivers available:
mount -o loop $PTH/base/000-kernel*.xzm /opt/000-kernel 2>/dev/null
mount -o bind /opt/000-kernel/lib/modules /lib/modules 2>/dev/null

# Create symlinks used often by porteux scripts:
if [ $CFGDEV = /mnt/nfs -o $CFGDEV = /mnt/isoloop ];then
    ln -sf /mnt/live$PTH/modules /porteux/modules
    ln -sf /mnt/live$PTH/optional /porteux/optional
else
    ln -sf $PTH/modules /porteux/modules
    ln -sf $PTH/optional /porteux/optional
fi

# Setup changes:
if [ $CHANGES ]; then
    CHNEXIT=`echo $CHANGES | cut -d: -f1`
    [ $CHNEXIT = EXIT ] && CHANGES=`echo $CHANGES | cut -d: -f2-`
    [ -r $CFGDEV/$CHANGES ] && { DEV=`echo $CFGDEV | sed s@/mnt/@@`; LPTH=$CHANGES; } || locate $CHANGES && [ -r /mnt/$DEV/$LPTH ]
    if [ $? -eq 0 ]; then
        if [ -d /mnt/$DEV/$LPTH ]; then
            mkdir -p /mnt/$DEV/$LPTH/changes 2>/dev/null && \
            mount -o bind /mnt/$DEV/$LPTH/changes /memory/changes && touch /memory/changes/._test1 2>/dev/null
        else
            if blkid /mnt/$DEV/$LPTH 2>/dev/null | cut -d" " -f3- | grep -q _LUKS; then
                modprobe -a dm_crypt cryptd cbc sha256_generic aes_generic aes_x86_64 2>/dev/null
                load_hid_drivers &
                losetup /dev/loop2 /mnt/$DEV/$LPTH
                echo $i"found encrypted .dat container"
                /opt/000-kernel/sbin/cryptsetup luksOpen /dev/loop2 crypt
                fsck_dat /dev/mapper/crypt
                mount /dev/mapper/crypt /memory/changes 2>/dev/null && touch /memory/changes/._test1 2>/dev/null
            else
                fsck_dat /mnt/$DEV/$LPTH
                mount -o loop /mnt/$DEV/$LPTH /memory/changes 2>/dev/null && touch /memory/changes/._test1 2>/dev/null
            fi
        fi
        if [ $? -eq 0 ]; then
            ln -s /memory/changes/._test1 /memory/changes/._test2 2>/dev/null && chmod +x /memory/changes/._test1 2>/dev/null && [ -x /memory/changes/._test1 ] && chmod -x /memory/changes/._test1 2>/dev/null && [ ! -x /memory/changes/._test1 ] && rm -f /memory/changes/._test1 /memory/changes/._test2
            if [ $? -ne 0 ]; then
                rm -f /memory/changes/._test1 /memory/changes/._test2
                umount /memory/changes
                echo -e $i${YELLOW}"posix not detected, disabling automatic save changes"${RST}
                CHGERR=1
                rmdir /mnt/$DEV/$LPTH/changes
                fail_chn
            else
                echo $i"filesystem is posix compatible"
                CHNDEV=/mnt/$DEV
                rmdir /memory/changes/mnt/* 2>/dev/null
                rm -rf /memory/changes/var/lock/* /var/run/laptop-mode-tools/* /var/spool/cron/cron.??????
                for x in `find /memory/changes/var/run -name "*pid" 2>/dev/null`; do
                    rm $x
                done
                if [ $CHNEXIT = EXIT -o "`egrep -o " changes-ro( |\$)" /proc/cmdline`" ]; then
                    CHNEXIT=$CHNDEV/$LPTH
                    echo $CHNEXIT >/tmp/changes-exit
                    param changes-ro && echo -e $i${LIGHT_RED}"changes will not be saved for this session"${RST} || echo -e $i${X_BLUE}"changes will be saved only during reboot/shutdown"${RST}
                    for x in `find /memory/changes -name ".wh.*" | grep -v '.wh..wh..opq' | tr ' ' '@' `; do
                        x=`echo $x | tr '@' ' ' `
                        cp -a --parents "$x" /var
                    done
                    umount /memory/changes
                    mount -nt tmpfs -o size=$RAMSIZE tmpfs /memory/changes
                    mv /var/memory/changes/* /memory/changes 2>/dev/null
                    CHANGES=memory
                fi
            fi
        else
            echo $i"changes not writable, using memory instead"
            CHGERR=2
            umount /memory/changes 2>/dev/null
            fail_chn
        fi
    else
        CHGERR=3
        fail $CHANGES
        fail_chn
    fi
else
    echo $i"changes cheatcode not found, using memory only"
    fail_chn
fi

mkdir -p /memory/changes/mnt/live

# Setup aufs:
echo $i"creating live filesystem"
mount -t aufs -o nowarn_perm,xino=/memory/xino/.aufs.xino,br:/memory/changes=rw aufs /union
if [ $? -ne 0 ]; then
    echo -e ${LIGHT_RED}"can't setup union (aufs) - read only filesystem?\nWhen you finish debugging press Ctrl+Alt+Del to reboot."${RST}
    sh
fi

# Find modules:
find -L $PTH/base $PTH/modules -name "*.xzm" 2>/dev/null | egrep -ve "$NOLOAD" | sort >/tmp/modules
find -L $PTH/optional -name "*.xzm" 2>/dev/null | egrep -e "$LOAD" | sort >>/tmp/modules

# Find nvidia video card
if param vga_detect; then
    nvidia=`lspci | grep "0300: 10de:"`
    if [ "$nvidia" ]; then
        echo $i"nvidia video card found"
        find $PTH/optional -name "*nvidia-[0-9]*.xzm" 2>/dev/null >>/tmp/modules
    fi
fi

if param base_only; then
    grep base/0 /tmp/modules > /tmp/mod
    mv /tmp/mod /tmp/modules
else
    if [ "$EXTRAMOD" ]; then
        for folder in $EXTRAMOD; do
            locate $folder && { echo $i"loading additional modules in $folder"
                    find -L /mnt/$DEV/$LPTH -name "*.xzm" 2>/dev/null | egrep -ve "$NOLOAD" | sort >> /tmp/modules
                } || echo -e $i${LIGHT_RED}"couldn't load additional modules in $folder"${RST}
        done
    fi
fi

# Copy data to RAM:
if param copy2ram; then
    echo $i"copying PorteuX data to RAM..."
    [ $RAMMOD ] && { egrep -e "$RAMMOD" /tmp/modules > /tmp/rammod; cpmod /tmp/rammod; } || cpmod /tmp/modules
fi

# Populate aufs with modules:
umount /lib/modules /opt/000-kernel 2>/dev/null
while read line; do
    NAME=`basename "$line"`
    if [ -d "/memory/images/$NAME" ];then
        echo "  $m_warning $NAME"
    else
        mkdir /memory/images/"$NAME"
        mount -o loop "$line" /memory/images/"$NAME" 2>/dev/null
        if [ $? -eq 0 ]; then
            echo "  $m $NAME"
            mount -no remount,add=1:/memory/images/"$NAME"=rr aufs /union
        else
            echo -e $i${LIGHT_RED}"Cannot read $NAME - corrupted module?"${RST}
            rmdir /memory/images/"$NAME"
        fi
    fi
done < /tmp/modules
mount -no bind /union/lib/modules /lib/modules 2>/dev/null

# Add "changes on exit" device/file/folder:
if [ -e /tmp/changes-exit ]; then
    mkdir /memory/images/changes
    if [ -d $CHNEXIT ]; then
        mount -o bind $CHNEXIT/changes /memory/images/changes
    elif [ -b /dev/mapper/crypt ]; then
        mount /dev/mapper/crypt /memory/images/changes
    else
        mount -o loop $CHNEXIT /memory/images/changes
    fi
    echo "  $m changes"
    mount -no remount,add=1:/memory/images/changes=ro aufs /union
    echo $CHNEXIT/changes >>/tmp/modules
    param changes-ro && rm /tmp/changes-exit
fi

# Copy /rootcopy folder:
if param norootcopy; then
    ROOTCOPY=none
    echo $i"skipping /rootcopy directory"
else
    FILESYSTEM=$(cat /etc/fstab | grep -o /mnt/$DEV.* | cut -f2- -d' ' | cut -f1 -d' ')
    COPYPARAMS="-af"

    # when non-posix filesystem, always copy rootcopy keeping destination permissions
    if [ $FILESYSTEM = "vfat" ] || [ $FILESYSTEM = "ntfs" ] || [ $FILESYSTEM = "exfat" ]; then
        COPYPARAMS="-rf"
        NONPOSIX=true
    fi

    if [ $ROOTCOPY ]; then
        locate $ROOTCOPY && ROOTCOPYPATH=/mnt/$DEV/$LPTH/.
    elif [ -e $PTH/rootcopy ]; then
        ROOTCOPYPATH=$PTH/rootcopy/.
    else
        ROOTCOPY=none
        fail $ROOTCOPY
    fi

    if [ $ROOTCOPYPATH ]; then
        if param rootmount && ! param copy2ram && [ ! $NONPOSIX ]; then
            echo $i"mounting $ROOTCOPYPATH directory..."
            mount -no remount,add=1:"$ROOTCOPYPATH"=rr aufs /union
        else
            echo $i"copying $ROOTCOPYPATH directory..."
            cp $COPYPARAMS "$ROOTCOPYPATH" /union/. 2>/dev/null
        fi
    fi
fi

profileFolder=/union/etc/profile.d
profileFile=$profileFolder/porteux.sh
mkdir -p $profileFolder 2>/dev/null
cat > "$profileFile" << EOF 
export DISTRO=porteux
export BOOTDEV=$CFGDEV
export BASEDIR=${PTH%/*}
export PORTDIR=$PTH
export MODDIR=$MODDIR
export PORTCFG=$PORTCFG
EOF
if [ $CHGERR ]; then
  echo "export CHGERR=$CHGERR" >> $profileFile
fi
chmod +x $profileFile

# Collect boot arguments
grep "^[aA0-zZ9]" $PORTCFG > /union/etc/bootcmd.cfg
cat /proc/cmdline | tr ' ' '\n' >> /union/etc/bootcmd.cfg

## Finish:
# Create 7 free loop devices for truecrypt, etc...
x=`grep -oE 'loop[0-9]+$' /proc/partitions | tail -n1 | tr -d [:alpha:]`
let y=x+7
while [ $x -le $y ]; do
    [ -b /dev/loop$y ] && break || mknod /dev/loop$y b 7 $y
    let y=y-1
done

if param nonetwork; then
    echo $i"disabling dhcpcd and NetworkManager services"
    chmod -x /union/etc/rc.d/rc.inet1 /union/etc/rc.d/rc.networkmanager 2>/dev/null
    nma=/union/etc/xdg/autostart/nm-applet.desktop
    test -e $nma && ! grep -q "Hidden=true" $nma && echo "Hidden=true" >> $nma
fi

cp -af /dev/console /union/dev
fstab

if chk_bootcfg copy2ram; then
    echo -e $i${X_BLUE}"finished copying to RAM - booting media can be removed safely"${RST}
fi

# Create debug file:
[ -e /tmp/devices ] && { echo "# Recognized devices:" >$livedbg
        cat /tmp/devices >>$livedbg
    }
[ $BOOTDEV ] && CFGDEV=$BOOTDEV
echo -e "\n# Booting device:\n$CFGDEV\n\n# PorteuX data found in:\n$PTH\n\n# Changes are stored in:\n$CHANGES\n\n# Non standard /rootcopy dir:\n$ROOTCOPY\n\n# Modules activated during boot time:" >>$livedbg
cat /tmp/modules >>$livedbg
[ -e /mnt/isoloop ] && echo "" >> $livedbg && echo "ISO=$ISOSRC" >> $livedbg
cp -af $livedbg /union/var/log/porteux-livedbg

## Check for text mode cheatcode
chk_bootcfg 3 && export OPTS="3"

# Cleanup mount points at union/mnt for this session
for x in `ls -1 /union/mnt | grep -v "live"`; do
    [ -d /union/mnt/$x ] && rmdir /union/mnt/$x # Will fail if dir not empty!
    [ -L /union/mnt/$x ] && rm -f /union/mnt/$x
done

if chk_bootcfg noauto; then
    for x in `grep /mnt/ /etc/fstab | cut -d/ -f3`; do
        mkdir -p /union/mnt/$x
        umount -n /mnt/$x 2>/dev/null && rmdir /mnt/$x
    done
else
    for x in `grep /mnt/ /etc/fstab | cut -d/ -f3`; do
        mkdir -p /union/mnt/$x
        mount -n --move /mnt/$x /union/mnt/$x
        rmdir /mnt/$x
    done
fi

sed -i 's/ ntfs / ntfs-3g /g' /etc/fstab
cp -f /etc/fstab /union/etc 2>/dev/null

# Add all symlinks of all mount points at /mnt to union
for x in `ls -1 /mnt`; do
    [ -d /union/mnt/$x ] && rmdir /union/mnt/$x
    ln -sf /mnt/live/mnt/$x /union/mnt/$x
done

cp -r /etc/porteux /union/etc 2>/dev/null
umount -n /lib/modules 2>/dev/null
rm -r /lib/* /usr/*

echo -e ${X_BLUE}"live system is ready - starting PorteuX"${RST}
cp -f /union/sbin/init /bin
if [ $? -eq 0 ]; then
    pivot_root /union /union/mnt/live
    exec bin/chroot . /mnt/live/bin/init "$@" $OPTS <dev/console >dev/console 2>&1
else
    echo -e ${LIGHT_RED}"!!ERROR!!\nSomething went wrong and the system cannot be initialized.\nPress Ctrl+Alt+Del to reboot."${RST}
    sh
fi
fulalas commented 10 months ago

One more file from initrd that I forgot to post:

## Functions for porteux init

# Export some color functions
RED='\033[0;31m'
LIGHT_RED='\033[1;31m'
GREEN='\033[0;32m'
LIGHT_GREEN='\033[1;32m'
X_BLUE='\x1b[1;38;2;0;150;255m'
CYAN='\033[0;36m'
YELLOW='\033[1;33m'
BOLD='\033[1;37m'
RST='\033[0m' # Reset Color

# Find a parameter on boot line
param() {
    if [ -e $CFGDEV/$FOLDER/$CFG ]; then
        egrep -qo "^${1}$" $CFGDEV/$FOLDER/$CFG || egrep -qo " $1( |\$)" /proc/cmdline
    else
        egrep -qo " $1( |\$)" /proc/cmdline
    fi
}

value() {
    if [ -e $CFGDEV/$FOLDER/$CFG ]; then
        egrep -o "^${1}=[^ ]+" $CFGDEV/$FOLDER/$CFG | cut -d= -f2
        egrep -o " $1=[^ ]+" /proc/cmdline | cut -d= -f2
    else
        egrep -o " $1=[^ ]+" /proc/cmdline | cut -d= -f2
    fi
}

# Run fstab for setup
fstab() {
    rm -f /tmp/devices
    param nocd || for x in /dev/sr*; do
        blkid $x >>/tmp/devices
        done
    param nohd || blkid | egrep -v '/dev/sr|/dev/loop|/dev/mapper' >>/tmp/devices
    dev=`egrep -v 'TYPE="sw|TYPE="LVM|TYPE=".*_raid_member"' /tmp/devices 2>/dev/null | cut -d: -f1 | cut -d/ -f3 | sort | uniq`
    cat > /etc/fstab << EOF
# Do not edit this file as fstab is recreated automatically during every boot.
# Please use /etc/rc.d/rc.local or sysvinit scripts if you want to mount/unmount
# drive, filesystem or network share.

# System mounts:
aufs / aufs defaults 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
devtmpfs /dev devtmpfs defaults 0 0
devpts /dev/pts devpts rw,mode=0620,gid=5 0 0

# Device partitions:
EOF
    for x in $dev; do
        fs=`grep -w /dev/$x /tmp/devices | egrep -o ' TYPE=[^ ]+' | cut -d'"' -f2`
        [ $fs = vfat ] && echo "/dev/$x /mnt/$x vfat $MOPT,umask=0,check=s,utf8,uid=1000 0 0" >>/etc/fstab || echo "/dev/$x /mnt/$x $fs $MOPT 0 0" >>/etc/fstab
        if [ ! -d /mnt/$x ]; then
            mkdir /mnt/$x
            if [ $fs = ntfs ]; then
                ntfs-3g /dev/$x /mnt/$x -o $MOPT,uid=1000,big_writes 2>/dev/null || { sed -i "/$x /d" /etc/fstab; rmdir /mnt/$x; }
            else
                mount -n /mnt/$x 2>/dev/null || { modprobe $fs 2>/dev/null && mount -n /mnt/$x 2>/dev/null || { sed -i "/$x /d" /etc/fstab; rmdir /mnt/$x; }; }
            fi
        fi
    done

    if [ -z "`egrep -o " noswap( |\$)" /proc/cmdline`" -a -e /tmp/devices ]; then
        for x in `grep 'TYPE="swap"' /tmp/devices | cut -d: -f1`; do
            echo "$x none swap sw,pri=1 0 0" >> /etc/fstab
        done
    fi
}

# Mount devices
mount_device() {
    fs=`blkid /dev/$1 | egrep -o ' TYPE=[^ ]+' | cut -d'"' -f2`
    if [ "$fs" ]; then
        mkdir /mnt/$1
        case $fs in
            vfat) mount -n /dev/$1 /mnt/$1 -o $MOPT,umask=0,check=s,utf8,uid=1000 2>/dev/null || rmdir /mnt/$1 ;;
            ntfs) ntfs-3g /dev/$1 /mnt/$1 -o $MOPT,uid=1000,big_writes 2>/dev/null || rmdir /mnt/$1 ;;
            *) mount -n /dev/$1 /mnt/$1 -o $MOPT 2>/dev/null || { modprobe $fs 2>/dev/null && mount -n /dev/$1 /mnt/$1 -o $MOPT || rmdir /mnt/$1; } ;;
        esac
    fi
}

# Search for uuid -- if the uuid inside initrd (generated during install) matches
# a unit that contains /porteux/porteux.cfg then that's the unit we want to boot from
searchUuid() {
    for x in `ls /mnt | tac`; do
        if [ ! -f /mnt/$x/$1 ]; then
            continue
        fi
        currentUnitInfo=`blkid /dev/$x`
        currentUnitUuid=`echo ${currentUnitInfo##* UUID} | cut -d '"' -f2`
        initrdUuid=`cat uuid`
        if [ $initrdUuid = $currentUnitUuid ]; then
            DEV=$x
            FOUNDPORTEUXUNIT=true
            return 0
        fi
    done
    return 1
}

# Search for boot location
search() {
    for x in `ls /mnt | tac`; do
        if [ -f /mnt/$x/$1 ]; then
            DEV=$x
            FOUNDPORTEUXUNIT=true
            return 0
        fi
    done
    return 1
}

# Delay booting a little until devices have settled
nap() {
    echo -en $i"device not ready yet? delaying ${X_BLUE}$SLEEP${RST} seconds \r"
    sleep 1
}

lazySearchUuid() {
    [ ! -e uuid ] && return 1
    SLEEP=10
    while [ $SLEEP -gt 0 ]; do
        searchUuid $*
        if [ $FOUNDPORTEUXUNIT ]; then
            return 0
        fi
        nap
        fstab
        let SLEEP=SLEEP-1
    done
    return 1
}

lazySearch() {
    SLEEP=10
    while [ $SLEEP -gt 0 ]; do
        search $*
        if [ $FOUNDPORTEUXUNIT ]; then
            return 0
        fi
        nap
        fstab
        let SLEEP=SLEEP-1
    done
    return 1
}

# Find location of PorteuX files
locate() {
    PATHPREFIX=`echo $1 | cut -b-5 | sed s@/dev@/mnt@`
    if [ $PATHPREFIX = /mnt/ ]; then
        DEV=`echo $1 | cut -d/ -f3`
        LPTH=`echo $1 | cut -d/ -f4-`
        SLEEP=6
        while [ $SLEEP -gt 0 -a ! -b /dev/$DEV ]; do
            nap
            let SLEEP=SLEEP-1
            fstab
        done
        [ -d /mnt/$DEV ] || mount_device $DEV
        [ -e /mnt/$DEV/$LPTH ]
    elif [ $PATHPREFIX = UUID: -o $PATHPREFIX = LABEL ]; then
        ID=`echo $1 | cut -d: -f2 | cut -d/ -f1`
        LPTH=`echo $1 | cut -d/ -f2-`
        SLEEP=6
        while [ $SLEEP -gt 0 ]; do
            DEV=`blkid | grep $ID | cut -d: -f1 | cut -d/ -f3`
            if [ "$DEV" ]; then
                break
            fi
            nap
            let SLEEP=SLEEP-1
            fstab
        done
        [ -d /mnt/$DEV ] || mount_device $DEV
        [ -e /mnt/$DEV/$LPTH ]
    else
        LPTH=$1
        lazySearch $1
    fi
}

# Booting failed. Failed to find porteux files.
fail() {
    echo -e ${YELLOW}"couldn't find $1. Correct your from= cheatcode."${RST}
    CHGERR=4
}

# Failed to initiate changes. Creating temporary changes on tmpfs for this session.
fail_chn() {
    mount -nt tmpfs -o size=$RAMSIZE tmpfs /memory/changes
    CHANGES=memory
    CHNDEV=memory
}

# Just draw a line
draw() {
    echo -e ${YELLOW}"---------------------------------------------------------"${RST}
}

# Error checking a save file.
fsck_dat() {
    local log=/tmp/fsck.log
    echo $i"checking $1 for errors..."
    echo "Save data x scan result:" >> $log
    fs=`blkid $1 | egrep -o ' TYPE=[^ ]+' | cut -b8-10`
    case $fs in
        xfs) echo "Detected xfs partition - fsck is automatically performed at mount time" >> $log ;;
        ext|ext2|ext3|ext4)
            e2fsck -C 0 -p $1 >> $log 2>&1
            wait
        ;;
        *) echo "Detected unsupported filesystem - skipping fsck" >> $log ;;
    esac
    echo "----------" >> $log
}

# Copy modules
cpmod() {
    NUM=`grep -c '.' $1`
    modfile=$1
    while read x; do
        echo -en ${X_BLUE}"  ($NUM modules left)  \r"${RST}
        let NUM=NUM-1
        NAME=`basename "$x"`
        cp -L "$x" /memory/copy2ram 2>/dev/null
        if [ $? -eq 0 ]; then
            sed -i s@^.*/"$NAME"@/memory/copy2ram/"$NAME"@ /tmp/modules
        else
            rm /memory/copy2ram/"$NAME"
            echo -e $i${LIGHT_RED}"Not enough memory to copy $NAME"${RST}
            echo -e $i${LIGHT_RED}"Other modules will be skipped."${RST}
            find /memory/copy2ram -name "*.xzm" | sort >/tmp/modules
            break
        fi
    done < $modfile
    echo -en "                     \r"
}

# If bootlog cheatcode is present then make log entry
blog() {
    param log && echo "$1" >> $LOGFILE
}

# Check for a boot param
chk_bootcfg() {
    grep "^$1" /union/etc/bootcmd.cfg
}

# Make sure all keyboards will work
load_hid_drivers() {
    hid_drivers=$(find /lib/modules/$(uname -r)/kernel/drivers/hid -type f -name '*.ko' | rev | cut -d / -f1 | rev)
    modprobe -a ${hid_drivers//.ko/} 2>/dev/null
}
sfjro commented 10 months ago

fulalas:

Without tmpfs-idr.patch (kernel 6.6.1):


tmpfs /mnt/live tmpfs rw,relatime,mode=755,inode64 0 0
:::
inode64 option may be related.
I will dive into tmpfs. It will take some moment. hold on plz.

J. R. Okajima

sfjro commented 10 months ago

"J. R. Okajima":

fulalas:

Without tmpfs-idr.patch (kernel 6.6.1):


tmpfs /mnt/live tmpfs rw,relatime,mode=755,inode64 0 0
:::
inode64 option may be related.
I will dive into tmpfs. It will take some moment. hold on plz.

Unfortunately (or fortunately for me), I got busy. This tmpfs-idr.patch issue is on my todo list, but the priority is down. For a while, use aufs without tmpfs-idr.patch please.

J. R. Okajima

fulalas commented 10 months ago

Hahaha! No rush! :)

sfjro commented 9 months ago

@.***

This tmpfs-idr.patch issue is on my todo list, but the priority is down. For a while, use aufs without tmpfs-idr.patch please.

I'm still continuing the investigation intermittently, and I could not reproduce the problem on my 6.6 kernel. If I send you some debug print patch, would try it and send back the kernel log?

J. R. Okajima

fulalas commented 9 months ago

Sure! :)

sfjro commented 9 months ago

fulalas:

I can confirm this issue. It seems the system fails to create /union for AUFS.

Thanx for the info. But I am going slightly confusing. Currently we have two issues.

Issue #31 from fulalas, Version 6.6: Kernel panic - not syncing: Can't create rootfs Issue #32 from peabee, kernel 6.6.4 gives kernel panic

They MAYBE rooted on the same problem, or at least related, or nothing related at all. I'm not sure.

I'll try one by one. At first, here is a debug patch for you fulalas. The base version is linux-v6.6. Please apply, build, boot, and report the kernel log. If 'pr_err' doesn't show the message, then try replacing by pr_crit, pr_alert, or pr_emerg. It depends on your log level setting. Note that this is a FIRST debug print patch to find the cause and never fix the problem. Such debug-print patch MAY continue a few times.

Thanx in advance.

J. R. Okajima

a.patch diff --git a/fs/fs_context.c b/fs/fs_context.c index 98589aae5208..e1c7a4da542e 100644 --- a/fs/fs_context.c +++ b/fs/fs_context.c @@ -186,6 +186,7 @@ int vfs_parse_fs_string(struct fs_context fc, const char key, }

ret = vfs_parse_fs_param(fc, &param);

diff --git a/fs/namespace.c b/fs/namespace.c index 1f68adec5b74..f106c7974177 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1138,18 +1138,23 @@ struct vfsmount vfs_kern_mount(struct file_system_type type, return ERR_PTR(-EINVAL);

fc = fs_context_for_mount(type, flags);