Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Trying to migrate to initramfs fails on fsck
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
plasmid
n00b
n00b


Joined: 02 May 2005
Posts: 56

PostPosted: Sat Aug 17, 2024 1:36 pm    Post subject: Trying to migrate to initramfs fails on fsck Reply with quote

I have been trying to migrate my system to using an initramfs. My system boots fine using my old kernel which doesn't use an initframfs but when I use genkernel to make an initiramfs, I run into problems. It looks like /var is not getting mounted because the system isn't find fsck.ext4 and thus the remainder of the boot goes badly. I thought this might be because genkernel.conf had e2fsprogs commented out, but I have set this to yes and rebuilt and confirmed that e2fsprogs was included in the initramfs. I was wondering if it might I have to do with my fstab set up so I have included that below. Can someone assist me in figuring out why my system is getting stuck by not finding my /var at boot when using initramfs?

Code:

# /etc/fstab: static file system information.
#
# noatime turns off atimes for increased performance (atimes normally aren't
# needed); notail increases performance of ReiserFS (at the expense of storage
# efficiency).  It's safe to drop the noatime options if you want and to
# switch between notail / tail freely.
#
# The root filesystem should have a pass number of either 0 or 1.
# All other filesystems should have a pass number of 0 or greater than 1.
#
# See the manpage fstab(5) for more information.
#

# <fs>                  <mountpoint>    <type>          <opts>          <dump/pass>

# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.
#
# NOTE: Even though we list ext4 as the type here, it will work with ext2/ext3
#       filesystems.  This just tells the kernel to use the ext4 driver.
#
# NOTE: You can use full paths to devices like /dev/sda3, but it is often
#       more reliable to use filesystem labels or UUIDs. See your filesystem
#       documentation for details on setting a label. To obtain the UUID, use
#       the blkid(8) command.

#LABEL=boot             /boot           ext4            noauto,noatime  1 2
#UUID=58e72203-57d1-4497-81ad-97655bd56494              /               ext4            noatime             0 1
#LABEL=swap             none            swap            sw              0 0
/dev/cdrom              /mnt/cdrom      auto            noauto,user,ro  0 0

/dev/nvme0n1p2          /boot           vfat            rw,fmask=0022,dmask=0022        0 2
/dev/nvme0n1p3          none            swap            sw,nofail       0 0
/dev/nvme0n1p4          /var            ext4            defaults        0 2
/dev/nvme0n1p5          /               ext4            noatime         0 1

UUID="73c33834-645f-4a45-a18c-1fc2dacd4a99" /mnt/data   ext4 defaults   0 2


/dev/cdrom              /mnt/dvd        auto            noauto,user,ro  0 0


UUID="54115363-7c35-41ac-9747-8784bdb99be6" /mnt/backup ext4 defaults 0 2
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 4845
Location: Bavaria

PostPosted: Sat Aug 17, 2024 2:11 pm    Post subject: Re: Trying to migrate to initramfs fails on fsck Reply with quote

What happens if you change the order from:
plasmid wrote:
Code:
/dev/nvme0n1p4          /var            ext4            defaults        0 2
/dev/nvme0n1p5          /               ext4            noatime         0 1

to
Code:
/dev/nvme0n1p5          /               ext4            noatime         0 1
/dev/nvme0n1p4          /var            ext4            defaults        0 2

?

(and of course generate a new initramfs)
_________________
https://wiki.gentoo.org/wiki/User:Pietinger
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20341

PostPosted: Sat Aug 17, 2024 2:58 pm    Post subject: Reply with quote

Depending on the actual error, this may be related:

https://forums.gentoo.org/viewtopic-t-1170267-highlight-.html
_________________
Quis separabit? Quo animo?
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 4845
Location: Bavaria

PostPosted: Sat Aug 17, 2024 6:12 pm    Post subject: Reply with quote

pjp wrote:
Depending on the actual error, this may be related:

https://forums.gentoo.org/viewtopic-t-1170267-highlight-.html

I have thought you must first mount the root partition to be able to mount /var ... and it cannot be a problem with e2fsprogs because both partitions are ext4 (so, the root partition would have the same problem).
_________________
https://wiki.gentoo.org/wiki/User:Pietinger
Back to top
View user's profile Send private message
plasmid
n00b
n00b


Joined: 02 May 2005
Posts: 56

PostPosted: Sat Aug 17, 2024 7:19 pm    Post subject: Re: Trying to migrate to initramfs fails on fsck Reply with quote

pietinger wrote:
What happens if you change the order from:
plasmid wrote:
Code:
/dev/nvme0n1p4          /var            ext4            defaults        0 2
/dev/nvme0n1p5          /               ext4            noatime         0 1

to
Code:
/dev/nvme0n1p5          /               ext4            noatime         0 1
/dev/nvme0n1p4          /var            ext4            defaults        0 2

?

(and of course generate a new initramfs)


I will give it a try
Back to top
View user's profile Send private message
plasmid
n00b
n00b


Joined: 02 May 2005
Posts: 56

PostPosted: Sat Aug 17, 2024 7:53 pm    Post subject: Re: Trying to migrate to initramfs fails on fsck Reply with quote

pietinger wrote:
What happens if you change the order from:
plasmid wrote:
Code:
/dev/nvme0n1p4          /var            ext4            defaults        0 2
/dev/nvme0n1p5          /               ext4            noatime         0 1

to
Code:
/dev/nvme0n1p5          /               ext4            noatime         0 1
/dev/nvme0n1p4          /var            ext4            defaults        0 2

?

(and of course generate a new initramfs)


It didn't work unfortunately/

When I looked closer, it looks like it is not seeing the device itself. Trying to figure out how to get the log from boot as it would be stored in /var...

Anyway, it looks like fsck.ext4 cannot find the device.
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22395

PostPosted: Sat Aug 17, 2024 9:14 pm    Post subject: Reply with quote

Does the device exist? Is it discovered soon enough?

An initramfs has no natural place to write logs, though some tools might generate an initramfs that can mount persistent storage and write logs there. In the general case, you will need to get the output from the kernel's console, through netconsole, serial console, or transcription of the monitor.
Back to top
View user's profile Send private message
plasmid
n00b
n00b


Joined: 02 May 2005
Posts: 56

PostPosted: Sun Aug 18, 2024 3:07 am    Post subject: Reply with quote

I can also confirm that the problem must be in the initramfs as if I delete it and reconfigure grub to boot without it, that same kernel boots just fine. I built the initramfs with genkernel, so I am including my conf if that helps at all.

Quote:

# Configuration file for genkernel

# This file is sourced by genkernel at startup and determines which options
# we will be using to compile our kernel. The order of precidence is simple,
# with the internal settings being least important, configuration file
# settings next, and command line options being most important.

# =========COMMON COMMAND LINE OPTION DEFAULTS=========

# Install to $BOOTDIR
#INSTALL="yes"

# Run 'make oldconfig' before compiling this kernel
OLDCONFIG="yes"

# Run 'make menuconfig' before compiling this kernel
#MENUCONFIG="no"

# Run 'make gconfig' before compiling this kernel
#GCONFIG="no"

# Run 'make nconfig' (ncurses 'menuconfig') before compiling this kernel
#NCONFIG="no"

# Run 'make xconfig' before compiling this kernel
#XCONFIG="no"

# Run 'make mrproper' before compiling this kernel
#MRPROPER="yes"

# Run 'make clean' before compiling this kernel
# Only needed if MRPROPER is set to NO because
# MRPROPER implies 'make clean'.
#CLEAN="yes"

# Mount BOOTDIR automatically if it isn't mounted
#MOUNTBOOT="yes"

# Make symlinks in BOOTDIR automatically
#SYMLINK="no"

# Save the new configuration in /etc/kernels upon
# successful compilation
#SAVE_CONFIG="yes"

# Enable color output in genkernel
NOCOLOR="false"

# Clear build cache dir on gernkernel start
#CLEAR_CACHEDIR="no"

# Clear all tmp files and caches after genkernel has run
#POSTCLEAR="no"

# Check for x MB free disk space in BOOTDIR
#CHECK_FREE_DISK_SPACE_BOOTDIR=0

# Check for x MB free disk space in kernel outputdir
#CHECK_FREE_DISK_SPACE_KERNELOUTPUTDIR=0

# Genkernel uses an independent configuration for MAKEOPTS, and does not source
# /etc/portage/make.conf . You can override the default setting by uncommenting
# and tweaking the following line. Default setting is set up by
# ${GK_SHARE}/${ARCH_OVERRIDE}/config.sh . The recommended value for -j
# argument is: <number of processors>*<number of cores per processor>+1
#MAKEOPTS="$(portageq envvar MAKEOPTS)"

# Run the kernel make at the following NICE level
#NICE=10

# Add bcache support
#BCACHE="no"

# Add LVM support
LVM="yes"

# Add LUKS support
LUKS="yes"

# Add GnuPG support
#GPG="no"

# Add keyctl support for loading LUKS passphrase into a keyring
#KEYCTL="no"

# Add in early microcode support: this sets the kernel options for early microcode loading
# Possible values: empty/"no", "all", "intel", "amd"
#MICROCODE="all"

# Include early microcode in generated initramfs.
# Only needed if system cannot load multiple initramfs.
# NOTE: >=sys-boot/grub-2 will detect and auto-load {amd,intel}-uc.img file
# provided by sys-firmware/intel-microcode[initramfs] or
# sys-kernel/linux-firmware[initramfs].
MICROCODE_INITRAMFS="yes"

# Add NFS support
#NFS="no"

# Add DMRAID support
#DMRAID="no"

# Add SSH support
#SSH="no"

# Add b2sum support
#B2SUM="no"

# Include busybox in the initramfs. If included, busybox is rebuilt
# if the cached copy is out of date.
#BUSYBOX="yes"

# Add MDRAID support
MDADM="yes"

# Specify a custom mdadm.conf.
# By default the initramfs will be built *without* an mdadm.conf and will auto-detect
# arrays during bootup. Usually, this should not be needed.
MDADM_CONFIG="/etc/mdadm.conf"

# Add Multipath support
#MULTIPATH="no"

# Add iSCSI support
#ISCSI="no"

# Add e2fsprogs support
E2FSPROGS="yes"

# Include support for unionfs
#UNIONFS="no"

# Include support for zfs volume management. If unset, genkernel will attempt
# to autodetect and enable this when rootfs is on zfs.
#ZFS="no"

# Add BTRFS support
#BTRFS="no"

# Add xfsprogs support
#XFSPROGS="no"

# Install firmware onto root filesystem
# Will conflict with sys-kernel/linux-firmware package
#FIRMWARE_INSTALL="no"

# Include full contents of FIRMWARE_DIR
# (if FIRMWARE option below is set to YES).
#ALLFIRMWARE="no"

# Add firmware(s) to initramfs required by copied modules
#FIRMWARE="no"

# Specify directory to pull from
#FIRMWARE_DIR="/lib/firmware"

# Specify a comma-separated list of firmware files or directories to include,
# relative to FIRMWARE_DIR (if FIRMWARE option above is set to YES
# and ALLFIRMWARE is set to NO).
#FIRMWARE_FILES=""

# Add new kernel to grub
# Possible values: empty/"no", "grub", "grub2"
#BOOTLOADER="no"

# Use sandbox when building initramfs
#SANDBOX="yes"

# Embed and set font early on boot
# Possible values: empty/"none", "current", <PSF file>
#BOOTFONT="none"

# Add boot splash using splashutils
#SPLASH="no"

# Use this splash theme. If commented out - the "default" name theme is used.
# Also, SPLASH="yes" needs to be enabled for this one to work.
# This supersedes the "SPLASH_THEME" option in '/etc/conf.d/splash'.
#SPLASH_THEME="gentoo"

# Includes or excludes Plymouth from the initramfs. If "splash" is
# passed at boot, Plymouth will be activated.
#PLYMOUTH="no"

# Embeds the given plymouth theme in the initramfs.
#PLYMOUTH_THEME="text"

# Run "emerge @module-rebuild" automatically when possible and necessary
# after kernel and modules have been compiled
#MODULEREBUILD="yes"

# Run the specified command in the current environment after the kernel and
# modules have been compiled, useful to rebuild external kernel module
# (see MODULEREBUILD above) or installing additional
# files (use 'copy_image_with_preserve dtb path/to/dtb dtb <kernelname>')
#CMD_CALLBACK=""


# =========KEYMAP SETTINGS=========
#
# Force keymap selection at boot
#DOKEYMAPAUTO="no"

# Enables keymap selection support
#KEYMAP="yes"


# =========LOW LEVEL COMPILE SETTINGS=========
#
# Assembler to use for the kernel. See also the --kernel-as command line
# option.
#KERNEL_AS="as"

# Archiver to use for the kernel. See also the --kernel-ar command line
# option.
#KERNEL_AR="ar"

# Compiler to use for the kernel (e.g. distcc). See also the --kernel-cc
# command line option.
#KERNEL_CC="gcc"

# Linker to use for the kernel. See also the --kernel-ld command line option.
#KERNEL_LD="ld"

# NM utility to use for the kernel. See also the --kernel-nm command line option.
#KERNEL_NM="nm"

# GNU Make to use for kernel. See also the --kernel-make command line option.
#KERNEL_MAKE="make"

# objcopy utility to use for the kernel. See also the --kernel-objcopy command
# line option.
#KERNEL_OBJCOPY="objcopy"

# objdump utility to use for the kernel. See also the --kernel-objdump command
# line option.
#KERNEL_OBJDUMP="objdump"

# ranlib utility to use for the kernel. See also the --kernel-ranlib command
# line option.
#KERNEL_RANLIB="ranlib"

# readelf utility to use for the kernel. See also the --kernel-readelf command
# line option.
#KERNEL_READELF="readelf"

# strip utility to use for the kernel. See also the --kernel-strip command line
# option.
#KERNEL_STRIP="strip"

# Assembler to use for the utilities. See also the --utils-as command line
# option.
#UTILS_AS="as"

# Archiver to use for the utilities. See also the --utils-ar command line
# option.
#UTILS_AR="ar"

# C Compiler to use for the utilities (e.g. distcc). See also the --utils-cc
# command line option.
#UTILS_CC="gcc"

# C++ Compiler to use for the utilities (e.g. distcc). See also the --utils-cxx
# command line option.
#UTILS_CXX="g++"

# Linker to use for the utilities. See also the --utils-ld command line
# option.
#UTILS_LD="ld"

# NM utility to use for the utilities. See also the --utils-nm command line option.
#UTILS_NM="nm"

# GNU Make to use for the utilities. See also the --utils-make command line
# option.
#UTILS_MAKE="make"

# Target triple (i.e. aarch64-linux-gnu) to build for. If you do not
# cross-compile, leave blank for auto detection.
#CROSS_COMPILE=""

# Target triple (i.e. aarch64-linux-gnu) to build kernel for. Utilities will be
# built for the native target, not this target. If you do not cross-compile,
# leave blank.
#KERNEL_CROSS_COMPILE=""

# Override default make target (bzImage). See also the --kernel-target
# command line option. Useful to build a uImage on arm.
#KERNEL_MAKE_DIRECTIVE_OVERRIDE="fooImage"

# Override default kernel binary path. See also the --kernel-binary
# command line option. Useful to install a uImage on arm.
#KERNEL_BINARY_OVERRIDE="arch/foo/boot/bar"


# =========GENKERNEL LOCATION CONFIGURATION=========
#
# Variables:
# %%ARCH%% - Final determined architecture
# %%CACHE%% - Final determined cache location

# Set genkernel's temporary work directory
#TMPDIR="/var/tmp/genkernel"

# Set the boot directory, default is /boot
#BOOTDIR="/boot"

# Default share directory location
GK_SHARE="${GK_SHARE:-/usr/share/genkernel}"

# Location of the default cache
CACHE_DIR="/var/cache/genkernel"

# Location of DISTDIR, where our source tarballs are stored
DISTDIR="${GK_SHARE}/distfiles"

# Log output file
LOGFILE="/var/log/genkernel.log"

# Debug Level
LOGLEVEL=1


# =========COMPILED UTILS CONFIGURATION=========
#
# Default location of kernel source
DEFAULT_KERNEL_SOURCE="/usr/src/linux"

# Default kernel config (only use to override using
# arch/%%ARCH%%/kernel-config-${VER}.${PAT} !)
#DEFAULT_KERNEL_CONFIG="${GK_SHARE}/arch/%%ARCH%%/kernel-config"

# Specifies a user created busybox config
#BUSYBOX_CONFIG="/path/to/file"

# NOTE: Since genkernel 3.4.41 the version of
# busybox, lvm, mdadm, ... have been moved to
# /usr/share/genkernel/defaults/software.sh in order to
# reduce the merging you have to do during etc-update.
# You can still override these settings in here.


# =========MISC KERNEL CONFIGURATION=========
#
# Set kernel filename which will be used when kernel will be installed
# into BOOTDIR. See man page to learn more about available placeholders.
#KERNEL_FILENAME="vmlinuz-%%KV%%"

# Set kernel symlink name which will be used when kernel will be installed
# into BOOTDIR and SYMLINK option is enabled
#KERNEL_SYMLINK_NAME="kernel"

# This option will set kernel option CONFIG_LOCALVERSION.
# Use special value "UNSET" to unset already set CONFIG_LOCALVERSION.
#KERNEL_LOCALVERSION="-%%ARCH%%"

# This option is only valid if kerncache is
# defined. If there is a valid kerncache no checks
# will be made against a kernel source tree.
#KERNEL_SOURCES="yes"

# Build a static (monolithic kernel)
#BUILD_STATIC="no"

# Make and install kernelz image (PowerPC)
#GENZIMAGE="no"

# Archive file created using tar containing kernel binary, content
# of /lib/modules and the kernel config.
# NOTE: Archive is created before the callbacks are run!
#KERNCACHE="/path/to/file.tar.xz"

# Prefix to kernel module destination, modules
# will be installed in <prefix>/lib/modules
#KERNEL_MODULES_PREFIX=""


# =========MISC INITRAMFS CONFIGURATION=========
#
# Set initramfs filename which will be used when initramfs will be
# installed into BOOTDIR. See man page to learn more about available
# placeholders.
#INITRAMFS_FILENAME="initramfs-%%KV%%.img"

# Set initramfs symlink name which will be used when initramfs will be
# installed into BOOTDIR and SYMLINK option is enabled
#INITRAMFS_SYMLINK_NAME="initramfs"

# Copy all compiled kernel modules to the initramfs
#ALLRAMDISKMODULES="no"

# Copy selected modules to the initramfs based on arch-specific modules_load file
#RAMDISKMODULES="yes"

# Archive file created using tar containing kernel and initramfs.
# NOTE: No modules outside of the initramfs will be included!
#MINKERNPACKAGE="/path/to/file.tar.xz"

# Add additional modules to the initramfs using the module groups defined
# in /usr/share/genkernel/defaults/modules_load (see this file for
# more details). This would be used if, for example, you
# required an additional crypto module or network device at boot
# time and did not want to statically compile these in the kernel.
# Options take the form AMODULES_{group} where {group} is one of
# the groups in modules_load (which are in the form MODULES_{group}).
# Use this with caution.
#AMODULES_group="module-to-include another-module"

# Override the default modules in the initramfs, for a given group, as defined by
# /usr/share/genkernel/defaults/modules_load and the per-arch modules_load
# files. You PROBABLY want to use AMODULES_* above, and NOT MODULES_* here.
# If you use MODULES_* here, the default and per-arch modules will NOT be used.
#MODULES_group1="some-module"
#MODULES_group2="" # Load no modules for this group

# Override the default used linuxrc script.
#LINUXRC="/path/to/custom/linuxrc"

# Archive file created using tar containing modules after
# the callbacks have run
#MODULESPACKAGE="/path/to/file.tar.xz"

# Directory structure to include in the initramfs,
# only available on >=2.6 kernels
#INITRAMFS_OVERLAY=""

# Build the generated initramfs into the kernel instead of
# keeping it as a separate file
#INTEGRATED_INITRAMFS="no"

# Compress generated initramfs
#COMPRESS_INITRD="yes"

# Types of compression: best, xz, lzma, bzip2, gzip, lzop, lz4, zstd, fastest
# "best" selects the best available compression method
# "fastest" selects the fastest available compression method
#COMPRESS_INITRD_TYPE="best"

# wrap initramfs using mkimage for u-boot bootloader
# WRAP_INITRD=no

# Create a self-contained env in the initramfs
#NETBOOT="no"


# =========MISC BOOT CONFIGURATION=========
#
# Specify a default for real_root=
#REAL_ROOT="/dev/one/two/gentoo"
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 4845
Location: Bavaria

PostPosted: Sun Aug 18, 2024 9:45 am    Post subject: Reply with quote

plasmid wrote:
I can also confirm that the problem must be in the initramfs as if I delete it and reconfigure grub to boot without it, that same kernel boots just fine. I built the initramfs with genkernel, [...]

You can always check what an initramfs is doing by extracting the "init" file and read it:
https://wiki.gentoo.org/wiki/Custom_Initramfs#Extracting_the_cpio_archive

Maybe you want to build your own initramfs without using genkernel:
https://wiki.gentoo.org/wiki/User:Pietinger/Tutorials/Initramfs_Overview
(here you will find links to every important wiki article)
_________________
https://wiki.gentoo.org/wiki/User:Pietinger
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22395

PostPosted: Sun Aug 18, 2024 1:52 pm    Post subject: Reply with quote

If the kernel can boot the system properly without the initramfs, why are you trying to use an initramfs? Typically, people use one because they need early-boot processing, like unlocking a LUKS device, activating LVM, activating MD, or mounting secondary filesystems. If your kernel boots with no initramfs, that suggests to me that you do not need any of those things, and are only making your life complicated with no benefit if we get this working.
Back to top
View user's profile Send private message
plasmid
n00b
n00b


Joined: 02 May 2005
Posts: 56

PostPosted: Wed Aug 21, 2024 4:51 am    Post subject: Reply with quote

I'm mainly trying to learn something new that I haven't mastered yet.
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20341

PostPosted: Wed Aug 21, 2024 5:35 pm    Post subject: Reply with quote

pietinger wrote:
pjp wrote:
Depending on the actual error, this may be related:

https://forums.gentoo.org/viewtopic-t-1170267-highlight-.html

I have thought you must first mount the root partition to be able to mount /var ... and it cannot be a problem with e2fsprogs because both partitions are ext4 (so, the root partition would have the same problem).
It might not be, but I didn't see any errors mentioned.

I have some errors that I don't think are related, but I recalled that thread because maybe it is, maybe not.

In my case fsck errors showed up in boot.log in February. I'm guessing this is around the time support was dropped for mounting /usr without an initramfs. Until recently I simply manually mounted /usr and moved on. Not long ago I got a simple initramfs working, so I'm suspecting it doesn't have what it needs to perform fsck. As for / and /var having the same filesystem, that may not matter. For example:
tune2fs -l:
Filesystem created:       Sat Oct 27 11:06:18 2018
Last checked:             Sat Oct 27 11:06:18 2018
/ in fstab has "0 1" for checking, so maybe by default fs settings don't check it? I'm not sure how that works. Maybe "Last checked" means something else?
_________________
Quis separabit? Quo animo?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum