Thread View: muc.lists.freebsd.current
2 messages
2 total messages
Started by Hiroki Sato
Fri, 27 Nov 2026 15:29
CFT: User-mode GEOM
Author: 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
CFT: User-mode GEOM
Author: Ruslan Zalata
Date: Fri, 27 Nov 2026 23:46
Date: Fri, 27 Nov 2026 23:46
35 lines
6432 bytes
6432 bytes
Hello Hiroki. On 2026-11-27 20:29, Hiroki Sato wrote: > 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. This is whole lot of a patch! Great work! Although I was able to apply this patch to 16.0-current with only one hunk failing (had to fix sys/geom/geom_ctl.c manually) and build the kernel, I hesitate to try it on real/working system because there are too many changes made to GEOM code. If something goes wrong I may loose the data. So, need to setup bhyve first with my own image. Anyways, don't we have a simpler solution to this problem ? I observe that GEOM code has been recently changed to use GID_OPERATOR. Can be go further and allow operators do mdconfig, gpart and mount GEOMs ? I suppose this issue of making GEOM/gpart to work with regular files without root access has been already discussed somewhere ? Would like to read that. --- WBR, Ruslan. PGP: D7545516DF544C4A, Get by finger rz@fabmicro.ru -- Posted automagically by a mail2news gateway at muc.de e.V. Please direct questions, flames, donations, etc. to news-admin@muc.de
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads