geom_lvm2.ko
Learning GEOM: Tasting
I have been quite busy these last days and didn't got as much time as expected to have fun with geom(4) — the FreeBSD modular disk transformation framework. Since documentation is quite sparse compared to the rocket science inside GEOM, I spend a lot of time in man pages and reading existing GEOM classes source code... However, as recently said on the freebsd-geom mailing list:
Ahh you're believing the code comment :( (Rule #1: Never believe the code comments).
Well, this doesn't make things easy, but I can cope with that (or at least I hope so). I have already located interesting classes to study for the purpose of geom_lvm2:
- geom/geom_bsd.c
- This class looks relatively simple and is well commented. It seems to be a good starting point for learning how GEOM works (687 SLOC);
- geom/concat/g_concat.c
- This class seems a little more complex. Concatenation will have to be handled when a logical volume has physical extends on different physical volumes. Maybe will it be possible to rely directly on this class for this purpose (876 SLOC);
- geom/vinum/*
- Gvinum is a really complex^Wcool piece of code. Since it internally relies on various representation of disk chunks to provide services such as RAID, it can be a good source of inspiration for geom_lvm2's internals (7637 SLOC).
- Romain Tartière's blog
- Login to post comments
- Read more
Dumping LVM2 logical volumes under FreeBSD
At work, I generally use the Debian GNU/Linux operating system: as all our servers run Debian, it avoids loads of clashes when we put in production our work. But I am frequently complaining about how Debian works and globally can't bear it's frustrating package management system (which becomes even worth than ever when you run a advanced-user / developer / desktop machine
). Anyway, there are many situations I could do my job with another operating system that fits much more my needs, let's say FreeBSD... The problem is that as a paranoid sysadmin, my current /home directory is a LVM2 logical volume on top of software RAID controlled by mdadm.
FreeBSD features a cool abstraction layer in the kernel called GEOM and documented as a modular disk I/O request transformation framework
. Basically, it fits between your devices as represented by files in /dev and the physical disks, providing on the fly mirroring / stripping / whatever, without the need of any external tool (it's a bit more complex in fact, but keep it simple
).
Unfortunately, all this is uterly not compatible with either MD or LVM2.
LVM2 has been designed and implemented for the Linux kernel. Unfortunately — while FreeBSD features gvinum which provides similar services — the two systems are not compatible and so interoperability is not possible.