Tugger the SLUGger!SLUG Mailing List Archives

[SLUG] Migrating from LVM to a plain old disk


IMHO if the previous instructions were too brief you ought not be doing this BOTOH how would you/interested naive users ever learn
... so more words ...
painful unless you've no clue ...

On 15/04/2012, at 10:00 AM, slug-request@xxxxxxxxxxx wrote:

> I want to migrate away from a LVM Volume Group (2 disks) to a single
> plain old disk (500G).
> 
> Back story: A couple years I thought I might have to learn about LVM.
> So I created a Volume Group using the Debian installer and have never
> done anything else.
> 
> My ideal solution (I think) is if there is a device I can `dd` from,
> and I can just set the destination disk as a non LVM'd disk.
> 
> Some output:
> # vgdisplay
> File descriptor 4 (/dev/urandom) leaked on vgdisplay invocation.
> Parent PID 4932: bash
> --- Volume group ---
> VG Name               erupt
> System ID
> Format                lvm2
> Metadata Areas        2
> Metadata Sequence No  4
> VG Access             read/write
> VG Status             resizable
> MAX LV                0
> Cur LV                3
> Open LV               2
> Max PV                0
> Cur PV                2
> Act PV                2
> VG Size               146.71 GiB
> PE Size               4.00 MiB
> Total PE              37557
> Alloc PE / Size       37557 / 146.71 GiB
> Free  PE / Size       0 / 0
> VG UUID               hrlysx-65nB-56Yt-VwUv-cC5O-wJIr-vjz4Jx
> 
> # pvscan
> File descriptor 4 (/dev/urandom) leaked on pvscan invocation. Parent
> PID 4932: bash
> PV /dev/sdb2   VG erupt   lvm2 [36.79 GiB / 0    free]
> PV /dev/sdc2   VG erupt   lvm2 [109.92 GiB / 0    free]
> Total: 2 [146.71 GiB] / in use: 2 [146.71 GiB] / in no VG: 0 [0   ]
> 
> Is this asking to much?

Without shadow of doubt dd will fail.
Don't use dd unless you understand what you are doing and why. In general dd should be avoided (but apologies because it is often MOST useful, just not here) 

I assume your LVM disks are /dev/sda and /dev/sdb and the new disk is /dev/sdc. Adjust names as needed.

as root, and in root's home: find / >list
fdisk /dev/sdc
create partitions eg 
/dev/sdc1 as root (say 10G)
/dev/sdc2 as swap (say 1G)
/dev/sdc3 as /home (the rest)

mkfs.ext4 (ext4 or whatever you choose) /dev/sdc3
mount /dev/sda3 /mnt

cat list | cpio -pdv > /mnt

The choice of sdc3 sdc1 etc depends on what you know you are doing ie do you have a root partition and an LVM /home in this case I use /dev/sdc1 as root and /dev/sdc3 as /home

reinstall grub/lilo
depends so much on your distro. if in doubt INSTALL your distro on the sdc1 partition presumably by disconnectiong the two LVM discs and choosing /dev/sda1 as root and using /dev/sda3 as /home without formatting it

James