Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

6 Answers 6

up vote 9 down vote accepted

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:

  • /boot located on a separate partition. If you have a combined root filesystem (everyting is stuffed into / ) then this won't work.
  • The ability to boot from a USB hard drive.
  • an external drive large enough to hold all of the data and programs on your existing system. Be sure to run a "du /" and wait for the end result, to get a real feel for the kind of space you'll need.

General Procedure (forgive me for lack of a few commands, I'm writing this very quickly):

  1. Attach the external drive and locate its device name. Let's pretend that you see it as /dev/sdb.
  2. Create a two partitions on your external drive. In our example, this will show up as /dev/sdb1 and /dev/sdb2.

    parted /dev/sdb

  3. Format the first partition as ext2 or ext3, and labeled "boot". Format the second partition on the external drive as type "Linux LVM".

  4. Get the newly minted LVM volume recognized by the system using

    pvscan ; vgscan

  5. 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.

  6. Format your LVM-based volume as ext3 or whatever filesystem tickles your fancy.

    mke3fs /dev/ExternalUSBVolume/ExternalRoot

  7. 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".

  8. create the special mountpoints by hand, so that they exist on your external drive. Do not populate them, just make sure the names and permissions match.
  9. (Very carefully) use your bootloader to install a boot image on your external drive, into the /boot partition. This process is a bit complex so I'll leave it to you to find the info elsewhere. It's also dangerous if you botch it - you could end up trying to overwrite your bootloader on your laptop drive. Be careful.
  10. Reboot your laptop. When it is going through the POST, be sure to specify the external drive as your boot drive. At this point in time, you should have a (more-or-less) near-replica of your laptop's drive. (to the other admins out there: yes, I know, the log files and others are not in a 100% copied state, but that's not the emphasis here...it's on getting the data and tools moved over...)
  11. Once you can boot from the external drive, you can then use it to wipe your laptop drive. At this point, you're "living out of" your external drive. Keep this in mind.
  12. Then use a partition editor - gparted or whatever - to delete the original laptop partitions (bye-bye data...), then mark your newly-minted area as "LVM". Go through the process of getting your LVM volume recognized, partitioned, formatted, etc.
  13. Using LVM's mirroring process, mirror your live system (which is currently on the external drive) back to the laptop drive. Take a lunch break (or two) for this as it will take time.
  14. Remount the live filesystem, moving the / filesystem from the external drive to your laptop LVM volume.
  15. Re-run your bootloader installation process. This is critical as the current ramdisk will not have the right settings and will not know you've moved things around. Failing to do this will result in an unbootable system and a visit to a rescue disk. If all else fails, you can boot from your external drive again (nothing lost...)
  16. Reboot the laptop without the external drive attached, and specifying the laptop's internal drive instead. It should boot fine. Note anything that feels or looks hurt or broken (there shouldn't be anything), and fix it.
  17. Sit back and enjoy a beverage for a job well done.
share|improve this answer
It's of course possible to do a live migration to the external storage (if you're brave enough you can even pivot the running system to the external disk and back without a reboot :D); doing the whole process from a live CD should be less error prone though (e.g. virtual FSs out of the way...) –  Luca Tettamanti May 4 '09 at 18:52
And by the way, LILO and the new version of GRUB (the one that will eventually become 2.0) have native support for LVs - no need for a separate /boot partition. –  Luca Tettamanti May 4 '09 at 18:55
I know. But I figured "better safe than sorry". Having a native partition makes fixing things a little easier. Perhaps the OP has to use a windows-based tool that doesn't understand LVM (many don't) - in which case, at least he can modify menu.lst with grub, etc. as needed. But thanks for the input! :) –  Avery Payne May 4 '09 at 19:18

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.

share|improve this answer
I just migrated my 2 ext4 partitions (totalling 120GB) to LVM in about 2 minutes using blocks. Worked flawlessly. –  Amr Mostafa Jul 28 at 21:43

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.

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

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)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.