Dark's Code Dump

Possibly useful

Convert LVM LV to regular partition

I decided to simplify my storage configuration where LVM had ended up being used for 1 or 2 contiguous partitions, with 1 VG per PV, so it served no purpose over basic partitions.

Several answer sites claim this cannot be done and requires a full backup and restore, but where is the fun in that?

  1. Ensure the LVM LVs are contiguous using e.g. pvs -v --segments. If they aren't, either pvmove them so they are, or use the traditional backup+restore technique.
  2. Write down the contents of dmsetup table and fdisk -l /dev/sd-whatever for all the relevant disks.
  3. Grab the last number from dmsetup table (representing start offset) for the relevant partition and add it to the 'start' column of the PV partition from fdisk -l. This is the true physical start sector of the partition, ignoring LVM.
  4. Also grab the second number from dmsetup table - this is the size of the partition in sectors.
  5. Using fdisk, delete the partition holding the LVM PV, and add a new partition. The start sector is the sector calculated in step 3. The end should be specified as an offset (prefix +) of the sectors gathered in step 4.
  6. Optional: fire up gparted and move partitions to fill the gaps

Comments

Hossein says:

found you through a google search. you’re awesome. thank you for sharing 🙂

Leave a Reply