ephestione
Posts: 48
Joined: Wed Aug 15, 2018 10:46 am

btrfs support in kernel, yes or maybe?

Sat Sep 11, 2021 4:17 pm

Using latest 64bit build on a raspi4 8GB, intending to create a RAID1 with two SSD's.
I followed this guide: https://feldspaten.org/2019/07/05/raspbian-and-btrfs/
and I could boot off btrfs no problem, but I despise the idea of having to remember to re-issue mkinitramfs each time I update kernel BEFORE rebooting, or my system goes byebye. I contacted the author of the article, who very kindly replied that what he wrote was old, and that probably new kernels would have native support for btrfs.

So I tried mounting a btrfs partition on a vanilla 64bit system where no initramfs was made: out of the box, it won't mount, reporting an error about unsupported file system.
After I issue

Code: Select all

sudo apt get update && sudo apt get full-upgrade
I get the updated kernel among all the packages, and a reboot will let me sudo mount /dev/sdxn where /dev/sdxn is a btrfs partition. Everything goes smoothly.

I then convert the rootfs of said vanilla 64bit system to btrfs (placing the device on desktop linux and running

Code: Select all

sudo btrfs-convert /dev/sdy2
where /dev/sdy2 is the root partition of the raspi OS), in the same exact way I did while following the aforementioned tutorial, but without the initramfs stuff... and trying to boot that system (after obviously having updated cmdline.txt with btrfs instead of ext4 ,and disabled fsck.repair) leads to a kernel panic because of an unrecognized file system.

If I can mount a btrfs partition while system is running, why can't the kernel mount a btrfs root partition during boot?

User avatar
dickon
Posts: 1997
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, in Towcester

Re: btrfs support in kernel, yes or maybe?

Sat Sep 11, 2021 4:36 pm

Because it'll load the btrfs module from the rootfs it's booted from, in the same way it would from an initramfs.

I believe some work was done recently to better-support initramfses. You might try looking around here for comments.
As it is apparently board policy to disallow any criticism of anything, as it appears to criticise something is to criticise all the users of that something, I will no longer be commenting in threads which are not directly relevant to my uses of the Pi.

ejolson
Posts: 8022
Joined: Tue Mar 18, 2014 11:47 am

Re: btrfs support in kernel, yes or maybe?

Sat Sep 11, 2021 4:51 pm

ephestione wrote:
Sat Sep 11, 2021 4:17 pm
Using latest 64bit build on a raspi4 8GB, intending to create a RAID1 with two SSD's.
I followed this guide: https://feldspaten.org/2019/07/05/raspbian-and-btrfs/
and I could boot off btrfs no problem, but I despise the idea of having to remember to re-issue mkinitramfs each time I update kernel BEFORE rebooting, or my system goes byebye. I contacted the author of the article, who very kindly replied that what he wrote was old, and that probably new kernels would have native support for btrfs.

So I tried mounting a btrfs partition on a vanilla 64bit system where no initramfs was made: out of the box, it won't mount, reporting an error about unsupported file system.
After I issue

Code: Select all

sudo apt get update && sudo apt get full-upgrade
I get the updated kernel among all the packages, and a reboot will let me sudo mount /dev/sdxn where /dev/sdxn is a btrfs partition. Everything goes smoothly.

I then convert the rootfs of said vanilla 64bit system to btrfs (placing the device on desktop linux and running

Code: Select all

sudo btrfs-convert /dev/sdy2
where /dev/sdy2 is the root partition of the raspi OS), in the same exact way I did while following the aforementioned tutorial, but without the initramfs stuff... and trying to boot that system (after obviously having updated cmdline.txt with btrfs instead of ext4 ,and disabled fsck.repair) leads to a kernel panic because of an unrecognized file system.

If I can mount a btrfs partition while system is running, why can't the kernel mount a btrfs root partition during boot?
To avoid the difficulty of remembering to run mkinitramfs consider adding a hook that runs each time the kernel is updated.

An example is provided in

viewtopic.php?p=1700689#p1700689

which may need updating since things may have changed since then, or not.

Note that Btrfs is not built in to the official kernel since it is a huge amount of code.

User avatar
pasman1
Posts: 214
Joined: Mon Aug 10, 2020 3:01 pm
Location: Poland

Re: btrfs support in kernel, yes or maybe?

Sat Sep 11, 2021 5:08 pm

ephestione wrote:
Sat Sep 11, 2021 4:17 pm
So I tried mounting a btrfs partition on a vanilla 64bit system where no initramfs was made: out of the box, it won't mount, reporting an error about unsupported file system.
you may try to convert only some directories to btrfs, for example /usr/share
/usr/bin etc.
Pi4 RaspbOS 64+LXQT, linux 5.10.52-v8

User avatar
dickon
Posts: 1997
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, in Towcester

Re: btrfs support in kernel, yes or maybe?

Sat Sep 11, 2021 5:42 pm

dickon wrote:
Sat Sep 11, 2021 4:36 pm
I believe some work was done recently to better-support initramfses. You might try looking around here for comments.
ejolson wrote:
Sat Sep 11, 2021 4:51 pm
To avoid the difficulty of remembering to run mkinitramfs consider adding a hook that runs each time the kernel is updated.

An example is provided in

viewtopic.php?p=1700689#p1700689
That's the bunny. Ta.
As it is apparently board policy to disallow any criticism of anything, as it appears to criticise something is to criticise all the users of that something, I will no longer be commenting in threads which are not directly relevant to my uses of the Pi.

ephestione
Posts: 48
Joined: Wed Aug 15, 2018 10:46 am

Re: btrfs support in kernel, yes or maybe?

Sat Sep 11, 2021 6:19 pm

Thank you all for the numerous and fast replies!

I indeed had noticed other threads elsewhere than these forums, where there was a reference to hooks to be exploited for this usage, the actual scope of which is way beyond my level, as the only thing I understand for my specific use case, is that, after each kernel update, I should run "mkinitramfs -o /boot/initramfs-btrfs.gz" after having made sure to add in /etc/initramfs-tools/modules the lines:

Code: Select all

btrfs
xor
zlib_deflate
raid6_pq
All the references I found to hooks instead explained that I needed to cross-check the kernel version with a corresponding number in the img filename, and at that point I got completely lost... in other words, I am unable to make sure that the needed operation will definitely be taken automatically, without serious efforts on my part, the risk being that what I do won't work, and the system will be rendered useless, and downtime on this system is not a good option.

What I take from this thread, is that yes, btrfs support exists, as I can manually mount a btrfs partition once booted, but the support ends there, as a btrfs root partition cannot be mounted without tampering with initramfs.

User avatar
dickon
Posts: 1997
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, in Towcester

Re: btrfs support in kernel, yes or maybe?

Sat Sep 11, 2021 7:54 pm

ephestione wrote:
Sat Sep 11, 2021 6:19 pm
All the references I found to hooks instead explained that I needed to cross-check the kernel version with a corresponding number in the img filename, and at that point I got completely lost...
Most search results will be for x86 architectures, and grub (the usual x86 bootloader these days) does have certain expectations. The Pi is a tad different, and the kernel and initrd filenames are specified in config.txt in the FAT32 partition. The Pi's kernel packages replace kernel*.img, and never encode the version number in the filename, so you can't have multiple kernels and initrds around on the same uSD card [0] -- just make sure the initrd is rebuilt each time the kernel package is updated, and ends up in the same place (/boot/initrd.gz or similar).

It is a bit annoying. Have I ever mentioned just how much better everything is if you netboot everything? :-)


[0] You *can*, but for the purposes of this thread, forget it.
As it is apparently board policy to disallow any criticism of anything, as it appears to criticise something is to criticise all the users of that something, I will no longer be commenting in threads which are not directly relevant to my uses of the Pi.

ephestione
Posts: 48
Joined: Wed Aug 15, 2018 10:46 am

Re: btrfs support in kernel, yes or maybe?

Sun Sep 12, 2021 7:37 am

Great news, this simplified the matter very much... I should test the hook on a vanilla install off the unmodified 64bit image, migrate to btrfs right away, then trigger apt full-upgrade to have the kernel updated, and see if it can still boot without my intervention :idea:

User avatar
pasman1
Posts: 214
Joined: Mon Aug 10, 2020 3:01 pm
Location: Poland

Re: btrfs support in kernel, yes or maybe?

Sun Sep 12, 2021 8:49 am

ephestione wrote:
Sun Sep 12, 2021 7:37 am
Great news, this simplified the matter very much... I should test the hook on a vanilla install off the unmodified 64bit image, migrate to btrfs right away, then trigger apt full-upgrade to have the kernel updated, and see if it can still boot without my intervention :idea:
is visible difference between working rpios on btrfs and ext4 ?

on desktop computer btrfs compression boosts boot time on slow disks
compared to ext4.

compression ratio is about 2
Pi4 RaspbOS 64+LXQT, linux 5.10.52-v8

ephestione
Posts: 48
Joined: Wed Aug 15, 2018 10:46 am

Re: btrfs support in kernel, yes or maybe?

Sun Sep 12, 2021 9:42 am

pasman1 wrote:
Sun Sep 12, 2021 8:49 am
is visible difference between working rpios on btrfs and ext4 ?

on desktop computer btrfs compression boosts boot time on slow disks
compared to ext4.

compression ratio is about 2
I didn't test compression,and have not previous data on this system to make a comparison, my real reason for favouring btrfs over a mdadm raid since bootstrapping the server is checksumming, and native raid1

ephestione
Posts: 48
Joined: Wed Aug 15, 2018 10:46 am

Re: btrfs support in kernel, yes or maybe?

Sun Sep 12, 2021 10:11 am

ejolson wrote:
Sat Sep 11, 2021 4:51 pm
ephestione wrote:
Sat Sep 11, 2021 4:17 pm
Using latest 64bit build on a raspi4 8GB, intending to create a RAID1 with two SSD's.
I followed this guide: https://feldspaten.org/2019/07/05/raspbian-and-btrfs/
and I could boot off btrfs no problem, but I despise the idea of having to remember to re-issue mkinitramfs each time I update kernel BEFORE rebooting, or my system goes byebye. I contacted the author of the article, who very kindly replied that what he wrote was old, and that probably new kernels would have native support for btrfs.

So I tried mounting a btrfs partition on a vanilla 64bit system where no initramfs was made: out of the box, it won't mount, reporting an error about unsupported file system.
After I issue

Code: Select all

sudo apt get update && sudo apt get full-upgrade
I get the updated kernel among all the packages, and a reboot will let me sudo mount /dev/sdxn where /dev/sdxn is a btrfs partition. Everything goes smoothly.

I then convert the rootfs of said vanilla 64bit system to btrfs (placing the device on desktop linux and running

Code: Select all

sudo btrfs-convert /dev/sdy2
where /dev/sdy2 is the root partition of the raspi OS), in the same exact way I did while following the aforementioned tutorial, but without the initramfs stuff... and trying to boot that system (after obviously having updated cmdline.txt with btrfs instead of ext4 ,and disabled fsck.repair) leads to a kernel panic because of an unrecognized file system.

If I can mount a btrfs partition while system is running, why can't the kernel mount a btrfs root partition during boot?
To avoid the difficulty of remembering to run mkinitramfs consider adding a hook that runs each time the kernel is updated.

An example is provided in

viewtopic.php?p=1700689#p1700689

which may need updating since things may have changed since then, or not.

Note that Btrfs is not built in to the official kernel since it is a huge amount of code.
To be fair, there already is a initramfs-tools script in /etc/kernel/postinst.d/ that read:

Code: Select all

#!/bin/sh -e

version="$1"
bootopt=""

command -v update-initramfs >/dev/null 2>&1 || exit 0

# passing the kernel version is required
if [ -z "${version}" ]; then
        echo >&2 "W: initramfs-tools: ${DPKG_MAINTSCRIPT_PACKAGE:-kernel package} did not pass a version number"
        exit 2
fi

# exit if kernel does not need an initramfs
if [ "$INITRD" = 'No' ]; then
        exit 0
fi

# absolute file name of kernel image may be passed as a second argument;
# create the initrd in the same directory
if [ -n "$2" ]; then
        bootdir=$(dirname "$2")
        bootopt="-b ${bootdir}"
fi

# avoid running multiple times
if [ -n "$DEB_MAINT_PARAMS" ]; then
        eval set -- "$DEB_MAINT_PARAMS"
        if [ -z "$1" ] || [ "$1" != "configure" ]; then
                exit 0
        fi
fi

# we're good - create initramfs.  update runs do_bootloader
# shellcheck disable=SC2086
INITRAMFS_TOOLS_KERNEL_HOOK=1 update-initramfs -c -k "${version}" ${bootopt} >&2
but I doubt it will create automatically the same file of the same name that I need in /boot and is loaded in config.txt, so I'll write my own instead,and see what happens on this test-system-on-a-stick

ephestione
Posts: 48
Joined: Wed Aug 15, 2018 10:46 am

Re: btrfs support in kernel, yes or maybe?

Sun Sep 12, 2021 12:33 pm

Ok, I'mofficially lost.

I spent time and effort to hack together everything: flashed latest 64bit image to usb stick, had it booted, followed guide by feldspaten linked in OP to convert and boot from a btrfs root partition, all fine.

Then I created the file /etc/kernel/postinst.d/btrfs-update, chmodded to 755 like the other files in the same folder, its source:

Code: Select all

#!/bin/bash
echo ============ UPDATE INITRAMFS ==============
mkinitramfs -o /boot/initramfs-btrfs.gz
echo ============ UPDATE COMPLETED ==============
I then watched like an idiot all the full-upgrade output on a slow usb stick, and this happened:

Code: Select all

run-parts: executing /etc/kernel/postinst.d/btrfs-update 5.10.60+ /boot/kernel.img
/etc/kernel/postinst.d/btrfs-update:
============ UPDATE INITRAMFS ==============
W: missing /lib/modules/5.10.17-v8+
W: Ensure all necessary drivers are built into the linux image!
depmod: ERROR: could not open directory /lib/modules/5.10.17-v8+: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
cat: /var/tmp/mkinitramfs_2lXbkP/lib/modules/5.10.17-v8+/modules.builtin: No such file or directory
find: ‘/var/tmp/mkinitramfs_2lXbkP/lib/modules/5.10.17-v8+/kernel’: No such file or directory
depmod: WARNING: could not open modules.order at /var/tmp/mkinitramfs_2lXbkP/lib/modules/5.10.17-v8+: No such file or directory
depmod: WARNING: could not open modules.builtin at /var/tmp/mkinitramfs_2lXbkP/lib/modules/5.10.17-v8+: No such file or directory
============ UPDATE COMPLETED ==============
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 5.10.60+ /boot/kernel.img
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 5.10.60-v7+ /boot/kernel7.img
run-parts: executing /etc/kernel/postinst.d/btrfs-update 5.10.60-v7+ /boot/kernel7.img
/etc/kernel/postinst.d/btrfs-update:
============ UPDATE INITRAMFS ==============
W: missing /lib/modules/5.10.17-v8+
W: Ensure all necessary drivers are built into the linux image!
depmod: ERROR: could not open directory /lib/modules/5.10.17-v8+: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
cat: /var/tmp/mkinitramfs_8PaGer/lib/modules/5.10.17-v8+/modules.builtin: No such file or directory
find: ‘/var/tmp/mkinitramfs_8PaGer/lib/modules/5.10.17-v8+/kernel’: No such file or directory
depmod: WARNING: could not open modules.order at /var/tmp/mkinitramfs_8PaGer/lib/modules/5.10.17-v8+: No such file or directory
depmod: WARNING: could not open modules.builtin at /var/tmp/mkinitramfs_8PaGer/lib/modules/5.10.17-v8+: No such file or directory
============ UPDATE COMPLETED ==============
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 5.10.60-v7+ /boot/kernel7.img
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 5.10.60-v7l+ /boot/kernel7l.img
run-parts: executing /etc/kernel/postinst.d/btrfs-update 5.10.60-v7l+ /boot/kernel7l.img
/etc/kernel/postinst.d/btrfs-update:
============ UPDATE INITRAMFS ==============
W: missing /lib/modules/5.10.17-v8+
W: Ensure all necessary drivers are built into the linux image!
depmod: ERROR: could not open directory /lib/modules/5.10.17-v8+: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
cat: /var/tmp/mkinitramfs_QvU7GT/lib/modules/5.10.17-v8+/modules.builtin: No such file or directory
find: ‘/var/tmp/mkinitramfs_QvU7GT/lib/modules/5.10.17-v8+/kernel’: No such file or directory
depmod: WARNING: could not open modules.order at /var/tmp/mkinitramfs_QvU7GT/lib/modules/5.10.17-v8+: No such file or directory
depmod: WARNING: could not open modules.builtin at /var/tmp/mkinitramfs_QvU7GT/lib/modules/5.10.17-v8+: No such file or directory
============ UPDATE COMPLETED ==============
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 5.10.60-v7l+ /boot/kernel7l.img
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 5.10.60-v8+ /boot/kernel8.img
run-parts: executing /etc/kernel/postinst.d/btrfs-update 5.10.60-v8+ /boot/kernel8.img
/etc/kernel/postinst.d/btrfs-update:
============ UPDATE INITRAMFS ==============
W: missing /lib/modules/5.10.17-v8+
W: Ensure all necessary drivers are built into the linux image!
depmod: ERROR: could not open directory /lib/modules/5.10.17-v8+: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
cat: /var/tmp/mkinitramfs_VlTVS0/lib/modules/5.10.17-v8+/modules.builtin: No such file or directory
find: ‘/var/tmp/mkinitramfs_VlTVS0/lib/modules/5.10.17-v8+/kernel’: No such file or directory
depmod: WARNING: could not open modules.order at /var/tmp/mkinitramfs_VlTVS0/lib/modules/5.10.17-v8+: No such file or directory
depmod: WARNING: could not open modules.builtin at /var/tmp/mkinitramfs_VlTVS0/lib/modules/5.10.17-v8+: No such file or directory
============ UPDATE COMPLETED ==============

Obviously if I reboot this is NOT going to work.

What the heck am I supposed to do?

I see now that in /lib/modules/ the only folder is /5.10.60-v8+, so the old one must have been deleted... but the mkinitramfs command in my hook script is version agnostic, why the script is looking for the old version?

ephestione
Posts: 48
Joined: Wed Aug 15, 2018 10:46 am

Re: btrfs support in kernel, yes or maybe?

Sun Sep 12, 2021 12:39 pm

EDIT: FOUND IT!

I needed to run:
sudo mkinitramfs -o /boot/initramfs-btrfs.gz 5.10.60-v8+

manually in the cli,an initramfs succeeded, otherwise either in the hook script or manually on CLI, I get the same error messages.
Now, how do I parametrize the newest kernel folder in the hook script?

ephestione
Posts: 48
Joined: Wed Aug 15, 2018 10:46 am

Re: btrfs support in kernel, yes or maybe?

Sun Sep 12, 2021 12:52 pm

I hacked a script to get the latest kernel's version from the post linked above:

Code: Select all

kfile=kernel8.img
pos=`hexdump -ve '"%_ad " 1/1 "%02x\n"' $kfile |
    grep -B1 '8b' | grep -m1 '1f' | awk '{print $1}'`
vers=`dd if=$kfile skip=$pos iflag=skip_bytes |
    gunzip | strings | grep -iPm1 'Linux version' |
    awk '{print $3}'`

echo Latest version $vers
The difference from that code is that, on my raspi boot partition, the file is kernel8.img and not kernel.img, will this always be consistent in time with future kernel updates?

User avatar
dickon
Posts: 1997
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, in Towcester

Re: btrfs support in kernel, yes or maybe?

Sun Sep 12, 2021 12:57 pm

It tells you what it's running:

Code: Select all

run-parts: executing /etc/kernel/postinst.d/btrfs-update 5.10.60+ /boot/kernel.img
You'll want to check that $2 is /boot/kernel8.img (or you'll just be building the thing multiple times for no good reason), and pass $1 as the version number to mkinitramfs. mkinitramfs is very irritating in that it won't accept multiple versions, so you can't have one initramfs for all the kernels on the system.
As it is apparently board policy to disallow any criticism of anything, as it appears to criticise something is to criticise all the users of that something, I will no longer be commenting in threads which are not directly relevant to my uses of the Pi.

ephestione
Posts: 48
Joined: Wed Aug 15, 2018 10:46 am

Re: btrfs support in kernel, yes or maybe?

Sun Sep 12, 2021 1:01 pm

Final (?) version of my automatic update script:

Code: Select all

#!/bin/bash
echo ============ UPDATE INITRAMFS ==============
cd /boot

# Please change the line below to kernel.img, kernel7.img, kernel7l.img
# or kernel8.img depending on the model of Pi and whether you are
# running in 32 or 64-bit mode.
kfile=kernel8.img


pos=`hexdump -ve '"%_ad " 1/1 "%02x\n"' $kfile |
    grep -B1 '8b' | grep -m1 '1f' | awk '{print $1}'`
vers=`dd if=$kfile skip=$pos iflag=skip_bytes |
    gunzip | strings | grep -iPm1 'Linux version' |
    awk '{print $3}'`

mkinitramfs -o /boot/initramfs-btrfs.gz $vers
echo ============ UPDATE COMPLETED ==============

User avatar
dickon
Posts: 1997
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, in Towcester

Re: btrfs support in kernel, yes or maybe?

Sun Sep 12, 2021 1:19 pm

That will break if the compression method is ever changed. Better to use the parameter the script is passed.
As it is apparently board policy to disallow any criticism of anything, as it appears to criticise something is to criticise all the users of that something, I will no longer be commenting in threads which are not directly relevant to my uses of the Pi.

ephestione
Posts: 48
Joined: Wed Aug 15, 2018 10:46 am

Re: btrfs support in kernel, yes or maybe?

Sun Sep 12, 2021 1:22 pm

[quote=dickon post_id=1912492 time=1631452795 user_id=45367

That will break if the compression method is ever changed. Better to use the parameter the script is passed.
[/quote]

I don't understand, is there a kernel version value that I can address from inside the script when it's called by the hooks? I'll need to look further into it
Maybe I can reverse engineer one of the scripts already in there

User avatar
dickon
Posts: 1997
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, in Towcester

Re: btrfs support in kernel, yes or maybe?

Sun Sep 12, 2021 1:25 pm

As it is apparently board policy to disallow any criticism of anything, as it appears to criticise something is to criticise all the users of that something, I will no longer be commenting in threads which are not directly relevant to my uses of the Pi.

ejolson
Posts: 8022
Joined: Tue Mar 18, 2014 11:47 am

Re: btrfs support in kernel, yes or maybe?

Sun Sep 12, 2021 2:42 pm

dickon wrote:
Sun Sep 12, 2021 12:57 pm
It tells you what it's running:

Code: Select all

run-parts: executing /etc/kernel/postinst.d/btrfs-update 5.10.60+ /boot/kernel.img
You'll want to check that $2 is /boot/kernel8.img (or you'll just be building the thing multiple times for no good reason), and pass $1 as the version number to mkinitramfs. mkinitramfs is very irritating in that it won't accept multiple versions, so you can't have one initramfs for all the kernels on the system.
I agree the way the hook I wrote earlier parses the kernel version out of the binary is fragile. It's possible I was unaware of the two arguments that are passed to the hook when I wrote it. It's also possible I was also using the script outside of the hook mechanism or found the arguments unreliable. Sorry for not remembering the details anymore.

At any rate, thanks for pointing out how the hook arguments might be used. I think one might still need to keep track separately which architecture kernel is used by config.txt as my understanding is the hook is called separately for each type of kernel as it's installed.

ephestione
Posts: 48
Joined: Wed Aug 15, 2018 10:46 am

Re: btrfs support in kernel, yes or maybe?

Sun Sep 12, 2021 3:00 pm

dickon wrote:
Sun Sep 12, 2021 1:25 pm
Er, yeah: viewtopic.php?p=1912488#p1912488
lol, I must have written another reply before seeing yours, because I went to the hassle of checking the source of those scripts and then noticed you already told me :|
Let's go and make YET ANOTHER test! yay!

Possible final (?) version:

Code: Select all

#!/bin/bash
echo ============ UPDATE INITRAMFS ==============
mkinitramfs -o /boot/initramfs-btrfs.gz $1
echo ============ UPDATE COMPLETED ==============
I don't care for building multiple times, actually, I'm not proficient enough to check if $1 == "kernel8", can't wrap my head around bash conditionals.

User avatar
dickon
Posts: 1997
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, in Towcester

Re: btrfs support in kernel, yes or maybe?

Sun Sep 12, 2021 3:51 pm

Code: Select all

if [ "x$2" != "x/boot/kernel8.img" ]; then
	exit 0
fi
or similar should do it. The 'x's are traditional to handle the case of empty variables and old (read: prehistoric) shells which don't have /bin/test as a builtin.
As it is apparently board policy to disallow any criticism of anything, as it appears to criticise something is to criticise all the users of that something, I will no longer be commenting in threads which are not directly relevant to my uses of the Pi.

ephestione
Posts: 48
Joined: Wed Aug 15, 2018 10:46 am

Re: btrfs support in kernel, yes or maybe?

Sun Sep 12, 2021 3:55 pm

Maybe this:

Code: Select all

#!/bin/bash
if [ "$2" == "/boot/kernel8.img" ]; then 
echo ============ UPDATE INITRAMFS ==============
mkinitramfs -o /boot/initramfs-btrfs.gz $1
echo ============ UPDATE COMPLETED ==============
testing again....

ephestione
Posts: 48
Joined: Wed Aug 15, 2018 10:46 am

Re: btrfs support in kernel, yes or maybe?

Sun Sep 12, 2021 3:56 pm

dickon wrote:
Sun Sep 12, 2021 3:51 pm

Code: Select all

if [ "x$2" != "x/boot/kernel8.img" ]; then
	exit 0
fi
or similar should do it. The 'x's are traditional to handle the case of empty variables and old (read: prehistoric) shells which don't have /bin/test as a builtin.
dang too late reading once again! I was missing a "fi" at the end as well

Current candidate:

Code: Select all

#!/bin/bash
if [ "x$2" != "x/boot/kernel8.img" ]; then
	exit 0
fi

echo ============ UPDATE INITRAMFS ==============
mkinitramfs -o /boot/initramfs-btrfs.gz $1
echo ============ UPDATE COMPLETED ==============

BTW, nice bash-fu you have! I liked the "x" trick.
(this forum editor has the worst habit of just making "$n" disappear after you click edit on an existing post)
Last edited by ephestione on Sun Sep 12, 2021 5:25 pm, edited 1 time in total.

ephestione
Posts: 48
Joined: Wed Aug 15, 2018 10:46 am

Re: btrfs support in kernel, yes or maybe?

Sun Sep 12, 2021 4:32 pm

Tested, and it works!

Return to “Advanced users”