Error messages when booting kernel 6.14, the 2nd

Since the thread in which I first raised the problem has now been closed (because it may have been solved), I am reopening the same topic here, since the same problem occurs again and again.

I now have the current kernel 6.1.7. The problem is the following: I have a swapfile from Calamares during the installation with exclusive root rights. But every few reboots I get error messages that the swapfile could not be activated. Remedy is every time I recreate the swapfile and activate it again:

sudo swapoff /swap/swapfile
sudo truncate -s 0 /swap/swapfile
sudo dd if=/dev/zero of=/swap/swapfile bs=1M count=4096 status=progress
sudo mkswap /swap/swapfile
sudo swapon /swap/swapfile

However, I can be sure that a few days later, when I reboot, it will again not be able to be activated at boot time.

My last logfile:

https://0x0.st/ohw8.txt

This was happening with me every time I ran a balance / in my BTRFS filesystem.

1 Like

OK, that could be the case with me, too, if I think about it carefully. I have done this manually from time to time. So I should also turn off the automated balance function in the Btrfs Assistant again? Stupid …

I’m using btrfs assistant to configure balance through btrfsmaintenance and it is working now.
I’m using swapfile.

This problem only happens to me when I ran like this:


Image from: https://wiki.archlinux.org/title/btrfs

If I run my balance like this:

sudo systemctl start btrfs-balance.service

The problem doesn’t happen.

I would suggest you to let the .timer run once a month.

I have also activated the balance timer only via the Btrfs Assistant, which works systemd. Where is the difference?

I’m just reporting that if I run sudo btrfs balance start --bg /, I get the same errors as you.
So I suppose that could be the balance procedure affecting your swap, just like it was happening with me before.
Note that this is just an assumption based on my previously problems with balance and swap and I could be wrong.

I’m not sure… Probably we will need someone with more skills in BTRFS like Dalto to help us to answer that…

Am just reading into this:

But I don’t get much smarter from this …

1 Like

hmm, nice info in that link

    Balance and/or convert (change allocation profile of) chunks that
    passed all filters in a comma-separated list of filters for a
    particular chunk type.  If filter list is not given balance all
    chunks of that type.  In case none of the -d, -m or -s options is
    given balance all chunks in a filesystem. This is potentially
    long operation and the user is warned before this start, with
    a delay to stop it.

This means that if you run the command for balance found in the arch wiki, which has no filters, it would balance all chunks in a filesystem.
btrfsmaintenace is using filters, 10% for data and 5% for metadata, so they are different it seems…

Here # btrfs balance start -dusage=5 / is recommended as a start.

https://github.com/kdave/btrfsmaintenance
btrfsmaintenance is also using 5% but you can tune it editing the file /etc/default/btrfsmaintenance
Edit: btrfsmaintenace is using filters, 10% for data and 5% for metadata

1 Like

Sorry, but an img is not so good, because I can’t paste it into DeepL like that. My english is not good enough to do without the translator.

You can check everything here in this link: https://github.com/kdave/btrfsmaintenance

1 Like

In the article that @anon50380917 linked to, the author issues a warning against running balance on metadata though in some cases it seems to be legit.

WARNING: Do not run balance on Metadata chunks as this can increase the risk for ENOSPC errors. Only run Metadata balance when converting between RAID profiles or when changing the number of devices in the filesystem.

:thinking:

1 Like

I’m trying to understand the code but I’m not a programmer.

Inside this file: /etc/default/btrfsmaintenance
We have this:

# The usage percent for balancing data block groups.
#
# Note: default values should not disturb normal work but may not reclaim
# enough block groups. If you observe that, add higher values but beware that
# this will increase IO load on the system.
BTRFS_BALANCE_DUSAGE="5 10"
## Path:        System/File systems/btrfs
## Type:        string
## Default:     "5"
#
# The usage percent for balancing metadata block groups. The values are also
# used in case the filesystem has mixed blockgroups.
#
# Note: default values should not disturb normal work but may not reclaim
# enough block groups. If you observe that, add higher values but beware that
# this will increase IO load on the system.
BTRFS_BALANCE_MUSAGE="5"

Inside this file /usr/share/btrfsmaintenance/btrfs-balance.sh, we have this:

#!/bin/bash
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.

umask 022
PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH

if [ -f /etc/sysconfig/btrfsmaintenance ] ; then
    . /etc/sysconfig/btrfsmaintenance
fi

if [ -f /etc/default/btrfsmaintenance ] ; then
    . /etc/default/btrfsmaintenance
fi

LOGIDENTIFIER='btrfs-balance'
. $(dirname $(realpath "$0"))/btrfsmaintenance-functions

{
BTRFS_BALANCE_MOUNTPOINTS=$(expand_auto_mountpoint "$BTRFS_BALANCE_MOUNTPOINTS")
OIFS="$IFS"
IFS=:
exec 2>&1 # redirect stderr to stdout to catch all output to log destination
for MM in $BTRFS_BALANCE_MOUNTPOINTS; do
	IFS="$OIFS"
	if ! is_btrfs "$MM"; then
		echo "Path $MM is not btrfs, skipping"
		continue
	fi
	echo "Before balance of $MM"
	btrfs filesystem df "$MM"
	df -H "$MM"

	if detect_mixed_bg "$MM"; then
		run_task btrfs balance start -musage=0 -dusage=0 "$MM"
		# we use the MUSAGE values for both, supposedly less aggressive
		# values, but as the data and metadata space is shared on
		# mixed-bg this does not lead to the situations we want to
		# prevent when the blockgroups are split (ie. underused
		# blockgroups)
		for BB in $BTRFS_BALANCE_MUSAGE; do
			# quick round to clean up the unused block groups
			run_task btrfs balance start -v -musage=$BB -dusage=$BB "$MM"
		done
	else
		run_task btrfs balance start -dusage=0 "$MM"
		for BB in $BTRFS_BALANCE_DUSAGE; do
			# quick round to clean up the unused block groups
			run_task btrfs balance start -v -dusage=$BB "$MM"
		done
		run_task btrfs balance start -musage=0 "$MM"
		for BB in $BTRFS_BALANCE_MUSAGE; do
			# quick round to clean up the unused block groups
			run_task btrfs balance start -v -musage="$BB" "$MM"
		done
	fi

	echo "After balance of $MM"
	btrfs filesystem df "$MM"
	df -H "$MM"
done

} | \
case "$BTRFS_LOG_OUTPUT" in
	stdout) cat;;
	journal) systemd-cat -t "$LOGIDENTIFIER";;
	syslog) logger -t "$LOGIDENTIFIER";;
	none) cat >/dev/null;;
	*) cat;;
esac

exit 0

So, it seems that there is a condition to run, ifs and elses .
Not sure if the metadata part of the code runs every time…

Edit: I suppose BB is BTRFS_BALANCE_DUSAGE and MM is BTRFS_BALANCE_MUSAGE ?
But only when mixed_bg MM is found ? What this means?

1 Like

Now it’s as good as confirmed that at least running Balance manually on the Btrfs Assistant start page will cripple the swapfile. Balance => restart => swapfile broken …

@dalto please help! :pray:t2:

I first disabled the balance timer in btrfs-maintenance …

1 Like

Did you kick off the balance and then restart? A swapfile can’t be activated while a balance is running. So if you started a balance and restarted right away, that would leave the balance in a paused state and may stop swap activation.

If that is the case, you could resume the balance, let it finish and then activate the swapfile.

1 Like

No, I waited until the button was again on START and then restarted., but also not immediately …

As it is now, I have to re-enable the swapfile after each balance run. This can’t be the way it’s supposed to be …

Update: I now have the LTS kernel in use again (5.15.90) and the balancing of the swapfile doesn’t seem to matter. But after I rebooted into 6.18, the swapfile was broken again. Am curious what happens when the 6.1 then LTS has become …

I don’t think this is a problem with kernel.
Its not clear to me what happened here to correct that swap problem.

Can you show your btrfs-assistant - btrfsmaintenance tab?
I suspect that the problem could be related to the options you ticked there for balance.