JP Vossen on 8 Jan 2009 23:43:57 -0800

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PLUG] Debian/Ubuntu installer LVM issue

I tried to talk about this before but mangled the details quite a lot.
I have a problem every time I configure LVM.  I want to leave free
extents, to allow for snapshots [1], but I can't figure out how to
calculate it.  Here's an example.

I've created a 2G lv_swap_1 and now according to pvdisplay I have:
	PV Size		465.52GB
	PE Size (KByte)	4096
	Total PE	119173
	Free PE		118661
	Allocated PE	512

If I allow it to use the entire rest of the disk, 497700MB, it works,
and I end up with 0 free PE (which is bad since it prevents snapshots). 
  But when I try to make 497700MB *smaller,* I get an error that there
are not enough free PEs!  WTH?!?

I want to leave about 2G free, so you'd think 497700-2048=495652.  When
I try to create an LV that size, in the curses GUI I get:
	Unable to create a new logical volume (lv_root)
	on vg_hostname with the new size 0."

But on ALT-F4's text console I get:
	...partman-lvm: Insufficient free extents (118661) in
	volume group vg_hostname: 123913 required.

Huh?!?!?  So it turns out this is a really stupid bug in the Debian
installer where it uses totally different bases to calculate the

Note I am bad at simple math (or complicated math for that matter :), so
if anyone has a better way, let me know.  The rule of thumb I've come up
with is this:

Assuming 2G is about 512 PEs (i.e. default PE Size = 4096):
	lv_swap_1 = 512PE = 2G = "2147MB"
	lv_root = (#Free PE-515)*2/512 = approx G
		round to integer and enter as nnnG in GUI

You can get the "#Free PE" by going to another PTTY and running 
lvdisplay, or just trying it, then going to ALT-F4 and reading the error.

This "method" just worked on a test machine, but I'm pretty sure I'm 
doing something amazingly stupid with that math, and that several folks 
are about to slap me around for missing something blindingly obvious to 
a 3rd grader.  Bring it on...  :-)


[1] Guided partitioner with LVM leaves no free space for snapshots
JP Vossen, CISSP            |:::======|        jp{at}jpsdomain{dot}org
My Account, My Opinions     |=========|
"Microsoft Tax" = the additional hardware & yearly fees for the add-on
software required to protect Windows from its own poorly designed and
implemented self, while the overhead incidentally flattens Moore's Law.

Philadelphia Linux Users Group         --
Announcements -
General Discussion  --