[Gllug] Removing LVM (RHEL4)

Peter Grandi pg_gllug at gllug.for.sabi.co.UK
Tue Oct 18 10:33:32 UTC 2005


>>> On Tue, 18 Oct 2005 10:51:00 +0100, Mick Farmer
>>> <mick at dcs.bbk.ac.uk> said:

mick> Dear GLLUGers, I'd like to remove the LVM created when
mick> I installed RHEL4.  However, the man page for lvremove
mick> states that you can't remove an LV that has something
mick> mounted on it.

That is not at all surprising; note also that unless you take
special care, removing even an unmounted LV might ''remove''
also what is in it.

mick> The root file system is mounted there!

Well, that's to be expected -- the root filesystem ''sits on
top'' the LVM2, so you take away the LVM2, bye root filesystem,
so what happens to the mount?

mick> Does anyone know of a workround?

Well, only for the brave...

While logically the root filesystem is ''on top'' the LVM2,
physically it is ''inside'' it, that is a filesystem is
contained inside the logical boundaries of a LV.

Now the big question is whether the physical mapping for the LV
containing the root filesystem is just one contiguous mapping
(which is sort of likely, unless you enlarged the LV); if so you
can ''just erase'' the DM/LVM2 mapping tables, and then create a
new partition table with a partition that begins where the
mapping for the LV began and ends where it ended.

One way of doing this would be to run 'gpart' or 'testdisk' that
scan discs for filesystem boundaries and try to reconstruct the
partition table using those boundaries.

Now while I suspect that the truly brave :-) could do this
''online'' and it might even work (and it most probably requires
hand binary patching the running kernel), it should really be
done 'offline'' from a rescue CD.

  Almost all of which come with at least 'gpart' and most Linux
  live CDs too have it too. Then there are tool CDs, and I like
  those at UltimateBootCD.com and SysRescCD.org among several.

    http://WWW.stud.Uni-Hannover.DE/user/76201/gpart/
    http://WWW.CGSecurity.org/index.html?testdisk.html
    http://WWW.PartitionSupport.com/utilities.htm
    http://WWW.LinuxDocs.org/HOWTOs/mini/Partition-Rescue.html

If at all: I personally reckon that the best way to reorganize
filesystems is to have a second backup disc of at least the same
capacity, on which to create the new layout, and then copy
contents across either with a double-'dd' (or equivalent) line,
or with a double-'tar' (or equivalent) line, which also has the
advantage of freshly reloading (optimally) the contents, and
then either swap disks or copy back.

Mostly because this implies creating a backup (a surprisingly
good idea when messing around with on disc data), in part
because (but it does not apply to your case here) copying
between two discs is much, much faster than copying around
things on the same disc.

-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list