Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[INITRAMFS] mount ?? - ARM, hardened musl, /usr (SOLVED)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo on ARM
View previous topic :: View next topic  
Author Message
Mr. T.
Guru
Guru


Joined: 26 Dec 2016
Posts: 477

PostPosted: Tue Jun 13, 2017 11:52 am    Post subject: [INITRAMFS] mount ?? - ARM, hardened musl, /usr (SOLVED) Reply with quote

I can not boot the RPi 2 with the initramfs. My configuration is characterized by the musl library with the hardened profile on an ARM board.

The expected result would be that the initramfs mount the root filesystem and then other file systems like usr, var, tmp, home, etc.

A message displayed said that the root filesystem is located on an unrecognized device. This is surprising because the commands that are manually executed
in the shell of BusyBox make it possible to boot Gentoo. So, I believe it is a bug.

Could you help me to solve the issue, please?


Last edited by Mr. T. on Thu Jun 15, 2017 7:41 pm; edited 2 times in total
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


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

PostPosted: Tue Jun 13, 2017 5:26 pm    Post subject: Reply with quote

helecho,

Fom your Pi install
Put your kernel .config on a pastebin site and post a link.
Post your /boot/cmdline.txt.
Post your /boot/config.txt.

Post the output of
Code:
ls -l /boot


What is the text of the panic message. The numbers in Unknown-block(x,y) are very important, if that the message you get.

Explain how you made your kernel and initrd.

-- edit --

Wild guess ... you need to add rootwait to /boot/cmdline.txt
_________________
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
Mr. T.
Guru
Guru


Joined: 26 Dec 2016
Posts: 477

PostPosted: Wed Jun 14, 2017 8:30 am    Post subject: Reply with quote

NeddySeagoon wrote:
What is the text of the panic message. The numbers in Unknown-block(x,y) are very important, if that the message you get.

I had a confusion between two error messages that look alike. I believe the error message is related to the mount command but I do not remember exactly the error message.
I think the error message was "unable to mount /dev/... on /mnt/root: no such file or directory".

I'm trying to reproduce the error message but I have an issue to create a new initramfs. The old initramfs is not erased and replaced by the new one.
Here are the configuration files:

.config (linux)

/boot/config.txt:
max_usb_current=1
boot_delay=5

/boot/cmdline.txt:
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p3 rootfstype=ext4 elevator=deadline fsck.repair=yes rootdelay=10

/etc/fstab:
/dev/mmcblk0p1            /boot              vfat           defaults     1 2
/dev/mmcblk0p2            none               swap           sw           0 0
/dev/mmcblk0p3            /                  ext4           defaults     0 1
# extended partition begins here:
/dev/mmcblk0p5            /usr               ext4           defaults     0 3
/dev/mmcblk0p6            /var               ext4           defaults     0 3
/dev/mmcblk0p7            /tmp               ext4           defaults     0 3
/dev/mmcblk0p8            /home              ext4           defaults     0 3
/dev/mmcblk0p9            /srv               ext4           defaults     0 3
/dev/mmcblk0p10           /usr/portage       ext4           defaults     0 3

/usr/src/linux/initramfs/init:
#!/bin/busybox sh

rescue_shell() {
    echo "Something went wrong. Dropping to a shell."
    exec sh
}

# Mount the /proc, /sys and /dev filesystems.
mount -t proc none /proc
mount -t sysfs none /sys
mount -t devtmpfs none /dev

# Do your stuff here.
echo "This script just mounts rootfs and usrfs, nothing else!"

# Mount the root filesystem.
mount -o ro /dev/mmcblk0p3 /mnt/root || rescue_shell

# Mount the usr filesystem.
mount -o rw /dev/mmcblk0p5 /mnt/root/usr || rescue_shell

# Clean up.
umount /proc
umount /sys
umount /dev

# Boot the real thing.
exec switch_root /mnt/root /sbin/init

/usr/src/linux/initramfs/initramfs_list:
# Files and directories included in the initramfs

dir /bin      755 0 0
dir /dev      755 0 0
dir /lib      755 0 0
dir /proc     755 0 0
dir /sys      755 0 0
dir /usr      755 0 0

dir /mnt           755 0 0
dir /mnt/root      755 0 0

nod /dev/console   644 0 0 c 5 1
nod /dev/null      666 0 0 c 1 3
nod /dev/ptmx      666 0 0 c 5 2
nod /dev/tty       666 0 0 c 5 0

sock /dev/log      666 0 0

file /bin/busybox   /bin/busybox             755 0 0
file /init          /usr/src/initramfs/init  755 0 0


NeddySeagoon, thank you for the help provided! :)

edit: moved the nodes (in the file) below the directories in the specification file used to create the initramfs.


Last edited by Mr. T. on Thu Jun 15, 2017 3:21 pm; edited 1 time in total
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


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

PostPosted: Wed Jun 14, 2017 9:10 am    Post subject: Reply with quote

helecho,

Lets add some diagnostics to your initrd.
Code:
rescue_shell() {
    echo "$@"
    echo "Something went wrong. Dropping you to a shell."
# have time to read the message
    /bin/sleep 20
    /bin/busybox --install -s
    exec /bin/sh

}

The echo "$@" prints a message, so you can tell where it went wrong.
The /bin/busybox --install -s writes all the symlinks, so you don't need to.

Now you can write
Code:
# Mount the root filesystem.
mount -o ro /dev/mmcblk0p3 /mnt/root || rescue_shell "Failed to Mount Root"

# Mount the usr filesystem.
mount -o rw /dev/mmcblk0p5 /mnt/root/usr || rescue_shell "Failed to Mount /usr"


Your initrd does not set PATH. I'm not sure if that matters in your use case.
If it does matter, mount will fail.
Either set the PATH environment variable
Code:
PATH=/sbin:/bin
export PATH
and whatever else you may need, or use full pant names to the commands you call.

Once /usr is mounted in the initrd, its not possible to have the boot process run fsck on it.
That needs to be done in the initrd before /usr is mounted.

Your
Code:
mount -o rw /dev/mmcblk0p5 /mnt/root/usr
will fail as you don't create /mnt/root/usr before you try to use it.
It should be added to initramfs_list.
Maybe that's all thats wrong?
_________________
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
Mr. T.
Guru
Guru


Joined: 26 Dec 2016
Posts: 477

PostPosted: Thu Jun 15, 2017 7:08 am    Post subject: Reply with quote

I had to make the initramfs several times because of errors (cf. note 1) (and because my method (cf. note 2) is not effective). :(

I manually write what was displayed on the screen during startup.

boot screen:
[ .........] [vc_sm_connected_init]: start
[ .........] [vc_sm_connected_init]: end - returning 0
[ .........] 3f201000.serial: ttyAMA0 at MMIO 0x3f201000 (irq = 87, base_baud = 0) is a PL011 rev 2
[ .........] console [ttyAMA0] enabled
[ .........] sdhost: lag_buf @ ba9130000 (fa9130000)
[ .........] Indeed it is in host mod hprt0 = 0021501
[ .........] mmc0: sdhost-bcm2835 loaded - DMA enabled (>1)
[ .........] random: fast init done
[ .........] of_cfs_init
[ .........] of_cfs_init: OK
[ .........] Freeing unused kernel memory: 2048K
mount: /etc/mtab: No such file or directory
mount: /etc/mtab: No such file or directory
mount: /etc/mtab: No such file or directory
This script just mounts rootfs and usrfs, nothing else!
mount: mounting /dev/mmcblk0p3 on /mnt/root failed: No such file or directory
Failed to mount Root!
Something went wrong. Dropping you to a shell.
[ .........] usb 1-1: new high speed USB device number 2 using dwc_otg
[ .........] Indeed it is in host mode hprt0 = 00001101
[ .........] mmc0: host does not support reading read-only switch, assuming write-enabled
[ .........] mmc0: new high speed SDHC card at address aaaa
[ .........] mmcblk0: mmc0:aaaa SE32G 29.7 GiB
[ .........]   mmblk0: p1 p2 p3 p4 <p5 p6 p7 p8 p9 p10>
[ .........] usb 1-1: New USB device found, idVendor=0424, idProduct=9514
[ .........] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ .........] hub 1-1:1.0 USB found
[ .........] hub 1-1:1.0 5 ports detected
[ .........] usb 1-1.1: new high-speed USB device number 3 using dwc_otg
[ .........] usb 1-1.1: New USB device found, idVendor=0424, idProduct=ec00
[ .........] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ .........] smsc95xx v1.0.5
[ .........] smsc95xx 1-1.1:1.0 eth0: register 'smsc95xx' at usb-3f980000 usb-1.1, smsc95xx USB 2.0 Ethernet, b8:27:eb:2c:c1:50
sh can't acess tty; job control turned off
/# [ .........] usb 1-1.4: new low-speed USB device number 4 using dwc_otg
[ .........] usb 1-1.4: New USB device found, idVendor=0461, idProduct=0010
[ .........] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ .........] Product: USB Keyboard
[ .........] Manufacturer: NOVATEK
[ .........] input: NOVATEK USB Keyboard as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/0003:0461:0010.0001/input/input0
[ .........] hid-generic 003:0461:0010.0001: input,hidraw0: USB HID v1.10 Keyboard [NOVATEK USB Keyboard] on usb-3f980000.usb-1.4/input0
[ .........] input: NOVATEK USB Keyboard as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/0003:0461:0010.0001/input/input1
[ .........] hid-generic 003:0461:0010.0002: input,hidraw0: USB HID v1.10 Keyboard [NOVATEK USB Keyboard] on usb-3f980000.usb-1.4/input1



  1. I believe the file used to generate the initramfs was wrong: I wrote the dev nodes before specifying the "dev" directory. I got the error: "Warning: unable to open an initial console".
  2. The method is not efficient. I create, compress and decompress various archives several times because of the partitionning scheme.


There are some things I need to think about but I am making progress through this thread.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


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

PostPosted: Thu Jun 15, 2017 9:49 am    Post subject: Reply with quote

helecho,

Some random comments
Code:
[ .........] 3f201000.serial: ttyAMA0 at MMIO 0x3f201000 (irq = 87, base_baud = 0) is a PL011 rev 2
[ .........] console [ttyAMA0] enabled

This will stop bluetooth from working as it gets attached to /dev/ttyAMA0 but if you have a 3.3v USB/serial adapter, you can capture the console on your PC.
If you try to use a 5v USB/serial adapter, you will destroy the Pi. With a 4 wire adapter, only connect 0v, Tx and Rx. Do not connect the power.

Code:
mount: /etc/mtab: No such file or directory
mount: /etc/mtab: No such file or directory
mount: /etc/mtab: No such file or directory
is harmless. This suggests that the initrd is mounted as root and its trying to mount other things but wants to check mtab to make sure that they are not mounted.
To get rid of this message add the symlnk
Code:
/etc/mtab -> /proc/self/mounts
to the initrd.

...Hmm and ...
You have 3 messages and 3 mounts
Code:
# Mount the /proc, /sys and /dev filesystems.
mount -t proc none /proc
mount -t sysfs none /sys
mount -t devtmpfs none /dev

# Do your stuff here.
echo "This script just mounts rootfs and usrfs, nothing else!"

before your echo.

That might mean that /bin/mount is not found.

Code:
# Files and directories included in the initramfs

nod /dev/console   644 0 0 c 5 1
nod /dev/null      666 0 0 c 1 3
nod /dev/ptmx      666 0 0 c 5 2
nod /dev/tty       666 0 0 c 5 0


Does not include.
Code:
/dev/mmcblk0p3
/dev/mmcblk0p5
but your kernel has
Code:
CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y
so that may not matter.

You can look around with the rescue shell, change things and execute the intit script one line at a time to find out what you need to do.
There is no need to remake the initrd every 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
Mr. T.
Guru
Guru


Joined: 26 Dec 2016
Posts: 477

PostPosted: Thu Jun 15, 2017 2:14 pm    Post subject: Reply with quote

NeddySeagoon, I created the symbolic link as you suggested and the messages with "mount" disappeared. I also removed the text "console=serial0,115200" in cmdline.txt because
I do not use a serial console.

I had not noticed that the shell was operational because of the text displayed after. Now, I use the shell and the modifications are less painful.
I can boot Gentoo by executing the commands manually within the shell. I notice a warning message when I unmount the "proc" filesystem: "/etc/mtab: no such file or directory",
however we can umount the filesystems.


I have no idea why the boot process does not work.
Back to top
View user's profile Send private message
Mr. T.
Guru
Guru


Joined: 26 Dec 2016
Posts: 477

PostPosted: Thu Jun 15, 2017 3:14 pm    Post subject: Reply with quote

I think I do not have the set of skills to solve the problem. I should try to make an initramfs without using BusyBox.

I hope that I will understand studying existing initramfs built "from scratch". I'm putting the thread on hold. Of course, suggestion, information or help is appreciated!
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


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

PostPosted: Thu Jun 15, 2017 4:52 pm    Post subject: Reply with quote

helecho,

When you unmount /proc, /etc/mtab goes away. Its a symlink into /proc.
mount tries to update /etc/mtab to remove /proc from the list of mounted filesystems, but its gone.
Its normal expected behaviour, so ignore that warning.

Thats you doing the mounts by hand.
dmesg:
[   70.115665] EXT4-fs (mmcblk0p3): couldn't mount as ext3 due to feature incompatibilities
[   70.117710] EXT4-fs (mmcblk0p3): couldn't mount as ext2 due to feature incompatibilities
[   70.131193] EXT4-fs (mmcblk0p3): mounted filesystem with ordered data mode. Opts: (null)
[   85.564116] EXT4-fs (mmcblk0p5): couldn't mount as ext3 due to feature incompatibilities
[   85.566130] EXT4-fs (mmcblk0p5): couldn't mount as ext2 due to feature incompatibilities
[   86.864041] EXT4-fs (mmcblk0p5): recovery complete
[   86.865316] EXT4-fs (mmcblk0p5): mounted filesystem with ordered data mode. Opts: (null)

The warnings can be suppressed by passing the -t ext4 option to mount.

Code:
# Mount the root filesystem.
mount -t ext4 -o ro /dev/mmcblk0p3 /mnt/root || rescue_shell

# Mount the usr filesystem.
mount -t ext4 -o rw /dev/mmcblk0p5 /mnt/root/usr || rescue_shell


In the case of /usr, providing an /etc/fstab in the initrd. It can be a symlink to the real fstab.
You can have the initrd init generate that.

Did you type the commands exactly as they are it the init file?
If so, the only difference between you giving the command and the script is one of timing.

What fails when the init script runs normally?
From dmesg, it looks like that /dev/mmcblk0p3 has not been provided by devtmpfs, so a sleep statement may be useful

Code:
mount -t devtmpfs none /dev

echo "Letting  devtmpfs do its thing ..."
sleep 3

# Do your stuff here.
echo "This script just mounts rootfs and usrfs, nothing else!"

# Mount the root filesystem.
mount -o ro /dev/mmcblk0p3 /mnt/root || rescue_shell

The 3 seconds is just a guess.
_________________
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
Mr. T.
Guru
Guru


Joined: 26 Dec 2016
Posts: 477

PostPosted: Thu Jun 15, 2017 7:40 pm    Post subject: Reply with quote

I worked on this issue during several weeks. Thank you so much for your help!

Indeed, the sleep statement "sleep 3" allows automatic detections of the devices.

helecho.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


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

PostPosted: Thu Jun 15, 2017 8:28 pm    Post subject: Reply with quote

helecho,

Code:
[    4.375359] EXT4-fs (mmcblk0p3): mounted filesystem with ordered data mode. Opts: (null)
[    5.545751] EXT4-fs (mmcblk0p5): recovery complete
[    5.555848] EXT4-fs (mmcblk0p5): mounted filesystem with ordered data mode. Opts: (null)


That's the messages about ext2 and ext3 gone now.

The
Code:
[    5.545751] EXT4-fs (mmcblk0p5): recovery complete
is a cause for concern.
The system is being shut down without /usr being cleanly unmounted.
The shutdown script should unmount everything it can and remount everything else read only.
All the other filesystems are OK, so its not a power failure shutdown.

You mount /usr read/write without doing any filesystem checks in the initrd.
Normally, localmount would do any required filesystem checks but for /usr, its too late. Its already mounted read/write.
_________________
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 Gentoo on ARM All times are GMT
Page 1 of 1

 
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