[CentOS] Upgrading to larger HD with LVM

Thu Dec 21 16:48:54 UTC 2006
Paul <unix at bikesn4x4s.com>

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:
>
> 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

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.