Find the new disk:
Initialize the disk for LVM use:
You can now see the new physical LVM volume with pvs. Add the physical volume to an existing volume group:
vgextend vg_oracle /dev/sdb
vgs should now show that the vg_oracle volume group now has a bunch of new free space (VFree). This space can be added to an existing logical volume with lvextend, or it can be used to create new logical volumes.
This is actually pretty easy. Just be careful, and have a good backup, as we are messing with a mounted(!) root file system.
First, we need to find some free space in an available physical volume. One way to do this is to decrease the size of one of your other partitions, per my "Reduce an LVM Volume" post in this same Admin/LVM section.
Then add the free space to the root logical volume, for example:
lvextend /dev/mapper/x201i--vg-root /dev/dm-0
where the first parameter is the device associated with the root logical volume, and the second parameter is the name of the physical volume with free space. Without further qualification, lvextend simply adds all the available free space to the specified logical volume.
Now adjust the size of the file system inside the root logical volume, ie.
Now df should show that the root file system is bigger. LVM = OUTSTANDING!!
Now suppose you have a b0rked hard disk that will no longer boot, but it still seems to be partly there. And it has LVM on it. So you pop the disk into a USB enclosure, plug it into another machine, and:
vgchange -a y
to make all logical volumes mounted anywhere on the machine (including the USB drive) available. (At this point you will be very glad if you have been in the habit of giving every volume group you have a unique name, otherwise you will now be trying to figure out how to rename a volume group.)
will now display all LVM volumes, and you can mount the LVM partitions on the USB drive per usual, with the device name (at least on debian) being:
Create the logical volume:
lvcreate --size 200G volgroupname -n scratch
Format the volume:
Create an entry in /etc/fstab to mount the volume:
/dev/volgroupname/scratch /scratch ext3 defaults 0 2
Then create the /scratch directory and mount it.
"pvs" and "pvdisplay" lists all physical volumes,
"vgs" and "vgdisplay" lists all volume groups,
"lvs" and "lvdisplay" lists all volumes.
"vgs" displays the amount of free space that has not yet been assigned to a volume.
The Volume must be unmounted before it can be rduced:
Check the volume for errors:
fsck -f /dev/mapper/home/
Shrink the file system to 200G:
resize2fs /dev/mapper/home 200G
Shrink the LVM volume group to the same size:
lvresize -L 200G /dev/mapper/home