What's the easiest way to transition to a larger HD when using LVM2? I'm running Centos 4.4. I'm going from a 20gb HD to a 40gb HD. I've already DD'd it to the 40gb HD. So now I have 20gb of unused space. Ideally, I'd like to make it one big physical space for the logical space instead of making another physical partition to expand the logical. Here is what I have now with the system on hda, and with another HD of hdb for moving data if i need to:
# fdisk -l
Disk /dev/hda: 41.1 GB, 41174138880 bytes 255 heads, 63 sectors/track, 5005 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System /dev/hda1 * 1 13 104391 83 Linux /dev/hda2 14 2501 19984860 8e Linux LVM
Disk /dev/hdb: 15.3 GB, 15361597440 bytes 255 heads, 63 sectors/track, 1867 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System /dev/hdb1 1 1867 14996646 83 Linux
Dear If u have two harddisk or partition then u have to create physical volume then u can add multiple PV in to single VG. so there is no way to combine two hard drive or two parttion into single PV , as i know .
thanks
Paul unix@bikesn4x4s.com wrote: What's the easiest way to transition to a larger HD when using LVM2? I'm running Centos 4.4. I'm going from a 20gb HD to a 40gb HD. I've already DD'd it to the 40gb HD. So now I have 20gb of unused space. Ideally, I'd like to make it one big physical space for the logical space instead of making another physical partition to expand the logical. Here is what I have now with the system on hda, and with another HD of hdb for moving data if i need to:
# fdisk -l
Disk /dev/hda: 41.1 GB, 41174138880 bytes 255 heads, 63 sectors/track, 5005 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System /dev/hda1 * 1 13 104391 83 Linux /dev/hda2 14 2501 19984860 8e Linux LVM
Disk /dev/hdb: 15.3 GB, 15361597440 bytes 255 heads, 63 sectors/track, 1867 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System /dev/hdb1 1 1867 14996646 83 Linux
_______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Abhishek Kr. Singh System Administrator DSC. LTD. Mob.No. +91-9871563248 Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download Now! http://messenger.yahoo.com/download.php
Paul wrote:
What's the easiest way to transition to a larger HD when using LVM2? I'm running Centos 4.4. I'm going from a 20gb HD to a 40gb HD. I've already DD'd it to the 40gb HD. So now I have 20gb of unused space. Ideally, I'd like to make it one big physical space for the logical space instead of making another physical partition to expand the logical. Here is what I have now with the system on hda, and with another HD of hdb for moving data if i need to:
You should let LVM do the move, not dd. The last paragraph has some advice what you might try to do since you already did dd thingie. First how you should have done it:
What you wanted to do is to leave first drive as is in the system. Add second drive, create new physical volume on it, and add it to the volume group. See manual pages for pvcreate and vgextend. Than migrate all extents from physical volume on the first drive to physical volume on the second drive. See manual page for pvmove command. Once all extents are migrated, you can remove physical volume that was on the first drive (since all extents on it are free now), and after that remove first drive from the system. See manual page for pvremove command. Other than physical addition and/or removal of drives from the system, the rest can be done while the system is up and all services on it running.
Once data is migrated, you can either create new logical volumes using free space that you have (lvcreate). Or you could expand existing logical volumes (either lvextend or lvresize will do the job) and resize filesystems (ext2online). You are enlarging file systems, so you want to do it in exactly this order, first extend logical volume, than extend file system. Since you are extending file system, this can be done while the system is up and running and file system(s) mounted and in use. No need for downtime.
If you had anything outside of LVM on the old hard drive (for example /boot partition was there), you'd have to move that separately by hand. The easiest way would be to simply create new partition for it on new drive, than dump/restore /boot onto it. You'd also need to handle boot loader (LILO or Grub) separately if it was present on the drive you want to remove.
Since you already did that dd thingie, you might also try simply enlarging the partition used for physical volume, than use pvresize to make physical volume use all the space on the partition. Do note that pvresize wasn't available in original CentOS 4, it was added in one of the updates (to be more precise, command was there, but it would only print out that it is not functional and than exit). So if it is an old system without updates, you'd need to update at least lvm2 related packages and kernel to the latest versions before you could use pvresize. If it's CentOS 4.4 box you should be fine.
On Thu, December 21, 2006 12:21 am, Aleksandar Milivojevic wrote:
Since you already did that dd thingie, you might also try simply enlarging the partition used for physical volume, than use pvresize to make physical volume use all the space on the partition. Do note that pvresize wasn't available in original CentOS 4, it was added in one of the updates (to be more precise, command was there, but it would only print out that it is not functional and than exit). So if it is an old system without updates, you'd need to update at least lvm2 related packages and kernel to the latest versions before you could use pvresize. If it's CentOS 4.4 box you should be fine.
I could dd it back and start from scratch. I see that fdisk must be run to resize the partition, then run pvresize. I was under the impression that changing the partition with fdisk will lose any data on it?
Here's what I have. Yes, I am running LVM2, latest updates on Centos4.4:
# fdisk -l
Disk /dev/hda: 41.1 GB, 41174138880 bytes 255 heads, 63 sectors/track, 5005 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System /dev/hda1 * 1 13 104391 83 Linux /dev/hda2 14 2501 19984860 8e Linux LVM
# pvresize --test /dev/hda2 Test mode: Metadata will NOT be updated. Physical volume "/dev/hda2" changed 1 physical volume(s) resized / 0 physical volume(s) not resized
# fdisk /dev/hda2 Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable.
The number of cylinders for this disk is set to 2488. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Quoting Paul unix@bikesn4x4s.com:
I could dd it back and start from scratch. I see that fdisk must be run to resize the partition, then run pvresize. I was under the impression that changing the partition with fdisk will lose any data on it?
As long as the start of partition does not change (or in other words, partition only gets resized, but not moved), you will not loose any data. The steps are:
1. Expanding file system - expand partition using fdisk - expand physical volume - expand logical volume - expand file system
2. Shrinking file system - shrink file system - shrink logical volume - shrink physical volume (currently not always possible) - shrink partition
Here's what I have. Yes, I am running LVM2, latest updates on Centos4.4:
# fdisk -l
Disk /dev/hda: 41.1 GB, 41174138880 bytes 255 heads, 63 sectors/track, 5005 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System /dev/hda1 * 1 13 104391 83 Linux /dev/hda2 14 2501 19984860 8e Linux LVM
So you'd just recreate hda2 to start at the cylinder 14 and end the end of the disk. Also make sure the ID stays 8e (Linux LVM).
# fdisk /dev/hda2
Well, you can't fdisk /dev/hda2. It's partition. Hopefully you haven't exited from fdisk using "w" command (it could really screw up whatever was on hda2). You probably wanted to "fdisk /dev/hda".
On Thu, December 21, 2006 10:17 am, Aleksandar Milivojevic wrote:
As long as the start of partition does not change (or in other words, partition only gets resized, but not moved), you will not loose any data. The steps are:
Expanding file system
- expand partition using fdisk
- expand physical volume
- expand logical volume
- expand file system
Shrinking file system
- shrink file system
- shrink logical volume
- shrink physical volume (currently not always possible)
- shrink partition
OK, here's what I have so far. Been trying various things with --test and not getting anywhere:
# fdisk -l
Disk /dev/hda: 41.1 GB, 41174138880 bytes 255 heads, 63 sectors/track, 5005 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System /dev/hda1 * 1 13 104391 83 Linux /dev/hda2 14 5005 40098240 8e Linux LVM # df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup00-LogVol00 17G 5.7G 11G 35% / /dev/hda1 99M 22M 73M 24% /boot none 506M 0 506M 0% /dev/shm # pvs PV VG Fmt Attr PSize PFree /dev/hda2 VolGroup00 lvm2 a- 38.22G 19.22G # lvs LV VG Attr LSize Origin Snap% Move Log Copy% LogVol00 VolGroup00 -wi-ao 17.25G LogVol01 VolGroup00 -wi-ao 1.75G
# lvresize -L +10G --test /dev/mapper/VolGroup00-LogVol00 /dev/hda2 Test mode: Metadata will NOT be updated. Volume group mapper doesn't exist
Well, you can't fdisk /dev/hda2. It's partition. Hopefully you haven't exited from fdisk using "w" command (it could really screw up whatever was on hda2). You probably wanted to "fdisk /dev/hda".
Oops, ya, thanks.
Quoting Paul unix@bikesn4x4s.com:
# lvresize -L +10G --test /dev/mapper/VolGroup00-LogVol00 /dev/hda2 Test mode: Metadata will NOT be updated. Volume group mapper doesn't exist
Logical volume name should be specified as /dev/VolGroup00/LogVol00.
Also, you might prefer to use pvdisplay, vgdisplay and lvdisplay. For example, it will print sizes in physical extents too (in case you want to use -l instead of -L option).
On Thu, December 21, 2006 1:00 pm, Aleksandar Milivojevic wrote:> Logical volume name should be specified as /dev/VolGroup00/LogVol00.
Also, you might prefer to use pvdisplay, vgdisplay and lvdisplay. For example, it will print sizes in physical extents too (in case you want to use -l instead of -L option).
Thank you, Aleksander! All well. Thanks for you explanations, presented very easy to understand.
Only downtime, was to reboot once after fdisk.
# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup00-LogVol00 36G 5.7G 29G 17% / /dev/hda1 99M 22M 73M 24% /boot none 506M 0 506M 0% /dev/shm
My commands were:
1. fdisk /dev/hda 2. init 6 3. pvresize 4. lvresize 5. ext2online
On Thu, December 21, 2006 2:50 pm, Paul wrote:
On Thu, December 21, 2006 1:00 pm, Aleksandar Milivojevic wrote:> Logical volume name should be specified as /dev/VolGroup00/LogVol00.
Also, you might prefer to use pvdisplay, vgdisplay and lvdisplay. For example, it will print sizes in physical extents too (in case you want to use -l instead of -L option).
Thank you, Aleksander! All well. Thanks for you explanations, presented very easy to understand.
Only downtime, was to reboot once after fdisk.
# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup00-LogVol00 36G 5.7G 29G 17% / /dev/hda1 99M 22M 73M 24% /boot none 506M 0 506M 0% /dev/shm
My commands were:
- fdisk /dev/hda
- init 6
- pvresize
- lvresize
- ext2online
Now that this was successful, I am now wishing I left some space for doing snapshots. Is there a way to free up some space so I can get some free PE?
Right now I have this: # vgdisplay --- Volume group --- VG Name VolGroup00 System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 7 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 1 Act PV 1 VG Size 38.22 GB PE Size 32.00 MB Total PE 1223 Alloc PE / Size 1223 / 38.22 GB Free PE / Size 0 / 0 VG UUID 0mB18U-4VRo-1GMC-oKdf-ZndA-slFy-eOQtYD
So, it won't let me do this: # lvcreate -L1G -s -n fullbakup /dev/VolGroup00/LogVol00 Insufficient free extents (0) in volume group VolGroup00: 32 required
Ext2online will not reduce size, so the man page says and I also tried it for the fun of it.
lvresize won't work either.