mkinitcpio - bunnyamin/bunnix GitHub Wiki
Configuration | Example |
---|---|
Build from /etc/mkinitcpio.conf . |
# mkinitcpio -p linux |
Test configuration at different path. Excluding -g <file> will invoke a dry/test run. |
# mkinitcpio -c <file> |
Build configuration at different path. | # mkinitcpio -c <file> -g /boot/initramfs-linux.img |
Error | Remedy |
---|---|
/lib/modules/4.8.11-1-ARCH' is not a valid kernel module directory |
Manually specify one of the available kernel version in mkinitcpio using -k , for example, list available kernel modules ls -la /lib/modules and provide one to mkinitcpio -k 4.8.12-3-ARCH . |
Default configuration /etc/mkinitcpio.conf
.
Directory | Description |
---|---|
/etc/initcpio/install |
The directory install contains user bash scripts that are to be built. |
/etc/initcpio/hooks |
The directory hooks contains user runtime bash scripts that must have a corresponding build script. |
The resulting initramfs
should be
- small, around 50MiB and below, because a larger file could result in
error: timeout reading netboot/initramfs-linux.nfs.img
(atftpd.log),ICMP enp0s0.localdomain udp port 46503 unreachable, length 40
(tcpdump), and - readable otherwise
ATFTP
returns errorFile netboot/initramfs-linux.nfs.img not found
.
- Copy the
net
bash script
asnet_nfs4
cp /usr/lib/initcpio/install/net /etc/initcpio/install/net_nfs4
. - Edit
/etc/initcpio/install/net_nfs4
- -
add_module nfsv3?
- +
add_module nfsv4?
- -
add_binary "/usr/lib/initcpio/nfsmount" "/bin/nfsmount"
- +
add_binary "/usr/lib/initcpio/nfsmount" "/bin/mount.nfs4"
- -
- Copy the
net
bash script
asnet_nfs4
cp /usr/lib/initcpio/hooks/net /etc/initcpio/hooks/net_nfs4
. - Edit
/etc/initcpio/hooks/net_nfs4
- -
nfsmount ${nfs_option:+-o ${nfs_option}} "${nfs_server}:${nfs_path}" "$1"
- +
mount.nfs4 "${nfs_server}:${nfs_path}" "$1" ${nfs_option:+-o ${nfs_option}}
- -
- Configure the mkinitcpio.netboot.nfs.conf
- Auto-detect is necessary to keep the size of the
initamfs
image low. - If building on another hardware than the one to deploy on then auto-detect
may exclude the necessary network driver. Therefore, manually add the
module to ensure that
ipconfig
finds the network device.
MODULES=(nfsv4 [module for network device])
BINARIES=(/usr/bin/mount.nfs4)
FILES=()
HOOKS="base udev autodetect net_nfs4 ..."
COMPRESSION="xz"
COMPRESSION_OPTIONS="-9e"
- Auto-detect is necessary to keep the size of the
- Build the new image:
mkinitcpio -c <file> -g /netboot/initramfs-linux.nfs.img
- Ensure that the binaries are embedded in the
initamfs
:$ lsinitcpio -a /boot/initramfs-linux.img
The name of the hook must be "net_nfs4". For exemple, the name "net_nfs" causes
the mkinitcpio
to report:
==> WARNING: Hook 'net_nfs' is deprecated. Replace it with 'net_nfs4' in your config
For debugging purposes, in /usr/lib/initcpio/hooks/net_nfs4
add the following
nfs_mount_handler() {
if
...
fi
+ echo ""
+ echo "debug> mount.nfs4 ${nfs_server}:${nfs_path} [$1] -v ${nfs_option:+-o ${nfs_option}}"
+ echo ""
- mount.nfs4 "${nfs_server}:${nfs_path}" "$1" ${nfs_option:+-o ${nfs_option}}
+ mount.nfs4 "${nfs_server}:${nfs_path}" "$1" -v ${nfs_option:+-o ${nfs_option}}
+ sleep 12
}
Error | Event | Consequence | Cause | Remedy |
---|---|---|---|---|
:: mounting '/dev/nfs' on real root mount.nfs: remote share not in 'host:dir' format
|
:: Triggering uevents... |
Drops to emergency shell. | Unknown; the net_nfs4 hook is never executed? |
Unknown |
:: mounting '/dev/nfs' on real root mount: /new_root: bad option; for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount.<type> helper program dmesg(1) may have more information after failed mount system call.
|
:: Triggering uevents... |
Drops to emergency shell. | Unknown; the net_nfs4 hook is never executed? |
Unknown |
ipconfig: eth1: SIOCGIFINDEX: No such device ipconfig: no devices to configure
|
:: running hook [net_nfs4] |
mount.nfs4: Network is unreachable... ERROR: Failed to mount the real root device. Bailing out, you are on your own. Good luck. |
Missing module or drivers for network device. | Assign the network device module to the mkinitcpio configuration MODULES . |
ipconfig: eth1: SIOCGIFINDEX: No such device ipconfig: no devices to configure
|
:: running hook [net_nfs4] |
mount.nfs4: Network is unreachable... ERROR: Failed to mount the real root device. Bailing out, you are on your own. Good luck. |
The network interface name is wrong. | Adjust the name in the boot kernel parameter ip=:::::eth1:dhcp or let it attempt to identify the interface ip=::::::dhcp . |
No error | Starting systemd-udevd... :: running hook [udev] |
Nothing happens | The network interface name is wrong. | Adjust the name in the boot kernel parameter ip=:::::eth1:dhcp or let it attempt to identify the interface ip=::::::dhcp . |