2. Partitioning the disk (BIOS with MBR)
Table of Contents
Create the partition layout
Table 2.2. Partition layout (BIOS with MBR) 1
№ | Label | File system | Size |
---|---|---|---|
1 | /boot | ext2 | 250 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 MBR disklabel
Type “o” to create new MBR disklabel on the disk and remove all existing partitions.
Create the boot partition
Type “n”, followed by “p” and “1” to create new primary partition under number 1.
First sector should start with 2048. Hit <Enter> to continue. For the last sector, type “+256M” to create a partition 256 MB in size.
Type “a”, followed by the “1” to set the boot flag for the first partition.
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”, followed by “p” and “2” to create new primary 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 “82” to set the partition type to “Linux Swap”.
Create the root partition
Type “n”, followed by “p” and “3” to create new primary 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”, followed by “p” to create new primary 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.ext2 -T small /dev/sdx1
Since the boot partition is less than 8 GB, the “-T small” option is used to reserve enough inodes for the filesystem.
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