Jump to content

Initramfs/Inspecting: Difference between revisions

From postmarketOS Wiki
m use source_deviceinfo instead of sourcing /etc/deviceinfo directly
Susurrus (talk | contribs)
m Highlighting improvements and update <source> tags
Line 5: Line 5:
It is possible to enable a telnet daemon that gives you a shell this way:
It is possible to enable a telnet daemon that gives you a shell this way:


<source lang="shell-session">
<syntaxhighlight lang="shell-session">
$ pmbootstrap initfs hook_add debug-shell
$ pmbootstrap initfs hook_add debug-shell
$ pmbootstrap flasher flash_kernel # or however you flash/boot the kernel
$ pmbootstrap flasher flash_kernel # or however you flash/boot the kernel
Line 19: Line 19:
# pmos_continue_boot
# pmos_continue_boot
Connection closed by foreign host.
Connection closed by foreign host.
</source>
</syntaxhighlight>


If the telnet command does not work out of the box, read [[connect via USB Networking in the Initramfs]].
If the telnet command does not work out of the box, read [[connect via USB Networking in the Initramfs]].
Line 26: Line 26:


To enable functionality from initramfs-extra, run the following commands in the telnet shell:
To enable functionality from initramfs-extra, run the following commands in the telnet shell:
<source lang="shell-session">
<syntaxhighlight lang="shell-session">
# . /usr/share/misc/source_deviceinfo
# . /usr/share/misc/source_deviceinfo
# . /init_functions.sh
# . /init_functions.sh
Line 34: Line 34:
Extract /boot/initramfs-extra
Extract /boot/initramfs-extra
24128 blocks
24128 blocks
</source>
</syntaxhighlight>


In general, while inspecting the initramfs, you can execute commands in order listed in [https://gitlab.com/postmarketOS/pmaports/-/blob/master/main/postmarketos-initramfs/init.sh postmarketos-initramfs/init.sh], starting with the line <code>mount_boot_partition /boot</code> and below (everything above it was already executed before entering debug-shell).
In general, while inspecting the initramfs, you can execute commands in order listed in [https://gitlab.com/postmarketOS/pmaports/-/blob/master/main/postmarketos-initramfs/init.sh postmarketos-initramfs/init.sh], starting with the line <code>mount_boot_partition /boot</code> and below (everything above it was already executed before entering debug-shell).
Line 42: Line 42:


=== Deleting the debug shell ===
=== Deleting the debug shell ===
<source lang="shell-session">
<syntaxhighlight lang="text">
pmbootstrap initfs hook_del debug-shell
pmbootstrap initfs hook_del debug-shell
</source>
</syntaxhighlight>


=== Tips and tricks ===
=== Tips and tricks ===

Revision as of 17:45, 26 October 2023

Note This is considered a security hole. Only use it for debugging, and uninstall the debug-shell hook afterwards.
Note TODO: add description about pmbootstrap initfs hooks_ls

This page explains how to connect to your device when it has booted to the initramfs by installing the debug-shell hook. This is useful if you want to know more about the boot process, simply inspect the initramfs or if you want to debug why something doesn't work.

It is possible to enable a telnet daemon that gives you a shell this way:

$ pmbootstrap initfs hook_add debug-shell
$ pmbootstrap flasher flash_kernel # or however you flash/boot the kernel
(wait until the device booted up and you are connected to it)
$ telnet 172.16.42.1
Trying 172.16.42.1...
Connected to 172.16.42.1.
Escape character is '^]'.

Type 'pmos_continue_boot' to continue booting:
# echo "hello world"
hello world
# pmos_continue_boot
Connection closed by foreign host.

If the telnet command does not work out of the box, read connect via USB Networking in the Initramfs.

Enable initramfs-extra

To enable functionality from initramfs-extra, run the following commands in the telnet shell:

# . /usr/share/misc/source_deviceinfo
# . /init_functions.sh
# mount_boot_partition /boot
Mount boot partition (/dev/dm-0)
# extract_initramfs_extra /boot/initramfs-extra
Extract /boot/initramfs-extra
24128 blocks

In general, while inspecting the initramfs, you can execute commands in order listed in postmarketos-initramfs/init.sh, starting with the line mount_boot_partition /boot and below (everything above it was already executed before entering debug-shell).

Additional programs

After installing the debug-shell initramfs hook, the evtest, fftest and fbdebug programs are available in the initramfs (#1358).

Deleting the debug shell

pmbootstrap initfs hook_del debug-shell

Tips and tricks