You are on page 1of 40

Linux SysAdmin

Topic 102
Linux Installation and Package Management
102.1 Design hard disk layout
102.1 Design hard disk layout (2)
Hard disk geometry is concerned with the following terms:

1. Track - concentric circles on a platter. These are where data are stored.
2. Cylinder - same tracks of different platters make up a cylinder.
3. Sector - a portion of a track. 63 sectors per track. Contains 512 bytes.
4. Head or Side - two heads per platter.

Disk size = cylinders * heads * sectors * bytes per sector

CHS Geometry
102.1 Design hard disk layout (2)


Hierarchical tree-
like filesystem
structure

Mount points are
directories on the
tree where block
devices are
mapped to or
attached
102.1 Design hard disk layout (3)
Partitioning your disk:

For desktops, three to four partitions are sufficient:

1. /
2. /boot (optional, highly recommended)
3. /home
4. swap

For servers, there may be separate partitions for /srv and /var.
102.1 Design hard disk layout (3)
Partitioning your disk:

Primary partitions

Logical partitions

Extended partitions
102.1 Design hard disk layout (5)
Partitioning your disk:

fdisk command is used to display the partition table of a disk. It is also used interactively
to partition the disk.
102.1 Design hard disk layout (6)
The EFI (Extensible Firmware Interface) system partition or ESP is a partition on a data storage
device (usually a hard disk drive or solid-state drive) that is used by computers adhering to the
Unified Extensible Firmware Interface (UEFI). When a computer is booted, UEFI firmware loads files
stored on the ESP to start installed operating systems and various utilities.

If your Linux box needs to boot to ESP, the following must be present:

/sys/firmware/efi
/boot/efi/grubx64.efi
/boot/efi/EFI/ubuntu/grubx64.efi (ubuntu 18.04)

For setting up EFI on Ubuntu: https://help.ubuntu.com/community/UEFI


102.1 Design hard disk layout (7)
Logical Volume Manager (LVM). It is a software-based system that lets you create "pools"
of storage and add hard drive space to those pools as needed. There are lots of reasons to
use it, especially in a data center or any place where storage requirements change over
time.

LVM is a system of managing logical volumes, or filesystems, that is much more


advanced and flexible than the traditional method of partitioning a disk into one or more
segments and formatting that partition with a filesystem.

For it to work, LVM assumes you have more than one physical volumes (or disks or
drives). You can create a pool for one or more PVs.
102.1 Design hard disk layout (8)
References for study:

https://wiki.ubuntu.com/Lvm

https://www.digitalocean.com/community/tutorials/how-to-use-lvm-to-manage-storage-de
vices-on-ubuntu-16-04

https://www.thegeekdiary.com/redhat-centos-a-beginners-guide-to-lvm-logical-volume-ma
nager/
102.2 Install a boot manager
GRUB vs. GRUB2

Grand Unified Bootloader (GRUB) has long replaced LILO as boot loader for modern
computing devices.

But even with GRUB, there are now two types: GRUB Legacy and GRUB2. The latter is
now the default bootloader for Linux distributions.
102.2 Install a boot manager (2)
GRUB Legacy

The configuration file is usually stored in /boot/grub/menu.lst (for Debian and


derivatives) and /boot/grub/grub.conf (for Red Hat and derivatives).
102.2 Install a boot manager (3)
Some GRUB directives or parameters

Any line starting with a # is a comment and is ignored by GRUB.

default

Specifies which system to load if the user does not make a choice within a timeout. default=0 means
to load the first entry. Remember that GRUB counts from 0 rather than 1. If not specified, then the
default is to boot the first entry, entry number 0.
102.2 Install a boot manager (4)
timeout

Specifies a timeout in seconds before booting the default entry. Note that LILO uses tenths of a
second for timeouts, while GRUB uses whole seconds.

splashimage

Specifies the background, or splash, image to be displayed with the boot menu. GRUB Legacy refers
to the first hard drive as (hd0) and the first partition on that drive as (hd0,0), so the specification of
splashimage=(hd0,0)/boot/grub/splash.xpm.gz means to use the file /boot/grub/splash.xpm.gz located
on partition 1 of the first hard drive. Remember to count from 0. The image is an XPM file
compressed with gzip.
102.2 Install a boot manager (5)
password

Specifies a password that you must enter before you can unlock the menu and either edit a
configuration line or enter GRUB commands. The password can be in clear text. GRUB
also permits passwords to be stored as an MD5 digest

title

Is a descriptive title that is shown as the menu item when Grub boots. You use the arrow
keys to move up and down through the title list and then press Enter to select a particular
entry.
102.2 Install a boot manager (6)
root

Specifies the partition that will be booted. As with splashimage, remember that counting
starts at 0, so the first filesystem that is specified as root (hd0,6) is actually on partition 7
of the first hard drive (/dev/hda7 in this case).

kernel

Specifies the kernel image to be loaded and any required kernel parameters. A kernel
value like /boot/grub2/i386-pc/core.img usually means loading a GRUB 2 boot loader
from the named root partition.
102.2 Install a boot manager (7)
initrd

Is the name of the initial RAM disk, which contains modules needed by the kernel before
your file systems are mounted.

rootnoverify

Is similar to root, except that GRUB does not attempt to mount the file system or verify its
parameters. This is usually used for file systems such as NTFS that are not supported by
GRUB.
102.2 Install a boot manager (8)
Interact with GRUB boot loader

Hold down the Shift or Esc key while Linux is being booted. When the GRUB menu
appears, use the arrow keys to select entry to edit. Then press 'e' to edit that entry.
102.2 Install a boot manager (9)
GRUB2

GRUB 2's default menu looks familiar to GRUB users but there are a great number of
differences beneath the surface.

With no other installed operating systems, GRUB 2 will boot directly to the login prompt
or Desktop. No menu will be displayed. Hold down (right) SHIFT to display the menu
during boot. In certain cases, pressing the ESC key may also display the menu.

No /boot/grub/menu.lst for Debian. It has been replaced by /boot/grub/grub.cfg. No


/boot/grub/grub.conf for Red Hat. It has been replaced by /boot/grub2/grub.cfg.
102.2 Install a boot manager (10)
GRUB2

The main Grub 2 configuration file, normally located in the /boot/grub folder (for Debian)
and /boot/grub2 (for Oracle Linux), is grub.cfg. It is the product of various scripts and
should not normally be edited directly.

grub.cfg is overwritten by certain Grub 2 package updates, whenever a kernel is added or


removed, or when the user runs update-grub.

The menu list of available Linux kernels is automatically generated by running update-
grub.
102.2 Install a boot manager (11)
The user can create a custom file in which the user can place his own menu entries. This
file will not be overwritten. By default, a custom file named 40_custom is available for
use in the /etc/grub.d folder.

The primary configuration file for changing menu display settings is called grub and by
default is located in the /etc/default folder.

There are multiple files for configuring the menu - /etc/default/grub mentioned above, and
all the files in the /etc/grub.d/ directory.
102.2 Install a boot manager (12)
Partition numbering has changed. The first partition is now 1 rather than 0. The first
device/drive is still hd0 by default (no change). These designations can be altered if
necessary in the device.map file in the /boot/grub folder.

Automated searches for other operating systems, such as Windows, are accomplished
whenever update-grub is executed. Operating systems found will be placed in the Grub 2
menu.

Changes made in the configuration files will not take effect until the update-grub
command is executed.

You may change the default parameters of grub by editing /etc/default/grub.


102.2 Install a boot manager (13)
References:

https://help.ubuntu.com/community/Grub2

https://developer.ibm.com/tutorials/l-lpic1-102-2/
102.3 Manage shared libraries
Shared libraries are compiled code which is intended to be shared among several different
programs. They are distributed as .so files in /usr/lib/.

ldd prints the shared objects (shared libraries) required by each program or shared object
specified on the command line.

ldconfig is used to create, update and remove symbolic links for the current shared
libraries based on the lib directories present in the /etc/ld.so.conf. The file is actually a
pointer to the directory /etc/ld.so.conf.d.
About package management
What is meant by package?

An application is 'packaged' by a Linux distribution so it may be installed easily by a


privileged user. Debian and its derivatives use packages whose names end in .deb. Red
Hat and its derivatives use .rpm.

A package format is a type of archive containing computer programs and additional


metadata needed by package managers. While the archive file format itself may be
unchanged, package formats bear additional metadata, such as a manifest file or certain
directory layouts. Packages may contain either source code or executable files.
102.4 Use Debian package management
The apt suite

APT (for Advanced Package Tool) is a set of tools for managing Debian packages, and
therefore the applications installed on your Debian system. APT makes it possible to
install applications, remove application, keep your applications up to date, among others.

apt-get command is probably the most often used member of the apt suite of packaging
tools. Its main purpose is interfacing with remote repositories maintained by the
distribution's packaging team and performing actions on the available packages.
102.4 Use Debian package management (2)
Keeping the /etc/apt/sources.list. The file contains a list of configured APT data sources.

apt-get update. Update the local cache (/var/cache/apt/archives)

apt-get upgrade. Update packages without package removal

apt-get dist-upgrade. Update packages and remove as necessary

apt-cache. This utility uses the local cache to query information about the available
packages and their properties.

apt-cache show package-name


102.4 Use Debian package management (3)
apt-get install [package1] [package2] … [packageN]. Install a particular package.

Use -s to simulate the installation.

Use -y to ignore prompts for user action.

Use -f to fix broken dependencies.

dpkg --configure -a (to continue and finish disrupted upgrading of the system)
dpkg-reconfigure package (to reconfigure a package)
102.4 Use Debian package management (3.1)
apt-get remove package. Remove or uninstall a package.
102.4 Use Debian package management (4)
dpkg - Package manager for Debian

-i install a package

-l list installed packages

-r remove a package (excluding configuration files)

-c view contents of a deb file

-L location of package

-P purge package, including configuration files

-p print information about a package


02.5 Use RPM and YUM package management
Yum is the Red Hat package manager that is able to query for information about available
packages, fetch packages from repositories, install and uninstall them, and update an
entire system to the latest available version. Yum performs automatic dependency
resolution on packages you are updating, installing, or removing, and thus is able to
automatically determine, fetch, and install all available dependent packages.

General configuration: /etc/yum.conf.

Package repositories are placed in /etc/yum.repos.d.


02.5 Use RPM and YUM package management (2)
yum check-update - To see which installed packages on your system have updates
available.

The packages in the above output are listed as having updates available. The first package
in the list is PackageKit, the graphical package manager. The line in the example output
tells us:

PackageKit — the name of the package


x86_64 — the CPU architecture the package was built for
0.5.8 — the version of the updated package to be installed
rhel — the repository in which the updated package is located
02.5 Use RPM and YUM package management (3)
yum update - To update all packages and their dependencies.

yum update package-name - To update a particular package

yum install package - To install a package

rpm -i package.rpm

For automatic updating of packages:

1. yum install yum-cron


2. chkconfig yum-cron on
3. service yum-cron start
02.5 Use RPM and YUM package management (4)
To list all installed packages, enter:

rpm -qa

yum list installed

Find out if a package is installed or not on the system

rpm -qa | grep [string]*

yum list installed [string]


02.5 Use RPM and YUM package management (5)
To search for packages:

yum search package-name


yum list [words]*

To know detailed info about a package:

yum info package-name

To remove a package:

yum remove package


yum erase package
102.6 Linux as a virtualization guest
What is Virtualization?

Virtualization is the technique of importing a Guest operating system on top of a Host operating
system. This technique was a revelation at the beginning because it allowed developers to run multiple
operating systems in different virtual machines all running on the same host. This eliminated the need
for extra hardware resource. The advantages of Virtual Machines or Virtualization are:

1. Multiple operating systems can run on the same machine


2. Maintenance and Recovery were easy in case of failure conditions
3. Total cost of ownership was also less due to the reduced need for infrastructure
102.6 Linux as a virtualization guest (2)
What is Containerization?

Containerization is the technique of bringing virtualization to the operating system level. While
Virtualization brings abstraction to the hardware, Containerization brings abstraction to the operating
system. Do note that Containerization is also a type of Virtualization. Containerization is however
more efficient because there is no guest OS here and utilizes a host’s operating system, share relevant
libraries & resources as and when needed unlike virtual machines. Application specific binaries and
libraries of containers run on the host kernel, which makes processing and execution very fast. Even
booting-up a container takes only a fraction of a second. Because all the containers share, host
operating system and holds only the application related binaries & libraries. They are lightweight and
faster than Virtual Machines.
102.6 Linux as a virtualization guest (3)
Advantages of Containerization over Virtualization:

1. Containers on the same OS kernel are lighter and smaller


2. Better resource utilization compared to VMs
3. Boot-up process is short and takes few seconds

Reference: https://www.webopedia.com/TERM/C/containerization.html
102.6 Linux as a virtualization guest (4)
102.6 Linux as a virtualization guest (5)
References:

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/virtualizat
ion/sect-virtualization-installing_red_hat_enterprise_linux_as_a_fully_virtualized_guest

You might also like