The Mess That is Linux Volume Management
The ProblemIt all started when I installed Gentoo for the first time. Or actually, my friend did it for me - since it was more difficult than installing OpenBSD, as the latter can be done in two minutes. After Slackware, it was the second Linux distribution to touch the platters of my harddrive. I was quite used to the rather rigid partition schemes of OpenBSD, in which /usr, /var, /tmp, /opt and /home all have their own partitions. Not being experienced at all, I remember I thought "1GB must be enough for /usr" only to find out it wasn't if I installed a lot of applications. Normally, such a thing would require re-installation of the OS if it was too difficult to re-partition the disk without losing data.That's when my friend said to me: "You know, in Linux there's some way to prevent this kind of problem, by using a system in which you can dynamically resize partitions without even having to reboot your computer!". The SolutionThat's when I learned about LVM, and I immediately wanted to try it. I was encouraged when I found a guide how to install Gentoo on an LVM-system. I found out the most important thing to make LVM work was the device mapper. The device mapper makes virtual block devices; which basically means virtual partitions. On this virtual partitions, one can put a filesystem and mount that filesystem to use it. Or - and that's what makes Linux volume management so flexible - one can put another virtual partition on a virtual partition, in other words layer the virtual devices. Using LVM wasn't really hard: I just typed over the commands given in the HOWTO while changing some parameters to my liking, and in a short amount of time, Gentoo booted using my new LVM environment. However, because I was using LVM1 back then, my system wouldn't boot at first. Running lvchange -a y when the boot halted halfway cured this.Not much later, my friend and I were once again in a contemplating mood, and my friend told "Did you know you can encrypt your harddisk in such a way that even most secret services (almost) can't decrypt them?". I was eager to find out, and in no time I stacked up an encrypted virtual block device on top of the LVM virtual block devices. OK, I had to type 32 characters everytime /home was mounted, but it gave a great feeling of privacy. But I did came across a problem: The Gentoo-init scripts assumed you would encrypt a physical partition and put virtual partitions on top of that encryped partitions. I did it the other way around: I put my encrypted partition on top of virtual partitions, so I had to write a bash-script to mount my encrypted partition. It was in the time of Fedora 2 probably (though I hadn't heard of Fedora back then), and I remember even the 'cryptsetup' CLI-frontend wasn't available back then. I had to use the dmsetup command, which took lot and lots of parameters. Yeah, I remember being glad when Christopher wrote cryptsetup. I tried to hack the Gentoo-init scripts but failed. Only one year later or so the Gentoo-init scripts were changed exactly in the way I tried: Making it possible to stack encrypted virtual block devices on LVM virtual block devices or the other way around both worked. However, having Gentoo without experimenting doesn't make much sense, so when buying a new computer I decided to take my volume management to the next level. Finally, a GUI!About the same time I learned about volume management, I learned about software-RAID too. However, mastering the Linux' mdadm commando looked quite difficult. I was rather scared of the mdadm tool. That doesn't make sense at all for somebody who used the dmsetup commando to setup encrypted partitions, but choices are not always rational. However, I found out about Enterprise Volume Management System, a graphical frontend which handles LVM2, software RAID and even much more. "That's what I've been looking for!" I thought. About reading some more, I even thought "Phew, this EVMS thing is going to save me a lot of time!". Indeed it did, when setting up my new volume management scheme. However, I couldn't have foreseen the way it would screw up that very same scheme two years later.The SchemeThe scheme was quite complex for a home-PC; but I'll try to explain. I had two 80Gb / ~73GB hard drives. Both Lilo and GRUB are not capable of booting from EVMS. Therefore, one needs a non-EVMS partition to boot from, or an initrd, but I detest the latter. However I wanted to use software-RAID on my two drives, which works best if the two partitions used are equal of size. Therefore, I reserved the first 2GB of both drives for my small root-partition and I used the other 71GB for my software RAID-drive. That very same decision would cost me a lot of trouble later, but at that moment it seemed a good idea to do it that way. EVMS put the two 71GB partitions used for RAID in one software-RAID device named md0. One can directly make a filesystem on such an md-device, but instead I added all space on md0 to my LVM-container named c0. That LVM container can be seen as an aquarium with water: I can take out glasses of water of any size out of it, and put water from my glasses back in to the aquarium and after that into other glasses of water as much as I want.
Off course, there's a maximum of water I can use: The amount in the aquarium. The glasses were my LVM virtual block devices, which contained the /usr, /opt and so on partitions mentioned earlier. On top of those LVM virtual block devices I could have put another mapped virtual device, for example an encryption layer, but I was rather tired of typing 32 character passphrases every morning when I boot my computer. I had to boot my computer because software-suspend didn't support crypto layers back then, and I wouldn't be surprised if it still doesn't. My new scheme worked really well. In fact, it worked so good, when I built my second computer I decided to use two 80GB drives also and used exactly the same EVMS scheme. I even used the same names for the LVM containers and virtual block devices. Not smart, as would be proven later. Like always: Windows is the forerunner of troubleSo, Everything worked like I envisioned, until I needed Windows. Like usual, Windows also meant problems this time. I needed AutoCAD which wouldn't run on Wine because the freakin' thing needs SP2. Therefore, I tried to install Windows on my 2GB. That was quite hard, but eventually I managed to do it by using space-saving tricks. Being really economic, like a genuine Dutchman is ought to, I only used 300MB of my other 2GB partition for Linux' root partition. That meant I had 1.7GB left, which was exactly enough to install AutoCAD. All worked quite well, but then I wanted to install AutoDesk Inventor. A real nightmare, (also) when it comes to hard disk requirements. I figured out I needed 3.5+GB to install it, so of course my almost filled two 2GB partitions were not enough. "I need to add some of my EVMS-space to my Windows FAT partitions" I decided, but how would I do that?First I thought "EVMS is meant for easy volume management, so this can't be hard at all; probably it is even very simple'. Boy was I wrong! In theory, it goes like this:
Screwing it upInstead of buying an external disk, I decided to take the two EVMS arrays, take the files of the smallest EVMS array which were not on the second and backup those to the second. Then, all my files would be on the second array, and I could start over with my first EVMS array. After that, I could move my data to the by then 'reschemed' first array, and 'rescheme' my second array.Nonetheless, this required me two connect all four hard drives to my computer at the same time. That was no problem; my mobo supported that, and I booted from a Gentoo Minimal CD. I thought the fun could start, when I noticed a problem: Both LVM containers were named c1, so I only could use one of those at the same time. Stupid. Really stupid. So I tried to rename one of them to c1. And failed. EVMS wouldn't run my arrays anymore. Instead of EVMS I tried using LVM2 directly now, but that didn't work and made things worse; and as you can see when following the link help didn't turn up. I finally decided to use mdadm to restart my software-RAID arrays but because it was the first time had I used mdadm; I screwed up even more dramatically by using the force switch and -assume- clean and after that mounting my software-RAID device. It only used one of the two RAID-partitions, so all my files were halved. Mounting the failed RAID-device caused some important EVMS meta-data to screw up in such a way that finally I considered my 80GB of files on that array as lost. Sadly, it was the array that was the most filled with files. On the bright side of things, this enabled me to wipe it all out and start again. This time using LVM2 and mdadm from the start on. Again, as in the 'old days', from the command line... Alternatives and ConclusionNot much later, I saw somebody on LXer asking for a GUI for LVM. That would be a very logical thing to ask. EVMS is just that and much more, however I can't recommend it to anyone while it's not supported anymore; and as you can't shrink software-RAID partitions. Then there is system-config-lvm, but it's something from RedHat which is not in the repository of Gentoo, meaning Gentoo doesn't support it. Update: I was wrong, it is in the Gentoo repository, but hardmasked because it needs testing.There's also the Aperi project, but it's not finished yet. SunsZFS would be a solution, but GNU/Linux's license is not compatible with the ZFS license, so that's not an option for Linux either. Which means, at this moment, you have to use RedHat or the CLI if you want to use LVM. Kinda sad, I'd say. For now we can only hope someone makes a simple GUI for LVM available on all distro's, or - like open source works - and do it ourselves of course! |
|
|
Comments (15)
Bad luck and some mistakes
Quoting:after I successfully shrunk my LVM container, I couldn't figure out how to shrink the md0 software-RAID partition. Turned out it wasn't possible in EVMS. And worse, IBM - the maintainer of EVMS - stopped to maintain it.
EVMS is just a front-end. You could have easily used the mdadm CLi tools to shrink md0.
Quoting:nadequate backup system - you know better. Shame on you.
Indeed; that's the main problem.
Quoting:Why install Windows to a partition when you could have used a VM?
Ah, forgot about that. I had 'problems' installing the VMWare-tools which made it all very slow; too slow to work with. The problem was I just didn't know how to install VMWare-tools. I thought it had to be done from Linux with a package from some repository. If that's the way you're searching, it's going to take a long time. At this moment, AutoCAD runs beautifully in a VM, and the native Windows installation is entirely gone!
The only problem is AD Inventor needs 3D acceleration for an acceptable result. VirtualBox doesn't provide that, otherwise I wouldn't be using VMWare, and for VMWare 3D acceleration is beta at this moment. I once got DirectX9 working in VMWare, but sometimes it crashed. Right now Inventor uses the OpenGL 3D-acceleration in VMware, but still it sometimes crasheh. Performance is rather good though, but I did have to expand my RAM beyond 1GB because that was not enough.
Quoting: You could have easily used the mdadm CLi tools to shrink md0.
Something tells me I have been trying that and failed, but I'm not exactly sure what I did and where it went wrong. Probably when I ran LVM instead of EVMS. I should have ran mdadm without EVMS to shrink it before running LVM without EVMS. OK, that's for next time!
A problem of expectations, not of Linux volume Management
LVM is designed to provide flexible volume management within Linux and it does that well. It is not designed to provide fault-tolerance, nor to accommodate Windows.
MDADM software raid is designed to provide fault-tolerance and the performance benefits of RAID and it does that well. It is not designed to provide flexible volume management, nor to accommodate Windows.
Your initial setup was designed to provide flexible volume management with fault-tolerance within Linux -- and it does that well. But you were not thinking ahead to accommodate Windows. Can't blame Linux, LVM, or even EVMS for that!
Could it have been done, using the same tools, but with greater foresight? Sure -- here's how:
Let's say you want the flexibility of being able to repurpose the diskspace however you like in 10 G chunks... Take your two 80G disks, carve out space for /boot as you describe above, then partition the rest of the disks identically in a series of 10G partitions and a final partition of whatever is left. Now, use software raid to mirror each pair: sda2 + sdb2 = md0, sda3 + sdb3 = md1, etc.
That leaves you with two partitions used for /boot and a series of software RAID devices (md0, md1, md2, etc.). Initialize each RAID device as an LVM physical volume and add them all to the volume group. At this point -- the result is the same as your setup. You have 2 G for /boot and roughly 71G in a volume group for use with your logical volumes. But NOW, to make room for Windows, you need only resize filesystems as needed, resize logical volumes as needed, use pvmove to move all data off of one of the 10 G raid devices acting as physical volumes and you can remove that raid device from the volume group. Then you could disassemble the raid device and you would have two 10 G partitions available for use by Windows.
As an aside, you really should get over your dislike of initrd and the command line tools. initrd is widely used in enterprise systems and works very well. And mdadm and lvm are easy, easy to use at the command line with just a little practice.
Quoting:You're asking a set of tools to be able do whatever you currently need
Maybe. I see it more like this: I was hoping EVMS would do whatever I currently need. I'm not blaming LVM or mdadm; they don't pretend to be the all-in solution. But I however agree the expectations are the most important problem; if I have had lower expectations of EVMS I would have left more HD-space unused probably. Anyway, I hope some people with EVMS-expectations read this article to make their expectations more 'real-world'.
Back to LVM/mdadm: maybe that wasn't clear from the article; in fact I do like LVM and mdadm very much. LVM never let me down, and both LVM and mdadm didn't create my troubles, and even could have prevented my troubles. I also like to use the command line, but basically the problem is other people want to do the same things without using the CLI. For me, it was more like 'why use the CLI (LVM/mdadm) if a GUI is available?'
Quoting:But you were not thinking ahead to accommodate Windows
I did plan that in fact. But of course, 2GB is far too less. Being used to Linux however, I did think it was enough when I partitioned my HD. I also didn't know about Inventor HD requirements back then. So there was some thinking ahead, but not enough.
Quoting:Let's say you want the flexibility of being able to repurpose the diskspace however you like in 10 G chunks... Take your two 80G disks, carve out space for /boot as you describe above, then partition the rest of the disks identically in a series of 10G partitions
That's exactly what I thought and was planning to do! However, after the 'foresight problems' I kind of 'locked myself in' to EVMS and this wasn't possible anymore. Yes, it would have been if I had used 'mdadm' to shrink my RAID partition like Sander suggests in the other thread. But I didn't know that was the way to go. If I had asked on some forum instead of just try & pray I would have got better results. Consider that a lesson learned!
Quoting:GParted is a lot faster and easier than running all the individual programs that lie under its hood.
Indeed, that's what I was trying to say Carla. EVMS is faster and easier than running all of the individual programs. You can use the EVMS CLI too if you want; I normally use the GUI or ncurses GUI if X isn't available. But it doesn't have all the capabilities the individual programs under its hood have. I'm not blaming (IBM for stopping to maintain) EVMS, in fact I was glad it existed - and still does. However, I find it very sad to see some IBM-devs working on the new Aperi project while the other former IBM-project EVMS is being unmaintained.
I do not totally agree with you guys when you say that LVM is not designed to provide fault-tolerance.
There is a RAID mirroring solution within LVM (lvconvert -m1 ...).
I think the problem is always the same, a few teams working on different products to reach the same goal, MD team and LVM team, which finally feeds the confusion down here.
1) DM-Multipath provides multipath
2) MD provides RAID and also provides multipath -- I think in a failover fashion only !
3) LVM2 provides volume management and also RAID (1 and may be more).
The question that always get asked is :
What solution do I need to use to be completely redundant and optimal. In clear, what are the best practices to provide to my computer (imagine a server with critical apps) both optimal path load-balancing, maximum security by eliminating disks SPOF's, and flexibility by allowing me to resize a FS if needed.
As I did, you have to try different solutions to reach the not less complex one, use these 3 tools jointly even if, on, the paper 2 would have been sufficient.
For information, mirroring with LVM is quite simple, but when you get to resize your LV's, you then discover that you have to first split your mirrors. I'm not even mentioning the need of a 3rd disk to keep the mirror metadata !!!
I think having a look at the other unices (HP-UX, Solaris, though I consider HP-UX superior in terms of volume mgmt than Solaris before ZFS gets completely considered production ready ) and take the ideas.
Brem
Gentoo & system-config-lvm
http://packages.gentoo.org/package/app-admin/system-config-l...
Also, really really start doing better backup, and stop using EVMS, just use LVM2 only (and softraid if you need, which is better than the LVM2 mirror/stripe).
Quoting:Gentoo does contain system-config-lvm, it's just hardmasked
Corrected it in the article; thanks. Thought 'hardmasked' means it doesn't work or is dangerous. Usually the emerge -a or emerge -p shows the remarks explaining why it's hardmasked. But now I see the remark actually says it "only' needs testing" and doesn't break my system. Great, I'm going to give it a try!
Quoting:Also, really really start doing better backup, and stop using EVMS
The second is already done, the first not, so thanks for reminding. Still have to buy that external HD!
system-config-lvm
in debian in testing (soon becoming stable) and unstable http://packages.qa.debian.org/s/system-config-lvm.html
it will be in the next version of ubuntu due in October : http://packages.ubuntu.com/intrepid/system-config-lvm
So, this package is not RedHat only now....
LVM2 and mirroring
lvcreate [--addtag Tag] [--alloc AllocationPolicy] [-A/--autobackup y/n] [-C/--contiguous y/n] [-d/--debug] [-h/-?/--help] [-i/--stripes Stripes [-I/--stripesize StripeSize]] {-l/--extents LogicalExtentsNum? ber[%{VG|PVS|FREE}] | -L/--size LogicalVolumeSize[kKmMgGtT]} [-M/--persistent y/n] [--minor minor] [-m/--mirrors Mirrors [--nosync] [--mirrorlog {disk|log}] [--corelog]
But there's still a problem, it needs a third disk for the log or the mirror will be reconstructed at each reboot.
Hardware RAID is not applicable in all cases, in mine it is not for what I want to do.
I need to mirror 2 FC disks from 2 disk arrays, this is not Hardware RAID possible.
cf my blog at http://brehak.blogspot.com/2008/08/lvm2.html for detailed explanation on what I'm trying to do
The thing would be to submit RFE's to the LVM2 development team, based on the most popular features, especially taking into account the professional uses of Linux.
Grub and lvm
Post a comment
A free account is needed to post. Write your comment here first: your text is kept in this browser while you sign up or log in, and is waiting for you when you come back.
Your message:Sign up and post (it is free) or Log in and post


You got burned by the unforeseen deprecation of EVMS. You know the routine - if it's open source you can fix it yourself or organize a group who has a shared interest in doing so.
You made some early mistakes with drive configuration and partitioning. It happens to most beginners as the filesytem hierarchy is confusing and you don't know how much space to reserve for each directory tree.
Inadequate backup system - you know better. Shame on you.
On Ubuntu Hardy Heron I am using RAID1 > LVM > LUKS/dm-crypt. I have a small RAID1 partition mounted as /boot, a second 2G RAID1 for LUKS/dm-crypt swap, and the rest as a RAID1 LVM physical device. Within the LVM there are several logical volumes which are individually encrypted. I have volumes for /, /usr/local (unmanaged third-party games mostly), and several for various home directories. Except for the root volume I don't enter individual decryption keys for anything. Swap is unlocked and mounted via /etc/crypttab using a preset key. Home directories are mounted similarly using pam_mount. The keys I keep in /etc/keys/dm-crypt/ which is readable only by root.
Setting this all up was not easy. The Ubuntu Alternate CD has to be used and the partman has a lot of bugs and fundamental design flaws ( [url=https://bugs.launchpad.net/ubuntu/ source/mdadm/ bug/68308]https://bugs.launchpad.net/ubuntu/ source/mdadm/ bug/68308[/url] ). I've found workarounds like allocating space for swap but not formatting or using it until after install else partman fails. Fedora and Suse have user-friendlier tools for it but they can't handle RAID + LVM + LUKS/dm-crypt all at the same time. I refuse to spend time making custom images with custom initrd scripts just to make them work.
For management I agree that there needs to be some GUI tools. Webmin does handle RAID and LVM but it's overkill, tedious, and doesn't handle LUKS/dm-crypt. But some management tasks like resizing are hard to implement with a GUI on a running system. Mounted volumes can't be messed with usually and only some filesystems can be resized. LUKS/dm-crypt volumes are difficult to resize in-place. Basically doing anything other than informing you that the RAID is desynched (cat /proc/mdstat) is difficult.
A LiveCD designed for a specific distribution to support common management tasks would be more practical.
But you made one decision I don't understand. Why install Windows to a partition when you could have used a VM? I run Altium DXP on Windows XP in VMware Player 2 without any problems. I store the image file on DVD so I can delete it from the drive if I need more space. Dual-booting is obsolete.