Moving LVM partitions to a new system

A few months ago I lost my main workstation that also doubled as my backup server, my web development server, the white noise generator and over all everything machine for my home network.

On that system I run Arch Linux, like do for all of my systems except for my daughters which runs Edubuntu 8.04. I had all of my internal hard drives setup on LVM2 (Logical Volume Manager) partitions. When that system went down I was a shocked. To this day my beloved system still isn’t up and working correctly. So, in the mean time I was able to gather some old PC parts I had sitting in boxes and build out my “official” storage solution.

My storage solution is built up using a dual Pentium III 700 Mhz system with 256MB of RAM, a 4 port SATA PCI card, four 1 Terabyte hard drive & a 20Gig system drive. Over all it is a clunker besides the 4TB of hard drive space. But you are hear to read about my storage system & to know how to re-access your stranded LVM2 partitions.

Step 1: Move the functional hard drive(s) into a system that can read the LVM mappings (This means you have all the proper kernel modules installed & corresponding LVM software). Now if you have multiple drives that make up your LVM mappings, then you need to be able to have all drives accessible in one system. For me I only had one large drive mapped out to different volumes. I was able to add my drive to my storage server by using an external USB case.

Step 2: Once that the drive(s) is physically accessible in new system, you need to know what are the Physical Volume(s) (PV), Volume Groups (VG) & Logical Volume(s) (LV). To obtain this information run the following commands with root privileges & take note of the VG & LV names.

Step 2a: Show the list of available physical volumes by running su -c ‘pvdisplay’ .

[testuser ~]$ su -c 'pvdisplay'
--- Physical volume ---
 PV Name               /dev/sdf3
 VG Name               VolGroup00
 PV Size               150.56 GiB / not usable 2.66 MiB
 Allocatable           yes
 PE Size               4.00 MiB
 Total PE              38542
 Free PE               14222
 Allocated PE          24320
 PV UUID               YSFO73-x3IY-wNTg-CUND-e3wT-7Whb-yLk4iO

 ...

Step 2b: Show the list of available volume groups by running su -c ‘vgdisplay’ .

[testuser ~]$ su -c 'vgdisplay'
  --- Volume group ---
  VG Name               VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  25
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               150.55 GiB
  PE Size               4.00 MiB
  Total PE              38542
  Alloc PE / Size       24320 / 95.00 GiB
  Free  PE / Size       14222 / 55.55 GiB
  VG UUID               oGX7wj-BLCd-6M8Q-3hPc-8wVN-r7jR-3Z6dgU

  ...

Step 2c: Show the list of available logical volume by running su -c ‘lvdisplay’ .

[testuser ~]$ su -c 'lvdisplay'
  --- Logical volume ---
  LV Name                /dev/VolGroup00/Root
  VG Name                VolGroup00
  LV UUID                lnKn4G-BH0d-tn38-KJuz-o1ci-afVD-ncm5Zn
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                15.00 GiB
  Current LE             3840
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2

  --- Logical volume ---
  LV Name                /dev/VolGroup00/Home
  VG Name                VolGroup00
  LV UUID                l7oeK7-YKNV-KS2c-fXvO-hXpe-hIQP-LsqFxR
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                80.00 GiB
  Current LE             20480
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3

  ...

Step 3: Now that you have the volume group name you need to make the volume(s) accessible on the new system. That is done by exporting (aka removing) the historical volume mappings, importing the volume group into the new system & activating the volume group.

Step 3a: Export the volume group with su -c ‘vgexport <replace with volume group>’

[testuser ~]$ vgimport VolGroup00
 Volume group "VolGroup00" is not exported

Step 3b: Importing the Volume Group using pvscan & then su -c ‘vgimport <replace with volume group’

[testuser ~]$ su -c 'pvscan'
 PV /dev/sdf3    is in exported VG VolGroup00 [150.55 GiB / 55.55 GiB free]
 PV /dev/md0    VG RaidArray    lvm2 [2.73 TiB / 1.17 TiB free]
 Total: 2 [897.09 GiB] / in use: 2 [897.09 GiB] / in no VG: 0 [0   ]

[testuser ~]$ su -c 'vgimport VolGroup00'
  Volume group "VolGroup00" successfully imported

Step 3c: Activating the Volume Group by using su -c ‘vgchange -ay ‘

[testuser ~]$ su -c 'vgchange -ay VolGroup00'
  2 logical volume(s) in volume group "VolGroup00" now active

Now that you have imported & activated the volume group,  you should be able to list the available logical volume drive mappings under /dev/mapper/.

ls -l /dev/mapper/

Step 4: The next step is to mount the logical volumes to check the integrity of the data. I would also suggest doing an file system check (fsck) of the partitions on logical volume before mounting them.

That it. You are ready to resume using your LVM partitions on your new system.

- Ken

LVM resource used for this post:

RAID to the AID (part 1)

raid5 diagramFor the past while I’ve been itching to build a storage array and/or a NAS. The reason for the need & desire for a storage solution is that between my wife and myself, we have hundreds of gigs of photos, home movie, music & ripped movies spread across 3 computers, multiple backups and some of stuff stored on DVD-Rs. Basically our current data storage & backup solution is CRAP!

So, I’ve tossed back & forth the idea of getting one of the off the shelf NAS devices by Thecus, Netgear, LaCie or Buffalo. I am mostly considering one of the Thecus devices. I believe they are running Linux, which I really like. Plus they provide a long laundry list of features amoung their devices. I have been looking at one of the N4100 serious or the N5200. The N4100s supports 4 SATA drives and the N5200 holds 5. Either would work. They all support RAID 0, 1, 5 and JBOD. The networking options are pretty nice to.

The other option I have kicked around was using an existing machine, loading it with SATA disks and then using FreeNAS or rolling my own solution with Linux to manage the data store. Doing it this way adds some limitation. One limit is the bus speed. In my existing system I only have standard PCI slots. Then in my box of extra motherboards, processors & parts I am still limited by only having PCI slots. It would be nice to have a system with PCI-X for PCI-Express slots, but to go out and upgrade a full system to gain that level of bus speed is not economical.

The next limit I have is cold hard cash!

OK, I am not truly limited on the financial side, but I do prefer to be on the cheap side. I don’t like to spend too much on items that I know I can get similar functionality from a less expensive items. The cost of a “true” hardware RAID card is way out of my mental budget. I can’t see paying over $200 for a damn expansion card. That means I am looking at RAID enabled cards that are providing software RAID, a.k.a. Fake RAID. The software RAID provided on the expansion cards can be a step above the “fake” RAID provided on most modern motherboards. That doesn’t sit all that well in the pit of my stomach. Not after recently talking with a co-worker that lost a lot of personal data because the RAID on his motherboard failed & corrupted his hard drives. He was running a 1+0 RAID across 4 drives. He should have been pretty safe against failure, but he wasn’t. I am looking at running RAID for the reliability factor. After that story I am over all worried. Myself, I would not run anything but RAID 5.

So knowing that I am not going to put out the cash for a full hardware RAID card & I am still not sure if I am going to do an external NAS system. I am left at looking at rolling my own solution using the software RAID provided by a sub 200 dollar SATA RAID card or buying any cheap SATA card that provides 4 to 8 ports and using the RAID capabilities built into the Linux kernel. This final solution doesn’t scare me too much. I am pretty damn sure that the reliability of the Linux kernel’s RAID is good. I would bet most of the software RAID cards are running embedded Linux anyways and using the RAID stack within the card.raid_cage

So now the research and testing starts. I have purchased 4 1 terabyte SATA II hard drives. I still need a SATA controller to drive the hard drives and a raid cage to hold the hard drives. I am currently scowering newegg.com, Tiger Direct and other sites for highly rated SATA controllers that work well with Linux. Once I buy the controller and start my testing I will post the next piece of RAID to the AID.

-Ken

WordPress .