My Linux server uses LVM because I replace the machine a year ago and installed from scratch. LVM has been a life saver and I love its flexibility. My Linux laptop, however, was last fully installed three years ago, and thus uses straight partitions.
Is it possible -- without a reinstall -- to convert an existing system to LVM? If so, what tools can do this job?
I expect that any filesystems to be shared with Windows on a dual-boot system cannot be LVM. If I am wrong, please let me know, but I would be surprised.
Yes, this can be done.
Yes, you can use it for a dual-boot windows system, provided you make Windows the first partition, and it's a primary partition (not an extended inside a logical). My instructions here do not cover this situation, which requires you have some experience dealing with dual booting. If you're after a dual-boot windows/linux setup, don't follow any advice below this point.
I'll go one better: with only a few exceptions, you should be able to migrate your entire laptop live, provided you use an external drive with enough capacity.
Warning! This proceedure is EXTREMELY DANGEROUS! It assumes you have intimate knowledge of the partitioning process, you have a separate /boot partition, and you know a botched attempt can leave you with a brain-damaged installation THAT WON'T BOOT! YOU HAVE BEEN WARNED!
You'll need:
General Procedure (forgive me for lack of a few commands, I'm writing this very quickly):
Create a two partitions on your external drive. In our example, this will show up as /dev/sdb1 and /dev/sdb2.
Format the first partition as ext2 or ext3, and labeled "boot". Format the second partition on the external drive as type "Linux LVM".
Get the newly minted LVM volume recognized by the system using
Carve off a large-enough chunk of the external LVM volume to hold the entire laptop's hard drive. If in doubt, just use all of the space available.
Format your LVM-based volume as ext3 or whatever filesystem tickles your fancy.
For each non-special file system mount, create a directory on your external disk and copy (with attributes) all of your files in each mount to that disk. Ignore copies of mountpoints like /proc, etc. as these are "special".
I recently wrote blocks (née lvmify) which does this conversion in-place. It takes a single partition, shrinks the filesystem if necessary, moves the start of the filesystem to the end of the partition, and copies an LVM superblock (preconfigured with the right PV/LV/VG) in its place. If you have multiple partitions, merging the newly created volume groups is done with
vgmerge
. It can't work on mounted filesystems.The easiest way to move a linux system to LVM is to use a external disk (USB, eSATA) and a CD-ROM based system like grml to move away all data from the PC to the external disk, then re-partition the PC with LVM. Finally copy everything back and configure and re-install grub to the MBR.
This procedure is slightly involved, but you always have the data on the external drive and the CD-ROM to boot your system.
As you correctly expect, Windows is not able to access any LVM volumes.
http://serialized.net/2006/04/migrating-live-filesystems-to-lvm/ has an interesting way of migrating a live fs. Add it as part of a RAID-1 group, which the OS will then mirror to the other device (which could be an LVM logical volume). It's a bit dated, so I don't know if that would still work.
Starting from the bottom: no, windows cannot read LVM logical volumes (partitions).
If you have a spare disk that can be used as temporary storage the it's just a matter of booting from a live CD, copying the data to the temporary location, creating one or more LVs and putting the data back. It's impractical (but possible) to do an in-place conversion to LVM; you basically have to shrink the old partition and resize the the LV multiple times (and the final LV would be fragmented)
You have a several year old installation on a laptop. It is a losing proposition to convert it to LVM. Backup your data, reinstall, and copy your data back. You will have a clean system with new software, and your data.
If you can't do this because you don't know where your data is, you have a big problem and this is your chance to solve it.
You will probably have to backup the data to another drive or partition (or iso?), create the LVM container, and then restore the data to the container.