Package: initramfs-tools
Version: 0.130
Severity: wishlist
Tags: patch

Dear Maintainer,

when connecting to the InitRAMFS via network (e.g. encrypted root fs), then it 
is
helpful if the machine can be registered by its name in the DNS, making it 
possible
to connect to it via its DNS name. Otherwise you have to look up the assigned 
ip in
the DHCP server log.
Therefore please provide a config and hook that dynamically sets the host name
on InitRAMFS creation.

My current workaround consists of a simple config file and a simple hook script:
/etc/initramfs-tools/conf.d/network
/etc/initramfs-tools/hooks/set_hostname_in_network_config.sh

This workaround is easy to use on any machine without manually editing the host 
name
on installation or whenever it changes. Also avoiding typos of the host name.
Additionally it gives an explicit point where to define your network 
configuration
for InitRAMFS-only (not as a kernel command line).

Would be great if you could consider adding this to the package.

Kind regards
Maddes

-- Package-specific info:
-- initramfs sizes
-rw------- 1 root root 18M Jul  8 13:51 /boot/initrd.img-4.9.0-3-amd64
-- /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-4.9.0-3-amd64 root=/dev/sda1 ro quiet

-- resume
RESUME=UUID=6c849bd6-03b5-4464-9ffe-6a8601f3f23e
-- /proc/filesystems
        ext3
        ext2
        ext4

-- lsmod
Module                  Size  Used by
crct10dif_pclmul       16384  0
crc32_pclmul           16384  0
ghash_clmulni_intel    16384  0
ppdev                  20480  0
pcspkr                 16384  0
vmw_balloon            20480  0
intel_rapl_perf        16384  0
joydev                 20480  0
evdev                  24576  1
serio_raw              16384  0
sg                     32768  0
parport_pc             28672  0
vmwgfx                237568  1
battery                20480  0
shpchp                 36864  0
parport                49152  2 parport_pc,ppdev
acpi_cpufreq           20480  0
ttm                    98304  1 vmwgfx
drm_kms_helper        155648  1 vmwgfx
vmw_vmci               69632  1 vmw_balloon
drm                   360448  4 vmwgfx,ttm,drm_kms_helper
ac                     16384  0
button                 16384  0
ip_tables              24576  0
x_tables               36864  1 ip_tables
autofs4                40960  2
ext4                  585728  1
crc16                  16384  1 ext4
jbd2                  106496  1 ext4
crc32c_generic         16384  0
fscrypto               28672  1 ext4
ecb                    16384  0
mbcache                16384  2 ext4
hid_generic            16384  0
usbhid                 53248  0
hid                   122880  2 hid_generic,usbhid
sr_mod                 24576  0
cdrom                  61440  1 sr_mod
sd_mod                 45056  3
ata_generic            16384  0
crc32c_intel           24576  2
aesni_intel           167936  1
aes_x86_64             20480  1 aesni_intel
glue_helper            16384  1 aesni_intel
lrw                    16384  1 aesni_intel
gf128mul               16384  1 lrw
ablk_helper            16384  1 aesni_intel
cryptd                 24576  3 ablk_helper,ghash_clmulni_intel,aesni_intel
psmouse               135168  0
xhci_pci               16384  0
xhci_hcd              188416  1 xhci_pci
usbcore               249856  3 usbhid,xhci_pci,xhci_hcd
usb_common             16384  1 usbcore
vmxnet3                57344  0
vmw_pvscsi             24576  2
ahci                   36864  0
libahci                32768  1 ahci
i2c_piix4              24576  0
ata_piix               36864  0
libata                249856  4 ahci,ata_piix,libahci,ata_generic
scsi_mod              225280  5 sd_mod,libata,sr_mod,sg,vmw_pvscsi

-- /etc/initramfs-tools/modules

-- /etc/kernel-img.conf
# Kernel image management overrides
# See kernel-img.conf(5) for details
do_symlinks = yes
do_bootloader = no
do_initrd = yes
link_in_boot = no

-- /etc/initramfs-tools/initramfs.conf
MODULES=most
BUSYBOX=auto
KEYMAP=n
COMPRESS=gzip
DEVICE=
NFSROOT=auto

-- /etc/initramfs-tools/update-initramfs.conf
update_initramfs=yes
backup_initramfs=no

-- /etc/crypttab
# <target name> <source device>         <key file>      <options>

-- mkinitramfs hooks
/etc/initramfs-tools/hooks/:
set_hostname_in_network_config.sh

/usr/share/initramfs-tools/hooks:
cryptgnupg
cryptkeyctl
cryptopenct
cryptopensc
cryptpassdev
cryptroot
cryptroot-unlock
dmsetup
dropbear
fsck
keymap
klibc-utils
kmod
resume
thermal
udev
zz-busybox


-- System Information:
Debian Release: 9.0
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.9.0-3-amd64 (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US:en (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages initramfs-tools depends on:
ii  initramfs-tools-core  0.130
ii  linux-base            4.5

initramfs-tools recommends no packages.

Versions of packages initramfs-tools suggests:
ii  bash-completion  1:2.1-4.3

-- no debconf information
# Define your network setup for the InitRAMFS via IP variable
#
# Still a kernel ip parameter will override any initramfs-tools config
# setting (see script /usr/share/initramfs-tools/init).
#
# Additional information:
# * https://www.kernel.org/doc/Documentation/filesystems/nfs/nfsroot.txt
#   In Debian as kernel command via /etc/default/grub
# * The "variable" ${hostname} (case-sensitive) will be replaced on InitRAMFS 
creation
#   with the current host name through the hook 
`set_hostname_in_network_config.sh`
#   This allows the machine to be registered with its name in DNS.

IP=::::${hostname}
#!/bin/sh

#
# This InitRAMFS hook provides:
# Simple script to set IP parameter in InitRAMFS with current hostname,
# instead of manually maintaining /etc/initramfs-tools/initramfs.conf or
# a file in /etc/initramfs-tools/conf.d.
# Intended for static DHCP via host name.
#
# This will override any IP setting of /etc/initramfs-tools/initramfs.conf
# or a file in /etc/initramfs-tools/conf.d that comes before the generated
# config file.
# 
# Still a kernel ip parameter will override any initramfs-tools config
# setting (see script /usr/share/initramfs-tools/init).
#
# Copyright: Matthias Bücher, see http://www.maddes.net/
# License: GNU GPL v2 or later, see http://www.gnu.org/licenses/gpl.html
#
# Additional information:
# * https://www.kernel.org/doc/Documentation/filesystems/nfs/nfsroot.txt
#   In Debian as kernel command via /etc/default/grub
#
# Tested:
# * Debian 4.x
# * Debian 8.x
# * Debian 9.x
#
# History:
# v1.0 - 2017-07-01
#  initial release
#

PREREQ=""

prereqs()
{
	echo "${PREREQ}"
}

case "${1}" in
 prereqs)
	prereqs
	exit 0
	;;
esac

. /usr/share/initramfs-tools/hook-functions

#
# Begin real processing
#
sed -i -e "s#\${hostname}#$(hostname)#" "${DESTDIR}/conf/conf.d/network"

Reply via email to