[CentOS] Upgrading to larger HD with LVM

Thu Dec 21 14:49:04 UTC 2006
Paul <unix at bikesn4x4s.com>

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)