|Free Software at Schools: Installing and Maintaining a Skolelinux/Debian-edu Network; Based on Debian Sarge, prerelease pr05|
|Prev||Chapter 8. Fine-tuning||Next|
|Remember to reduce the size of the filesystem.|
You must remember to reduce the size of the filesystem that is on the volume before you shrink the volume itself, otherwise you will lose data. When shrinking the size of the filesystem, you must know the knew size of the volume, in blocks!!!!
|Remember backing up your data before trying to resize your filesystems!|
It's always smart to read the manual-pages regarding the commands you use. The manual-page for lvreduce, says it all:
tjener:~# man lvreduce lvreduce allows you to reduce the size of a logical volume. Be careful when reducing a logical volume's size, because data in the reduced part is lost!!! You should therefore ensure that any filesystem on the volume is resized before running lvreduce so that the extents that are to be removed are not in use.
At the moment, there are 7 partitions of the lvm type in Skolelinux/Debian-edu. They are grouped in two different vg's, vg_system and vg_data:
All installed programs are placed in this partition. If this partition is full, you can't add new packages to the system, other than that the system will function just fine.
The resizing of this partition is a bit tricky.
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 with the command init 1.
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 1from the command line.
You can verify that you now are running under a different runlevel with the command runlevel
tjener:~# runlevel 1 SYou might also see "Unknown" instead of "1 S"
First you need to notice the current size of /usr before you change it, use the command df -h /usr
tjener:~# df -h /usr Filesystem Size Used Avail Use% Mounted on /dev/vg_system/lv_usr 1.0G 400M 600M 40% /usr
Then have a look at how much free space there is in vg_system
Look for a line such as:
Free PE / Size 175 / 5.47 GB
The machine is now in runlevel 1. Login as user root and switch to another shell
exec /bin/ashYou will recognize 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
Before you can unmount the partition /usr, you must unmount all other partitions.
tjener:~# exec /bin/ash \h:\w$ df -h Filesystem Size Used Avail Use% Mounted on /dev/hda1 206M 70M 126M 36% / tmpfs 126M 0 126M 0% /dev/shm /dev/mapper/vg_system-lv_usr 933M 409M 486M 46% /usr /dev/mapper/vg_system-lv_var 388M 37M 335M 10% /var /dev/mapper/vg_data-lv_home0 489M 8.1M 461M 2% /skole/tjener/home0 /dev/mapper/vg_data-lv_backup 669M 17M 619M 3% /skole/backup /dev/mapper/vg_system-lv_squid 237M 8.1M 217M 4% /var/spool/squid none 126M 0 126M 0% /tmp tmpfs 10M 652K 9.4M 7% /dev \h:\w$ umount /var/spool/squid \h:\w$ umount /skole/backup \h:\w$ umount /skole/tjener/home0 \h:\w$ umount /var \h:\w$ umount /usr \h:\w$ df -h Filesystem Size Used Avail Use% Mounted on /dev/hda1 206M 70M 126M 36% / tmpfs 10M 652K 9.4M 7% /dev
If you found, when checking the space available in vg_system, something like this:
Free PE / Size 175 / 5.47 GBthen 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 commands to use:
e2fsck -fy /dev/vg_system/lv_usr
lvextend --size +1G /dev/vg_system/lv_usr
If you want to increase the size with 100MB, then this is the commands to use:
e2fsck -fy /dev/vg_system/lv_usr
lvextend --size +100M /dev/vg_system/lv_usr
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
Now you can restart the machine with init 6, and your users can logon.
A: This is most likely due to the fact that a user, or a program, is using that partition. If you are trying to unmount /skole/tjener/home0, then it is possible that not all of your users have logged out. If you are trying to unmount /var, then you must first unmount the partition /var/opt/ltsp/swapfiles. If the device is still busy, then if possible, try to bring the machine down to runlevel 1, init 1 .
A: The only solution I know of, is to restart the machine hard, which means to use the power button to turn the machine off and then on again. This problem could have been avoided if you had used init 6, or reboot after you had resized the partition in runlevel 1, and not just used the exit.
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.
Login as root, and tell all your users they must logout.
Check the current size of your partition,
df -h /skole/tjener/home0
Unmount the partition,
If you get
tjener:~# umount /skole/tjener/home0/ umount: /skole/tjener/home0: device is busy umount: /skole/tjener/home0: device is busyIt might help stopping nfs, since /skole/tjener/home0/ might be nfs-mounted on thinclientserver and workstations.
tjener:~# /etc/init.d/nfs-common stop Stopping NFS common utilities: statd. tjener:~# /etc/init.d/nfs-kernel-server stop Stopping NFS kernel daemon: mountd nfsd. Unexporting directories for NFS kernel daemon...done.
Then try again to unmount.
If you have stopped nfs, remember to start it afterwards, once you are done with resizing and have mounted it again.
Check the amount of available space in the volume group,
tjener:~# vgdisplay /dev/vg_data --- Volume group --- VG Name vg_data System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 6 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 1 Act PV 1 VG Size 1.94 GB PE Size 4.00 MB Total PE 496 Alloc PE / Size 296 / 1.16 GB Free PE / Size 200 / 800.00 MB VG UUID xplJyV-3xRB-H3FU-jO9Q-8CrV-R8mL-ZWxb2RYou can also use
tjener:~# pvscan PV /dev/hda6 VG vg_data lvm2 [1.94 GB / 800.00 MB free] PV /dev/hda5 VG vg_system lvm2 [2.73 GB / 692.00 MB free] Total: 2 [4.67 GB] / in use: 2 [4.67 GB] / in no VG: 0 [0 ]
Resize the partition, in this example it's increased with 100M
tjener:~# e2fsck -fy /dev/vg_data/lv_home0 fsck 1.37 (21-Mar-2005) e2fsck 1.37 (21-Mar-2005) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/vg_data/lv_home0: 22/103632 files (0.0% non-contiguous), 21334/413696 blocks tjener:~# lvextend --size +100M /dev/vg_data/lv_home0 Extending logical volume lv_home0 to 504.00 MB Logical volume lv_home0 successfully resized tjener:~# resize2fs /dev/vg_data/lv_home0 resize2fs 1.37 (21-Mar-2005) Resizing the filesystem on /dev/vg_data/lv_home0 to 516096 (1k) blocks. The filesystem on /dev/vg_data/lv_home0 is now 516096 blocks long.
Mount the partition, mount /skole/tjener/home0
Check the new size of the partition, df -h /skole/tjener/home0
Start nfs again, if you had to stop it.
tjener:~# /etc/init.d/nfs-kernel-server start
tjener:~# /etc/init.d/nfs-common start
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- it belongs to the same vg-group, vg_data.
If you want to increase /skole/backup with 600MB, the command would be
e2fsck -fy /dev/vg_data/lv_backup
lvextend --size +600M /dev/vg_data/lv_backup
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 .
You must also remember to umount the partition /var/spool/squid before trying to umount /var, otherwise you just get:
tjener:~# umount /var/ umount: /var: device is busy umount: /var: device is busyThis means you should be in runlevel 1, use the command init 1.
If you want to increase /var with 400MB, the command would be
e2fsck -fy /dev/vg_system/lv_var
lvextend --size +400M /dev/vg_system/lv_var
This lv belongs to vg_system. It's only present in the profile thinclientserver
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 192.168.0.10.swap, 192.168.0.11.swap,192.168.0.12.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
e2fsck -fy /dev/vg_system/lv_ltsp_swap
lvextend --size +600M /dev/vg_system/lv_ltsp_swap
If there is already thinclients running using such a swapfile, you might have to stop nfs before you manage to umount /var/opt/ltsp/swapfiles
Resize the swap-partition is a bit different than the other partitions, mainly because there is no ext2 filesystem on this partition.
First use free to see the current size of swap
ltspserver05:~# free total used free shared buffers cached Mem: 256968 96684 160284 0 5536 48500 -/+ buffers/cache: 42648 214320 Swap: 524280 0 524280
Then turn swap off with the command swapoff
ltspserver05:~# swapoff /dev/vg_system/lv_swap
Then resize the swap-partition, as usual
ltspserver05:~# lvextend --size +200M /dev/vg_system/lv_swap Extending logical volume lv_swap to 712,00 MB Logical volume lv_swap successfully resized
Then make new swap with the mkswap
ltspserver05:~# mkswap /dev/vg_system/lv_swap Setting up swapspace version 1, size = 746582 kB no label, UUID=fd634991-e5ca-4aac-9fe8-a000bde6bc38
Then turn on swap again with the command swapon
ltspserver05:~# swapon /dev/vg_system/lv_swap
Then check if you now have a different swapsize
ltspserver05:~# free total used free shared buffers cached Mem: 256968 97036 159932 0 5768 48520 -/+ buffers/cache: 42748 214220 Swap: 729080 0 729080
As you can see, 200MB more swap.
Probably the most interesting would be to make the swap-partition smaller, for that use the same commands as above, but use lvresize -L -300M /dev/vg_system/lv_swap to reduce the size by 300MB
ltspserver05:~# swapoff /dev/vg_system/lv_swap ltspserver05:~# lvreduce --size -300M /dev/vg_system/lv_swap WARNING: Reducing active logical volume to 412,00 MB THIS MAY DESTROY YOUR DATA (filesystem etc.) Do you really want to reduce lv_swap? [y/n]: y Reducing logical volume lv_swap to 412,00 MB Logical volume lv_swap successfully resized ltspserver05:~# mkswap /dev/vg_system/lv_swap Setting up swapspace version 1, size = 432009 kB no label, UUID=9db01ef6-7623-4e5b-956e-b6fe607aec4f ltspserver05:~# swapon /dev/vg_system/lv_swap ltspserver05:~# free total used free shared buffers cached Mem: 256968 97576 159392 0 6456 48544 -/+ buffers/cache: 42576 214392 Swap: 421880 0 421880
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 stopotherwise 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/squid.conf for the line number 699
# cache_dir ufs /var/spool/squid 100 16 256
If you need a bigger squid-cache, remove the # in front of the line, and change the 100 to desired size. Then you must stop squid, resize the squid-cache and finally start squid again. If you need 500MB for your squid-cache, this line will do that:
cache_dir ufs /var/spool/squid 500 32 256
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_dataor maybe there is more space in vg_system
vgdisplay /dev/vg_systemAnother option that displays the same kind of information is
You must create the mount point /skole/video
mkdir /skole/videoThen you create the new volume
lvcreate --size 2G --name lv_video vg_dataIn 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
|Not tested with Sarge|
This has not yet been tested with Sarge.
This warning will go away once it has been tested.
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 autofs 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 pointThis is the info that you want to add, like this:
slapadd -l /root/video.ldif
In addition, this partition must be added to the export file by adding the following line to the file /etc/exports
/skole/video @ltsp-server-hosts(rw,async) @workstation-hosts(rw,async) @server-hosts(rw,async)After that you must run exportfs -ra
Hook up the new disk to the system. In this example, it becomes /dev/hdb, and we will add it to the volume group vg_data
We will add the whole disk, without partitioning it first.
First lets use the command pvscan to se what we have
tjener:/dev# pvscan PV /dev/hda6 VG vg_data lvm2 [1.94 GB / 800.00 MB free] PV /dev/hda5 VG vg_system lvm2 [2.73 GB / 692.00 MB free] Total: 2 [4.67 GB] / in use: 2 [4.67 GB] / in no VG: 0 [0 ]
Then we create a volume group descriptor on the disk, using the command pvcreate
tjener:/dev# pvcreate /dev/hdb Physical volume "/dev/hdb" successfully created
Then we add the whole disk /dev/hdb to the volume-group vg_data using the command
tjener:/dev# vgextend vg_data /dev/hdb Volume group "vg_data" successfully extended
Then we use pvscan again to verify that we indeed have managed to successfully add /dev/hdb to vg_data
tjener:/dev# pvscan PV /dev/hda6 VG vg_data lvm2 [1.94 GB / 800.00 MB free] PV /dev/hdb VG vg_data lvm2 [6.83 GB / 6.83 GB free] PV /dev/hda5 VG vg_system lvm2 [2.73 GB / 692.00 MB free] Total: 3 [11.50 GB] / in use: 3 [11.50 GB] / in no VG: 0 [0 ]
That looks nice, now we may resize any of the lv-groups lv_home or lv_backup with more than the original 800MB that we had free. Lets se if we can manage to increase /skole/backup with 1000M, which should then make /skole/backup span across two different disks.
tjener:~# umount /skole/backup/ tjener:~# e2fsck -fy /dev/vg_data/lv_backup tjener:~# resize2fs /dev/vg_data/lv_backup tjener:~# lvextend --size +1000M /dev/vg_data/lv_backup tjener:~# mount /skole/backup/ tjener:~# df -h /skole/backup Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_data-lv_backup 1.7G 17M 1.6G 2% /skole/backup tjener:~# pvscan PV /dev/hda6 VG vg_data lvm2 [1.94 GB / 0 free] PV /dev/hdb VG vg_data lvm2 [6.83 GB / 6.64 GB free] PV /dev/hda5 VG vg_system lvm2 [2.73 GB / 692.00 MB free] Total: 3 [11.50 GB] / in use: 3 [11.50 GB] / in no VG: 0 [0 ]
As you can see, /skole/backup is now 1G bigger, and there is 0 Free in /dev/hda6 while there is still place in /dev/hdb for vg_data to grow.
Sometimes things go horribly wrong, and your system ends up being really hosed. In such a case it is very often lifesaving having a KNOPPIX cd lying about.
I trust you did download/order a KNOPPIX cd as I suggest you do in Section 6.1
I use KNOPPIX_V4.0 in this example, but any other recent version of KNOPPIX or any similar live-cd should probably also work just as well
Boot up your non-optimal-working system. I prefer to just use runlevel 2 (no GUI), that boots much faster than a full GUI, and I don't need any mouse. So you can either just press Enter to boot full GUI KNOPPIX.
Once you have booted KNOPPIX, make sure you have Internet connectivity, the command ifconfig will tell. If you don't have any ip-address, then run the command netcardconfig and just follow the instructions. You need a functional network because we need to download some packages.
You might see a few error messages at this point, something relating to Ndiswrapper, never mind those.
apt-get install lvm2 lvm-common
Now we may activate the lvm-groups and volumes
lndir /lib/lvm-200/ /usr/sbin/
vgchange -a y
If everything went well, you should see some info about KNOPPIX having found your lvm-groups.
Lets assume that you have an IDE disk as master on channel 1, which would you make your disk a hda.
We need to mount it, but first we must make a mountpoint
mount /dev/hda1 /mnt/lvm
Now you may begin mounting those lvm-partitions you have, like
mount /dev/vg_data/lv_home0 /mnt/lvm/skole/tjener/home0
Now you can use tools such as scp, ssh and tar to transfer files over to another machine. Have a look at Section 9.3 for more info about how to use these tools. For now I'll just say that if you want to transfer the whole content of /skole/tjener/home0, which holds all you users files, over to another linux-machine with ip-address 10.0.2.50 and there place it in /backup, this command will do that
tar czvf - /mnt/lvm/skole/tjener/home0 | ssh email@example.com "cat >/backup/home0.tgz"
The thin clients must have their MAC address locked to an IP address in /etc/dhcp3/dhcpd.conf in order to get a swapfile.
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 USE_NFS_SWAP = Y