Linux Learning · Part 2 of 7

💿 Installation

Distros · Partitioning · LVM · Kickstart · cloud-init · Post-Install hardening.


Choosing a Distribution

🟠

Ubuntu / Debian

Best for beginners and cloud VMs. LTS releases every 2 years. Package manager: apt / dpkg

🔴

RHEL / Rocky / AlmaLinux

Enterprise standard. RHEL is paid; Rocky and Alma are free clones. Package manager: dnf / rpm

🎦

Fedora

Bleeding-edge features. Upstream of RHEL. Great for developers. Package manager: dnf

🏔

Alpine

Tiny (5MB). Perfect for containers and security-focused installs. Package manager: apk


Recommended Partition Layout

Server partition layout
Mount       Size              Notes
─────────────────────────────────────────────────────────────
/boot       1 GB              Kernel + initrd. Outside LVM. ext4 or xfs.
/boot/efi   512 MB            EFI System Partition (UEFI only). FAT32.
/           20–50 GB          Root filesystem.
/home       Remaining space   User data. Survives OS reinstall if separate.
/var        10–20 GB          Logs, databases, spool. Grows fast on servers.
/tmp        2–5 GB            Temp files. Can be tmpfs (RAM).
swap        = RAM (≤8GB)      Or 4–8 GB on systems with lots of RAM.
Manual installation steps (most installers)
1.  Choose language, keyboard, timezone
2.  Configure network — DHCP or static IP / gateway / DNS
3.  Partition disks — use LVM for flexibility
4.  Create swap partition or swap file
5.  Set hostname (e.g. webserver01.example.com)
6.  Set root password + create non-root admin user
7.  Select software packages (minimal server vs full desktop)
8.  Configure firewall and SELinux/AppArmor
9.  Install bootloader (GRUB2) to the disk
10. Reboot, remove install media

LVM — Logical Volume Manager

LVM abstracts physical disks into flexible logical volumes you can resize on the fly without repartitioning.

LVM concepts: PV → VG → LV
# PV = Physical Volume  (a real disk or partition)
# VG = Volume Group     (pool of one or more PVs)
# LV = Logical Volume   (what you format and mount)

$ sudo pvcreate /dev/sdb1              # create PV
$ sudo vgcreate myvg /dev/sdb1         # create VG from PV
$ sudo lvcreate -L 20G -n data myvg    # create 20 GB LV

$ sudo mkfs.xfs /dev/myvg/data         # format it
$ sudo mount /dev/myvg/data /mnt/data   # mount it

# Extend LV live (no unmount needed with XFS):
$ sudo lvextend -L +10G /dev/myvg/data
$ sudo xfs_growfs /mnt/data

# View everything:
$ pvs && vgs && lvs

Swap File (Modern Method)

Create a 4 GB swap file
$ sudo fallocate -l 4G /swapfile
$ sudo chmod 600 /swapfile
$ sudo mkswap /swapfile
$ sudo swapon /swapfile

# Make permanent — add to /etc/fstab:
$ echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

$ free -h          # verify swap is active
$ swapon --show

Automated Installation

Kickstart (RHEL / Fedora) — minimal example
#version=RHEL9
install
url --url="http://mirror.example.com/rhel9"
lang en_US.UTF-8
keyboard us
network --bootproto=dhcp
rootpw --plaintext s3cr3t
timezone America/New_York
bootloader --location=mbr
clearpart --all --initlabel
autopart
%packages
@minimal
%end

# Pass to installer at boot prompt:
linux ks=http://server/ks.cfg
cloud-init user-data (cloud VMs)
#cloud-config
hostname: webserver01
users:
  - name: saad
    sudo: ALL=(ALL) NOPASSWD:ALL
    ssh_authorized_keys:
      - ssh-rsa AAAA...your-public-key

packages:
  - nginx
  - git
  - htop

runcmd:
  - systemctl enable --now nginx

Post-Installation Checklist

First things to do on a fresh Linux server
# 1. Update all packages
$ sudo apt update && sudo apt upgrade -y       # Debian/Ubuntu
$ sudo dnf update -y                           # RHEL/Fedora

# 2. Set hostname
$ sudo hostnamectl set-hostname myserver

# 3. Set timezone
$ sudo timedatectl set-timezone America/New_York

# 4. Create non-root sudo user
$ sudo useradd -m -s /bin/bash saad
$ sudo passwd saad
$ sudo usermod -aG sudo saad          # Debian/Ubuntu
$ sudo usermod -aG wheel saad         # RHEL/Fedora

# 5. Set up SSH key auth (from your local machine)
$ ssh-keygen -t ed25519 -C "saad@server"
$ ssh-copy-id saad@server-ip

# 6. Enable firewall
$ sudo ufw allow ssh && sudo ufw enable

# 7. Verify disk layout
$ lsblk && df -h
🖥
Sponsored

Need a Linux VPS? Try DigitalOcean

Spin up a Linux droplet in 60 seconds and practice every step in this guide on a real server.

Get Started →