vgscan --force-all-update-reread-and-take-that-kernel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello lvm folks,
    Before I give you the whole shpiel... the issue I am having here
is that vgscan is unable to find an existing volume group after
a repartitioning of the disk using 'parted' (hence the subject line that
implies that vgscan needs an option to slap the kernel a little harder
in some cases).

    I am using lvm to automaticly extend a logical partition
to span the "rest of the harddisk", in the case that there are
some unused gigs on the disk.

I've written a little script (which I'll attach here) that
basicly:
    - Resizes the extended partition
    - Creates a new logical partition in the newly allocated space
      inside the extended partition
    - Creates a new "physical volume" on the new partition
    - Adds the new "physical volume" to the already existing "volume group"
    - Extends the "logical volume" to span the entire "volume group"

The script works fine it you type it all out by hand in the shell and
wait a few secs and repeatedly check vgscan to see if its back up,
when I run the script... I get:

From when I first issue a vgscan:
=================================
  Reading all physical volumes.  This may take a while...
  No volume groups found

From my next call to pvcreate:
==============================
  Couldn't find device with uuid 'HAkK8E-D3CS-87kk-GtL0-6ZGC-1NKI-x65WQg'.
  Couldn't find all physical volumes for volume group massgaol.
  Couldn't find device with uuid 'HAkK8E-D3CS-87kk-GtL0-6ZGC-1NKI-x65WQg'.
  Couldn't find all physical volumes for volume group massgaol.
  get_pv_from_vg_by_id: vg_read failed to read VG massgaol
  Physical volume "/dev/hdb7" successfully created

Anyway, I guess at this point y'all know what I'm rambling on about...

please let me know what I'm doing wrong or what I could be doing
better :)

Cheers,
                            -Tristan


#!/bin/bash

# This scrip makes some evil assumptions:
#
# o That the disk was partitioned as 120 Gigs
# o That the real disk size will be reported as numGB (in Gigs)
#   (i.e. this wont work if parted decides to display it in terabytes
#   or megabytes on some disks)
#

OUTPATTERN="Disk /dev/hdb: "
DISKOUT=`parted /dev/hdb print | grep "$OUTPATTERN"`

DISKSIZE=${DISKOUT#$OUTPATTERN}

echo "this disk size is $DISKSIZE"

echo "that would be ${DISKSIZE%GB} Gigs I think"

DISKGIGS=${DISKSIZE%GB}

if [ $DISKGIGS -gt 120 ]; then
	# Found a disk that is physically bigger than 120GB

	# Resize the extended partition to span till the end of the disk
	parted /dev/hdb resize 4 3208MB $DISKSIZE

	# Create /dev/hdb7 with the remaining disk space
	parted /dev/hdb mkpart logical 120GB $DISKSIZE

	# XXX massgaol dissapears here for a few secs....
	sleep 2
	vgscan

        # Give the system some time to create the fs nodes needed
        # to proceed
        sleep 5

	# Create a physical volume for 
	pvcreate -y -ff /dev/hdb7

	# Adding more ...
	sleep 2

        # Scan volume groups... needed to make 'massgaol' recognized
	# in the next step.
        vgscan

	# Add new physical volume to the volume group
	vgextend massgaol /dev/hdb7

	# Get the current size of the virtual group now...
	# (get the 12'th field, separated by ':').
	VGSIZE=`vgdisplay -c massgaol | cut -d : -f12`

	# Activate the group -- this creates /dev/massgaol/massgaolLV
	vgchange -ay 

	# Extend the logical volume to span the entire volume group
	lvextend /dev/massgaol/massgaolLV -L${VGSIZE}KB

	# Resize sometimes wants an fsck first.
	e2fsck -f /dev/massgaol/massgaolLV

	# Resize the overlying filesystem
	resize2fs /dev/massgaol/massgaolLV

        # deactivate the group for now
	vgchange -an

fi

_______________________________________________
linux-lvm mailing list
linux-lvm@redhat.com
https://www.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/

[Index of Archives]     [Gluster Users]     [Kernel Development]     [Linux Clusters]     [Device Mapper]     [Security]     [Bugtraq]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]

  Powered by Linux