Binary package hint: ubuntu-docs
I propose the following rewrite for the LVM section of ubuntu server guide
that is to say from current 2592 to current 2617
<!-- beginning of rewrite -->
Continuing with <emphasis>srv</emphasis> as an LVM volume example, this section covers adding a second hard disk, creating a Physical Volume (PV), adding it to the volume group (VG), extending the logical volume <filename role="directory">srv</filename> and finally extending the filesystem. This example assumes a second hard disk has been added to the system. This hard disk will be named /dev/sdb in our example. BEWARE: make sure you don't already have an existing /dev/sdb before issuing the commands below. You could lose some data if you issue those commands on a non-empty disk. In our example we will use the entire disk as a physical volume (you could choose to create partitions and use them as different physical volumes)
First, create the physical volume, write:
sudo pvcreate /dev/sdb
Now extend the Volume Group (VG):
sudo vgextend vg01 /dev/sdb
Use <emphasis>vgdisplay</emphasis> to find out the free physical extents - Free PE / size (the size you can allocate). We will assume a free size of 511 PE (equivalent to 2GB with a PE size of 4MB) and we will use the whole free space available. Use your own PE and/or free space.
The Logical Volume (LV) can now be extended by different methods, we will only see how to use the PE to extend the LV:
sudo lvextend /dev/vg01/srv -l +511
The <emphasis>-l</emphasis> option allows the LV to be extended using PE.
The <emphasis>-L</emphasis> option allows the LV to be extended using Meg, Gig, Tera, etc bytes.
Even though you are supposed to be able to <emphasis>expand</emphasis> an ext3 or ext4 filesystem without unmounting it first, it may be a good pratice to unmount it anyway and check the filesystem, so that you don't mess up the day you want to reduce a logical volume (in that case unmounting first is compulsory).
The following commands are for an <application>EXT3</application> or <application>EXT4</application> filesystem. If you are using another filesystem there may be other utilities available.
sudo umount /srv
sudo e2fsck -f /dev/vg01/srv
The <emphasis>-f</emphasis> option of e2fsck force checking even if the system seems clean.
Finally, resize the filesystem:
sudo resize2fs /dev/vg01/srv
mount the partition and check its size.
mount /dev/vg01/srv /srv && df -h /srv
<!-- end of rewrite -->