LVM migration to regular volume
when I originally installed FC3 on my webserver / mailserver at home I used LVM to join two 20GB hard drives into one 40gb logical volume.
I now have an extra 80gb drive that I would like to install into that box to replace the 40GB logical volume. Any ideas on what would be the best way to move away from the logical volumes to one regular volume, without totally redoing the entire setup? Here are some commands from my machine: # lvdisplay --- Logical volume --- LV Name /dev/VolGroup00/LogVol00 VG Name VolGroup00 LV UUID sI0iHC-irla-CdaF-iWh9-VQxC-U1sM-pRwoKt LV Write Access read/write LV Status available # open 1 LV Size 37.34 GB Current LE 1195 Segments 2 Allocation inherit Read ahead sectors 0 Block device 253:0 --- Logical volume --- LV Name /dev/VolGroup00/LogVol01 VG Name VolGroup00 LV UUID xxAJSm-BaQ0-spnd-QeTG-sN4K-Tov7-ECh0BZ LV Write Access read/write LV Status available # open 1 LV Size 512.00 MB Current LE 16 Segments 1 Allocation inherit Read ahead sectors 0 Block device 253:1 # vgdisplay --- Volume group --- VG Name VolGroup00 System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 2 Act PV 2 VG Size 37.91 GB PE Size 32.00 MB Total PE 1213 Alloc PE / Size 1211 / 37.84 GB Free PE / Size 2 / 64.00 MB VG UUID 02Fevp-4SHU-Z9UO-X045-YOqa-4nZF-o5r47A # pvdisplay --- Physical volume --- PV Name /dev/hda2 VG Name VolGroup00 PV Size 18.91 GB / not usable 0 Allocatable yes (but full) PE Size (KByte) 32768 Total PE 605 Free PE 0 Allocated PE 605 PV UUID rWIbJh-UXPW-s5zy-xRSF-s3eG-BhGi-uS14mr --- Physical volume --- PV Name /dev/hdb1 VG Name VolGroup00 PV Size 19.00 GB / not usable 0 Allocatable yes PE Size (KByte) 32768 Total PE 608 Free PE 2 Allocated PE 606 PV UUID zhYtFd-7ERI-DaUI-Xsp5-NWOt-UgZX-zEoaOS |
There are two things you can do:
Compress and tar all your data and configuration files to an external USB drive. Install the new OS under the new drive then restore. Or, install the new drive, create the VG and LVs, mount them, copy the root partition to one LV, setup the new MBR and grub menu on the new drive. Unplugg the older drives, plug new drive and test. |
I just cleaned up some data, so now my usage is less than one 20gb disk.
Is there anyway that I can REMOVE lvm from this machine, which would result in all the data being on one of the 20gb drives? Then I would like to just use a tool like ghost to ghost that drive over to the 80gb drive and then I wouldn't have to mess with grub? |
You don't need ghost; you can do it with dd. However, you will still need to expand the partition with parted. The fastest and safest way would be to mount both drives and then copy the data over to the new drive, initialize grub on the new drive then restart with the new drive. This is especially useful for a quick and dirty upgrade to a production server.
|
Quote:
THANKS! |
After you copy the data run 'grub', then inside the grub prompt type:
grub> root (hd1,0) grub> setup (hd1) (hd1,0) = means second disk, first partition = where /boot is located. |
just to be thorough, here is my filesystem layout (its simple)
#df -k Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 38542824 15630860 20954076 43% / /dev/hda1 101086 39254 56613 41% /boot none 257452 0 257452 0% /dev/shm So, using dd and assuming that the new HDD is hdc with the boot partition on hdc1 and the filesystem on hdc2 would I use dd like this: # Copies the data dd if=/dev/mapper/VolGroup00-LogVol00 of=/dev/hdc2 # Copies the boot partition dd if=/dev/hda1 of=/dev/hdc1 then I would need to do grub like you said: grub> root (hdc1,0) grub> setup (hdc1) |
No, you need to boot with a rescue CD first. At the boot: prompt of the install CD type 'linux rescue'. It will drop you to a prompt. Run 'fdisk l' to detect both drives. Run:
dd if=/dev/hda of=/dev/hdc and wait about one or more hours. dd takes very long. hence, if you're in a hurry then use ghost. After run 'grub' then: grub> root (hd1,0) grub> setup (hd1) Turn PC off, swap drives and test. Turn off again and use a rescue disk that has parted such as Knoppix or Sysresccd to expand the partition on the bigger new drive. |
I forgot, after you use parted then you will need to extend the LVM that is overlaying the disk partition with command 'lvextend'.
|
This is what I have done so far.
I booted via Knoppix b/c I didn't have a rescue CD that worked correctly. I opened up a terminal window and did an 'su' and then did fdisk -l. I could see all 3 HDDs. So I started with 'dd if=/dev/hda of=/dev/hdd' I thought this might be wrong and did a ctrl-c after about a minute, and did fdisk -l again, I saw that now hda and hdd had an identical layout, so I restarted with the same dd command as above. Once this is done, from your instructions you say to do grub, next: grub> root (hd1,0) grub> setup (hd1) I was thinking that I might be able to just install hdd into the IDE chain where hda *was* and leave hdb in place. (skipping the grub step above) How do I go about getting any data that *might* be on hdb onto the new 80gb drive? |
Mount /dev/hdb1 to a temporary folder like /mnt/hdb1 then copy whatever you need from /mnt/hdb1. If hdb1 has an LV then you'll first need to run 'vgchange -a', I think, in order to activate the LV.
|
This is where I am at now...
I have rebooted with the 80gb drive in place of the old disk which had /boot on it. It now has hda1, hda2, hda3, and hda4. hda1 and hda2 were the old partitions which were copied over via dd. I created hda3 and hda4 and added them to the VolGroup. This is what the vgdisplay shows now: #vgdisplay --- Volume group --- VG Name VolGroup00 System ID Format lvm2 Metadata Areas 4 Metadata Sequence No 11 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 4 Act PV 4 VG Size 95.19 GB PE Size 32.00 MB Total PE 3046 Alloc PE / Size 1936 / 60.50 GB Free PE / Size 1110 / 34.69 GB VG UUID 02Fevp-4SHU-Z9UO-X045-YOqa-4nZF-o5r47A and the Physical Volumes: #pvdisplay --- Physical volume --- PV Name /dev/hda2 VG Name VolGroup00 PV Size 18.91 GB / not usable 0 Allocatable yes (but full) PE Size (KByte) 32768 Total PE 605 Free PE 0 Allocated PE 605 PV UUID rWIbJh-UXPW-s5zy-xRSF-s3eG-BhGi-uS14mr --- Physical volume --- PV Name /dev/hdb1 VG Name VolGroup00 PV Size 19.00 GB / not usable 0 Allocatable yes PE Size (KByte) 32768 Total PE 608 Free PE 608 Allocated PE 0 PV UUID zhYtFd-7ERI-DaUI-Xsp5-NWOt-UgZX-zEoaOS --- Physical volume --- PV Name /dev/hda3 VG Name VolGroup00 PV Size 28.47 GB / not usable 0 Allocatable yes PE Size (KByte) 32768 Total PE 911 Free PE 170 Allocated PE 741 PV UUID b0HE2V-nHvU-7dmP-sSyB-fvuN-ujfd-sVrxeQ --- Physical volume --- PV Name /dev/hda4 VG Name VolGroup00 PV Size 28.81 GB / not usable 0 Allocatable yes PE Size (KByte) 32768 Total PE 922 Free PE 332 Allocated PE 590 PV UUID GyvDXf-M8F6-2j1u-kn6y-cdVH-96pr-FQQ4QB and Logical Volumes: # lvdisplay --- Logical volume --- LV Name /dev/VolGroup00/LogVol00 VG Name VolGroup00 LV UUID sI0iHC-irla-CdaF-iWh9-VQxC-U1sM-pRwoKt LV Write Access read/write LV Status available # open 1 LV Size 60.00 GB Current LE 1920 Segments 4 Allocation inherit Read ahead sectors 0 Block device 253:1 If you notice the Logical volmes are only 60GB while the volume group shows 95GB. I thought I needed to do something like this for pvmove to work. I then tried to do 'pvmove /dev/hdb' which then tried to remove hdb but that failed. Am I getting any closer to being able to remove that HDB disk? |
ahh sweet... I think I got it:
#vgreduce VolGroup00 /dev/hdb1 Removed "/dev/hdb1" from volume group "VolGroup00" But now my next question is: how do I get 'df -k' to show the actual size of my new VolGroup? # df -k Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 38542824 15630668 20954268 43% / /dev/hda1 101086 39254 56613 41% /boot none 257452 0 257452 0% /dev/shm its still only showing ~40gb |
I remember having a similar problem. I think after you add an a partition to an LV then you need to extend the LV to occupy the empty space in the underlying partition. You need to unmount the LV then run something like 'lvextend -L 20GB /dev/VolGroup00/LogVol00'. That will make it extend. However, do this only after unmounting. Do it with a linux rescue session or with a Knoppix disk if necessary after running 'vgchange -a'.
|
I think this is what I need to do, just found this online.
Gonna try this later tonight once I am back home on console: # umount /dev/myvg/homevol/dev/myvg/homevol # resize2fs /dev/myvg/homevol # mount /dev/myvg/homevol /home Sound about right? |
All times are GMT -5. The time now is 09:54 AM. |