Bug#945497: initramfs-tools: Resume function does not check for swap file

Package: initramfs-tools
Version: 0.133ubuntu10
Severity: normal
Dear Maintainer,
The resume hook script (/usr/share/initramfs-tools/hooks/resume) does not check
for a swap file. It checks for a swap device referenced by the RESUME variable.
The RESUME_OFFSET variable is additionally used to point to a file in the
RESUME device that acts as the swap device. In this case, since RESUME points
to a standard file system, a warning is generated:
W: initramfs-tools configuration sets RESUME=$RESUME
W: but no matching swap device is available.
The following contains a possible solution to check for a swap file. It relies
on a set RESUME_OFFSET variable indicating a swap file. At least two files
should be modified: 1) the resume hook script and 2) the mkinitramfs script.
The resume script contains the following line numbered items. The unnumbered
lines contain a possible fix to check for the use of a swap file.
20 # First check if a location is set and is a valid swap partition.
21 # If so, the config file will be copied in and there is nothing to do.
22 if ` -n "$RESUME" ` && ` "$RESUME" != auto `; then
23 if ` "$RESUME" = none `; then
24 exit 0
25 fi
if resume_dev_node="$(resolve_device "$RESUME")"; then
if ` -z "$RESUME_OFFSET" ` &&
blkid -p -n swap "$resume_dev_node" >/dev/null 2>&1;
exit 0
# Assume RESUME_OFFSET is a proper offset pointing to
# the first data block of an inode in RESUME.
# Then, the swap filename should be in /proc/swaps.
# Get largest filename that is NOT a /dev/...
for resume_filename in $( grep -v ^/dev/ /proc/swaps |
grep ^/ | sort -rnk3 | cut -d " " -f 1 ); do
if ` -n "$resume_filename" ` &&
blkid -p -n swap "$resume_filename"
>/dev/null 2>&1; then
exit 0
echo >&2 "W: initramfs-tools configuration sets
echo >&2 "W:
echo >&2 "W: but no matching swap file is available."
29 fi
31 echo >&2 "W: initramfs-tools configuration sets RESUME=$RESUME"
32 echo >&2 "W: but no matching swap device is available."
33 fi
Getting a file name from an inode from a block offset might be done, but is
problematic as tools related to this are dependent on the file system. For
ext*, this could be:
resume_inode=$( debugfs -R "icheck $RESUME_OFFSET" $resume_dev_node
2>/dev/null | tail -1 | cut -f2 )
resume_fn=$( debugfs -R "ncheck ${RESUME_INODE}" ${RESUME_DEV} 2>/dev/null |
tail -1 | cut -f2 )
However, this process is not generic and may not be available for every file
Additionally, the mkinitramfs script (/usr/sbin/mkinitramfs) does not export
the RESUME_OFFSET variable. It should be exported for use by the hook scripts.
242 # Export environment for hook scripts.
243 #
244 export MODULESDIR
245 export version
246 export CONFDIR
247 export DESTDIR
248 export DPKG_ARCH
249 export verbose
250 export MODULES
251 export BUSYBOX
253 export RESUME
-- System Information:
Debian Release: buster/sid
APT prefers eoan-updates
APT policy: (500, 'eoan-updates'), (500, 'eoan-security'), (500, 'eoan'), (100, 'eoan-backports')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 5.3.0-23-generic (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages initramfs-tools depends on:
ii initramfs-tools-core 0.133ubuntu10
ii linux-base 4.5ubuntu2
initramfs-tools recommends no packages.
Versions of packages initramfs-tools suggests:
ii bash-completion 1:2.9-1ubuntu1
-- no debconf information

Written by "Keven L. Ates" 26/11/2019 00:40:01
Check some pics on this site!
12/12/2019 09:50:59