Linux partitioning commands
A disk is the whole device. A partition is a slice of that disk. A filesystem (ext4, xfs, vfat) is the format Linux writes inside a slice. Mounting attaches that filesystem to a folder like / or /boot.
The picture
On two-disk RAID1, both disks get the same partition map. Linux then builds /dev/md0, md1, md2 from matching slices.
Device names
| You see | What it is |
|---|---|
/dev/sda | First SATA/SAS disk. Partitions: sda1, sda2, … |
/dev/nvme0n1 | First NVMe. Partitions: nvme0n1p1, nvme0n1p2, … |
/dev/md2 | Software RAID array |
/dev/mapper/vg0-root | LVM logical volume |
wipefs destroy data. Prefer installimage on Hetzner unless you already know the layout. Double-check the device with lsblk first.See what exists (safe)
lsblk -o NAME,SIZE,TYPE,FSTYPE,LABEL,MOUNTPOINT,UUIDlsblk -ffindmntdf -hTblkidfdisk -lparted -llsblk is the first command to memorize. TYPE tells you disk vs part vs raid vs lvm. MOUNTPOINT tells you what is actually in use.
GPT vs MBR
MBR is the old partition table. It struggles past 2 TiB. GPT is the modern table and is what you want on dedicated servers, together with an EFI System Partition if the box boots UEFI.
parted /dev/nvme0n1 print# orparted /dev/sda printparted (manual partitioning)
Use this in Rescue only when installimage cannot express what you want. This example is a single GPT disk:
parted /dev/sda mklabel gptparted /dev/sda mkpart ESP fat32 1MiB 257MiBparted /dev/sda set 1 esp onparted /dev/sda mkpart boot ext4 257MiB 1281MiBparted /dev/sda mkpart lvm 1281MiB 100%parted /dev/sda set 3 lvm onmkfs.vfat -F32 /dev/sda1mkfs.ext4 /dev/sda2pvcreate /dev/sda3vgcreate vg0 /dev/sda3lvcreate -L 50G -n root vg0lvcreate -L 8G -n swap vg0lvcreate -l 100%FREE -n var vg0mkfs.ext4 /dev/vg0/rootmkfs.ext4 /dev/vg0/varmkswap /dev/vg0/swapfdisk (interactive)
fdisk /dev/sdaInside fdisk, common keys are:
g— new GPT tablen— new partitiont— type (EFI, Linux filesystem, LVM)p— printw— write and exitq— quit without saving
LVM in one paragraph
LVM is a second layer on top of a partition (or RAID). Physical volume (PV) → volume group (VG) → logical volumes (LV). You can grow an LV later without repartitioning the whole disk. That is why Hetzner configs often use PART lvm vg0 all then several LV lines.
pvsvgslvsls /dev/mapper/lvextend -r -L +20G /dev/vg0/root# or give it all remaining free spacelvextend -r -l +100%FREE /dev/vg0/var-r resizes the filesystem too (ext4/xfs depending on tools). Always have backups before grow/shrink operations.
installimage partition syntax
PART /boot/efi esp 256MPART /boot ext4 1GPART / ext4 50GPART swap swap 8GPART lvm vg0 allLV vg0 root / ext4 50GLV vg0 swap swap swap 8GLV vg0 var /var xfs all- First field after
PARTis the mount point, orlvm, orswap. espmarks the EFI partition.- Filesystems you will see:
ext4,xfs,swap. - Size is
256M,50G, orall.
Mount, unmount, fstab
blkidmount UUID=YOUR-UUID /mntumount /mntcat /etc/fstab/etc/fstab is the table Linux uses at boot. Wrong UUIDs here are a common reason a server needs Rescue.
Wipe a disk (Rescue, reinstall only)
wipefs -n /dev/sdawipefs -fa /dev/sdawipefs -n is a dry run. -fa really erases signatures. Then run installimage.