Festplatten, Mounten & fstab
Die Verwaltung von Festplatten und Partitionen gehört zum Kernrepertoire der Systemadministration unter Ubuntu 26.04. Dieser Artikel zeigt, wie Sie Festplatteninformationen anzeigen, Partitionen manuell einhängen und die automatische Bereitstellung beim Booten über fstab konfigurieren.
Anzeigen von Festplatten- und Partitionsinformationen
lsblk – Blockgeräte auflisten
# Basic usage
lsblk
# Example output:
# NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
# sda 8:0 0 500G 0 disk
# ├─sda1 8:1 0 512M 0 part /boot/efi
# ├─sda2 8:2 0 488G 0 part /
# └─sda3 8:3 0 11.5G 0 part [SWAP]
# sdb 8:16 0 2T 0 disk
# └─sdb1 8:17 0 2T 0 part
# Show filesystem types and UUIDs
lsblk -f
# Show more detailed information
lsblk -o NAME,SIZE,FSTYPE,MOUNTPOINT,UUID,LABELWeitere Tools für Festplatteninformationen

# View partition table
sudo fdisk -l
# View disk usage
df -h
# View disk usage of a specific directory
du -sh /var/log
# View UUIDs of all partitions
sudo blkidPartitionierung
Partitionieren mit fdisk (MBR)
# Partition /dev/sdb
sudo fdisk /dev/sdb
# fdisk interactive commands:
# n - Create a new partition
# p - Print partition table
# d - Delete a partition
# t - Change partition type
# w - Write changes and exitPartitionieren mit gdisk (GPT)
sudo apt install gdisk
sudo gdisk /dev/sdbArbeiten mit parted
# Interactive mode
sudo parted /dev/sdb
# Non-interactive example: create a GPT partition table and one partition
sudo parted /dev/sdb mklabel gpt
sudo parted /dev/sdb mkpart primary ext4 0% 100%Partitionen formatieren
# Format as ext4
sudo mkfs.ext4 /dev/sdb1
# Format as XFS
sudo mkfs.xfs /dev/sdb1
# Format as Btrfs
sudo mkfs.btrfs /dev/sdb1
# Format as NTFS (requires ntfs-3g)
sudo mkfs.ntfs /dev/sdb1
# Set a volume label
sudo e2label /dev/sdb1 "DataDisk"Ein- und Aushängen
mount – eine Partition einhängen
# Create a mount point
sudo mkdir -p /mnt/data
# Mount a partition
sudo mount /dev/sdb1 /mnt/data
# Mount as read-only
sudo mount -o ro /dev/sdb1 /mnt/data
# Mount an ISO file
sudo mount -o loop ubuntu-26.04.iso /mnt/iso
# Mount an NFS share
sudo mount -t nfs 192.168.1.100:/shared /mnt/nfs
# Mount a CIFS/SMB share
sudo mount -t cifs //192.168.1.100/share /mnt/smb -o username=user,password=pass
# View all current mounts
mount | column -t
findmntumount – eine Partition aushängen
# Unmount a partition
sudo umount /mnt/data
# If the device is busy, find the processes using it
sudo lsof +f -- /mnt/data
sudo fuser -mv /mnt/data
# Force unmount (use with caution)
sudo umount -l /mnt/data # Lazy unmount
sudo umount -f /mnt/data # Force unmount (NFS)Automatisches Einhängen über /etc/fstab
Konfigurationsfehler in /etc/fstab (etwa Tippfehler bei UUIDs oder nicht vorhandene Einhängepunkte) können verhindern, dass das System normal startet. Sichern Sie die Datei deshalb immer vor dem Bearbeiten (sudo cp /etc/fstab /etc/fstab.bak) und prüfen Sie die Konfiguration nach jeder Änderung mit sudo mount -a und sudo findmnt --verify. Bei unkritischen Partitionen sollten Sie zusätzlich die Option nofail setzen, um Startfehler zu vermeiden.
Aufbau der fstab-Datei
/etc/fstab legt fest, welche Partitionen beim Booten automatisch eingehängt werden. Jede Zeile besteht aus sechs Feldern:
# <device> <mount point> <filesystem> <options> <dump> <fsck>
UUID=xxxx-xxxx /mnt/data ext4 defaults 0 2Beschreibung der Felder:
| Feld | Beschreibung |
|---|---|
| Gerät | Kennung der Partition; empfohlen wird die UUID |
| Einhängepunkt | Verzeichnispfad, unter dem eingehängt wird |
| Dateisystem | ext4, xfs, btrfs, ntfs usw. |
| Optionen | Mount-Optionen, durch Kommas getrennt |
| Dump | Backup-Kennzeichen, üblicherweise 0 |
| Fsck | Prüfreihenfolge beim Booten: 1 für Root, 2 für andere, 0 zum Überspringen |
UUID ermitteln
# Method 1: blkid
sudo blkid /dev/sdb1
# Output: /dev/sdb1: UUID="a1b2c3d4-e5f6-7890-abcd-ef1234567890" TYPE="ext4"
# Method 2: lsblk
lsblk -f /dev/sdb1
# Method 3: ls symlinks
ls -la /dev/disk/by-uuid/Beispiele für fstab-Konfigurationen
# Edit fstab (back up before modifying)
sudo cp /etc/fstab /etc/fstab.bak
sudo nano /etc/fstabHäufige Konfigurationen:
# ext4 data partition
UUID=a1b2c3d4-e5f6-7890-abcd-ef1234567890 /mnt/data ext4 defaults 0 2
# Mount with specific options
UUID=b2c3d4e5-f6a7-8901-bcde-f12345678901 /mnt/ssd ext4 defaults,noatime,discard 0 2
# NTFS partition (Windows data drive)
UUID=1234567890ABCDEF /mnt/windows ntfs-3g defaults,uid=1000,gid=1000,umask=022 0 0
# NFS network share
192.168.1.100:/shared /mnt/nfs nfs defaults,_netdev 0 0
# tmpfs (in-memory filesystem)
tmpfs /tmp tmpfs defaults,noatime,size=2G 0 0
# swap partition
UUID=c3d4e5f6-a7b8-9012-cdef-123456789012 none swap sw 0 0Häufige Mount-Optionen
| Option | Beschreibung |
|---|---|
defaults | Entspricht rw,suid,dev,exec,auto,nouser,async |
noatime | Aktualisiert die Zugriffszeit nicht und verbessert dadurch die Leistung |
nodiratime | Aktualisiert die Zugriffszeit von Verzeichnissen nicht |
discard | Aktiviert TRIM (für SSDs empfohlen) |
nofail | Blockiert den Start nicht, wenn das Gerät fehlt |
_netdev | Wartet vor dem Einhängen auf das Netzwerk |
ro | Hängt die Partition schreibgeschützt ein |
noexec | Verhindert die Ausführung von Binärdateien |
nosuid | Ignoriert SUID-/SGID-Bits |
fstab-Konfiguration überprüfen
# Mount all entries in fstab that are not yet mounted (tests if configuration is correct)
sudo mount -a
# Verify with findmnt
sudo findmnt --verify
# If there are errors, restore the backup
sudo cp /etc/fstab.bak /etc/fstabSwap-Verwaltung
# View current swap
swapon --show
free -h
# Create a swap file
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
# Add to fstab to make it persistent
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
# Disable swap
sudo swapoff /swapfileLVM-Verwaltung logischer Volumes
# Install LVM tools
sudo apt install lvm2
# Create a physical volume
sudo pvcreate /dev/sdb1
# Create a volume group
sudo vgcreate mydata /dev/sdb1
# Create a logical volume
sudo lvcreate -L 100G -n myvolume mydata
# Format and mount
sudo mkfs.ext4 /dev/mydata/myvolume
sudo mount /dev/mydata/myvolume /mnt/data
# Online extend a logical volume
sudo lvextend -L +50G /dev/mydata/myvolume
sudo resize2fs /dev/mydata/myvolume
# View LVM status
sudo pvs
sudo vgs
sudo lvsFehlerbehebung
fstab-Mountfehler beim Booten
Wenn eine Fehlkonfiguration der fstab das Booten verhindert, hilft der Wiederherstellungsmodus von GRUB:
# Remount root partition as read-write
mount -o remount,rw /
# Edit and fix fstab
nano /etc/fstab
# Reboot
rebootFehlender Speicherplatz
# View partition usage
df -h
# Find large files
sudo find / -type f -size +100M -exec ls -lh {} \;
# View directory space usage (sorted)
sudo du -sh /* | sort -rh | head -20
# Clean APT cache
sudo apt clean
sudo apt autoremove