You are not logged in.
Anybody made any progress on uuid-based (usb) drive mounting in xandros?
The /dev/disk/by-uusid directory present on my ubunto boxes is missing on Eee... (actually /dev/disk/ is missing).
Can't seem to get a straight answer if uuid is a kernel feature, or a module, or what...
Offline
GRRRRRRRRRRRRRRRRRRRRRRRRRRAAAAAAAAAAAARRRRRRRRRRRGGGGGGGGGGHHHHHHHH
Okay, so the good news is that Xandros linux does have mount -U insert-uuid-here functionality
the bad news is the busybox, which needs to mount the root file system, does not.
The good news is that dumpe2fs -h /dev/foo will tell you the UUID of the disk you want to put in your init or menu.lst
But busybox mount won't take the -U option. Even in newer versions of the source on CVS on the busybox project site.
Argh! how is this supposed to work?
I did find that the UUID can be read directly from an ext2/3 file system at offset 0x468-0x467
ie, dd if=/dev/sda1 bs=8 count=2 skip=141 | hexdump will yield the UUID without the usual dashes.
But trying to recompile busybox with addition programs is turning out to be a pain. I'd need something that did a find
and a for each kind of thing and then checked the UUID and produced a /dev/sdxn type result to pass to mount.
There's got to be a better solution for reliable usb booting...
Offline
tuxpocket wrote:
Okay, so the good news is that Xandros linux does have mount -U insert-uuid-here functionality
I have also tried Debian and Ubuntu and both support booting and mounting with uuid and label.
tuxpocket wrote:
the bad news is the busybox, which needs to mount the root file system, does not.
So I see where the problem is.
tuxpocket wrote:
The good news is that dumpe2fs -h /dev/foo will tell you the UUID of the disk you want to put in your init or menu.lst
I found that this command will only generate UUID for ext2/3 USB devices. Instead I use the command "blkid" or "/lib/udev/vol_id".
tuxpocket wrote:
Argh! how is this supposed to work?
I noticed that when Ubuntu boots up, in the init ram disk, there is the folder /dev/disk/by-uuid/ which is missing in the eeepc init ram filesystem.
Also, when I unpack the initrd.gz of Ubuntu, I found that they have no /dev, but it is rather created by udev. There are the udev files in /sbin and /lib/udev of initrd. So I think the difference is that in eeepc, the udev files resides in the root partition, whereas in Ubuntu, they pack them into the initrd.
This weekend, I will also compare the kernel .config files of Ubuntu and eeepc to check if anything is missing in the kernel.
Offline
I think you are right the udev is probably the answer.
Incidentally, how did you get into your ubuntu initrd image? I haven't figures out the right combination of unzipping and loop mounting or cpio extracting to do so yet.
I do have one other idea for a quick fix: the file /proc/partitions lists the size of each partition. We could use sed to extract the /dev/sd?? name from that, much as the default extracts it from the kernel command line, by looking for the known size of the partition we want to mount (ordinarily I'd use grep -o but this busybox configuration doesn't seem to support that option)
Of course this won't work if you have multiple partitions of the same size, such as my flash stick containing a dd copy of the internal SSD...
Another good menu choice might be to ask the user what partition to mount after they see the usb detection, with the option of retrying if that one doesn't work.
Last edited by tuxpocket (2007-12-15 2:33:52 pm)
Offline
Well I haven't gotten mounting by UUID to work, but I did finally get mounting by volume name to work, after hours of hacking with sed
it now takes parameters of the form
root=label:VOLUMELABEL
or the traditional
root=/dev/sdb1
Here is my init
#!/bin/sh
mount -t proc proc /proc
#load usb modules - this won't work unless you have
#copied them into the image
echo loading usb modules
insmod -f /modules/usbcore.ko
insmod -f /modules/ehci-hcd.ko
insmod -f /modules/uhci-hcd.ko
insmod -f /modules/libusual.ko
insmod -f /modules/usb-storage.ko
echo press any key when usb is done loading
read dummyvariable
if [ -n "$XANDROSBOOTDEBUG" ]; then
/bin/busybox sh
set -x
fi
ROOT=`cat /proc/cmdline | sed 's/.*root=// ; s/ .*//'`
echo seeking $ROOT
DESIRED=`echo $ROOT | sed -n 's/label\://p'`
if [ -n "$DESIRED" ] ; then
ROOT=
echo searching for volume with label $DESIRED
PARTS=`cat /proc/partitions | sed -n 's/.*sd/\/dev\/sd/p' | grep 'sd[a-z][1-9]'`
echo searchin in $PARTS
for i in $PARTS ; do
TEST=`dd if=$i bs=8 count=2 skip=143 2>/dev/null | \
sed -n "/^$DESIRED[^A-Za-z]*"'$/p'`
echo answer $TEST
if [ -n "$TEST" ] ; then
ROOT=$i
echo match $ROOT
# break
fi
done
else
echo mount parition from command line is $ROOT
fi
echo mount -t ext2 -o rw $ROOT /mnt
mount -t ext2 -o rw $ROOT /mnt
if [ $? -ne 0 ] ; then
echo Could not mount OS on $ROOT. Starting debugging shell....
/bin/busybox sh
fi
umount /proc
if [ -n "$INIT" ]; then
if [ -n "$XANDROSBOOTDEBUG" ]; then
exec switch_root /mnt $INIT </mnt/dev/console >/mnt/dev/console
else
exec switch_root /mnt $INIT </mnt/dev/null >/mnt/dev/null
fi
else
exec switch_root /mnt /sbin/fastinit "$@" </mnt/dev/console >/mnt/dev/console
fi
echo
echo Init Failed. Starting emergency shell....
/bin/busybox sh/boot/grub/menu.list needs an option like this:
title Experimental USB HDD boot root=label:USBSYSTEM
root (0x80,0)
kernel /boot/vmlinuz-2.6.21.4-eeepc rw vga=785 irqpoll i8042.noloop=1 root=label:USBSYSTEM
initrd /boot/initramfs-new.imgwhere initframfs-new.img is what I called my modified image (on real magnetic hard drive, I can keep a spare around since I am not short of space)
Last edited by tuxpocket (2007-12-15 7:24:56 pm)
Offline
tuxpocket wrote:
Incidentally, how did you get into your ubuntu initrd image? I haven't figures out the right combination of unzipping and loop mounting or cpio extracting to do so yet.
gunzip -c initrd.gz | cpio -i
tuxpocket wrote:
Another good menu choice might be to ask the user what partition to mount after they see the usb detection, with the option of retrying if that one doesn't work.
This option is not possible unless you have the USB drivers compiled into the kernel because you have the grub menu before USB drivers are loaded by initramfs.img
The ubuntu way of initrd is like this:
for x in $(cat /proc/cmdline); do
case $x in
init=*)
init=${x#init=}
;;
root=*)
ROOT=${x#root=}
case $ROOT in
LABEL=*)
ROOT="/dev/disk/by-label/${ROOT#LABEL=}"
;;
UUID=*)
ROOT="/dev/disk/by-uuid/${ROOT#UUID=}"
;;
esac
;;But we'll need to get udev working first.
Offline
tuxpocket wrote:
Well I haven't gotten mounting by UUID to work, but I did finally get mounting by volume name to work, after hours of hacking with sed
it now takes parameters of the form
root=label:VOLUMELABEL
or the traditional
root=/dev/sdb1
Here is my init
...
tuxpocket
I see that your init does not mount as unionfs, which I want to preserve. So I have taken your init and modify it.
For the unionfs, we also need to seek and mount the USER partition, which is a bit tricky as there is no way for grub to pass this parameter to init. So I just have it declared as "USER_USB" inside init. I also have to do the same for both /sbin/scanuser.sh and /sbin/formatuser.sh.
So here is the modified init for unionfs:
#!/bin/sh
mount -t proc proc /proc
#load usb modules - this won't work unless you have
#copied them into the image
echo loading usb modules
insmod -f /modules/usbcore.ko
insmod -f /modules/ehci-hcd.ko
insmod -f /modules/uhci-hcd.ko
insmod -f /modules/libusual.ko
insmod -f /modules/usb-storage.ko
echo press any key when usb is done loading
read dummyvariable
if [ -n "$XANDROSBOOTDEBUG" ]; then
/bin/busybox sh
set -x
fi
ROOT=`cat /proc/cmdline | sed 's/.*root=// ; s/ .*//'`
echo seeking $ROOT
DESIRED=`echo $ROOT | sed -n 's/label\://p'`
if [ -n "$DESIRED" ] ; then
ROOT=
echo searching for volume with label $DESIRED
PARTS=`cat /proc/partitions | sed -n 's/.*sd/\/dev\/sd/p' | grep 'sd[a-z][1-9]'`
echo searching in $PARTS
for i in $PARTS ; do
TEST=`dd if=$i bs=8 count=2 skip=143 2>/dev/null | \
sed -n "/^$DESIRED[^A-Za-z]*"'$/p'`
echo answer $TEST
if [ -n "$TEST" ] ; then
ROOT=$i
echo match $ROOT
# break
fi
done
else
echo mount partition from command line is $ROOT
fi
echo mount -t ext2 -o ro $ROOT /mnt-system
mount -t ext2 -o ro $ROOT /mnt-system
if [ $? -ne 0 ] ; then
echo Could not mount OS on $ROOT. Starting debugging shell....
/bin/busybox sh
fi
if [ -n "$XANDROSSCAN" ]; then
exec switch_root /mnt-system /sbin/scanuser.sh
fi
if [ -n "$XANDROSRESTORE" ]; then
exec switch_root /mnt-system /sbin/formatuser.sh
fi
if [ -z "`grep nosplash /proc/cmdline`" ]; then
echo -n "[?25l"
cp /mnt-system/boot/startup.fb /dev/fb/0
fi
USERPART=
echo seeking USER partition
DESIREDUSERPART="USER_USB"
echo searching for volume with label $DESIREDUSERPART
PARTS=`cat /proc/partitions | sed -n 's/.*sd/\/dev\/sd/p' | grep 'sd[a-z][1-9]'`
echo searching in $PARTS
for i in $PARTS ; do
TESTUSERPART=`dd if=$i bs=8 count=2 skip=143 2>/dev/null | \
sed -n "/^$DESIREDUSERPART[^A-Za-z]*"'$/p'`
echo answer $TESTUSERPART
if [ -n "$TESTUSERPART" ] ; then
USERPART=$i
echo match $USERPART
# break
fi
done
echo mount USER partition from command line is $USERPART
if ! mount -t ext3 -o rw $USERPART /mnt-user; then
echo Error mounting user partition. Must run filesystem scan!
# export USERPART
exec switch_root /mnt-system /sbin/scanuser.sh
fi
# Factory auto-format functionality
if [ -f /mnt-user/.autoformat ]; then
umount /mnt-user
exec switch_root /mnt-system /sbin/formatuser.sh -- --auto
fi
#insmod /mnt-system/lib/modules/$VERSION/kernel/fs/unionfs/unionfs.ko > /dev/null
mount -t unionfs -o dirs=/mnt-user=rw:/mnt-system=ro unionfs /mnt
if [ $? -ne 0 ]; then
echo Could not mount unionfs. Starting debugging shell....
/bin/busybox sh
fi
mount --move /mnt-system /mnt/mnt
umount -l /mnt-user
umount /proc
if [ -n "$INIT" ]; then
if [ -n "$XANDROSBOOTDEBUG" ]; then
exec switch_root /mnt $INIT </mnt/dev/console >/mnt/dev/console
else
exec switch_root /mnt $INIT </mnt/dev/null >/mnt/dev/null
fi
else
exec switch_root /mnt /sbin/fastinit "$@" </mnt/dev/console >/mnt/dev/console
fi
echo
echo Init Failed. Starting emergency shell....
/bin/busybox shOffline
Good addition. I had removed the unionfs when I installed a complete system on a magnetic usb hd, though I still have it on the almost stock internal SSD install (which I need when I mess up the usb hd init scripts!) . I had assumed I could put additional options on the command line to specify a user partition - even if they aren't formally recognized I would assume they could still be extracted from /proc/commandline but maybe not.
When I was speaking of offering the user a menu, I meant a menu in the init script, not in grub.
The having to press return after the usb loads needs improvement. I think there is often a usb scan complete type entry that we could grep dmesg for in a loop with a 1 second sleep between checks. I know some people just put a fixed sleep in, but I figure there will be a day when it takes longer and my system won't boot. May just compile in the usb modules to solve that problem for good.
Getting udev going may be the better long range solution. But if I get this script cleaned up a little more, I think I may put it on the SSD so I can use that grub all the time even if I am going to boot linux off the external drive.
Last edited by tuxpocket (2007-12-16 2:05:39 am)
Offline
tuxpocket wrote:
but I figure there will be a day when it takes longer and my system won't boot.
You are right. I found that it boots up much faster from the built-in card slot compared with an external SD card reader, and probably there will be speed difference with different card readers and on different desktop pcs. But so far it is working good with SLEEP 6 with my old init.
Offline
I think we can do a loop something like this:
#WARNING UNTESTED CODE
while [ -z `dmesg | grep 'usb-storage: device scan complete'` ] ; do
sleep .5
doneBut I'd like to find a way for the user to interrupt the loop and go to busybox if
it fails.
On another topic, I think there would be a way to launch bash instead of /sbin/init to get a single user console mode with real tools, but I haven't made it work yet.
Last edited by tuxpocket (2007-12-16 12:45:40 pm)
Offline
Regarding indentifying which USB device is which, in my backup system I get a device list from /proc/partitions and then look in /sys/block/$disk/device to get some information about it, where $disk is for example "sdb". I've read that the specific structure under /sys is not nailed down, but if you know which kernel is running it should be fine to access it. You can pick out e.g. vendor and model, which is good enough to let the user know which card it is.
For something stronger, most USB devices have unique serial numbers, so you can look those up too. I haven't found a tidy way to do it, but if you look at the "device" symlink itself you can tell what USB bus and target the device is using; then look in /proc/bus/usb/devices for the section with the right Bus and Dev#, and see if it lists a SerialNumber. If it does, I think it should be unique, so you could stamp it into your initrd when you create it and check for the device with a matching serial number on bootup.
I don't think this would work for SD cards though, as what you see on the USB bus is the cardreader, not the card itself. There may be some kind of serial number in the cards themselves but I doubt it. Your system of using volume labels is probably sufficient anyway, if the hard-coded offset is reliable.
Incidentally, it looks like Knoppix (or at least the version DSL is based on) just looks for any device with a KNOPPIX directory in its root - brute force and low tech, but it might be better than peeking into the partition without mounting it.
Offline
I have finally come up with a init that can sleep 1 sec and loop scan for USB partitions according to their volume label (which is passed as kernel parameters from grub to init), while still preserving the union filesystem, and retaining all the F9 options to "Perform Disk Scan", "Rescue Console" and "Restore Factory Settings", etc. in the original init.
Basically this init is achieved by combining the best of the volume label seeking method by tuxpocket and the init of the overlay filesystem method by Russell as per this thread. For this, we have to express our gratitude to both of them.
Here is my init, grub menu.lst, scanuser.sh and formatuser.sh:
init
#!/bin/sh
mount -t proc proc /proc
ROOTLABEL=`cat /proc/cmdline | sed 's/.*root=label:// ; s/ .*//'`
USERLABEL=`cat /proc/cmdline | sed 's/.*USERLABEL:// ; s/ .*//'`
#VERSION=`cat /proc/version | cut -f3 -d" "`
ROOT=
USERPART=
#load usb modules
insmod -f /modules/usbcore.ko > /dev/null
insmod -f /modules/ehci-hcd.ko > /dev/null
insmod -f /modules/uhci-hcd.ko > /dev/null
insmod -f /modules/libusual.ko > /dev/null
insmod -f /modules/usb-storage.ko > /dev/null
if [ -n "$XANDROSBOOTDEBUG" ]; then
/bin/busybox sh
set -x
fi
# loop scan $ROOTLABEL in USB partitions
echo loop scan USB partition label:$ROOTLABEL
while
[ -z "$ROOT" ]
do
PARTS=`cat /proc/partitions | sed -n 's/.*sd/\/dev\/sd/p' | grep 'sd[a-z]'`
for i in $PARTS ; do
TEST=`dd if=$i bs=4 count=4 skip=286 2>/dev/null | \
sed -n "/^$ROOTLABEL[^A-Za-z]*"'$/p'`
if [ -n "$TEST" ] ; then
ROOT=$i
fi
done
sleep 1
done
echo mounting "$ROOT" as root partition
mount -t ext2 -o ro $ROOT /mnt-system
if [ $? -ne 0 ] ; then
echo Could not mount OS on $ROOT. Starting debugging shell....
/bin/busybox sh
fi
#mount USER partition in RAM disk
if [ $USERLABEL = "RAM" ]; then
mount -t tmpfs tmpfs /mnt-user
retval=$?
if [ $retval -ne 0 ]; then
echo Error mounting user partition in RAM disk.
echo Starting debugging shell....
/bin/busybox sh
fi
else
# loop scan $USERLABEL in USB partitions
echo loop scan USB partition label:$USERLABEL
while
[ -z "$USERPART" ]
do
PARTS=`cat /proc/partitions | sed -n 's/.*sd/\/dev\/sd/p' | grep 'sd[a-z]'`
for j in $PARTS ; do
TEST=`dd if=$j bs=4 count=4 skip=286 2>/dev/null | \
sed -n "/^$USERLABEL[^A-Za-z]*"'$/p'`
if [ -n "$TEST" ] ; then
USERPART=$j
fi
done
sleep 1
done
if [ -n "$XANDROSSCAN" ]; then
exec switch_root /mnt-system /sbin/scanuser.sh
fi
if [ -n "$XANDROSRESTORE" ]; then
exec switch_root /mnt-system /sbin/formatuser.sh
fi
if [ -z "`grep nosplash /proc/cmdline`" ]; then
echo -n "[?25l"
cp /mnt-system/boot/startup.fb /dev/fb/0
fi
mount -t ext3 -o rw,noatime,nodiratime $USERPART /mnt-user
retval=$?
if [ $retval -ne 0 ]; then
echo 'Error mounting user partition. Must run filesystem scan!'
exec switch_root /mnt-system /sbin/scanuser.sh
fi
# Factory auto-format functionality
if [ -f /mnt-user/.autoformat ]; then
umount /mnt-user
exec switch_root /mnt-system /sbin/formatuser.sh -- --auto
fi
fi
mount -t unionfs -o dirs=/mnt-user=rw:/mnt-system=ro unionfs /mnt
if [ $? -ne 0 ]; then
echo Could not mount unionfs. Starting debugging shell....
/bin/busybox sh
fi
mount --move /mnt-system /mnt/mnt
umount -l /mnt-user
umount /proc
if [ -n "$INIT" ]; then
if [ -n "$XANDROSBOOTDEBUG" ]; then
exec switch_root /mnt $INIT </mnt/dev/console >/mnt/dev/console
else
exec switch_root /mnt $INIT </mnt/dev/null >/mnt/dev/null
fi
else
exec switch_root /mnt /sbin/fastinit "$@" </mnt/dev/console >/mnt/dev/console
fi
echo
echo Init Failed. Starting emergency shell....
/bin/busybox sh/boot/grub/menu.lst
#
# Configured by Xandros Configuration system.
#
hiddenmenu
# default boot entry
default=0
# Boot automatically after 1 second.
timeout=0
# Fallback to Configure.
fallback=2
title Normal Boot (label:SYSTEM_USB / USER_USB)
root (hd0,0)
kernel /boot/vmlinuz-2.6.21.4-eeepc quiet rw vga=785 irqpoll root=label:SYSTEM_USB USERLABEL:USER_USB
initrd /boot/initramfs-usblabel-eeepc.img
title Perform Disk Scan (label:SYSTEM_USB / USER_USB)
root (hd0,0)
kernel /boot/vmlinuz-2.6.21.4-eeepc quiet rw vga=785 irqpoll USERLABEL:USER_USB root=label:SYSTEM_USB XANDROSSCAN=y
initrd /boot/initramfs-usblabel-eeepc.img
title Rescue Console
root (hd0,0)
kernel /boot/vmlinuz-2.6.21.4-eeepc quiet rw vga=785 irqpoll i8042.noloop=1 USERLABEL:USER_USB root=label:SYSTEM_USB XANDROSBOOTDEBUG=y
initrd /boot/initramfs-usblabel-eeepc.img
title Restore Factory Settings (label:SYSTEM_USB / USER_USB)
root (hd0,0)
kernel /boot/vmlinuz-2.6.21.4-eeepc quiet rw vga=normal nosplash=y irqpoll USERLABEL:USER_USB root=label:SYSTEM_USB XANDROSRESTORE=y
initrd /boot/initramfs-usblabel-eeepc.img
title Boot to RAM disk (label:SYSTEM_USB / RAM)
root (hd0,0)
kernel /boot/vmlinuz-2.6.21.4-eeepc quiet rw vga=785 irqpoll root=label:SYSTEM_USB USERLABEL:RAM
initrd /boot/initramfs-usblabel-eeepc.img/sbin/scanuser.sh
#!/bin/sh
clear
echo "Scanning user partition, please wait..."
mount -tproc proc /proc
USERLABEL=`cat /proc/cmdline | sed 's/.*USERLABEL:// ; s/ .*//'`
USERPART=
echo seeking volume with label $USERLABEL
PARTS=`cat /proc/partitions | sed -n 's/.*sd/\/dev\/sd/p' | grep 'sd[a-z]'`
echo searching in $PARTS
for i in $PARTS ; do
TEST=`dd if=$i bs=4 count=4 skip=286 2>/dev/null | \
sed -n "/^$USERLABEL[^A-Za-z]*"'$/p'`
# echo answer $TEST
if [ -n "$TEST" ] ; then
USERPART=$i
echo match in $USERPART
fi
done
/sbin/fsck -C -f -y -text3 $USERPART
/sbin/tune2fs -j $USERPART
umount /proc
echo
echo "Press <ENTER> to reboot..."
read
/sbin/busybox.asus reboot -f/sbin/formatuser.sh
#!/bin/sh
clear
[ "$1" = "--auto" ] && AUTO=true
mount -tproc proc /proc
USERLABEL=`cat /proc/cmdline | sed 's/.*USERLABEL:// ; s/ .*//'`
USERPART=
echo seeking volume with label $USERLABEL
PARTS=`cat /proc/partitions | sed -n 's/.*sd/\/dev\/sd/p' | grep 'sd[a-z]'`
echo searching in $PARTS
for i in $PARTS ; do
TEST=`dd if=$i bs=4 count=4 skip=286 2>/dev/null | \
sed -n "/^$USERLABEL[^A-Za-z]*"'$/p'`
# echo answer $TEST
if [ -n "$TEST" ] ; then
USERPART=$i
echo match in $USERPART
fi
done
echo You are about to restore this unit to factory settings.
echo All user data will be lost!
echo format USER partition label:$USERLABEL $USERPART
echo Are you sure?
echo -n "Enter 'yes' to continue: "
read INPUT
if [ "$INPUT" != "yes" ]; then
if [ -n $AUTO ]; then
mount $USERPART /mnt
rm -f /mnt/.autoformat
umount /mnt
umount /proc
fi
/sbin/busybox.asus reboot -f
fi
echo -n "Formatting user partition, please wait... "
mount -tproc proc /proc
/sbin/mkfs.ext3 -q -L $USERLABEL $USERPART
echo "done!"
echo
if [ -z $AUTO ]; then
umount /proc
echo "Press <ENTER> to reboot..."
read
/sbin/busybox.asus reboot -f
else
echo "Press <ENTER> to shutdown..."
read
echo 5 > /proc/acpi/sleep
fiActually, I am thinking we should be able to make scanuser.sh and formatuser.sh simpler by passing arguments from init. This I will look into later.
Finally, the SYSTEM and USER partition do not need to be on the same disk. For example, if you give a root label:SYSTEM, and user label:USER in grub menu.lst, this will just mount the original Xandros in the SSD!
Also, I have added the F9 option to mount the unionfs in RAM disk. This will be useful for doing backup and repair, etc on the USER partition.
Last edited by albkwan (2008-01-11 8:41:12 pm)
Offline
Good work.
Last edited by tuxpocket (2008-01-11 11:34:19 am)
Offline
I've added it as enhancements to the wiki. http://wiki.eeeuser.com/xandrosbootfromusb
Offline
instead of this dd | hexdump stuff for finding partitions by fs UUID, it's actually really easy to call the full glibc dumpe2fs/mount binaries if you've got the base OS image already mounted - you just need to provide enough of the glibc runtime for the programs to link themselves. all it takes is a /lib in your initramfs that contains symlinks to a handful of files under /mnt-system/lib/ and they all just work.
if you take a look at the initramfs at http://slofith.org/projects/eeepc/initramfs you'll see I'm using /mnt-system/sbin/cryptsetup to do encrypted overlay, but the same works for any executable. ld-linux.so.2 and libc.so.6 are the required base, and you can run "ldd /sbin/whatever" to see what libraries any specific utility needs (ignore "linux-gate.so.1" though, it's kernel internal)
Last edited by russm (2008-01-11 11:48:12 pm)
Offline
Yep you can, already doing this with my project. Needed blkid, and most of what I'm writing is in C (for speed, flexibility) rather then bash, so I needed the libs.
A side note dd hexdump is fine for ext filesystems, but its a pain for fat which stores its (tiny) uuid chars in reverse. Course then again you could also just have it match the reverse.
Offline
Russell,
What library we need to run chmod in the initramfs? I have tried to create .firstrundone as per your init but the system is complaining command chown not found.
albkwan
Offline
I spent quite a while trying to figure out how to recompile busybox with a mount command that understood UUID's. Linking to something on the disk is an idea, but it only work if you know you have a partition available in a given place.
Yes, that dd incantation is limited to ext2/3. But then it's looking for a linux system volume, and that's unlikely to still be minix or xfs, so... (well it could be reiserfs I guess)
If someone can come up with a cleaner means of detecting the desired partition using only built in tools, or a *small* stand alone executable I'm all ears. Even getting that version of busybox to run an external executable was proving quite troublesome though... tried setting up uclibc... ironically some of these things are easier to get going on non-x86 embedded linux platforms.
Last edited by tuxpocket (2008-01-12 12:29:43 am)
Offline
chown only requires ld-linux and libc. if you're seeing "sh: /mnt-system/bin/chown: not found" it means that ld-linux wasn't found, which is the first part of loading the executable. if this is the case then the /lib in your initramfs isn't right - this is what mine looks like when unpacked
russm@nestor:/var/local/md1/russm/software/EeePC/initramfs/unpacked$ ls -lF total 44 drwxr-xr-x 2 russm russm 4096 2008-01-12 15:32 bin/ drwxr-xr-x 3 russm russm 4096 2008-01-12 15:32 dev/ drwxr-xr-x 2 russm russm 4096 2008-01-12 15:32 etc/ -rwxr-xr-x 1 russm russm 2555 2008-01-12 15:32 init* drwxr-xr-x 2 russm russm 4096 2008-01-12 15:32 lib/ drwxr-xr-x 2 russm russm 4096 2008-01-12 15:32 mnt/ drwxr-xr-x 2 russm russm 4096 2008-01-12 15:32 mnt-system/ drwxr-xr-x 2 russm russm 4096 2008-01-12 15:32 mnt-user/ drwxr-xr-x 2 russm russm 4096 2008-01-12 15:32 modules/ drwxr-xr-x 2 russm russm 4096 2008-01-12 15:32 proc/ drwxr-xr-x 2 russm russm 4096 2008-01-12 15:32 sys/ russm@nestor:/var/local/md1/russm/software/EeePC/initramfs/unpacked$ ls -lF lib/ total 0 lrwxrwxrwx 1 russm russm 29 2008-01-12 15:32 ld-linux.so.2 -> /mnt-system/lib/ld-linux.so.2 lrwxrwxrwx 1 russm russm 25 2008-01-12 15:32 libc.so.6 -> /mnt-system/lib/libc.so.6 lrwxrwxrwx 1 russm russm 36 2008-01-12 15:32 libdevmapper.so.1.02 -> /mnt-system/lib/libdevmapper.so.1.02 lrwxrwxrwx 1 russm russm 26 2008-01-12 15:32 libdl.so.2 -> /mnt-system/lib/libdl.so.2 lrwxrwxrwx 1 russm russm 28 2008-01-12 15:32 libpopt.so.0 -> /mnt-system/lib/libpopt.so.0 lrwxrwxrwx 1 russm russm 31 2008-01-12 15:32 libselinux.so.1 -> /mnt-system/lib/libselinux.so.1 lrwxrwxrwx 1 russm russm 29 2008-01-12 15:32 libsepol.so.1 -> /mnt-system/lib/libsepol.so.1 lrwxrwxrwx 1 russm russm 28 2008-01-12 15:32 libuuid.so.1 -> /mnt-system/lib/libuuid.so.1 russm@nestor:/var/local/md1/russm/software/EeePC/initramfs/unpacked$
if you're getting "error while loading shared libraries" and "cannot open shared object file" then the glibc runtime is at least minimally working and you just need to link whatever library it's complaining about into the initramfs's /lib directory.
Offline
How small you need? I can get the regular mount and blkid working in an image thats about a meg large.
Offline
The compressed original is 250k, with the usb modules that goes to 360k.
Sure, a little bigger won't hurt to much. But I found it easier to put an obscure incantation in a text file to make use of capabilities already included, than to mess around with getting just the right libraries.
Last edited by tuxpocket (2008-01-12 1:03:58 am)
Offline
hmmmm
Have you tried
ln -s /mnt-system/lib /lib (after mounting system first of course)
Then using the system mount from "/mnt-system/bin/mount"
Offline
Qatz wrote:
hmmmm
Have you tried
ln -s /mnt-system/lib /lib (after mounting system first of course)
No, because the purpose of this is to identify what should be mounted on /mnt-system... /dev/sda1 may contain xandros, or eexbuntu, or some distro with incompatible library versions, or even win xp
Last edited by tuxpocket (2008-01-12 1:05:57 am)
Offline
Oh sorry thought you were mounting user
Offline
It's been extended to do that too, but the original idea was so that an installation on a USB stick who's initramfs has been loaded by grub/bios can locate itself again using the linux kernel usb drivers and thus bring up the full system.
Offline