Skip to content

Instantly share code, notes, and snippets.

@duclos-cavalcanti
Last active August 10, 2023 19:43
Show Gist options
  • Save duclos-cavalcanti/e78ea4c665cdd3bb814b6fb57db68dc4 to your computer and use it in GitHub Desktop.
Save duclos-cavalcanti/e78ea4c665cdd3bb814b6fb57db68dc4 to your computer and use it in GitHub Desktop.
Using Parted CLI to partition your system

If needed, set the keyboard layout with setxkbmap us beforehand. Adjust the country to your device's configuration.

  1. Use lsblk to know what's the disk path to be partitioned.
  2. Launch parted on said disk path:
# Launches parted
sudo parted /dev/sda
  1. Partition:
# example w/ EFI

# Create a GPT partition table
mklabel gpt

# Create the EFI System Partition (ESP)
mkpart ESP fat32 1MiB 512MiB
set 1 esp on
name 1 EFI

# Create the root partition
mkpart primary ext4 512MiB -8GiB
name 2 root

# Create a swap partition
mkpart primary linux-swap -8GiB 100%
name 3 swap

quit
# Exits parted
  1. Format the partitioned areas:
sudo mkfs.fat -F32 -n EFI /dev/sda1
sudo mkfs.ext4 -L root /dev/sda2
sudo mkswap /dev/sda3
sudo swapon /dev/sda3
  1. Mount the system:
mount -L root /mnt
mkdir -p /mnt/boot/efi
mount -L EFI /mnt/boot/efi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment