Initramfs init: Difference between revisions

From Alpine Linux
No edit summary
(Add command when running outside system)
 
(18 intermediate revisions by 8 users not shown)
Line 1: Line 1:
== initramfs init cmdline options ==
[https://gitlab.alpinelinux.org/alpine/mkinitfs '''mkinitfs'''] is a tool to create initramfs images. Initramfs images are small images which contain a small filesystem with everything required to boot Alpine. For example, when booting a setup with [[Setting up encrypted volumes with LUKS|full disk encryption]], the initramfs contains the binaries required to prompt for a password and mount the encrypted disk.


The init script in the initramfs which is loaded by the kernel understands the following entires in your kernel command line:
== Usage ==
Under a running alpine machine, the following command can be used if for some reason the initramfs has not been created properly for a new kernel.
{{cmd|# mkinitfs -c /etc/mkinitfs/mkinitfs.conf -b / <kernelvers>}}
The script is located in {{path|/sbin/}} and is created with ash. It expects {{path|/lib/modules}} to be populated with the <code><kernelvers></code> listed.<br>
Therefore normally just running <code>mkinitfs</code> should be enough if you need to rebuild it.


<code>ip=dhcp</code> : use DHCP for network configuration.
Sometimes, e.g. to fix a non booting installation or when installing, you may have to rebuild the initramfs from another system, you do not need to chroot.<br>
Mount <code>/</code>, <code>/boot</code> etc. and then run:
{{cmd|# mkinitfs -c /mnt/etc/mkinitfs/mkinitfs.conf -b /mnt/ $(ls /mnt/lib/modules/)}}


<code>ip=client-ip:server-ip:gw-ip:netmask:hostname:device:autoconf:dns1:dns2</code> : use static IP configuration, each field is separated by a colon <code>:</code>
== Initramfs init cmdline options ==
* <code>client-ip</code> ip address of the guest VM where we are going to run the installer
* <code>server-ip</code> not used, leave blank or fill with <code>none</code>
* <code>gw-ip</code>    the gateway ip address
* <code>netmask</code>  the netmask
* <code>hostname</code>  not used, leave blank or fill with <code>none</code>
* <code>device</code>    the network interface of the guest VM, default is <code>eth0</code> if left blank
* <code>autoconf</code>  not used, leave blank or fill with <code>none</code> or <code>off</code>
* <code>dns1</code>      address of the DNS server
* <code>dns2</code>      address of the 2nd DNS server


<code>alpine_repo=</code> : the location of the Alpine repository from which packages are downloaded.
In addition to the [https://www.kernel.org/doc/html/v4.14/admin-guide/kernel-parameters.html kernel boot parameters] are a number of parameters that the init script understands. These are documented in the <code>mkinitfs-bootparam(7)</code> man page.


:For stable release, use <code>http://dl-cdn.alpinelinux.org/alpine/v3.9/main</code>
Depending on your HDD type and filesystem used, the file appears as follows:
{{cat|/etc/mkinitfs/mkinitfs.conf|features{{=}}"ata base ide scsi usb virtio ext4 nvme"}}


:For rolling release, use <code>http://dl-cdn.alpinelinux.org/alpine/edge/main</code>
Although you may specify your own init script when building an initramfs, these parameters allow for extensive control over the initial startup of an Alpine Linux system.


<code>modloop=</code> : the remote location of the image containing kernel's modules, required for LVM and raid setup.
== Troubleshooting ==


:The remote location of the <code>modloop</code> image is the same as the kernel and initramfs (see below).
To troubleshoot booting issues, when using [[Bootloaders#GRUB|grub]], replace <code>quiet</code> with <code>debug_init single</code> in the boot command line.


<code>ssh_key=</code> : the remote location of your SSH public key which is used to allow SSH connection into the installer. It will be downloaded and copied into <code>/root/.ssh/authorized_keys</code> in the installer.
== See Also ==
 
* [https://wiki.postmarketos.org/wiki/The_initramfs PostmarketOS Wiki]
{{Note|Fetching public keys from HTTP, HTTPS and FTPS are supported. HTTP should only be used in local development network where you own the network.}}
* [https://wiki.archlinux.org/title/Arch_boot_process#initramfs ArchWiki boot process]
 
{{Note|Alpine Linux security policies are against using passwords for root access via SSH as we consider using public-private key pairs is a much better approach.}}
[[category:Kernel]]
 
[[Category:Booting]]
<code>quiet</code> : less verbose init script execution
 
<code>debug_init</code> : sets '-x' in the init script and -d for mdev
 
* chart (flag)
* alpine_repo=
* blacklist=
* apkovl=URL load the apkovl file from URL
* dasd=
* s390x_net=
* rootfstype=
* modules=
* crytptroot=
* cryptdm=
* cryptheader=
* cryptoffset=
* cryptokey=
* nbd=
* root=
* resume
* rootflags
* init=
* init_args=
* usbdelay
* pkgs=
* ssh_key=
* keep_apk_new
* splash=
*

Latest revision as of 07:33, 28 September 2025

mkinitfs is a tool to create initramfs images. Initramfs images are small images which contain a small filesystem with everything required to boot Alpine. For example, when booting a setup with full disk encryption, the initramfs contains the binaries required to prompt for a password and mount the encrypted disk.

Usage

Under a running alpine machine, the following command can be used if for some reason the initramfs has not been created properly for a new kernel.

# mkinitfs -c /etc/mkinitfs/mkinitfs.conf -b / <kernelvers>

The script is located in /sbin/ and is created with ash. It expects /lib/modules to be populated with the <kernelvers> listed.
Therefore normally just running mkinitfs should be enough if you need to rebuild it.

Sometimes, e.g. to fix a non booting installation or when installing, you may have to rebuild the initramfs from another system, you do not need to chroot.
Mount /, /boot etc. and then run:

# mkinitfs -c /mnt/etc/mkinitfs/mkinitfs.conf -b /mnt/ $(ls /mnt/lib/modules/)

Initramfs init cmdline options

In addition to the kernel boot parameters are a number of parameters that the init script understands. These are documented in the mkinitfs-bootparam(7) man page.

Depending on your HDD type and filesystem used, the file appears as follows:

Contents of /etc/mkinitfs/mkinitfs.conf

features="ata base ide scsi usb virtio ext4 nvme"

Although you may specify your own init script when building an initramfs, these parameters allow for extensive control over the initial startup of an Alpine Linux system.

Troubleshooting

To troubleshoot booting issues, when using grub, replace quiet with debug_init single in the boot command line.

See Also