Free preview. This lesson is open to everyone. Enroll to get the whole course and keep track of your progress.

Lesson

1.3 Objective review

Partitions

Tool Use
lsblk Tree of block devices, partitions, LVM volumes and mount points. lsblk -f adds filesystem type, label and UUID
blkid Prints UUID, LABEL and TYPE of each block device. Use UUIDs in /etc/fstab
fdisk Interactive partitioning for MBR and GPT (fdisk -l lists)
gdisk GPT focused version of fdisk
parted Scriptable partitioning (parted /dev/sdb mklabel gpt mkpart data xfs 1MiB 100%)
growpart Grows a partition to fill free space after it, typically after a cloud disk was enlarged (growpart /dev/sda 2)

MBR supports 4 primary partitions (or 3 plus an extended one) and disks up to 2 TiB. GPT supports 128 partitions by default and very large disks, and is required for UEFI boot from the disk. After changing a disk that is in use, partprobe asks the kernel to re-read the table.

Filesystems

Format Notes
ext4 Mature journaling filesystem. Can grow online and shrink offline (resize2fs). Checked with fsck / e2fsck
xfs Default on RHEL. Excellent with large files and parallel I/O. Grows online with xfs_growfs, cannot shrink. Repaired with xfs_repair (not fsck)
btrfs Copy on write with snapshots, subvolumes, checksums, compression and built in RAID. Default on openSUSE and Fedora Workstation
tmpfs Lives in RAM (and swap). Contents vanish at reboot. Used for /run, often /tmp and /dev/shm
Utility Purpose
mkfs -t xfs /dev/sdb1 or mkfs.ext4 /dev/sdb1 Create a filesystem
fsck /dev/sdb1 Check and repair (ext family). Unmount first
resize2fs /dev/vg/lv Resize ext2/3/4 to the size of its device
xfs_growfs /mountpoint Grow a mounted XFS filesystem
xfs_repair /dev/sdb1 Repair an unmounted XFS filesystem
df -h Free and used space per mounted filesystem. df -i shows inodes
du -sh dir Space used by files in a directory tree
fio Flexible I/O tester: benchmarks IOPS, throughput and latency with defined workloads

Inodes store a file's metadata (owner, permissions, timestamps, pointers to data blocks) but not its name. ext4 creates a fixed number when the filesystem is made, so millions of tiny files can exhaust inodes while df -h still shows free space. df -i reveals it.

Logical Volume Manager (LVM)

LVM stacks three layers: physical volumes (PVs: disks or partitions) are pooled into volume groups (VGs), which are carved into logical volumes (LVs) that hold filesystems. LVs can be resized and moved between disks while in use.

Layer Create Show Change Remove
PV pvcreate /dev/sdb pvs, pvdisplay, pvscan pvresize (after the disk grew), pvmove (move extents off a disk) pvremove
VG vgcreate data /dev/sdb /dev/sdc vgs, vgdisplay, vgscan vgextend data /dev/sdd, vgchange -a y/n (activate), vgexport / vgimport (move to another host) vgremove
LV lvcreate -n web -L 20G data lvs, lvdisplay lvextend, lvresize, lvchange -a n lvremove

LVs appear as /dev/data/web and /dev/mapper/data-web.

Growing a filesystem on LVM in one step: lvextend -r -L +10G /dev/data/web (-r runs resize2fs or xfs_growfs for you). -l +100%FREE uses all free space in the VG.

Replacing a failing disk with no downtime: vgextend data /dev/sdd, then pvmove /dev/sdb (moves its extents), vgreduce data /dev/sdb, pvremove /dev/sdb.

terminal
pvcreate /dev/sdb /dev/sdc
vgcreate data /dev/sdb /dev/sdc
lvcreate -n web -L 20G data
mkfs.xfs /dev/data/web
mkdir -p /srv/web && mount /dev/data/web /srv/web
lvextend -r -L +10G /dev/data/web     # grow LV and filesystem together

Software RAID (mdadm)

Level Minimum disks Survives Usable capacity
RAID 0 (striping) 2 no failures all disks
RAID 1 (mirroring) 2 all but one disk one disk
RAID 5 (striping with parity) 3 one disk n minus 1 disks
RAID 6 (double parity) 4 two disks n minus 2 disks
RAID 10 (mirrored stripes) 4 one per mirror half
  • Create: mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1
  • Status: cat /proc/mdstat ([UU] healthy, [U_] degraded) and mdadm --detail /dev/md0
  • Replace a disk: mdadm /dev/md0 --fail /dev/sdc1 --remove /dev/sdc1, then --add the new one
  • Persist: mdadm --detail --scan >> /etc/mdadm.conf (/etc/mdadm/mdadm.conf on Debian)

Mounting

mount /dev/sdb1 /data attaches a filesystem; umount /data detaches it (it fails with "target is busy" while a process uses it: find it with lsof /data or fuser -vm /data).

  • /etc/fstab: filesystems to mount at boot. Six fields: device (UUID= preferred), mount point, type, options, dump (0), fsck order (1 for root, 2 for others, 0 to skip).
  • /proc/mounts: what the kernel actually has mounted right now. /etc/mtab is a symlink to it on modern systems.
  • mount -a mounts everything in fstab that is not yet mounted: test fstab edits with it before rebooting. findmnt shows the mount tree.
  • autofs mounts on demand when a path is accessed and unmounts after a timeout. The master map /etc/auto.master points a directory at a map file, for example /mnt/nfs /etc/auto.nfs.
UUID=7c1e...  /data  xfs  defaults,noatime,nofail  0 2
Option Effect
ro / rw Read only / read write
remount Change options of a mounted filesystem: mount -o remount,rw /
noatime Do not update access times on read (less I/O). nodiratime does the same for directories only
noexec Do not allow executing binaries from this filesystem (good for /tmp)
nosuid Ignore setuid and setgid bits
nodev Do not interpret device files
nofail Do not fail the boot if the device is missing (removable or network disks)
_netdev The device needs the network; wait for it

Network mounts

  • NFS: the server lists shares in /etc/exports (/srv/share 192.168.1.0/24(rw,sync,root_squash)) and applies them with exportfs -ra. Clients mount with mount -t nfs server:/srv/share /mnt/share. showmount -e server lists exports.
  • SMB (Samba): Windows compatible shares. Clients mount with mount -t cifs //server/share /mnt/share -o credentials=/root/.smbcred (cifs-utils). Keep passwords in a credentials file with mode 600, not in fstab.
XFS cannot shrink

A frequent exam trap: you can grow XFS but never shrink it. To make an XFS volume smaller, back it up, recreate it at the new size and restore.

1.2 Objective review

Course outline

1.1 Explain basic Linux concepts

Not started: 1.1 Objective review Lesson
Locked: 1.1 Practice exam Enroll to unlock Quiz

1.2 Summarize Linux device management concepts and tools

Not started: 1.2 Objective review Lesson
Locked: 1.2 Practice exam Enroll to unlock Quiz

1.3 Given a scenario, manage storage in a Linux system

Not started: 1.3 Objective review Lesson
Locked: 1.3 Practice exam Enroll to unlock Quiz

1.4 Given a scenario, manage network services and configurations on a Linux server

Locked: 1.4 Objective review Enroll to unlock Lesson
Locked: 1.4 Practice exam Enroll to unlock Quiz

1.5 Given a scenario, manage a Linux system using common shell operations

Locked: 1.5 Objective review Enroll to unlock Lesson
Locked: 1.5 Practice exam Enroll to unlock Quiz

1.6 Given a scenario, perform backup and restore operations for a Linux server

Locked: 1.6 Objective review Enroll to unlock Lesson
Locked: 1.6 Practice exam Enroll to unlock Quiz

1.7 Summarize virtualization on Linux systems

Locked: 1.7 Objective review Enroll to unlock Lesson
Locked: 1.7 Practice exam Enroll to unlock Quiz

2.1 Given a scenario, manage files and directories on a Linux system

Locked: 2.1 Objective review Enroll to unlock Lesson
Locked: 2.1 Practice exam Enroll to unlock Quiz

2.2 Given a scenario, perform local account management in a Linux environment

Locked: 2.2 Objective review Enroll to unlock Lesson
Locked: 2.2 Practice exam Enroll to unlock Quiz

2.3 Given a scenario, manage processes and jobs in a Linux environment

Locked: 2.3 Objective review Enroll to unlock Lesson
Locked: 2.3 Practice exam Enroll to unlock Quiz

2.4 Given a scenario, configure and manage software in a Linux environment

Locked: 2.4 Objective review Enroll to unlock Lesson
Locked: 2.4 Practice exam Enroll to unlock Quiz

2.5 Given a scenario, manage Linux using systemd

Locked: 2.5 Objective review Enroll to unlock Lesson
Locked: 2.5 Practice exam Enroll to unlock Quiz

2.6 Given a scenario, manage applications in a container on a Linux server

Locked: 2.6 Objective review Enroll to unlock Lesson
Locked: 2.6 Practice exam Enroll to unlock Quiz

3.1 Summarize authorization, authentication, and accounting methods

Locked: 3.1 Objective review Enroll to unlock Lesson
Locked: 3.1 Practice exam Enroll to unlock Quiz

3.2 Given a scenario, configure and implement firewalls on a Linux system

Locked: 3.2 Objective review Enroll to unlock Lesson
Locked: 3.2 Practice exam Enroll to unlock Quiz

3.3 Given a scenario, apply operating system (OS) hardening techniques on a Linux system

Locked: 3.3 Objective review Enroll to unlock Lesson
Locked: 3.3 Practice exam Enroll to unlock Quiz

3.4 Explain account hardening techniques and best practices

Locked: 3.4 Objective review Enroll to unlock Lesson
Locked: 3.4 Practice exam Enroll to unlock Quiz

3.5 Explain cryptographic concepts and technologies in a Linux environment

Locked: 3.5 Objective review Enroll to unlock Lesson
Locked: 3.5 Practice exam Enroll to unlock Quiz

3.6 Explain the importance of compliance and audit procedures

Locked: 3.6 Objective review Enroll to unlock Lesson
Locked: 3.6 Practice exam Enroll to unlock Quiz

4.1 Summarize the use cases and techniques of automation and orchestration in a Linux environment

Locked: 4.1 Objective review Enroll to unlock Lesson
Locked: 4.1 Practice exam Enroll to unlock Quiz

4.2 Given a scenario, perform automated tasks using shell scripting

Locked: 4.2 Objective review Enroll to unlock Lesson
Locked: 4.2 Practice exam Enroll to unlock Quiz

4.3 Summarize Python basics used for Linux system administration

Locked: 4.3 Objective review Enroll to unlock Lesson
Locked: 4.3 Practice exam Enroll to unlock Quiz

4.4 Given a scenario, implement version control using Git

Locked: 4.4 Objective review Enroll to unlock Lesson
Locked: 4.4 Practice exam Enroll to unlock Quiz

4.5 Summarize best practices and responsible uses of artificial intelligence (AI)

Locked: 4.5 Objective review Enroll to unlock Lesson
Locked: 4.5 Practice exam Enroll to unlock Quiz

5.1 Summarize monitoring concepts and configurations in a Linux system

Locked: 5.1 Objective review Enroll to unlock Lesson
Locked: 5.1 Practice exam Enroll to unlock Quiz

5.2 Given a scenario, analyze and troubleshoot hardware, storage, and Linux OS issues

Locked: 5.2 Objective review Enroll to unlock Lesson
Locked: 5.2 Practice exam Enroll to unlock Quiz

5.3 Given a scenario, analyze and troubleshoot networking issues on a Linux system

Locked: 5.3 Objective review Enroll to unlock Lesson
Locked: 5.3 Practice exam Enroll to unlock Quiz

5.4 Given a scenario, analyze and troubleshoot security issues on a Linux system

Locked: 5.4 Objective review Enroll to unlock Lesson
Locked: 5.4 Practice exam Enroll to unlock Quiz

5.5 Given a scenario, analyze and troubleshoot performance issues

Locked: 5.5 Objective review Enroll to unlock Lesson
Locked: 5.5 Practice exam Enroll to unlock Quiz

Full XK0-006 practice exam

Locked: About the XK0-006 exam Enroll to unlock Lesson
Locked: XK0-006 Full practice exam (90 questions) Enroll to unlock Quiz