depmod seems not to follow link

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

depmod seems not to follow link

#1 Post by Karl Godt »

Got me a new HDD and wanted to use a /boot partition not only for GRUB , the kernel and probably an initrd.gz ,
but also to store the drivers on it , to be able to boot any Linux with a kernel and it's drivers without need to have the modules also on every partition , too .
Space is not that problem nowerdays , since the drivers compiled without debugging symbols occupy only 30-100 MB disk space ( FULL Debugging 1GB and more ).
The intention is a smaller menu.lst , where to edit the kernel line from " root=/dev/sdaY " to " root=/dev/sdaX " should be enough in the grub shell .

I tried something like this in /etc/rc.d/rc.sysinit to achieve this :

Code: Select all

###+++2013-02-28 Support for mounting a boot partition containing the kernel modules
LINKTARGET=`readlink /lib/modules/$(uname -r)`
BOOTPARTITION=`echo "$LINKTARGET" | sed 's#/lib.*##'`
if [ "$BOOTPARTITION" ] ; then
echo "Using a Boot Partition"
BOOTDRIVE=`echo "$BOOTPARTITION" | grep -o -E -e 'hd[a-z][0-9]*|sd[a-z][0-9]*'`

if [ "$BOOTDRIVE" ] ; then
grep -w "$BOOTDRIVE" /proc/partitions || BOOTDRIVE='unknown';fi

if [ "$BOOTDRIVE" != 'unknown' ] ; then
BOOTPARTITION=`echo "$BOOTPARTITION" | sed 's#\(.*/[sh]d[a-z][0-9]*/\).*#\1#'`  #need to be like /mnt/sda1/
rm -rf "$BOOTPARTITION"
mkdir -p "$BOOTPARTITION"
mount /dev/$BOOTDRIVE "$BOOTPARTITION"
mount
else
echo "Sorry, could not find '$BOOTDRIVE' in /proc/partitions"
fi;fi
###+++2013-02-28 Support for mounting a boot partition containing the kernel modules
The outcome is that Busybox depmod and depmod-FULL both don't like to follow an absolute link like

/mnt/sda3/lib/modules/2.6.30.5: symbolic link to `/mnt/sda1/Kernel/Puppy-orig/2.6.30.5'

even if

Code: Select all

cd /mnt/sda3 && chroot . && depmod 2.6.30.5
At boot time it gave me empty modules.* files first in /mnt/sda1/Kernel/Puppy-orig/2.6.30.5 and later on /mnt/sda1/

Any ideas ?

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#2 Post by amigo »

You'd have to mount or bind the modules dir into the '/' to make that work.
In other words, /boot would have to be first mounted early in init process, then /lib/modules/`uname -r` would need to be 'bound' to /boot/whattever-dir-name
like this:
mount -o bind /boot/whattever-dir-name /lib/modules/`uname -r`

Remember that this also means that the kernel must contain hard-linked support for whatever filesystem /boot is on.

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#3 Post by Karl Godt »

Yup, first experiments seemed to work

ie

Code: Select all

mount-FULL --bind /mnt/sda1/Kernel/Puppy-orig/2.6.30.5/ /mnt/sda3/lib/modules/2.6.30.5/
and mount output is as
/dev/sda1 on /mnt/sda3/lib/modules/2.6.30.5 type ext4 (rw,relatime,barrier=1,data=ordered)
from the outside running OS on sdb2

and depmod worked creating filled files from inside the chroot terminal .

The mounting from inside the chroot terminal did not work until now .

*

I guess i need a mountpoint.db file to point to the /mnt/sda1/Kernel/Puppy-orig/2.6.30.5/ directory , since /lib/modules/2.6.30.5 needs to be a directory .

Or transform link to directory and transform back at shutdown , but in case of a hard poweroff that would not work next boot .

Other idea i have would be the zdrv.sfs mounted as loopdevice , but that would likely be read-only and would probably not allow to write new modules.* files ..

Will experiment further . Thanks amigo !

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#4 Post by Karl Godt »

Seems that I got it working with a Linkname as 2.6.30.5-LINK instead a db file so 2.6.30.5 can exist as directory :

Code: Select all

###+++2013-02-28 Support for mounting a boot partition containing the kernel modules
LINKTARGET=`readlink /lib/modules/"$(uname -r)"-LINK`
if [ "$LINKTARGET" ] ; then
BOOTPARTITION=`echo "$LINKTARGET" | sed 's#/lib.*##'`
if [ "$BOOTPARTITION" ] ; then
echo "Using a Boot Partition"
BOOTDRIVE=`echo "$BOOTPARTITION" | grep -o -E -e 'hd[a-z][0-9]*|sd[a-z][0-9]*'`

if [ "$BOOTDRIVE" ] ; then
grep -w "$BOOTDRIVE" /proc/partitions || BOOTDRIVE='unknown' #;fi

if [ "$BOOTDRIVE" != 'unknown' ] ; then
BOOTPARTITION=`echo "$BOOTPARTITION" | sed 's#\(.*/[sh]d[a-z][0-9]*/\).*#\1#'`  #need to be like /mnt/sda1/
rm -rf "$BOOTPARTITION"
mkdir -p "$BOOTPARTITION"
rm -rf "/lib/modules/`uname -r`"
mkdir -p "/lib/modules/`uname -r`" ; sleep 2s
mount /dev/$BOOTDRIVE "$BOOTPARTITION" ; sleep 2s
mount-FULL --bind "$LINKTARGET" "/lib/modules/`uname -r`" ; sleep 2s
mount
else
echo "Sorry, could not find '$BOOTDRIVE' in /proc/partitions"
fi
else
echo "Got '$BOOTPARTITION' but no BOOTDRIVE '$BOOTDRIVE'"
fi;fi;fi
###+++2013-02-28 Support for mounting a boot partition containing the kernel modules
The mount shows in /tmp/bootsysinit.log as
/dev/sda1 on /mnt/sda1 type ext4 (rw,relatime,barrier=1,data=ordered)
/dev/sda1 on /lib/modules/2.6.30.5 type ext4 (rw,relatime,barrier=1,data=ordered)
depmod ran some seconds now and the usb modules did load ,
so I had been able to finish the keyboard wizard , but missed the country wizard and xorgwizard did not start automatically . But I have had other weird behavior like ( /tmp/bootkernel.log of a kernel on sdb2 plus few /tmp/* files from xwin in /tmp/sda3 ) , all drivers deleted from /boot partition and such funny things before .

rc.sysinit is the only file I have my whole coding with for now , all other scripts should be Macpup Foxy 3 (Pup-4.3) original .

YippiHappy . :D

Post Reply