Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Booting from LVM
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Kaboosh
Apprentice
Apprentice


Joined: 10 Jun 2004
Posts: 162
Location: Edmonton, AB - Canada

PostPosted: Fri Sep 24, 2010 7:52 pm    Post subject: Booting from LVM Reply with quote

I've been reading about partition limits, MBR-style, and GPT-style partitions and I sorta like what this guy has to say: http://insan-it.blogspot.com/2010/09/gpt-versus-lvm.html

That being said I've used LVM enough to be comfortable but I've never had an "all-LVM" volume without a partition table. First:
1) Is this possible? Can I boot off an LVM volume?
2) If not, than can I try this guy's idea and create a small (512MB) /boot partition and embed LVM into the remainder of the disk? Can you create an LVM physical volume at an arbitrary offset (in this case at the end of the partitions)? I've looked into using loopback to achieve this since losetup takes an offset but what is the size limitation on loopback devices?
3) Someone mentioned that GRUB2 can boot from LVM. I'll RTM and try to set this up...then I'll post back with results. 8)
_________________
"The philosophy of one century is the common sense of the next." - Henry Ward Beecher
Back to top
View user's profile Send private message
chithanh
Developer
Developer


Joined: 05 Aug 2006
Posts: 2158
Location: Berlin, Germany

PostPosted: Fri Sep 24, 2010 9:29 pm    Post subject: Reply with quote

GRUB 2 can boot from LVM, by placing the necessary boot code in the reserved area between the MBR and the start of the first partition. But you still have to have one partition on the disk, containing your pv.

BTW that blog post is full of uninformed opinions.
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2977
Location: Germany

PostPosted: Fri Sep 24, 2010 11:29 pm    Post subject: Reply with quote

I boot off USB (regular grub and boot partition on the usb key) so yeah sure I could make the internal disk full LVM without any partitions whatsoever...

...but to what purpose?! I still partitioned the disk with GPT and put several LVM PVs onto GPT partitions of that disk. So should I ever need part of the disk as non-LVM (for example a Windows data partition for a dual boot system), I can free one of the PVs and format it with something else.

As far as I'm able to tell there is no speed penalty involved whatsoever with using LVM on partitions as opposed to direct on disk. Exception being the LVM tools themselves, creating new LVs takes a wee bit more time with several PVs as opposed to only one PV. However I don't go creating LVs all day.

Quote:
create a small (512MB) /boot partition and embed LVM into the remainder of the disk?


That's usually how it's done. You don't even need a bootloader with LVM support, then. Normal good old Grub suffices, as it can load the kernel from the boot partition manually. The kernel itself, naturally, will have to support LVM, and come with an initramfs that initialized LVM, so it can find and mount the LVM root partition. genkernel does that for you, alternatively check the initramfs guide in the gentoo wiki
Back to top
View user's profile Send private message
Kaboosh
Apprentice
Apprentice


Joined: 10 Jun 2004
Posts: 162
Location: Edmonton, AB - Canada

PostPosted: Sat Sep 25, 2010 4:18 am    Post subject: No Go Reply with quote

OK...so if you create an LVM volume on a disk you can "reserve" a small amount of space by moving the initial label up to the 3rd sector:
Code:
pvcreate --labelsector 3 /dev/sda


I did a hexdump and got:
Code:

00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000600  4c 41 42 45 4c 4f 4e 45  03 00 00 00 00 00 00 00  |LABELONE........|
00000610  68 6b 72 e7 20 00 00 00  4c 56 4d 32 20 30 30 31  |hkr. ...LVM2 001|
00000620  63 6c 44 51 6a 32 44 58  4b 53 36 38 47 6b 6e 61  |clDQj2DXKS68Gkna|
00000630  32 50 36 76 6a 44 32 49  59 6f 74 59 39 78 36 67  |2P6vjD2IYotY9x6g|
00000640  00 60 97 f2 1b 00 00 00  00 00 03 00 00 00 00 00  |.`..............|
00000650  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000660  00 00 00 00 00 00 00 00  00 10 00 00 00 00 00 00  |................|
00000670  00 f0 02 00 00 00 00 00  00 00 95 f2 1b 00 00 00  |................|
00000680  00 60 02 00 00 00 00 00  00 00 00 00 00 00 00 00  |.`..............|
00000690  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00001000  f7 a5 f9 a0 20 4c 56 4d  32 20 78 5b 35 41 25 72  |.... LVM2 x[5A%r|
00001010  30 4e 2a 3e 01 00 00 00  00 10 00 00 00 00 00 00  |0N*>............|
00001020  00 f0 02 00 00 00 00 00  00 06 00 00 00 00 00 00  |................|
00001030  a6 03 00 00 00 00 00 00  ea 36 42 05 00 00 00 00  |.........6B.....|
00001040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00001200  56 47 5f 54 45 53 54 20  7b 0a 69 64 20 3d 20 22  |VG_TEST {.id = "|
00001210


So there's usable space between 0x0000 and 0x0600 (1536 bytes). There's also space between 0x0690 and 0x1000 (2416 bytes) although I doubt it's "safe" to use that for boot code.

So I just installed Grub 2 and took a look at what I needed:
Code:

/lib/grub/i386-pc/lnxboot.img = 1024 bytes
/lib/grub/i386-pc/ext2.mod = 5524 bytes
/lib/grub/i386-pc/lvm.mod = 5496 bytes


Some other interesting ones:
Code:

/lib/grub/i386-pc/ata.mod = 7972 bytes
ata.mod.gz = 3963 bytes
/lib/grub/i386-pc/gzio.mod = 7740 bytes
ext2.mod.gz = 2968 bytes
lvm.mod.gz = 2896 bytes


Definitely a no go...bummer this was a fun mini-project. About the only steps I could take from here would be to use a slightly smaller LVM and embed grub code at the end of the disk or create a loopback device with an offset to make space for grub code. BOTH of these solutions are a bigger "kludge" than Mr. Opinionated suggests GPT is :P
_________________
"The philosophy of one century is the common sense of the next." - Henry Ward Beecher
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum