Disk partitioning¶
parted¶
Arch wiki: parted Parted Manual Beware of Rounding:
when creating a partition, you should prefer to specify units of bytes (“B”), sectors (“s”), or IEC binary units like “MiB”, but not “MB”, “GB”, etc.
Script mode:
Or interactively:
Use GPT as partition table:
Or for sdcards/compability with legacy devices:
Create partition (GPT):
mkpart "data partition" ext4 0% 100%
mkpart "ventoy" ext4 0% 64GiB
mkpart "data" ext4 64GiB 100%
quit
Then format the disk:
or for vfat:
Moving partitions¶
- Only possible with
gparted, parted removed this feature
Move swap partition to the right:
Now move the partition with gparted.
Afterwards:
sudo cryptsetup open --type luks /dev/nvme0n1p3 luks-6e172db0-9606-4aa8-afd8-c108cc190eea
sudo mkswap /dev/mapper/luks-6e172db0-9606-4aa8-afd8-c108cc190eea # only when resized
sudo swapon -a
cat /proc/swaps
Examples¶
Create a new single patition on i.e. a usb drive and format it with FAT32:
sudo parted -s /dev/sdX -- mklabel msdos mkpart primary fat32 2048s -1s
sudo mkfs.vfat -F 32 /dev/sdX1
gdisk¶
- How to Manipulate GPT Partition Tables with gdisk and sgdisk on Linux
- The Arch package
gptfdiskbundlescgdisk(ncurses interface),gdisk(interactive cli) andsgdisk(non-interactive cli)
sgdisk¶
Install:
Print partition table:
Backup MBR / GPT¶
Partition Table: gpt-> GPTPartition Table: msdos-> MBR
MBR¶
Backup:
Restore:
GPT¶
Backup:
Restore: