mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-29 04:19:35 +03:00
48df24d4ce
= Motivation At Delphix we are heavy users of kernel crash dumps that are captured through a crash kernel that is spawned whenever the main kernel panics. The way that this works internally is that a certain amount of memory is reserved while the main system is running so the initramfs of the crash kernel can be loaded when a panic occurs. In order to keep reserved memory at minimum we've been historically trying to identify the binaries that are part of the kernel's initramfs that are big and finding ways of either making them smaller or do not include them in the initramfs image. An example is always stripping the DWARF info of the ZFS kernel module copy that is included in the initramfs image of both our running and our crash kernel (the difference in size there is 76MB vs 4MB). We've recently identified that libzpool has been the largest binary in our initramfs images - currently sized around 17MB. = This Patch The ZFS scripts do not explicitly copy libzpool to initramfs. They copy zdb which pulls in libzpool as a dependency. Given that both zdb and libzpool are not really essential for initramfs (e.g. we'll still have access to the once the root filesystem is unpacked) this patch removes them from initramfs. Reviewed-by: Richard Laager <rlaager@wiktel.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Matthew Ahrens <mahrens@delphix.com> Reviewed-by: John Kennedy <john.kennedy@delphix.com> Reviewed-by: George Melikov <mail@gmelikov.ru> Signed-off-by: Serapheim Dimitropoulos <serapheim@delphix.com> Closes #12616
57 lines
1.4 KiB
Bash
Executable File
57 lines
1.4 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# Add OpenZFS filesystem capabilities to an initrd, usually for a native ZFS root.
|
|
#
|
|
|
|
if [ "$1" = "prereqs" ]; then
|
|
echo "udev"
|
|
exit
|
|
fi
|
|
|
|
. /usr/share/initramfs-tools/hook-functions
|
|
|
|
for req in "@sbindir@/zpool" "@sbindir@/zfs" "@mounthelperdir@/mount.zfs"; do
|
|
copy_exec "$req" || {
|
|
echo "$req not available!" >&2
|
|
exit 2
|
|
}
|
|
done
|
|
|
|
copy_exec "@udevdir@/vdev_id"
|
|
copy_exec "@udevdir@/zvol_id"
|
|
if command -v systemd-ask-password > /dev/null; then
|
|
copy_exec "$(command -v systemd-ask-password)"
|
|
fi
|
|
|
|
# We use pthreads, but i-t from buster doesn't automatically
|
|
# copy this indirect dependency: this can be removed when buster finally dies.
|
|
find /lib/ -type f -name "libgcc_s.so.[1-9]" | while read -r libgcc; do
|
|
copy_exec "$libgcc"
|
|
done
|
|
|
|
# shellcheck disable=SC2050
|
|
if [ @LIBFETCH_DYNAMIC@ != 0 ]; then
|
|
find /lib/ -name @LIBFETCH_SONAME@ | while read -r libfetch; do
|
|
copy_exec "$libfetch"
|
|
done
|
|
fi
|
|
|
|
copy_file config "/etc/hostid"
|
|
copy_file cache "@sysconfdir@/zfs/zpool.cache"
|
|
copy_file config "@initconfdir@/zfs"
|
|
copy_file config "@sysconfdir@/zfs/zfs-functions"
|
|
copy_file config "@sysconfdir@/zfs/vdev_id.conf"
|
|
copy_file rule "@udevruledir@/60-zvol.rules"
|
|
copy_file rule "@udevruledir@/69-vdev.rules"
|
|
|
|
manual_add_modules zfs
|
|
|
|
if [ -f "/etc/hostname" ]; then
|
|
copy_file config "/etc/hostname"
|
|
else
|
|
hostname="$(mktemp -t hostname.XXXXXXXXXX)"
|
|
hostname > "$hostname"
|
|
copy_file config "$hostname" "/etc/hostname"
|
|
rm -f "$hostname"
|
|
fi
|