Introduction to Linux: Storage and System Security                        
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                            Philipp Fruck & Pius Walter                                                            
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                    System Administration                                                     
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
            ██ Goal of this Lecture                                                                                                                
                                                                                                                                                   
               •  How storage is organized: partitions, file systems and mounting                                                                  
               •  How to protect data at rest: LUKS, TPM2 and measured boot                                                                        
               •  How to snapshot, update and roll back a system                                                                                   
               •  Mandatory access control and firewalls as additional layers                                                                      
                                                                                                                                                   
            ██ Why?                                                                                                                                
                                                                                                                                                   
               •  Lost disks and laptops are a common source of data leaks                                                                         
               •  Updates are the most effective security measure, but they can break systems                                                      
               •  Snapshots turn risky changes into reversible ones                                                                                
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                Introduction to Linux: Storage and System Security                                          2 / 14 
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                               Block Devices, Partitions and File systems                                
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                             Typical UEFI layout                                                   
                 lsblk -f              # devices, FS, UUIDs                                                                                        
                 sudo fdisk -l         # partition tables                    Partition │ Content                                                   
                 sudo blkid            # UUIDs and types                     ──────────┼─────────────────────────────                              
                 findmnt               # mounted filesystems                 ESP       │ FAT32, /boot/efi, loader                                  
                 df -hT                # usage and FS type                   /boot     │ Kernel, initramfs (optional)                              
                                                                             root      │ Encrypted ext4/btrfs/xfs                                  
                                                                                                                                                   
            Layers (bottom to top)                                                                                                                 
                                                                                                                                                   
               1. Disk (/dev/nvme0n1)                                                                                                              
               2. Partition table (GPT) and partitions                                                                                             
               3. Optional: LUKS, LVM, RAID                                                                                                        
               4. File system                                                                                                                      
               5. Mount point                                                                                                                      
                                                                                                                                                   
                                                                                                                                                   
            ▍ Always refer to disks by UUID or label: /dev/sdX names can change.                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                Introduction to Linux: Storage and System Security                                          3 / 14 
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                      Common File systems                                                       
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
            File system │ Typical use                  │ Notable features                                                                          
            ────────────┼──────────────────────────────┼──────────────────────────────────────────────                                             
            ext4        │ Default on Debian/Ubuntu     │ Stable, simple, journaling                                                                
            xfs         │ Default on RHEL, large files │ High performance, cannot be shrunk                                                        
            btrfs       │ Fedora, openSUSE             │ Snapshots, subvolumes, checksums, compression                                             
            zfs         │ Storage servers, BSD         │ Snapshots, RAID, out-of-tree on Linux                                                     
            vfat        │ ESP, USB sticks              │ No permissions, universal compatibility                                                   
            tmpfs       │ /tmp, /run                   │ Lives in RAM                                                                              
                                                                                                                                                   
                                                                                                                                                   
                                          sudo mkfs.ext4 -L data /dev/sdb1   # ⚠️ destroys existing data                                           
                                          sudo mount /dev/sdb1 /mnt                                                                                
                                          sudo umount /mnt                                                                                         
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                Introduction to Linux: Storage and System Security                                          4 / 14 
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                             Mounting at Boot: /etc/fstab                                              
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
            ██ What is /etc/fstab                                            ██ How systemd uses /etc/fstab                                        
                                                                                                                                                   
               •  Plain text configuration file defining file systems           •  systemd generates mount units for every entry                   
                  to mount at boot                                                 ◦  /boot -> boot.mount                                          
                                                                                   ◦  /mnt/data -> mnt-data.mount                                  
                                                                                •  Benefits:                                                       
              # <device>   <mount> <type> <options>  <dump> <fsck>                 ◦  Parallelized mounting (faster)                               
              UUID=1a2b…   /       ext4   defaults   0      1                      ◦  Dependency tracking, e.g. network file systems               
              UUID=3c4d…   /data   ext4   noatime    0      2                                                                                      
                                                                                                                                                   
                                                                                                                                                   
               •  Test before rebooting!                                                                                                           
                                                                                                                                                   
                                                                                                                                                   
                 sudo mount -a                                                                                                                     
                 sudo systemctl daemon-reload                                                                                                      
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
            ▍ A broken fstab entry can drop the system into emergency mode. Use nofail for non-essential disks.                                    
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                Introduction to Linux: Storage and System Security                                          5 / 14 
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                               Full Disk Encryption: LUKS                                                
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
            Problem: Anyone with physical access can read an                 Unlock at boot: /etc/crypttab                                         
            unencrypted disk.                                                                                                                      
                                                                                                                                                   
            Solution: LUKS (dm-crypt) encrypts a block device. The                # <name>  <device>     <keyfile> <options>                       
            filesystem lives inside the encrypted container.                      secret    UUID=5e6f…   none      luks                            
                                                                                                                                                   
                                                                                                                                                   
                 # ⚠️ wipes data                                             Then use /dev/mapper/secret in /etc/fstab                             
                 sudo cryptsetup luksFormat /dev/sdb1                                                                                              
                 sudo cryptsetup open /dev/sdb1 secret                          •  Multiple key slots: passphrase, recovery key,                   
                 sudo mkfs.ext4 /dev/mapper/secret                                 FIDO2, TPM2                                                     
                 sudo mount /dev/mapper/secret /mnt                             •  sudo cryptsetup luksDump /dev/sdb1                              
                 sudo cryptsetup close secret                                   •  Root filesystem: unlocked by the initramfs before               
                                                                                   the system starts                                               
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                Introduction to Linux: Storage and System Security                                          6 / 14 
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                   TPM2 and Measured Boot                                                    
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
            TPM: Tamper-resistant chip on the mainboard (or in firmware)              Inspect                                                      
                                                                                                                                                   
               •  Stores secrets and can seal them to a system state                                                                               
               •  Contains PCRs (Platform Configuration Registers)                      systemd-analyze pcrs                                       
                  ◦  Can only be extended: PCR = hash(PCR || new value)                 sudo tpm2_pcrread sha256                                   
                                                                                        systemd-cryptenroll --tpm2-device=list                     
            Measured boot: every stage measures the next one before running it                                                                     
                                                                                                                                                   
               1. Firmware -> PCR 0, 2                                                Enroll the TPM as an additional LUKS key                     
               2. Secure Boot state and keys -> PCR 7                                                                                              
               3. Boot loader / kernel (UKI) -> PCR 4, 11                                                                                          
                                                                                        sudo systemd-cryptenroll \                                 
            ▍ The TPM only releases the key if the PCR values match ->                      --tpm2-device=auto --tpm2-pcrs=0+2+7 \                 
            ▍ modified boot chain = no automatic unlock.                                    /dev/nvme0n1p3                                         
                                                                                                                                                   
            ▍ Unified Kernel Images (UKIs) provide support for measured boot:                                                                      
            ▍ Look them up if interested!                                                                                                          
                                                                                        # /etc/crypttab                                            
                                                                                        root UUID=… none tpm2-device=auto                          
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
            ▍ ⚠️ A TPM does not protect against a running, logged-in system. Combine it with a PIN or strong login if the device can be            
            ▍ stolen while on.                                                                                                                     
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                Introduction to Linux: Storage and System Security                                          7 / 14 
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                     Snapshots with btrfs                                                      
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
            Copy-on-write (CoW) filesystem: snapshots are instant and        Typical Fedora layout (/etc/fstab)                                    
            initially take no extra space.                                                                                                         
                                                                                                                                                   
               •  Subvolume: independently mountable directory tree             UUID=… /     btrfs subvol=root,compress=zstd:1 0 0                 
               •  Snapshot: subvolume created from another subvolume            UUID=… /home btrfs subvol=home,compress=zstd:1 0 0                 
                                                                                                                                                   
                                                                                                                                                   
                 sudo btrfs subvolume list /                                 Tooling                                                               
                 sudo btrfs subvolume create /data                                                                                                 
                                                                                •  snapper, timeshift: automatic snapshots + rollback              
                                                                                •  openSUSE: snapshot before and after each package                
                                                                                   transaction                                                     
                 # read-only snapshot                                           •  btrfs send | btrfs receive: incremental backups                 
                 sudo btrfs subvolume snapshot -r \                             •  cp --reflink: instant file copies                               
                     /home /.snapshots/home-$(date +%F)                                                                                            
                 sudo btrfs subvolume delete \                               ▍ ⚠️ Snapshots on the same disk are not a backup.                     
                     /.snapshots/home-2026-11-17                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                Introduction to Linux: Storage and System Security                                          8 / 14 
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                           System Updates                                                            
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
            ██ Packages                                             ██ Applications                                                                
                                                                                                                                                   
                                                                    Don't forget Flatpak/AppImage or custom applications!                          
              # Debian/Ubuntu                                                                                                                      
              sudo apt update && sudo apt upgrade                   Same for stuff installed via pip, npm and the like.                            
              # Fedora/RHEL                                                                                                                        
              sudo dnf upgrade --refresh                            ██ Safer update strategies                                                     
              # Arch                                                                                                                               
              sudo pacman -Syu                                         •  Snapshot first, then update, roll back on failure                        
                                                                       •  Image-based/atomic systems: new system image is written                  
                                                                          beside the old one                                                       
            ██ Firmware: LVFS                                             ◦  Fedora Atomic/Silverblue: rpm-ostree, bootc                           
                                                                          ◦  NixOS: nixos-rebuild switch --rollback                                
            Linux Vendor Firmware Service: vendors publish             •  Boot menu keeps the previous version                                     
            firmware (BIOS, SSD, docking stations) which                                                                                           
            fwupd installs (your device must be supported).         ▍ Firmware updates can change TPM measurements -> re-seal (                    
                                                                    ▍ systemd-pcrlock make-policy) or have the recovery key ready.                 
                                                                                                                                                   
              fwupdmgr refresh                                                                                                                     
              fwupdmgr get-devices                                                                                                                 
              fwupdmgr get-updates                                                                                                                 
              fwupdmgr update                                                                                                                      
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                Introduction to Linux: Storage and System Security                                          9 / 14 
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                        Mandatory Access Control: SELinux                                         
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
            Adds security labels (contexts) to files,               List and change file context / service port                                    
            processes and ports                                                                                                                    
                                                                                                                                                   
                                                                            sudo semanage fcontext -l                                              
              # show context                                                sudo chcon -t httpd_sys_content_t                                      
              ls -Z                                                         /var/www/html/index.html                                               
              ps -eZ                                                                                                                               
              # get/set SELinux state                                       # -m = modify, -a = append                                             
              getenforce                                                    sudo semanage port -m -t ssh_port_t -p tcp 2222                        
              setenforce {0,1}                                              sudo semanage port -l                                                  
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
            ▍ SELinux denies access -> Check logs with sudo journalctl -t setroubleshoot or use audit2allow                                        
                                                                                                                                                   
            ▍ If you see setenforce 0 in installation instructions, choose a different product. Disabling SELinux is not a proper                  
            ▍ solution.                                                                                                                            
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                Introduction to Linux: Storage and System Security                                         10 / 14 
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                     Linux Firewall Tools                                                      
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
            ██ iptables                                                      ██ ufw                                                                
                                                                                                                                                   
               •  Traditional Linux firewall                                    •  Stands for "Uncomplicated Firewall"                             
               •  Works at the packet-filtering level                           •  Front-end for iptables/nftables                                 
               •  Different commands for IPv4/IPv6                              •  Simple CLI for managing rules                                   
                  ◦  Complex structure & rules                                  •  Mostly used on Ubuntu/Debian                                    
               •  iptables -L -v -n [-t {nat,mangle}]                           •  ufw status verbose                                              
               •  ip6tables -L -v -n [-t {nat,mangle}]                                                                                             
               •  iptables-save; ip6tables-save                              ██ firewalld                                                          
                                                                                                                                                   
            ██ nftables                                                         •  Dynamic firewall manager for Linux                              
                                                                                •  Zones define network trust levels                               
               •  Successor to iptables                                         •  Works with nftables back-end                                    
               •  Single framework for IPv4, IPv6, ARP, and bridge              •  More complex & capable than ufw                                 
                  filtering                                                     •  Common on RHEL/Fedora                                           
               •  Uses concise syntax; replaces multiple iptables               •  sudo firewall-cmd --list-all                                    
                  commands                                                                                                                         
               •  nft list ruleset                                                                                                                 
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                Introduction to Linux: Storage and System Security                                         11 / 14 
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                 Alternative init systems                                                  
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
            Init System  │ Service File / Directory Location │ Enable/Start Command                                                                
            ─────────────┼───────────────────────────────────┼─────────────────────────────────                                                    
            SysVinit     │ /etc/init.d/<service> and         │ sudo update-rc.d sshd defaults                                                      
                         │ symlinks in /etc/rc*.d/           │ /etc/init.d/sshd start                                                              
            BusyBox init │ /etc/init.d/<service>             │ /etc/init.d/sshd start                                                              
            OpenRC       │ /etc/init.d/<service>             │ rc-service sshd start                                                               
                         │ /etc/runlevels/<level>/           │                                                                                     
            s6-rc        │ /etc/s6-rc/source/<service>/      │ s6-rc -u change sshd                                                                
                         │ or /service/<service>/            │                                                                                     
            runit        │ /etc/sv/<service>/ (definitions)  │ ln -s /etc/sv/sshd /var/service/                                                    
                         │ /var/service/ (active)            │                                                                                     
                                                                                                                                                   
               •  SysVinit is the traditional runlevel based init using shell scripts                                                              
               •  BusyBox init is a minimal SysV-style variant for embedded systems                                                                
               •  OpenRC is a modern dependency-aware script-based init with parallel startup                                                      
               •  runit is a fast three-stage init with built-in service supervision                                                               
               •  s6/s6-rc provides a highly modular, reliability-focused supervision framework ideal for minimal and containerized                
                  systems                                                                                                                          
                                                                                                                                                   
            ▍ Use ps [aux] | grep ' 1 ' to determine your init system (PID 1)                                                                      
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                Introduction to Linux: Storage and System Security                                         12 / 14 
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                 Exercise                                                                  
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
            ██ Filesystems and LUKS                                          ██ Snapshots                                                          
                                                                                                                                                   
            Use a loop file instead of a real disk:                                                                                                
                                                                               sudo btrfs subvolume create /mnt/data                               
                                                                               echo v1 | sudo tee /mnt/data/file                                   
                 truncate -s 256M disk.img                                     sudo btrfs subvolume snapshot -r /mnt/data /mnt/snap1               
                 sudo cryptsetup luksFormat disk.img                           echo v2 | sudo tee /mnt/data/file                                   
                 sudo cryptsetup open disk.img lab                                                                                                 
                 sudo mkfs.btrfs /dev/mapper/lab                                                                                                   
                 sudo mount /dev/mapper/lab /mnt                                1. Compare /mnt/data/file and /mnt/snap1/file                      
                                                                                2. Delete the snapshot                                             
                                                                                3. Clean up: umount, cryptsetup close lab, rm disk.img             
               1. Find the UUID with sudo blkid disk.img                                                                                           
               2. Write a matching crypttab entry (do not install it)                                                                              
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                Introduction to Linux: Storage and System Security                                         13 / 14 
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                               Thank you!                                                                
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
            Thank you for your attention!                                                                                                          
                                                                                                                                                   
            Don't forget the feedback in Moodle please!                                                                                            
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                                                                                                                   
                                                Introduction to Linux: Storage and System Security                                         14 / 14