Ubuntu 10.10 User Manual

Ubuntu Server Guide

Ubuntu Server Guide
Copyright © 2010 Canonical Ltd. and members of the Ubuntu Documentation Project
Abstract
Welcome to the Ubuntu Server Guide! It contains information on how to install and configure various server applications on your Ubuntu system to fit your needs. It is a step-by-step, task-oriented guide for configuring and customizing your system.
3
This document is maintained by the Ubuntu documentation team (https://wiki.ubuntu.com/DocumentationTeam). For a list of contributors, see the contributors page
1
This document is made available under the Creative Commons ShareAlike 2.5 License (CC-BY-SA).
You are free to modify, extend, and improve the Ubuntu documentation source code under the terms of this license. All derivative works must be released under this license.
This documentation is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE AS DESCRIBED IN THE DISCLAIMER.
A copy of the license is available here: Creative Commons ShareAlike License2.
3
https://launchpad.net/~ubuntu-core-doc
1
../../libs/C/contributors.xml
2
/usr/share/ubuntu-docs/libs/C/ccbysa.xml

Table of Contents

1. Introduction ........................................................................................................................... 1
1. Support .......................................................................................................................... 2
2. Installation ............................................................................................................................. 3
1. Preparing to Install ......................................................................................................... 4
2. Installing from CD ......................................................................................................... 6
3. Upgrading ...................................................................................................................... 9
4. Advanced Installation ................................................................................................... 10
3. Package Management ........................................................................................................... 17
1. Introduction ................................................................................................................. 18
2. dpkg ............................................................................................................................ 19
3. Apt-Get ........................................................................................................................ 20
4. Aptitude ....................................................................................................................... 22
5. Automatic Updates ....................................................................................................... 24
6. Configuration ............................................................................................................... 26
7. References ................................................................................................................... 28
4. Networking .......................................................................................................................... 29
1. Network Configuration ................................................................................................. 30
2. TCP/IP ......................................................................................................................... 38
3. Dynamic Host Configuration Protocol (DHCP) .............................................................. 42
4. Time Synchronisation with NTP ................................................................................... 45
5. Remote Administration ......................................................................................................... 47
1. OpenSSH Server .......................................................................................................... 48
2. Puppet ......................................................................................................................... 51
6. Network Authentication ........................................................................................................ 54
1. OpenLDAP Server ....................................................................................................... 55
2. Samba and LDAP ........................................................................................................ 74
3. Kerberos ...................................................................................................................... 80
4. Kerberos and LDAP ..................................................................................................... 87
7. Domain Name Service (DNS) ............................................................................................... 93
1. Installation ................................................................................................................... 94
2. Configuration ............................................................................................................... 95
3. Troubleshooting .......................................................................................................... 100
4. References ................................................................................................................. 104
8. Security ............................................................................................................................. 105
1. User Management ....................................................................................................... 106
2. Console Security ........................................................................................................ 112
3. Firewall ...................................................................................................................... 113
4. AppArmor .................................................................................................................. 120
5. Certificates ................................................................................................................. 124
6. eCryptfs ..................................................................................................................... 129
iii
Ubuntu Server Guide
9. Monitoring ......................................................................................................................... 131
1. Overview ................................................................................................................... 132
2. Nagios ....................................................................................................................... 133
3. Munin ........................................................................................................................ 137
10. Web Servers ..................................................................................................................... 139
1. HTTPD - Apache2 Web Server ................................................................................... 140
2. PHP5 - Scripting Language ......................................................................................... 147
3. Squid - Proxy Server .................................................................................................. 149
4. Ruby on Rails ............................................................................................................ 151
5. Apache Tomcat .......................................................................................................... 153
11. Databases ......................................................................................................................... 157
1. MySQL ...................................................................................................................... 158
2. PostgreSQL ................................................................................................................ 160
12. LAMP Applications .......................................................................................................... 162
1. Overview ................................................................................................................... 163
2. Moin Moin ................................................................................................................. 164
3. MediaWiki ................................................................................................................. 166
4. phpMyAdmin ............................................................................................................. 168
13. File Servers ...................................................................................................................... 170
1. FTP Server ................................................................................................................. 171
2. Network File System (NFS) ........................................................................................ 175
3. CUPS - Print Server ................................................................................................... 177
14. Email Services .................................................................................................................. 180
1. Postfix ....................................................................................................................... 181
2. Exim4 ........................................................................................................................ 188
3. Dovecot Server ........................................................................................................... 191
4. Mailman .................................................................................................................... 193
5. Mail Filtering ............................................................................................................. 199
15. Chat Applications ............................................................................................................. 206
1. Overview ................................................................................................................... 207
2. IRC Server ................................................................................................................. 208
3. Jabber Instant Messaging Server .................................................................................. 210
16. Version Control System .................................................................................................... 212
1. Bazaar ........................................................................................................................ 213
2. Subversion ................................................................................................................. 214
3. CVS Server ................................................................................................................ 219
4. References ................................................................................................................. 221
17. Windows Networking ....................................................................................................... 222
1. Introduction ................................................................................................................ 223
2. Samba File Server ...................................................................................................... 224
3. Samba Print Server ..................................................................................................... 227
4. Securing a Samba File and Print Server ....................................................................... 229
iv
Ubuntu Server Guide
5. Samba as a Domain Controller .................................................................................... 233
6. Samba Active Directory Integration ............................................................................. 237
7. Likewise Open ........................................................................................................... 239
18. Backups ........................................................................................................................... 243
1. Shell Scripts ............................................................................................................... 244
2. Archive Rotation ........................................................................................................ 248
3. Bacula ........................................................................................................................ 251
19. Virtualization .................................................................................................................... 256
1. libvirt ......................................................................................................................... 257
2. JeOS and vmbuilder ................................................................................................... 262
3. UEC .......................................................................................................................... 271
20. Clustering ......................................................................................................................... 284
1. DRBD ........................................................................................................................ 285
21. VPN ................................................................................................................................. 288
1. OpenVPN .................................................................................................................. 289
22. Other Useful Applications ................................................................................................. 293
1. pam_motd .................................................................................................................. 294
2. etckeeper .................................................................................................................... 296
3. Byobu ........................................................................................................................ 298
4. References ................................................................................................................. 300
A. Appendix .......................................................................................................................... 301
1. Reporting Bugs in Ubuntu Server Edition .................................................................... 302
v
List of Tables
2.1. Recommended Minimum Requirements ................................................................................ 4
16.1. Access Methods ............................................................................................................. 215
19.1. UEC Front End Requirements ........................................................................................ 272
19.2. UEC Node Requirements ............................................................................................... 273
vi

Chapter 1. Introduction

Welcome to the Ubuntu Server Guide!
Here you can find information on how to install and configure various server applications. It is a step­by-step, task-oriented guide for configuring and customizing your system.
This guide assumes you have a basic understanding of your Ubuntu system. Some installation details are covered in Chapter 2, Installation [p. 3], but if you need detailed instructions installing Ubuntu please refer to the Ubuntu Installation Guide1.
A HTML version of the manual is available online at the Ubuntu Documentation website2. The HTML files are also available in the ubuntu-serverguide package. See Chapter 3, Package Management [p. 17] for details on installing packages.
If you choose to install the ubuntu-serverguide you can view this document from a console by:
w3m /usr/share/ubuntu-serverguide/html/C/index.html
If you are using a localized version of Ubuntu, replace C with your language localization (e.g. en_GB).
1
https://help.ubuntu.com/10.10/installation-guide/
2
http://help.ubuntu.com
1
Introduction

1. Support

There are a couple of different ways that Ubuntu Server Edition is supported, commercial support and community support. The main commercial support (and development funding) is available from Canonical Ltd. They supply reasonably priced support contracts on a per desktop or per server basis. For more information see the Canonical Services3 page.
Community support is also provided by dedicated individuals, and companies, that wish to make Ubuntu the best distribution possible. Support is provided through multiple mailing lists, IRC channels, forums, blogs, wikis, etc. The large amount of information available can be overwhelming, but a good search engine query can usually provide an answer to your questions. See the Ubuntu
Support4 page for more information.
3
http://www.canonical.com/services/support
4
http://www.ubuntu.com/support
2

Chapter 2. Installation

This chapter provides a quick overview of installing Ubuntu 10.10 Server Edition. For more detailed instructions, please refer to the Ubuntu Installation Guide1.
1
https://help.ubuntu.com/10.10/installation-guide/
3
Installation

1. Preparing to Install

This section explains various aspects to consider before starting the installation.

1.1. System Requirements

Ubuntu 10.10 Server Edition supports two (2) major architectures: Intel x86 and AMD64. The table below lists recommended hardware specifications. Depending on your needs, you might manage with less than this. However, most users risk being frustrated if they ignore these suggestions.
Table 2.1. Recommended Minimum Requirements
Hard Drive Space
Install Type RAM
Server 128 megabytes 500
The Server Edition provides a common base for all sorts of server applications. It is a minimalist design providing a platform for the desired services, such as file/print services, web hosting, email hosting, etc.
The requirements for UEC are slightly different for Front End requirements see Section 3.2.1,
“Front End Requirements” [p. 271] and for UEC Node requirements see Section 3.2.2, “Node Requirements” [p. 272].
Base
All Tasks Installed
System
1 gigabyte
megabytes

1.2. Server and Desktop Differences

There are a few differences between the Ubuntu Server Edition and the Ubuntu Desktop Edition. It should be noted that both editions use the same apt repositories. Making it just as easy to install a server application on the Desktop Edition as it is on the Server Edition.
The differences between the two editions are the lack of an X window environment in the Server Edition, the installation process, and different Kernel options.
1.2.1. Kernel Differences:
• The Server Edition uses the Deadline I/O scheduler instead of the CFQ scheduler used by the Desktop Edition.
Preemption is turned off in the Server Edition.
• The timer interrupt is 100 Hz in the Server Edition and 250 Hz in the Desktop Edition.
When running a 64-bit version of Ubuntu on 64-bit processors you are not limited by memory addressing space.
4
Installation
To see all kernel configuration options you can look through /boot/config-2.6.35-server. Also,
Linux Kernel in a Nutshell2 is a great resource on the options available.

1.3. Backing Up

• Before installing Ubuntu Server Edition you should make sure all data on the system is backed up. See Chapter 18, Backups [p. 243] for backup options.
If this is not the first time an operating system has been installed on your computer, it is likely you will need to re-partition your disk to make room for Ubuntu.
Any time you partition your disk, you should be prepared to lose everything on the disk should you make a mistake or something goes wrong during partitioning. The programs used in installation are quite reliable, most have seen years of use, but they also perform destructive actions.
2
http://www.kroah.com/lkn/
5
Installation

2. Installing from CD

The basic steps to install Ubuntu Server Edition from CD are the same for installing any operating system from CD. Unlike the Desktop Edition the Server Edition does not include a graphical installation program. Instead the Server Edition uses a console menu based process.
• First, download and burn the appropriate ISO file from the Ubuntu web site3.
• Boot the system from the CD-ROM drive.
• At the boot prompt you will be asked to select the language. Afterwards the installation process begins by asking for your keyboard layout.
• From the main boot menu there are some additional options to install Ubuntu Server Edition. You can install a basic Ubuntu Server, or install Ubuntu Server as part of a Ubuntu Enterprise Cloud. For more information on UEC see Section 3, “UEC” [p. 271]. The rest of this section will cover the basic Ubuntu Server install.
• The installer then discovers your hardware configuration, and configures the network settings using DHCP. If you do not wish to use DHCP at the next screen choose "Go Back", and you have the option to "Configure the network manually".
• Next, the installer asks for the system's hostname and Time Zone.
• You can then choose from several options to configure the hard drive layout. For advanced disk options see Section 4, “Advanced Installation” [p. 10].
• The Ubuntu base system is then installed.
• A new user is setup, this user will have root access through the sudo utility.
• After the user is setup, you will be asked to encrypt your home directory.
• The next step in the installation process is to decide how you want to update the system. There are three options:
No automatic updates: this requires an administrator to log into the machine and manually install
updates.
Install security updates Automatically: will install the unattended-upgrades package, which
will install security updates without the intervention of an administrator. For more details see Section 5, “Automatic Updates” [p. 24].
Manage the system with Landscape: Landscape is a paid service provided by Canonical to help
manage your Ubuntu machines. See the Landscape4 site for details.
• You now have the option to install, or not install, several package tasks. See Section 2.1, “Package Tasks” [p. 7] for details. Also, there is an option to launch aptitude to choose specific packages to install. For more information see Section 4, “Aptitude” [p. 22].
• Finally, the last step before rebooting is to set the clock to UTC.
If at any point during installation you are not satisfied by the default setting, use the "Go Back" function at any prompt to be brought to a detailed installation menu that will allow you to modify the default settings.
6
Installation
At some point during the installation process you may want to read the help screen provided by the installation system. To do this, press F1.
Once again, for detailed instructions see the Ubuntu Installation Guide5.

2.1. Package Tasks

During the Server Edition installation you have the option of installing additional packages from the CD. The packages are grouped by the type of service they provide.
• DNS server: Selects the BIND DNS server and its documentation.
• LAMP server: Selects a ready-made Linux/Apache/MySQL/PHP server.
• Mail server: This task selects a variety of package useful for a general purpose mail server system.
• OpenSSH server: Selects packages needed for an OpenSSH server.
• PostgreSQL database: This task selects client and server packages for the PostgreSQL database.
• Print server: This task sets up your system to be a print server.
• Samba File server: This task sets up your system to be a Samba file server, which is especially suitable in networks with both Windows and Linux systems.
• Tomcat Java server: Installs Apache Tomcat and needed dependencies.
• Virtual Machine host: Includes packages needed to run KVM virtual machines.
• Manually select packages: Executes aptitude allowing you to individually select packages.
Installing the package groups is accomplished using the tasksel utility. One of the important difference between Ubuntu (or Debian) and other GNU/Linux distribution is that, when installed, a package is also configured to reasonable defaults, eventually prompting you for additional required information. Likewise, when installing a task, the packages are not only installed, but also configured to provided a fully integrated service.
Once the installation process has finished you can view a list of available tasks by entering the following from a terminal prompt:
tasksel --list-tasks
The output will list tasks from other Ubuntu based distributions such as Kubuntu and Edubuntu. Note that you can also invoke the tasksel command by itself, which will bring up a menu of the different tasks available.
You can view a list of which packages are installed with each task using the --task-packages option. For example, to list the packages installed with the DNS Server task enter the following:
tasksel --task-packages dns-server
5
https://help.ubuntu.com/10.10/installation-guide/
7
Installation
The output of the command should list:
bind9-doc bind9utils bind9
Also, if you did not install one of the tasks during the installation process, but for example you decide to make your new LAMP server a DNS server as well. Simply insert the installation CD and from a terminal:
sudo tasksel install dns-server
8
Installation

3. Upgrading

There are several ways to upgrade from one Ubuntu release to another. This section gives an overview of the recommended upgrade method.

3.1. do-release-upgrade

The recommended way to upgrade a Server Edition installation is to use the do-release-upgrade utility. Part of the update-manager-core package, it does not have any graphical dependencies and is installed by default.
Debian based systems can also be upgraded by using apt-get dist-upgrade. However, using do­release-upgrade is recommended because it has the ability to handle system configuration changes sometimes needed between releases.
To upgrade to a newer release, from a terminal prompt enter:
do-release-upgrade
It is also possible to use do-release-upgrade to upgrade to a development version of Ubuntu. To accomplish this use the -d switch:
do-release-upgrade -d
Upgrading to a development release is not recommended for production environments.
9
Installation

4. Advanced Installation

4.1. Software RAID

RAID is a method of configuring multiple hard drives to act as one, reducing the probability of catastrophic data loss in case of drive failure. RAID is implemented in either software (where the operating system knows about both drives and actively maintains both of them) or hardware (where a special controller makes the OS think there's only one drive and maintains the drives 'invisibly').
The RAID software included with current versions of Linux (and Ubuntu) is based on the 'mdadm' driver and works very well, better even than many so-called 'hardware' RAID controllers. This section will guide you through installing Ubuntu Server Edition using two RAID1 partitions on two physical hard drives, one for / and another for swap.
4.1.1. Partitioning
Follow the installation steps until you get to the Partition disks step, then:
1. Select Manual as the partition method.
2. Select the first hard drive, and agree to "Create a new empty partition table on this device?".
Repeat this step for each drive you wish to be part of the RAID array.
3. Select the "FREE SPACE" on the first drive then select "Create a new partition".
4. Next, select the Size of the partition. This partition will be the swap partition, and a general
rule for swap size is twice that of RAM. Enter the partition size, then choose Primary, then Beginning.
5. Select the "Use as:" line at the top. By default this is "Ext4 journaling file system", change that to
"physical volume for RAID" then "Done setting up partition".
6. For the / partition once again select "Free Space" on the first drive then "Create a new partition".
7. Use the rest of the free space on the drive and choose Continue, then Primary.
8. As with the swap partition, select the "Use as:" line at the top, changing it to "physical volume
for RAID". Also select the "Bootable flag:" line to change the value to "on". Then choose "Done setting up partition".
9. Repeat steps three through eight for the other disk and partitions.
4.1.2. RAID Configuration
With the partitions setup the arrays are ready to be configured:
1. Back in the main "Partition Disks" page, select "Configure Software RAID" at the top.
2. Select "yes" to write the changes to disk.
3. Choose "Create MD device".
10
Installation
4. For this example, select "RAID1", but if you are using a different setup choose the appropriate
type (RAID0 RAID1 RAID5).
In order to use RAID5 you need at least three drives. Using RAID0 or RAID1 only two drives are required.
5. Enter the number of active devices "2", or the amount of hard drives you have, for the array.
Then select "Continue".
6. Next, enter the number of spare devices "0" by default, then choose "Continue".
7. Choose which partitions to use. Generally they will be sda1, sdb1, sdc1, etc. The numbers will
usually match and the different letters correspond to different hard drives.
For the swap partition choose sda1 and sdb1. Select "Continue" to go to the next step.
8. Repeat steps three through seven for the / partition choosing sda2 and sdb2.
9. Once done select "Finish".
4.1.3. Formatting
There should now be a list of hard drives and RAID devices. The next step is to format and set the mount point for the RAID devices. Treat the RAID device as a local hard drive, format and mount accordingly.
1. Select "#1" under the "RAID1 device #0" partition.
2. Choose "Use as:". Then select "swap area", then "Done setting up partition".
3. Next, select "#1" under the "RAID1 device #1" partition.
4. Choose "Use as:". Then select "Ext4 journaling file system".
5. Then select the "Mount point" and choose "/ - the root file system". Change any of the other
options as appropriate, then select "Done setting up partition".
6. Finally, select "Finish partitioning and write changes to disk".
If you choose to place the root partition on a RAID array, the installer will then ask if you would like to boot in a degraded state. See Section 4.1.4, “Degraded RAID” [p. 11] for further details.
The installation process will then continue normally.
4.1.4. Degraded RAID
At some point in the life of the computer a disk failure event may occur. When this happens, using Software RAID, the operating system will place the array into what is known as a degraded state.
If the array has become degraded, due to the chance of data corruption, by default Ubuntu Server Edition will boot to initramfs after thirty seconds. Once the initramfs has booted there is a fifteen second prompt giving you the option to go ahead and boot the system, or attempt manual recover. Booting to the initramfs prompt may or may not be the desired behavior, especially if the machine is in a remote location. Booting to a degraded array can be configured several ways:
11
Installation
• The dpkg-reconfigure utility can be used to configure the default behavior, and during the process you will be queried about additional settings related to the array. Such as monitoring, email alerts, etc. To reconfigure mdadm enter the following:
sudo dpkg-reconfigure mdadm
• The dpkg-reconfigure mdadm process will change the /etc/initramfs-tools/conf.d/mdadm configuration file. The file has the advantage of being able to pre-configure the system's behavior, and can also be manually edited:
BOOT_DEGRADED=true
The configuration file can be overridden by using a Kernel argument.
• Using a Kernel argument will allow the system to boot to a degraded array as well:
• When the server is booting press Shift to open the Grub menu.
• Press e to edit your kernel command options.
• Press the down arrow to highlight the kernel line.
• Add "bootdegraded=true" (without the quotes) to the end of the line.
• Press Ctrl+x to boot the system.
Once the system has booted you can either repair the array see Section 4.1.5, “RAID Maintenance” [p. 12] for details, or copy important data to another machine due to major hardware failure.
4.1.5. RAID Maintenance
The mdadm utility can be used to view the status of an array, add disks to an array, remove disks, etc:
• To view the status of an array, from a terminal prompt enter:
sudo mdadm -D /dev/md0
The -D tells mdadm to display detailed information about the /dev/md0 device. Replace /dev/md0 with the appropriate RAID device.
• To view the status of a disk in an array:
sudo mdadm -E /dev/sda1
The output if very similar to the mdadm -D command, adjust /dev/sda1 for each disk.
• If a disk fails and needs to be removed from an array enter:
sudo mdadm --remove /dev/md0 /dev/sda1
12
Installation
Change /dev/md0 and /dev/sda1 to the appropriate RAID device and disk.
• Similarly, to add a new disk:
sudo mdadm --add /dev/md0 /dev/sda1
Sometimes a disk can change to a faulty state even though there is nothing physically wrong with the drive. It is usually worthwhile to remove the drive from the array then re-add it. This will cause the drive to re-sync with the array. If the drive will not sync with the array, it is a good indication of hardware failure.
The /proc/mdstat file also contains useful information about the system's RAID devices:
cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] md0 : active raid1 sda1[0] sdb1[1] 10016384 blocks [2/2] [UU]
unused devices: <none>
The following command is great for watching the status of a syncing drive:
watch -n1 cat /proc/mdstat
Press Ctrl+c to stop the watch command.
If you do need to replace a faulty drive, after the drive has been replaced and synced, grub will need to be installed. To install grub on the new drive, enter the following:
sudo grub-install /dev/md0
Replace /dev/md0 with the appropriate array device name.
4.1.6. Resources
The topic of RAID arrays is a complex one due to the plethora of ways RAID can be configured. Please see the following links for more information:
Ubuntu Wiki Articles on RAID6.
Software RAID HOWTO
Managing RAID on Linux
7
8

4.2. Logical Volume Manager (LVM)

Logical Volume Manger, or LVM, allows administrators to create logical volumes out of one or multiple physical hard disks. LVM volumes can be created on both software RAID partitions and
13
Installation
standard partitions residing on a single disk. Volumes can also be extended, giving greater flexibility to systems as requirements change.
4.2.1. Overview
A side effect of LVM's power and flexibility is a greater degree of complication. Before diving into the LVM installation process, it is best to get familiar with some terms.
Volume Group (VG): contains one or several Logical Volumes (LV).
Logical Volume (LV): is similar to a partition in a non-LVM system. Multiple Physical Volumes (PV) can make up one LV, on top of which resides the actual EXT3, XFS, JFS, etc filesystem.
Physical Volume (PV): physical hard disk or software RAID partition. The Volume Group can be extended by adding more PVs.
4.2.2. Installation
As an example this section covers installing Ubuntu Server Edition with /srv mounted on a LVM volume. During the initial install only one Physical Volume (PV) will be part of the Volume Group (VG). Another PV will be added after install to demonstrate how a VG can be extended.
There are several installation options for LVM, "Guided - use the entire disk and setup LVM" which will also allow you to assign a portion of the available space to LVM, "Guided - use entire and setup encrypted LVM", or Manually setup the partitions and configure LVM. At this time the only way to configure a system with both LVM and standard partitions, during installation, is to use the Manual approach.
1. Follow the installation steps until you get to the Partition disks step, then:
2. At the "Partition Disks screen choose "Manual".
3. Select the hard disk and on the next screen choose "yes" to "Create a new empty partition table
on this device".
4. Next, create standard /boot, swap, and / partitions with whichever filesystem you prefer.
5. For the LVM /srv, create a new Logical partition. Then change "Use as" to "physical volume for
LVM" then "Done setting up the partition".
6. Now select "Configure the Logical Volume Manager" at the top, and choose "Yes" to write the
changes to disk.
7. For the "LVM configuration action" on the next screen, choose "Create volume group". Enter a
name for the VG such as vg01, or something more descriptive. After entering a name, select the partition configured for LVM, and choose "Continue".
8. Back at the "LVM configuration action" screen, select "Create logical volume". Select the
newly created volume group, and enter a name for the new LV, for example srv since that is the intended mount point. Then choose a size, which may be the full partition because it can always be extended later. Choose "Finish" and you should be back at the main "Partition Disks" screen.
14
Installation
9. Now add a filesystem to the new LVM. Select the partition under "LVM VG vg01, LV srv", or
whatever name you have chosen, the choose Use as. Setup a file system as normal selecting /srv as the mount point. Once done, select "Done setting up the partition".
10. Finally, select "Finish partitioning and write changes to disk". Then confirm the changes and
continue with the rest of the installation.
There are some useful utilities to view information about LVM:
vgdisplay: shows information about Volume Groups.
lvdisplay: has information about Logical Volumes.
pvdisplay: similarly displays information about Physical Volumes.
4.2.3. Extending Volume Groups
Continuing with srv 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
srv 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)
1. First, create the physical volume, in a terminal execute:
sudo pvcreate /dev/sdb
2. Now extend the Volume Group (VG):
sudo vgextend vg01 /dev/sdb
3. Use vgdisplay 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 -l option allows the LV to be extended using PE. The -L option allows the LV to be extended using Meg, Gig, Tera, etc bytes.
4. Even though you are supposed to be able to expand an ext3 or ext4 filesystem without
unmounting it first, it may be a good practice 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).
15
Installation
The following commands are for an EXT3 or EXT4 filesystem. If you are using another filesystem there may be other utilities available.
sudo umount /srv sudo e2fsck -f /dev/vg01/srv
The -f option of e2fsck forces checking even if the system seems clean.
5. Finally, resize the filesystem:
sudo resize2fs /dev/vg01/srv
6. Now mount the partition and check its size.
mount /dev/vg01/srv /srv && df -h /srv
4.2.4. Resources
• See the Ubuntu Wiki LVM Articles9.
• See the LVM HOWTO10 for more information.
• Another good article is Managing Disk Space with LVM11 on O'Reilly's linuxdevcenter.com site.
• For more information on fdisk see the fdisk man page12.
16

Chapter 3. Package Management

Ubuntu features a comprehensive package management system for the installation, upgrade, configuration, and removal of software. In addition to providing access to an organized base of over 24,000 software packages for your Ubuntu computer, the package management facilities also feature dependency resolution capabilities and software update checking.
Several tools are available for interacting with Ubuntu's package management system, from simple command-line utilities which may be easily automated by system administrators, to a simple graphical interface which is easy to use by those new to Ubuntu.
17
Package Management

1. Introduction

Ubuntu's package management system is derived from the same system used by the Debian GNU/ Linux distribution. The package files contain all of the necessary files, meta-data, and instructions to implement a particular functionality or software application on your Ubuntu computer.
Debian package files typically have the extension '.deb', and typically exist in repositories which are collections of packages found on various media, such as CD-ROM discs, or online. Packages are normally of the pre-compiled binary format; thus installation is quick and requires no compiling of software.
Many complex packages use the concept of dependencies. Dependencies are additional packages required by the principal package in order to function properly. For example, the speech synthesis package Festival depends upon the package libasound2, which is a package supplying the ALSA sound library needed for audio playback. In order for Festival to function, it and all of its dependencies must be installed. The software management tools in Ubuntu will do this automatically.
18
Package Management

2. dpkg

dpkg is a package manager for Debian based systems. It can install, remove, and build packages, but unlike other package management system's, it can not automatically download and install packages or their dependencies. This section covers using dpkg to manage locally installed packages:
• To list all packages installed on the system, from a terminal prompt enter:
dpkg -l
• Depending on the amount of packages on your system, this can generate a large amount of output. Pipe the output through grep to see if a specific package is installed:
dpkg -l | grep apache2
Replace apache2 with any package name, part of a package name, or other regular expression.
• To list the files installed by a package, in this case the ufw package, enter:
dpkg -L ufw
• If you are not sure which package installed a file, dpkg -S may be able to tell you. For example:
dpkg -S /etc/host.conf
base-files: /etc/host.conf
The output shows that the /etc/host.conf belongs to the base-files package.
Many files are automatically generated during the package install process, and even though they are on the filesystem dpkg -S may not know which package they belong to.
• You can install a local .deb file by entering:
sudo dpkg -i zip_2.32-1_i386.deb
Change zip_2.32-1_i386.deb to the actual file name of the local .deb file.
• Uninstalling a package can be accomplished by:
sudo dpkg -r zip
Uninstalling packages using dpkg, in most cases, is NOT recommended. It is better to use a package manager that handles dependencies, to ensure that the system is in a consistent state. For example using dpkg -r you can remove the zip package, but any packages that depend on it will still be installed and may no longer function correctly.
For more dpkg options see the man page: man dpkg.
19
Package Management

3. Apt-Get

The apt-get command is a powerful command-line tool used to work with Ubuntu's Advanced Packaging Tool (APT) performing such functions as installation of new software packages, upgrade
of existing software packages, updating of the package list index, and even upgrading the entire Ubuntu system.
Being a simple command-line tool, apt-get has numerous advantages over other package management tools available in Ubuntu for server administrators. Some of these advantages include ease of use over simple terminal connections (SSH) and the ability to be used in system administration scripts, which can in turn be automated by the cron scheduling utility.
Some examples of popular uses for the apt-get utility:
Install a Package: Installation of packages using the apt-get tool is quite simple. For example, to install the network scanner nmap, type the following:
sudo apt-get install nmap
Remove a Package: Removal of a package or packages is also a straightforward and simple process. To remove the nmap package installed in the previous example, type the following:
sudo apt-get remove nmap
Multiple Packages: You may specify multiple packages to be installed or removed, separated by spaces.
Also, adding the --purge options to apt-get remove will remove the package configuration files as well. This may or may not be the desired effect so use with caution.
Update the Package Index: The APT package index is essentially a database of available packages from the repositories defined in the /etc/apt/sources.list file. To update the local package index with the latest changes made in repositories, type the following:
sudo apt-get update
Upgrade Packages: Over time, updated versions of packages currently installed on your computer may become available from the package repositories (for example security updates). To upgrade your system, first update your package index as outlined above, and then type:
sudo apt-get upgrade
For information on upgrading to a new Ubuntu release see Section 3, “Upgrading” [p. 9].
Actions of the apt-get command, such as installation and removal of packages, are logged in the /var/ log/dpkg.log log file.
20
Package Management
For further information about the use of APT, read the comprehensive Debian APT User Manual1 or type:
apt-get help
1
http://www.debian.org/doc/user-manuals#apt-howto
21
Package Management

4. Aptitude

Aptitude is a menu-driven, text-based front-end to the Advanced Packaging Tool (APT) system. Many of the common package management functions, such as installation, removal, and upgrade, are performed in Aptitude with single-key commands, which are typically lowercase letters.
Aptitude is best suited for use in a non-graphical terminal environment to ensure proper functioning of the command keys. You may start Aptitude as a normal user with the following command at a terminal prompt:
sudo aptitude
When Aptitude starts, you will see a menu bar at the top of the screen and two panes below the menu bar. The top pane contains package categories, such as New Packages and Not Installed Packages. The bottom pane contains information related to the packages and package categories.
Using Aptitude for package management is relatively straightforward, and the user interface makes common tasks simple to perform. The following are examples of common package management functions as performed in Aptitude:
Install Packages: To install a package, locate the package via the Not Installed Packages package category, for example, by using the keyboard arrow keys and the ENTER key, and highlight the package you wish to install. After highlighting the package you wish to install, press the + key, and the package entry should turn green, indicating it has been marked for installation. Now press g to be presented with a summary of package actions. Press g again, and you will be prompted to become root to complete the installation. Press ENTER which will result in a Password: prompt. Enter your user password to become root. Finally, press g once more and you'll be prompted to download the package. Press ENTER on the Continue prompt, and downloading and installation of the package will commence.
Remove Packages: To remove a package, locate the package via the Installed Packages package category, for example, by using the keyboard arrow keys and the ENTER key, and highlight the package you wish to remove. After highlighting the package you wish to install, press the - key, and the package entry should turn pink, indicating it has been marked for removal. Now press g to be presented with a summary of package actions. Press g again, and you will be prompted to become root to complete the installation. Press ENTER which will result in a Password: prompt. Enter your user password to become root. Finally, press g once more, and you'll be prompted to download the package. Press ENTER on the Continue prompt, and removal of the package will commence.
Update Package Index: To update the package index, simply press the u key and you will be prompted to become root to complete the update. Press ENTER which will result in a Password: prompt. Enter your user password to become root. Updating of the package index will commence. Press ENTER on the OK prompt when the download dialog is presented to complete the process.
Upgrade Packages: To upgrade packages, perform the update of the package index as detailed above, and then press the U key to mark all packages with updates. Now press g whereby you'll be
22
Package Management
presented with a summary of package actions. Press g again, and you will be prompted to become root to complete the installation. Press ENTER which will result in a Password: prompt. Enter your user password to become root. Finally, press g once more, and you'll be prompted to download the packages. Press ENTER on the Continue prompt, and upgrade of the packages will commence.
The first column of information displayed in the package list in the top pane, when actually viewing packages lists the current state of the package, and uses the following key to describe the state of the package:
i: Installed package
c: Package not installed, but package configuration remains on system
p: Purged from system
v: Virtual package
B: Broken package
u: Unpacked files, but package not yet configured
C: Half-configured - Configuration failed and requires fix
H: Half-installed - Removal failed and requires fix
To exit Aptitude, simply press the q key and confirm you wish to exit. Many other functions are available from the Aptitude menu by pressing the F10 key.
23
Package Management

5. Automatic Updates

The unattended-upgrades package can be used to automatically install updated packages, and can be configured to update all packages or just install security updates. First, install the package by entering the following in a terminal:
sudo apt-get install unattended-upgrades
To configure unattended-upgrades, edit /etc/apt/apt.conf.d/50unattended-upgrades and adjust the following to fit your needs:
Unattended-Upgrade::Allowed-Origins { "Ubuntu maverick-security"; // "Ubuntu maverick-updates"; };
Certain packages can also be blacklisted and therefore will not be automatically updated. To blacklist a package, add it to the list:
Unattended-Upgrade::Package-Blacklist { // "vim"; // "libc6"; // "libc6-dev"; // "libc6-i686"; };
The double “//” serve as comments, so whatever follows "//" will not be evaluated.
To enable automatic updates, edit /etc/apt/apt.conf.d/10periodic and set the appropriate apt configuration options:
APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Download-Upgradeable-Packages "1"; APT::Periodic::AutocleanInterval "7"; APT::Periodic::Unattended-Upgrade "1";
The above configuration updates the package list, downloads, and installs available upgrades every day. The local download archive is cleaned every week.
You can read more about apt Periodic configuration options in the /etc/cron.daily/apt script header.
The results of unattended-upgrades will be logged to /var/log/unattended-upgrades.
24
Loading...
+ 281 hidden pages