8.5. Changing the Size of the LVM-Partitions[id=lvmresize]

Tip

You should definitely supplement this short introduction to lvm with the full in-depth documentation on LVM which is available from The Linux Documentation Project under the link LVM-HOWTO

At the moment, there are 7 partitions[1] of the lvm type in Skolelinux/Debian-edu. They are grouped in two different vg's, vg_system and vg_data:

  1. /usr, see Section 8.5.1

  2. /skole/tjener/home0, see Section 8.5.2

  3. /skole/backup, see Section 8.5.3

  4. /var, see Section 8.5.4

  5. /var/opt/ltsp/swapfiles, see Section 8.5.5

  6. swap

  7. /var/spool/squid, see Section 8.5.7

8.5.1. Resizing the /usr Partition[id=lvm-usr]

This lv belongs to vg_system. It's present in the profiles mainserver, workstation and thinclientserver.

All installed programs are placed in this partition. If this partition is full, you can't add new packages to the system.

The resizing of this partition is a bit tricky.

  1. The tricky part about resizing this partition is that you have to unmount the partition that you are using, which is kind of like sawing off a tree branch that you are sitting on. However, we can manage it by using a neat little trick- switching to the shell ash. First, you need to bring the machine down to runlevel 1, then you switch to the shell ash.

    First of all, you need to tell all your users that they have to logout, otherwise they will be forcibly logged out, then type

    init 1

    from the command line

  2. The machine is now in runlevel 1. Login as user root and switch to another shell

    exec /bin/ash

    You will recognise that you are using a different shell by the prompt, which looks like: \h:w\$. If you make a typo in the shell ash, you have to start writing the command all over again, because the BACKSPACE and Arrow keys don't work here. You start all over with CTRL-C

  3. First you need to notice the current size of /usr before you change it df -h /usr

    Filesystem            Size  Used Avail Use% Mounted on
    /dev/vg_system/lv_usr
                                  1.0G  400M  600M  40%  /usr
    
  4. Then have a look at how much free space there is in vg_system

    vgdisplay /dev/vg_system

    Look for a line such as:

    Free  PE / Size       175 / 5.47 GB
  5. Then you unmount the partition (Note: the command for unmount is umount)

    umount /usr

  6. Then, to be on the safe side, do a check of the file system

    fsck -yf /dev/vg_system/lv_usr

    [2]

  7. If you found, when checking the space available in vg_system, something like this:

    vgdisplay /dev/vg_system

    Free  PE / Size       175 / 5.47 GB
    then you have 5.47GB free space that you can use to extend lv_usr

    If you want to increase the size with 1GB, then this is the command to use:

    e2fsadm -L +1G /dev/vg_system/lv_usr

    If you want to increase the size with 100MB, then this is the command to use:

    e2fsadm -L +100M /dev/vg_system/lv_usr

    If you want to decrease the size with 250MB, then this is the command to use:

    e2fsadm -L -250M /dev/vg_system/lv_usr

    . Due to the bug [3]

    Watch for this pattern when resizing:

    
resize2fs 1.27 (8-Mar-2002)
    Begin pass 1 (max = 2564)
    Extending the inode table     XXXXXXXXXXXXXXXXXXXXXXXXXXX
    Begin pass 2 (max = 160)
    Relocating blocks             XXXXXXXXXXXXXXXXXXXXXXXXXXX
    Begin pass 3 (max = 52)
    Scanning inode table          XXXXXXXXXXXXXXXXXXXXXXXXXXX
    Begin pass 5 (max = 9)
    Moving inode table            XXXXXXXXXXXXXXXXXXXXXXXXXXX
    
  8. If you do not see on your screen a long line of uppercase Xs, like this:

    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    when you resize a partition, then something has gone wrong.

    If something has gone wrong, you can try to mount, and the unmount the partition again, and then try to resize it again, but do not try to resize it with the same amount as last time.

    Warning

    If you have to resize your partition a second time, because the first try failed, then you should try to resize it with only 32MB, because it will "remember" the size you tried to resize it with the first time, and will use that value in addition to the amount you specify the second time. So, if you failed resizing the first time using +1200M, and try again with +1200M, the net effect will be +2400M, probably not what you wanted. If you try with +32M in the second try, then the net effect will be +1232M, which is probably close to what you wanted.

  9. If the resize was successful, then you can mount the partition with mount /usr. Then check the new size of the partition with df -h /usr. In this case it should look something like:

    Filesystem            Size  Used Avail Use% Mounted on
    /dev/vg_system/lv_usr
                                  2.0G  400M  1.6G  20%  /usr
    

  10. Now you can restart the machine with init 6, and your users can logon.

8.5.1.1. Problems and Solutions

8.5.2. Resizing /skole/tjener/home0[id=lvm-home0]

This lv belongs to vg_data. It's only present in the profile mainserver

This is the partition where the users' home directories are stored.

The resizing of /skole/tjener/home0 is done pretty much the same way as with /usr. As a matter of fact it's much easier, since it doesn't involve changing to runlevel 1 or changing the shell. I'll briefly mention the relevant commands; see resize /usr for more info.

  1. Login as root, and tell all your users they must logout.

  2. Check the current size of your partition,df -h /skole/tjener/home0

  3. Unmount the partition, umount /skole/tjener/home0

  4. Check and repair the file system, fsck -fy /skole/tjener/home0

  5. Check the amount of available space in the volume group,vgdisplay /dev/vg_data. You can also use pvscan

  6. Resize the partition, in this example it's increased with 400M, e2fsadm -L +400M /dev/vg_data/lv_home0

  7. Mount the partition, mount /skole/tjener/home0

  8. Check the new size of the partition, df -h /skole/tjener/home0

  9. If you do not see any change in the size, then the resizing probably wasn't successful. Have a look at /usr Section 8.5.1, and the Problems and Solutions

8.5.3. Resizing /skole/backup[id=lvm-backup]

This lv belongs to vg_data. It's only present in the profile mainserver

This is the default partition used for placing the backups made and administered with the Skolelinux/Debian-edu-developed Webmin module slbackup.

Resizing this partition is very similar to resizing /skole/tjener/home0. See Section 8.5.2- it belongs to the same vg-group, vg_data.

If you want to increase /skole/backup with 600MB, the command would be

umount /skole/backup
e2fsadm -L +600M /dev/vg_data/lv_backup
mount /skole/backup

8.5.4. Resizing /var[id=lvm-var]

This lv belongs to vg_system. It's present in the profiles mainserver and thinclientserver.

The resizing of this partition is done in a similar way to the resizing of /usr, except that you don't need to switch to another shell. But you must remember to unmount the partition /var/opt/ltsp/swapfiles if this is done a machine with the profile Thinclientserver installed. See swapfiles

If you want to increase /var with 400MB, the command would be

e2fsadm -L +400M /dev/vg_system/lv_var

8.5.5. Resizing /var/opt/ltsp/swapfiles[id=lvm-swapfiles]

This lv belongs to vg_system. It's only present in the profile thinclientserver

This partition contains the swapfiles for the thinclients. The size of each of these swapfiles is 32MB.[4][5]

This partition is resized similarly to /skole/tjener/home0.

A reasonable size for this partition would be 32MB times the number of thin clients you plan to have. If you try to boot more thin clients with swapfiles than you have space for in /var/opt/ltsp/swapfiles, then the thin client will not boot.

These swapfiles will be placed in /var/opt/ltsp/swapfiles, with the file names ltsp010.swap, ltsp011.swap,ltsp012.swap. If you delete these swapfiles, they will be created again next time the thin client boots.

If you want to increase /var/opt/ltsp/swapfiles with 600MB, the command would be

e2fsadm -L +600M /dev/vg_system/lv_ltsp_swap

Note

Unless you first umount the partition /var before trying to change this partition, you will not succeed. You will then only get the message

device is busy
. If you see this, make sure you have first umounted /var

8.5.6. Swap[id=lvm-swap]

This lv belongs to vg_system. It's present in the profiles mainserver, workstation and thinclientserver.

8.5.7. Resizing /var/spool/squid[id=lvm-squid]

This lv belongs to vg_system and it's only present in the profile mainserver. This partition hold the cache belonging to squid, which is a FTP, HTTP and HTTPS proxy cache. This partition is changed the same way as swapfiles. Make sure you stop squid before you try to resize,

/etc/init.d/squid stop

otherwise you only end up with
umount: /var/spool/squid: device is busy

The maximum size of this cache is default set to 100MB; look in the file /etc/squid.conf for the line

# cache_dir ufs /var/spool/squid 100 16 256

8.5.8. Adding a New Volume(lv)[id=newlv]

For things such as video and picture, as well as users that need extra file space, you might need to create a new volume. Let's pretend you need a volume for our video footage. Let us name it video, and place it in vg_data as /dev/vg_data/lv_video, and mount it at /skole/video

First you need to find out how much space you have available in vg_data

vgdisplay /dev/vg_data

or maybe there is more space in vg_system

vgdisplay /dev/vg_system

Another option that displays the same kind of information is

pvscan

You must create the mount point /skole/video

mkdir /skole/video

Then you create the new volume

lvcreate -L 2G -n lv_video vg_data

In this example, the size is 2GB. Have a look at
lvm-home0 to find out how to resize this. Then you need to make a file system

mke2fs -j /dev/vg_data/lv_video

Then add this new partition, using your favourite texteditor, to /etc/fstab, otherwise this new partition won't be mounted automatically at boot. In our example you add this line at the end of /etc/fstab


/dev/vg_data/lv_video  /skole/video          ext3    defaults                0       2

Now you test your new partition by mounting it manually with mount /skole/video. Have a look at the size with

df -h /skole/video

8.5.8.1. Adding the New Volume to autofs[id=newlvmautofs]

Warning

This has not yet been tested with the new LDAP schemas that comes with Skolelinux/Debian-edu 1.0.

Skolelinux/Debian-edu uses autofs to export partitions to machines that might need them, workstation and thinclientserver needs to be able to mount the users home directories. So, if you have made another home partition, for example /skole/tjener/home1 and /skole/tjener/home2 then you must make sure that they are also exported along with /skole/tjener/home0 via auofs to the needed machines. The necessary information lies in the LDAP-database, so we must add this new information the LDAP-database. This is most easily done by adding this new information to a file, and then adding the contents of this file to our LDAP-database. Let's call this file /root/video.ldif, with these contents:


dn: cn=video,ou=tjener,ou=skole,ou=Automount,dc=skole,dc=skolelinux,dc=no
objectClass: top
objectClass: automount
cn: video
automountInformation: -rw,rsize=8192,wsize=8192,intr tjener:/skole/video
description: /skole/video mount point
This is the info that you want to add, like this:

/etc/init.d/slapd stop
/etc/init.d/nscd stop
slapadd -l /root/video.ldif
/etc/init.d/slapd start
/etc/init.d/nscd start

In addition, this partition must be added to the export file by adding the following line to the file /etc/exports


	      /skole/video @allhosts(rw) 10.0.2.0/255.255.254.0(rw)[6]
	    
After that you must run exportfs -ra

8.5.9. Adding a New Disk to LVM in Skolelinux/Debian-edu

This is a short recipe; additional details will be available at a later date.

  1. Hook up the new disk to the system. In this example, it becomes /dev/hdb, and you want to add it to the volume group vg_data

  2. pvscan

  3. df -h

  4. pvcreate /dev/hdb

  5. Check with pvscan what the devfs-path to your new disc is

    vgextend vg_data /dev/ide/host0/bus0/target1/disc

  6. To remove the disk again from the vg-group, unmount all partitions, and then do a

    vgreduce vg_data /dev/ide/host0/bus0/target1/disc

Notes

[1]

There have been discussions about adding further partitions, such as one for /var/log/squid. This has been done in version 1.0r1

[2]

This check and repair is also done as a part of the resizing process by the command e2fsadm, but it's better to be on the safe side.

[3]

http://bugs.skolelinux.no/show_bug.cgi?id=439, you need to be a bit careful when resizing partitions.

[4]

The thin clients must have their MAC address locked to an IP address in /etc/dhcp3/dhcpd-skolelinux in order to get a swapfile.

[5]

The size of these swapfiles, and whether they are enabled or not, is defined in /opt/ltsp/i386/etc/lts.conf. Look for the lines SWAPFILE_SIZE=32m and USE_NFS_SWAP =

[6]

As of Skolelinux/Debian-edu pr47, all machines that you want to export must be members of a netgroup. See Section 8.6. The line will then look like this /skole/video @ltsp-server-hosts(rw) @workstation-hosts(rw) @server-hosts(rw)