Richard W.M. Jones wrote:
Richard W.M. Jones wrote:
> lvcreate -L 3G -n newroot raidvg
> lvcreate -L 1G -n newswap raidvg
I should add, in a libvirt context it's probably going to be useful to
also:
* list available volume groups (vgscan)
* list space available in each VG (vgdisplay name-of-vg)
* show how VGs relate to PGs (pvscan)
The LVM tools use quite a sophisticated internal API which isn't
exported - but see for example tools/tools.h and include/*.h in the LVM2
source code. <libdevmapper.h> is also available, but much more lowlevel.
I talked to Alasdair Kergon about all of this on Tuesday, and there are
a few clarifications.
Firstly, vgscan & vgdisplay are apparently deprecated (who knew?) and
there is a new command (vgs) which replaces both. The good news is that
vgs is designed so that the output can be parsed:
# /usr/sbin/vgs
VG #PV #LV #SN Attr VSize VFree
Home 1 1 0 wz--n- 298.09G 8.09G
VolGroup00 1 2 0 wz--n- 152.56G 32.00M
versus the old way:
# /usr/sbin/vgdisplay Home
--- Volume group ---
VG Name Home
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 2
[etc]
Similarly, pvs instead of pvscan/pvdisplay and lvs instead of
lvscan/lvdisplay.
Secondly there is an API of sorts for lvm2. I think Alasdair called it
"libcmd", but maybe I got that wrong because Google doesn't seem to turn
up anything. In any case, all it is is a wrapper around the command
line tools, so it seems doubtful that this is going to be any better
than just invoking the command line tools ourselves.
Thirdly, Alasdair is quite keen to see a proper programming API for
LVM2. However I don't think anyone has the time to do it, and he has
the usual concerns for backwards binary compatibility and making sure
the API mirrors the command line tools. LVM2 is still evolving at a
fair rate. There are few other candidates to use the API at the moment,
but apparently Anaconda does some really nasty stuff directly on LVM2
structures so it should be changed to use an API instead.
My current opinion is that we can use libparted as it is to both manage
virt-on-partition scenarios and to find orphan PVs as candidates to add
to a VG, and the command line tools like vgs to manage and allocate LVM2
partitions.
Rich.
--
Emerging Technologies, Red Hat
http://et.redhat.com/~rjones/
64 Baker Street, London, W1U 7DF Mobile: +44 7866 314 421
"[Negative numbers] darken the very whole doctrines of the equations
and make dark of the things which are in their nature excessively
obvious and simple" (Francis Maseres FRS, mathematician, 1759)