Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 817905 - sys-boot/os-prober-1.79 - fails to properly detect btrfs partitions (problem with 1.79-btrfs-subvolume-detection.patch)
Summary: sys-boot/os-prober-1.79 - fails to properly detect btrfs partitions (problem ...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Peter Levine
URL:
Whiteboard:
Keywords: PullRequest
Depends on:
Blocks:
 
Reported: 2021-10-12 22:06 UTC by ernsteiswuerfel
Modified: 2021-12-22 12:34 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
os-prober-1.79-debug (os-prober-1.79-debug.txt,186.58 KB, text/plain)
2021-10-12 22:06 UTC, ernsteiswuerfel
Details
os-prober-1.79-debug without btrfs-subvolume-detection.patch (os-prober-1.79_without-btrfs-subvolume-detection.patch-debug.txt,157.25 KB, text/plain)
2021-10-12 22:14 UTC, ernsteiswuerfel
Details
os-prober-1.79-btrfs-subvolume-detection.patch (os-prober-1.79-btrfs-subvolume-detection.patch,13.68 KB, patch)
2021-10-22 03:30 UTC, Peter Levine
Details | Diff
os-prober-1.79-handle-multiple-initrd-paths.patch (os-prober-1.79-handle-multiple-initrd-paths.patch,1.02 KB, patch)
2021-10-22 03:30 UTC, Peter Levine
Details | Diff
os-prober-1.79-handle-multiple-initrd-paths+.patch (os-prober-1.79-handle-multiple-initrd-paths+.patch,1.27 KB, text/plain)
2021-10-22 10:33 UTC, ernsteiswuerfel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ernsteiswuerfel archtester 2021-10-12 22:06:58 UTC
Created attachment 744633 [details]
os-prober-1.79-debug

grub-mkconfig fails to properly detect other btrfs-partitions with os-prober-1.79. It recognizes the partitions but it does not populate grub.cfg with the proper boot entries:

[...]
### BEGIN /etc/grub.d/30_os-prober ###
Warnung: Zur Erkennung anderer bootfähiger Partitionen wird os-prober ausgeführt.
Dessen Ausgabe wird zur Erkennung bootfähiger Programmdateien und Erzeugen neuer Boot-Einträge verwendet.
rmdir: konnte '/var/lib/os-prober/mount' nicht entfernen: Das Gerät oder die Ressource ist belegt
rmdir: konnte '/var/lib/os-prober/mount' nicht entfernen: Das Gerät oder die Ressource ist belegt
rmdir: konnte '/var/lib/os-prober/mount' nicht entfernen: Das Gerät oder die Ressource ist belegt
rmdir: konnte '/var/lib/os-prober/mount' nicht entfernen: Das Gerät oder die Ressource ist belegt
rmdir: konnte '/var/lib/os-prober/mount' nicht entfernen: Das Gerät oder die Ressource ist belegt
rmdir: konnte '/var/lib/os-prober/mount' nicht entfernen: Das Gerät oder die Ressource ist belegt
Windows Boot Manager auf /dev/nvme0n1p1@/EFI/Microsoft/Boot/bootmgfw.efi gefunden
menuentry 'Windows Boot Manager (auf /dev/nvme0n1p1)' --class windows --class os $menuentry_id_option 'osprober-efi-661F-CE51' {
	insmod part_gpt
	insmod fat
	search --no-floppy --fs-uuid --set=root 661F-CE51
	chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}
void auf /dev/nvme0n1p6 gefunden

Gentoo/Linux auf /dev/nvme0n1p7 gefunden

Gentoo/Linux auf /dev/nvme0n1p8 gefunden

### END /etc/grub.d/30_os-prober ###
[...]

After some fiddling around I found "1.79-btrfs-subvolume-detection.patch" to be guilty. When I rebuild os-prober-1.79 without this patch the partitions are detected and proper boot entries are added.

I use sys-fs/btrfs-progs-5.14.2, my btrfs-partitions got no sub-volumes.
Comment 1 ernsteiswuerfel archtester 2021-10-12 22:14:05 UTC
Created attachment 744636 [details]
os-prober-1.79-debug without btrfs-subvolume-detection.patch
Comment 2 Peter Levine 2021-10-13 21:49:41 UTC
Thanks for the debug.  I'll take a look at it in the next few days.  I might revert it in the interim.
Comment 3 Peter Levine 2021-10-22 03:30:18 UTC
Created attachment 746076 [details, diff]
os-prober-1.79-btrfs-subvolume-detection.patch
Comment 4 Peter Levine 2021-10-22 03:30:52 UTC
Created attachment 746079 [details, diff]
os-prober-1.79-handle-multiple-initrd-paths.patch
Comment 5 Peter Levine 2021-10-22 03:36:53 UTC
With the two patches above, try overwriting those in /var/db/repos/gentoo/sys-boot/os-prober/files/ and reemerge os-prober-1.79.

Does it resolve this issue without a regression of https://bugs.gentoo.org/790434?
Comment 6 ernsteiswuerfel archtester 2021-10-22 10:33:58 UTC
Created attachment 746118 [details]
os-prober-1.79-handle-multiple-initrd-paths+.patch

(In reply to Peter Levine from comment #5)
> With the two patches above, try overwriting those in
> /var/db/repos/gentoo/sys-boot/os-prober/files/ and reemerge os-prober-1.79.
Just wanted to test but both patches do not apply. I got the handle-multiple-initrd-paths.patch right, but with btrfs-subvolume-detection.patch there are major differences.
Comment 7 Peter Levine 2021-11-12 01:46:14 UTC
Sorry.  I forgot that I had further altered the patches and their order. If you can import my testing repo, or its sys-boot/os-prober subdirectory, then please test os-prober-1.79-r1.ebuild from https://github.com/Peter-Levine/gentoo-testing.
Comment 8 ernsteiswuerfel archtester 2021-11-15 20:47:58 UTC
(In reply to Peter Levine from comment #7)
> Sorry.  I forgot that I had further altered the patches and their order. If
> you can import my testing repo [...]
Just tried your os-prober-1.79-r1 but it didn't work out. My btrfs partitions don't get detected.
Comment 9 Peter Levine 2021-11-24 02:07:18 UTC
I'm willing to debug it if I can reproduce it on my end.  What is the ordered layout of disks/partition tables/partitions/filesystems that exhibit the issue on your end?
Comment 10 ernsteiswuerfel archtester 2021-12-07 20:32:02 UTC
(In reply to Peter Levine from comment #9)
> I'm willing to debug it if I can reproduce it on my end.  What is the
> ordered layout of disks/partition tables/partitions/filesystems that exhibit
> the issue on your end?
Sorry for my late answer, forgot about the issue temporarily.

 # blkid 
/dev/nvme0n1p9: UUID="132d14f5-b4cc-4bfe-bff4-48ba994eb526" TYPE="crypto_LUKS" PARTUUID="381ba779-54a5-4a9b-b764-c98814780a72"
/dev/nvme0n1p7: LABEL="supah" UUID="cfb46c37-ae0d-4a65-9f34-c1dc812afc2f" UUID_SUB="3feb7e0f-2da5-4dff-b2cc-2818414a252a" BLOCK_SIZE="4096" TYPE="btrfs" PARTUUID="76f8aa33-c10e-4268-87d8-d9ed4a9eb4c5"
/dev/nvme0n1p5: LABEL="swap" UUID="b946eb75-7dc8-4561-a49d-2935fc51b92b" TYPE="swap" PARTUUID="0855f4db-0ac2-4526-9b51-1e98cd2ab9b4"
/dev/nvme0n1p3: BLOCK_SIZE="512" UUID="7E7C20C07C207555" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="9a737028-703f-4b3c-a834-7007b4392f02"
/dev/nvme0n1p1: UUID="661F-CE51" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="EFI system partition" PARTUUID="9a39b4cc-aaa7-4e52-bc07-9cfb0cd1323b"
/dev/nvme0n1p8: LABEL="k8_musl" UUID="3091f9bb-bf99-41a6-86ff-43636e498599" UUID_SUB="9bcbda9e-4517-4d26-acc6-9193bc4ee961" BLOCK_SIZE="4096" TYPE="btrfs" PARTUUID="ef31b278-d462-4e09-9d0a-1133ca796ba0"
/dev/nvme0n1p6: LABEL="void" UUID="b61fc8a7-a7ed-4113-b61f-548a0888c31d" UUID_SUB="3808ce03-9711-4d38-ad48-2bae458ae5d2" BLOCK_SIZE="4096" TYPE="btrfs" PARTUUID="76f9ff86-16d2-4273-8d18-a8d98e082f16"
/dev/nvme0n1p4: BLOCK_SIZE="512" UUID="BE46CB5C46CB1455" TYPE="ntfs" PARTUUID="30c5b7d2-247c-4bca-b66a-29d032382417"
/dev/nvme0n1p2: PARTLABEL="Microsoft reserved partition" PARTUUID="723a4c79-8556-4b46-86c6-3ea9444da1e2"

Each of the 3 btrfs partitions is zstd compressed and uses xxhash instead of crc. One partition got subvolumes, the other 2 not.

 # mount /dev/nvme0n1p7 /mnt/mychroot/
 # btrfs subvolume list /mnt/mychroot/
ID 261 gen 126748 top level 5 path srv
ID 262 gen 126748 top level 5 path var/lib/portables
ID 263 gen 126748 top level 5 path var/lib/machines

 # btrfs inspect-internal dump-super /dev/nvme0n1p7
superblock: bytenr=65536, device=/dev/nvme0n1p7
---------------------------------------------------------
csum_type		1 (xxhash64)
csum_size		8
csum			0xc40309e94caa1f1a [match]
bytenr			65536
flags			0x1
			( WRITTEN )
magic			_BHRfS_M [match]
fsid			cfb46c37-ae0d-4a65-9f34-c1dc812afc2f
metadata_uuid		cfb46c37-ae0d-4a65-9f34-c1dc812afc2f
label			supah
generation		130168
root			1851621376
sys_array_size		97
chunk_root_generation	105579
root_level		0
chunk_root		1064960
chunk_root_level	0
log_root		0
log_root_transid	0
log_root_level		0
total_bytes		30064771072
bytes_used		13879881728
sectorsize		4096
nodesize		16384
leafsize (deprecated)	16384
stripesize		4096
root_dir		6
num_devices		1
compat_flags		0x0
compat_ro_flags		0x0
incompat_flags		0x171
			( MIXED_BACKREF |
			  COMPRESS_ZSTD |
			  BIG_METADATA |
			  EXTENDED_IREF |
			  SKINNY_METADATA )
cache_generation	130168
uuid_tree_generation	130168
dev_item.uuid		3feb7e0f-2da5-4dff-b2cc-2818414a252a
dev_item.fsid		cfb46c37-ae0d-4a65-9f34-c1dc812afc2f [match]
dev_item.type		0
dev_item.total_bytes	30064771072
dev_item.bytes_used	19876806656
dev_item.io_align	4096
dev_item.io_width	4096
dev_item.sector_size	4096
dev_item.devid		1
dev_item.dev_group	0
dev_item.seek_speed	0
dev_item.bandwidth	0
dev_item.generation	0

 # btrfs inspect-internal dump-super /dev/nvme0n1p8
superblock: bytenr=65536, device=/dev/nvme0n1p8
---------------------------------------------------------
csum_type		1 (xxhash64)
csum_size		8
csum			0x3ce3fbdd5877c198 [match]
bytenr			65536
flags			0x1
			( WRITTEN )
magic			_BHRfS_M [match]
fsid			3091f9bb-bf99-41a6-86ff-43636e498599
metadata_uuid		3091f9bb-bf99-41a6-86ff-43636e498599
label			k8_musl
generation		21528
root			1538949120
sys_array_size		97
chunk_root_generation	19423
root_level		0
chunk_root		1064960
chunk_root_level	0
log_root		0
log_root_transid	0
log_root_level		0
total_bytes		17179869184
bytes_used		5025701888
sectorsize		4096
nodesize		16384
leafsize (deprecated)	16384
stripesize		4096
root_dir		6
num_devices		1
compat_flags		0x0
compat_ro_flags		0x0
incompat_flags		0x171
			( MIXED_BACKREF |
			  COMPRESS_ZSTD |
			  BIG_METADATA |
			  EXTENDED_IREF |
			  SKINNY_METADATA )
cache_generation	21528
uuid_tree_generation	21528
dev_item.uuid		9bcbda9e-4517-4d26-acc6-9193bc4ee961
dev_item.fsid		3091f9bb-bf99-41a6-86ff-43636e498599 [match]
dev_item.type		0
dev_item.total_bytes	17179869184
dev_item.bytes_used	6731857920
dev_item.io_align	4096
dev_item.io_width	4096
dev_item.sector_size	4096
dev_item.devid		1
dev_item.dev_group	0
dev_item.seek_speed	0
dev_item.bandwidth	0
dev_item.generation	0

 # btrfs inspect-internal dump-super /dev/nvme0n1p6
superblock: bytenr=65536, device=/dev/nvme0n1p6
---------------------------------------------------------
csum_type		1 (xxhash64)
csum_size		8
csum			0xecbfe62c1b419778 [match]
bytenr			65536
flags			0x1
			( WRITTEN )
magic			_BHRfS_M [match]
fsid			b61fc8a7-a7ed-4113-b61f-548a0888c31d
metadata_uuid		b61fc8a7-a7ed-4113-b61f-548a0888c31d
label			void
generation		2214
root			1104134144
sys_array_size		97
chunk_root_generation	1065
root_level		0
chunk_root		1064960
chunk_root_level	0
log_root		0
log_root_transid	0
log_root_level		0
total_bytes		8589934592
bytes_used		4198670336
sectorsize		4096
nodesize		16384
leafsize (deprecated)	16384
stripesize		4096
root_dir		6
num_devices		1
compat_flags		0x0
compat_ro_flags		0x0
incompat_flags		0x171
			( MIXED_BACKREF |
			  COMPRESS_ZSTD |
			  BIG_METADATA |
			  EXTENDED_IREF |
			  SKINNY_METADATA )
cache_generation	2214
uuid_tree_generation	2214
dev_item.uuid		3808ce03-9711-4d38-ad48-2bae458ae5d2
dev_item.fsid		b61fc8a7-a7ed-4113-b61f-548a0888c31d [match]
dev_item.type		0
dev_item.total_bytes	8589934592
dev_item.bytes_used	5456789504
dev_item.io_align	4096
dev_item.io_width	4096
dev_item.sector_size	4096
dev_item.devid		1
dev_item.dev_group	0
dev_item.seek_speed	0
dev_item.bandwidth	0
dev_item.generation	0
Comment 11 Peter Levine 2021-12-19 03:36:17 UTC
There is a void detection patch at https://github.com/void-linux/void-packages/blob/master/srcpkgs/os-prober/patches/detect-void.patch.  Unfortunately it doesn't work well with openSUSE's btrfs patch.  Fedora's btrfs patch at https://github.com/void-linux/void-packages/blob/master/srcpkgs/os-prober/patches/detect-void.patch) augmented with openSUSE's https://build.opensuse.org/package/view_file/openSUSE:Factory/os-prober/Improve-btrfs-handling-on-os-probing-for-grub2.patch?rev=56), along with the void detection patch, seems to do the trick.  On my end, Manjaro cloned to multiple btrfs subvolumes are all detected and void linux, which is on btrfs without any other subvolumes, is also detected.

I've updated https://github.com/Peter-Levine/gentoo-testing. Please test and confirm if it resolves any outstanding issues.
Comment 12 ernsteiswuerfel archtester 2021-12-20 10:28:31 UTC
(In reply to Peter Levine from comment #11)
> I've updated https://github.com/Peter-Levine/gentoo-testing. Please test and
> confirm if it resolves any outstanding issues.
I can confirm the 1.79-r1 from your repo works. All partitions of my OSes properly detected now. Thanks!
Comment 13 Larry the Git Cow gentoo-dev 2021-12-22 12:34:13 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6d092b6cfd8e9f3512c536f20dfc1de445b21039

commit 6d092b6cfd8e9f3512c536f20dfc1de445b21039
Author:     Peter Levine <plevine457@gmail.com>
AuthorDate: 2021-12-21 00:42:02 +0000
Commit:     Ben Kohler <bkohler@gentoo.org>
CommitDate: 2021-12-22 12:33:50 +0000

    sys-boot/os-prober: bump os-prober-1.79-r1.ebuild
    
    Includes the Void Linux patch and moves the multiple-initrd-paths patch
    to the front since it's already accepted upstream.
    
    Closes: https://bugs.gentoo.org/817905
    Closes: https://github.com/gentoo/gentoo/pull/23445
    Package-Manager: Portage-3.0.30, Repoman-3.0.3
    Signed-off-by: Peter Levine <plevine457@gmail.com>
    Signed-off-by: Ben Kohler <bkohler@gentoo.org>

 sys-boot/os-prober/os-prober-1.79-r1.ebuild | 105 ++++++++++++++++++++++++++++
 1 file changed, 105 insertions(+)

Additionally, it has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8d6d17462775a88220078b4ae38e4e6228164a75

commit 8d6d17462775a88220078b4ae38e4e6228164a75
Author:     Peter Levine <plevine457@gmail.com>
AuthorDate: 2021-12-21 00:36:36 +0000
Commit:     Ben Kohler <bkohler@gentoo.org>
CommitDate: 2021-12-22 12:33:49 +0000

    sys-boot/os-prober: add void linux detection patch
    
    Bug: https://bugs.gentoo.org/817905
    Package-Manager: Portage-3.0.30, Repoman-3.0.3
    Signed-off-by: Peter Levine <plevine457@gmail.com>
    Signed-off-by: Ben Kohler <bkohler@gentoo.org>

 .../os-prober/files/os-prober-1.79-detect-void.patch | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4e135dcb12f4cc3716becfd461786bfa370eb416

commit 4e135dcb12f4cc3716becfd461786bfa370eb416
Author:     Peter Levine <plevine457@gmail.com>
AuthorDate: 2021-12-21 00:25:05 +0000
Commit:     Ben Kohler <bkohler@gentoo.org>
CommitDate: 2021-12-22 12:33:49 +0000

    sys-boot/os-prober: switch btrfs patch from openSUSE to Fedora
    
    Fixes issues related to undetected linux installations. This combines
    Fedora's os-prober-btrfsfix.patch and openSUSE's
    Improve-btrfs-handling-on-os-probing-for-grub2.patch, augmented to
    correctly parse multiple initrd paths.
    
    Tested-by: ernsteiswuerfel <erhard_f@mailbox.org>
    Bug: https://bugs.gentoo.org/817905
    Package-Manager: Portage-3.0.30, Repoman-3.0.3
    Signed-off-by: Peter Levine <plevine457@gmail.com>
    Signed-off-by: Ben Kohler <bkohler@gentoo.org>

 .../os-prober-1.79-btrfs-subvolume-detection.patch | 238 +++++++++++----------
 1 file changed, 122 insertions(+), 116 deletions(-)