I have in the past done this but after a recent update it panics on boot with a DEBUG kernel: I am pre-loading an md(4)image file from loader which has an odd size (md0 is a root image which seems fine if I disable the md1): md1: Preloaded image </bazrandom> 61281 bytes at 0xffff000005f95eb0 This leads to a panic when geom tries to taste but doesn't find a file system or disk-sized image: panic: wrong offset 60769 for sectorsize 512 cpuid = 0 time = 1 KDB: stack backtrace: db_trace_self() at db_trace_self db_trace_self_wrapper() at db_trace_self_wrapper+0x58 vpanic() at vpanic+0x220 panic() at panic+0x48 g_io_request() at g_io_request+0x5e4 g_read_data() at g_read_data+0xc8 g_label_generic_taste() at g_label_generic_taste+0x90 g_label_taste() at g_label_taste+0x268 g_load_class() at g_load_class+0x23c g_run_events() at g_run_events+0x13c fork_exit() at fork_exit+0x98 fork_trampoline() at fork_trampoline+0x18 KDB: enter: panic [ thread pid 14 tid 100075 ] Stopped at kdb_enter+0x78: str xzr, [x21, #2048]
I went back through the archive as this was to strange; turned out that all the "random" files were a multiple of sectorsize before so I assume this works as intended but I would want to question if this needs to be a panic rather than being handled as an error? If the panic is reasonable someone should just close this.
Could you please try https://reviews.freebsd.org/D47102
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=4bf34c597c44a2393ac5ec483e9cecac128d8202 commit 4bf34c597c44a2393ac5ec483e9cecac128d8202 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2024-10-13 21:28:22 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2024-10-14 08:08:21 +0000 md(4): always trim the last partial sector Do it also for the preloaded disk, in addition to the dynamically configured device. This is needed to avoid geom checking alignment and panicing on read of the last sector, e.g. for partition schemes and label tasting. PR: 281978 Reported by: bz Reviewed by: bz, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D47102 sys/dev/md/md.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=959f0d0cdb1482d754f24b7ae16bda0ac2e7b31a commit 959f0d0cdb1482d754f24b7ae16bda0ac2e7b31a Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2024-10-13 21:28:22 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2024-10-20 00:33:04 +0000 md(4): always trim the last partial sector PR: 281978 (cherry picked from commit 4bf34c597c44a2393ac5ec483e9cecac128d8202) sys/dev/md/md.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)