Skip to content

Partitions, File Systems and Swap

Disks🔗

Rescan/detect disk changes

1
echo 1>/sys/class/block/sdd/device/rescan

Partitioning🔗

  • linuxconfig.org | parted | fdisk | lsblk | sgdisk (GPT)
    • File systems: mkfs, mkswap
      • exFAT
        • package exfat-utils contains mkfs.exfat and exfatlabel
        • on Ubuntu/Debian package exfat-fuse
      • swap (not really a file system)
        • partition: mkswap [-L label] /dev/...
        • file: create sparse file (didn’t work for me 2023-02-16), see sparse files, or create dummy with dd if=/dev/zero of=/swap.img bs=1M count=4000 and then mkswap /swap.img
      • Partition types (parttype):

EFI🔗

HowTo Create A GPT Disk With EFI System And exFAT Partitions Using Parted

File Systems🔗

  • FUSE
    • CVMFS: FUSE module which implements a HTTP read-only file system
  • parallel and distributed

Labelling

1
2
3
4
5
6
7
8
# MS-DOS labels (didn't work as intended for FAT partition)
mlabel -i /dev/...  LABEL
# EXT
e2label /dev/... lblname
# NTFS
NTFS: ntfslabel device [label]
# FAT
(ex)fatlabel device [label]

Mount🔗

1
2
findmnt
mount # verbose list of mount points
  • Bind mount explained @StackExchange
  • Overlay filesystem: ArchWiki

    1
    mount -t overlay overlay -o lowerdir=/lower1:/lower2:/lower3,upperdir=/upper,workdir=/work /merged
    

    or in /etc/fstab

    1
    overlay /merged overlay noauto,x-systemd.automount,lowerdir=/lower,upperdir=/upper,workdir=/work 0 0
    

Tools and Commands🔗

  • lsblk
  • parted
    • only one to show free disk sectors: # parted /dev/xxx print free
    • unit only works with specifying a disk 🤦‍♂️
    • when letting parted align partitions for better performance (-a optimal) specify start/end in M
    • can be used in scripts like parted -s /dev/sda mklabel msdos mkpart primary ntfs 1M 100G mkpart primary ntfs 102400M 102912M mkpart primary 102912M
  • fdisk
  • sgdisk: for example helpful to wipe partition tables via sgdisk --zap-all /dev/name
  • Allocate file of given size ^e79fc2
1
2
3
fallocate -l 10G file.img # best choice: actually reserved, but not written, so it's fast
truncate -s 10G gentoo_root.img # "sparse file", not properly allocated, fast
dd if=/dev/zero of=./gentoo_root.img bs=4k iflag=fullblock,count_bytes count=10G # slow, actually writes
  • FSArchiver: save the contents of a file-system to a compressed archive file

References🔗