2. Partitioning the disk (UEFI with GPT)
Table of Contents
Create the partition layout
Table 2.2. Partition layout (UEFI with GPT) 1
№ | Label | File system | Size |
---|---|---|---|
1 | /boot | fat32 | 512 MB |
2 | swap | swap | See: “Table 2.1. Swap Size” |
3 | /root | ext4 | At least 30 GB |
4 | /home | ext4 | Remaining space |
This is the example of the basic partition layout that we’ll make.
Get the name of device to partition:
lsblk
The output may look like this:
NAME | MAJ:MIN | RM | SIZE | RO | TYPE | MOUNTPOINTS |
loop0 | 7:0 | 0 | 710.1M | 1 | loop | /run/archiso/airootfs |
sda | 8:0 | 0 | 8G | 0 | disk | |
sr0 | 11:0 | 1 | 824.3M | 0 | rom | /run/archiso/bootmnt |
Here “sda” is the name of our disk. For the remaining of this guide, we will refer to it as “sdx”.
Start “fdisk” utility and specify the device name:
fdisk /dev/sdx
Type “p” to view the current partition layout.
Create GPT disklabel
Type “g” to create new GPT disklabel on the disk and remove all existing partitions.
Create the boot partition
Type “n” and “1” to create new partition under number 1.
First sector should start with 2048. Hit <Enter> to continue. For the last sector, type “+512M” to create a partition 512 MB in size.
Type “t” to set the partition type and then press “1” to set the partition type to “EFI System”.
Create the swap partition
Table 2.1. Swap size 2
RAM | Recommended swap size | Hibernation |
---|---|---|
</= 2GB | 2 times the amount of RAM | 3 times the amount of RAM |
> 2-8GB | Equal to the amount of RAM | 2 times the amount of RAM |
> 8-64GB | At least 4 GB | 1.5 times the amount of RAM |
> 64GB | At least 4 GB | Hibernation not recommended |
Decide on the size of your “swap” partition using the table above.
Type “n” and “2” to create new partition under number 2.
Hit <Enter> when prompted for the first sector. For the last sector, type “+xG”, where “x” is the amount of space you require.
Type “t” to set the partition type. Select the second partition by entering “2” and then type “19” to set the partition type to “Linux swap”.
Create the root partition
Type “n” and “3” to create new partition under number 3.
Hit <Enter> when prompted for the first sector. For the last sector, type “+30G” to create a partition 30 GB in size.
Create the home partition
Type “n” and “4” to create new partition under number 4.
Hit <Enter> when prompted for both first and the last sectors to take the rest of the remaining space.
Save the partition layout
Preview the final layout by entering “p”. Then type “w” to write changes to the
disk.
Check the results:
lsblk /dev/sdx
Format the partitions
Format the boot partition
mkfs.vfat -F 32 /dev/sdx1
Format root and home partitions
mkfs.ext4 /dev/sdx3
mkfs.ext4 /dev/sdx4
Initialize swap
mkswap /dev/sdx2
Troubleshooting: If you encounter “mkswap: error: /dev/sdx2 is mounted; will not make swapspace.” execute “swapoff /dev/sdx2” to disable swap and then repeat “mkswap /dev/sdx2”.
Enable Swap
swapon /dev/sdx2