Article View: muc.lists.freebsd.current
Article #248CFT: User-mode GEOM
From: Hiroki Sato
Date: Fri, 27 Nov 2026 15:29
Date: Fri, 27 Nov 2026 15:29
117 lines
6717 bytes
6717 bytes
----Security_Multipart(Sat_Nov_28_00_29_04_2026_678)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hello,
I would appreciate testing and/or feedback on a GEOM CLI that runs in
user mode [1]. It exposes a regular file or a block device as a
single GEOM provider named disk0 in the DISK class. It shares code
with the in-kernel GEOM implementation but runs entirely in user mode,
independently of the latter. User-mode versions of commonly used GEOM
classes, such as PART, are also available through this CLI.
My primary motivation was GEOM PART. We already have mkimg(8) for
creating partitioned system images. However, its implementation is
independent of that of the GEOM PART class, even though both serve a
similar purpose. Whenever we add support for a new partitioning
scheme to GEOM PART, we also need to add it to mkimg(8) to maintain
feature parity. Moreover, mkimg(1) is designed to create disk images
from scratch and does not support subsequent modifications to their
partition tables. disklabel(8) was an option for manipulating disk
labels in a system image file, but it is no longer available.
Meanwhile, gpart(8) requires root privileges. Reusing the GEOM PART
code in user mode seems to me a useful way to fill this gap.
You can find a test image for amd64 at [1] and the patch set at [2].
The test image can be booted from a USB stick. Alternatively, if you
are running FreeBSD/amd64, you can try it with bhyve by simply
running:
# /bin/sh boot-bhyve.sh usermode-geom-amd64.img
The root account has no password. You can shut down the VM using the
poweroff(8) command.
[1] https://people.allbsd.org/~hrs/FreeBSD/usermode-geom-amd64.20261127-1.tar.gz
[2] https://github.com/freebsd/freebsd-src/compare/main...hrs-allbsd:freebsd-src:main-hrs-usermode-geom
The ugeom(8) utility provides a simple CLI. You can create a 32 MB
disk image with a GPT partition table and a freebsd-ufs partition
using the following commands. The main differences from the
conventional GEOM CLI are that the image filename is specified
immediately after the class name and that disk0 is the only underlying
disk provider exposed:
% truncate -s 32m disk.img
% ugeom part disk.img create -s gpt disk0
disk0 created
% ugeom part disk.img add -t freebsd-ufs disk0
disk0p1 added
% ugeom geom disk.img -t
Geom Class Provider
disk0 DISK disk0
disk0 PART disk0p1
disk0p1 LABEL gptid/af6d5140-ea15-11f1-a3e6-589cfc10f459
gzero ZERO gzero
You can then write the contents of a file to disk0p1 using the
"stream" pseudo-class:
% ugeom stream disk.img -w -n 512 disk0p1 < system.img
If the system image is compressed in the UZIP format, the UZIP class
can be used as follows:
% ugeom stream disk.img disk0p1 uzip > decompressed.img
Multiple classes can also be specified to form a chain when using the
stream pseudo-class. See ugeom(8) manual page for more details.
Some GEOM classes, such as MIRROR, are not currently available in user
mode. This is because they involve worker threads rather than simply
performing read/write operations on block devices. The user-mode
implementation does, however, include NOP as an example of such a
class. It is possible to make the other classes work in user mode as
well, but I am not sure how useful they would be in this context.
There are still two points I am pondering:
* Reuse of kernel code: I chose to introduce libukern to minimize
changes to the kernel code. I would particularly appreciate
feedback on this approach.
* Command-line interface: A GEOM tree can have a complex topology, but
ugeom(8) currently supports only linear chains. I think this is
sufficient in practice, but I would be interested in hearing about
any ideas or use cases that would benefit from more complex
topologies.
Unless there are any major objections raised here, I plan to submit
the patch set to reviews.FreeBSD.org for technical review.
Any comments are welcome. Thank you.
-- Hiroki
----Security_Multipart(Sat_Nov_28_00_29_04_2026_678)--
Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit
-----BEGIN PGP SIGNATURE-----
iMoEABMKAC4WIQRsDSNTJ8+Ax5Ae/dLbsH3Gbx9zfwUCawmhwBAcaHJzQGZyZWVi
c2Qub3JnAAoJENuwfcZvH3N/eCACCQG6E8Lht6/w3cTTQV+iDRuYUyu2OufBmDQr
xoY42QEcF2h1kS/XocVvlO8YcV6+tuT0/xQhBAiy34mAM/wWcT+oSQIJAUpCKsS3
OcZ4slk82+LJgxovpCwjTKZCX3xdbG/KO3OoYJxyzSDoeHa4qv5cET/QhBWguHy1
dW5TpsXHI5h4YEnu
=BjaP
-----END PGP SIGNATURE-----
----Security_Multipart(Sat_Nov_28_00_29_04_2026_678)----
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Technical Details
Message-ID:
<20261128.002904.1209955289456869098.hrs@FreeBSD.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!weretis.net!feeder8.news.weretis.net!3.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!weretis.net!feeder8.news.weretis.net!3.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mail From: Hiroki Sato <hrs@FreeBSD.org> Newsgroups: muc.lists.freebsd.current Subject: CFT: User-mode GEOM Date: Sat, 28 Nov 2026 00:29:04 +0900 (JST) Organization: Newsgate at muc.de e.V. Approved: news-admin@muc.de Distribution: world Message-ID: <20261128.002904.1209955289456869098.hrs@FreeBSD.org> MIME-Version: 1.0 Content-Type: Multipart/Signed; protocol="application/pgp-signature"; micalg=pgp-sha512; boundary="--Security_Multipart(Sat_Nov_28_00_29_04_2026_678)--" Content-Transfer-Encoding: 7bit Injection-Info: news.muc.de; posting-host="news.muc.de:193.149.48.2"; logging-data="29677"; mail-complaints-to="news-admin@muc.de" X-Original-To: current@mlmmj.nyi.freebsd.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795793444; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=m1HjTqBqSWlDE2t/G/bw0W6oBRWf5tt+P/IbpaiQ2tI=; b=NK6WKip2RmswjdQ16DOFWzCfXUZHqJ+OHUDeikd7qe00/2TV1tBxgQe6k6M27cf2RrKzji pmUEq1J3ux6q44APecvvfR3kFo5jkx9JXPQIlWXz/qWA9R+ORFM4KO4JuOOsd6krTXMcFq YfVb0cA+/L2MssYf5weO3Qs7IebDYkHsqcJrfXErrBmqRObknVvOT/XkXjsP7ReIQN+TZU hSghnMd4eWdWmbS0kmcgEwO+bKWoUMqaRa4PrDVeE4rrVDAT6vGdEu1kI/+6/mY3BQ8zoG e4eBW3R3Z7UcSq/5ap7mBkklfoLuepuSRs4Xf6gqcF6A3mi/tHMPob+GdeF6rA== X-Old-PGPkey-fingerprint: BDB3 443F A5DD B3D0 A530 FFD7 4F2C D3D8 2793 CF2D X-PGPkey-fingerprint: 6C0D 2353 27CF 80C7 901E FDD2 DBB0 7DC6 6F1F 737F Precedence: list X-Newsgate-Id: f02c70b8849f+ X-No-Archive: Yes