User:Carlduff/Partition tables
Prepare the storage devices
In this step, the storage devices that will be used by the new system will be prepared. Read Partitioning for a more general overview.
- Users intending to create stacked block devices for LVM, disk encryption or RAID, should keep those instructions into consideration when preparing the partitions.
- If intending to install to a USB flash key, see Installing Arch Linux on a USB key.
Identify the devices
The first step is identify the devices where the new system will be installed. The following command will show all the available devices:
# lsblk
This will list all devices connected to your system along with their partition schemes, including that used to host — and boot — the live Arch installation media (e.g. a USB drive). Not all devices listed will therefore be viable or appropriate mediums for installation. To filter out inappropriate results, the command can optionally be amended as follows:
# lsblk | grep -v "rom\|loop\|airoot"
Devices (e.g. hard disks) will be listed as sdx
, where x
is a lower-case letter starting from a
for the first device (sda
), b
for the second device (sdb
), and so on. Existing partitions on those devices will be listed as sdxY
, where Y
is a number starting from 1
for the first partition, 2
for the second, and so on. In the example below, only one device is available (sda
), and that device uses only one partition (sda1
):
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 80G 0 disk └─sda1 8:1 0 80G 0 part
The sdxY
convention will be used in the examples provided below for partition tables, partitions, and file systems. As they are just examples, it is important to ensure that any necessary changes to device names, partition numbers, and/or partition sizes (etc.) are made. Do not just blindly copy and paste the commands.
If the existing partition scheme needs not be changed, skip to #Create filesystems, otherwise continue reading the following section.
Partition table types
If you are installing alongside an existing installation (i.e. dual-booting), a partition table will already be in use. If the devices are not partitioned, or the current partitions table or scheme needs to be changed, you will first have to determine the partition tables (one for each device) in use or to be used.
There are two types of partition table:
Any existing partition table can be identified with the following command for each device:
# parted /dev/sdx print
Partitioning tools
For each device to be partitioned, a proper tool must be chosen according to the partition table to be used. Several partitioning tools are provided by the Arch installation medium, including:
Using parted in interactive mode
All the examples provided below make use of parted, as it can be used for both BIOS/MBR and UEFI/GPT. It will be launched in interactive mode, which simplifies the partitioning process and reduces unnecessary repetition by automatically applying all partitioning commands to the specified device.
In order to start operating on a device, execute:
# parted /dev/sdx
You will notice that the command-line prompt changes from a hash (#
) to (parted)
: this also means that the new prompt is not a command to be manually entered when running the commands in the examples.
To see a list of the available commands, enter:
(parted) help
When finished, or if wishing to implement a partition table or scheme for another device, exit from parted with:
(parted) quit
After exiting, the command-line prompt will change back to #
.
Create new partition table
.efi
stub required to boot it.If you want to start from scratch — and do not intend to keep existing partitions on a device — its existing partition table can be completely erased. This simplifies the creation of new partitions and avoids problems if converting disks from MBR to GPT or vice versa. Use the following command:
# sgdisk --zap-all /dev/sdx
Now open each device whose partition table must be (re)created with:
# parted /dev/sdx
To then create a new MBR/msdos partition table for BIOS systems, use the following command:
(parted) mklabel msdos
To create a new GPT partition table for UEFI systems instead, use:
(parted) mklabel gpt
Partition schemes
You can decide the number and size of the partitions the devices should be split into, and which directories will be used to mount the partitions in the installed system (also known as mount points). The mapping from partitions to directories is the partition scheme, which must comply with the following requirements:
- At least a partition for the
/
(root) directory must be created. - Depending on the motherboard's firmware interface, the chosen #Partition table type, and in some cases also the chosen boot loader, the following additional partitions will must be created:
- BIOS/MBR: no additional partition required.
- BIOS/GPT:
- If using syslinux: no additional partition required.
- If using GRUB: one 1MiB or 2MiB BIOS Boot Partition of type
EF02
.
- UEFI/GPT: one EFI System Partition.
- UEFI/MBR: no additional partition required.
In the examples below it is assumed that a new and contiguous partitioning scheme is applied to a single device. Some optional partitions will also be created for the /boot
and /home
directories: see also Arch filesystem hierarchy for an explanation of the purpose of the various directories; if separate partitions for directories like /boot
or /home
are not created, these will simply be contained in the /
partition. Also the creation of an optional partiton for swap space will be illustrated.
If not already open in a parted interactive session, open each device to be partitioned with:
# parted /dev/sdx
The following command will be used to create partitions:
(parted) mkpart part-type fs-type start end
part-type
is one ofprimary
,extended
orlogical
, and is meaningful only for MBR partition tables.fs-type
is one of the supported file systems listed in the manual. The partition will be properly formatted in #Create filesystems.start
is the beginning of the partition from the start of the device. It consists of a number followed by a unit, for example1M
means start at 1MiB.end
is the end of the partition from the start of the device (not from thestart
value). It has the same syntax asstart
, for example100%
means end at the end of the device (use all the remaining space).
Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel?In this case, read Partitioning#Partition alignment and follow GNU Parted#Alignment to fix it.
The following command will be used to flag the partition that contains the /boot
directory as bootable:
(parted) set partition boot on
partition
is the number of the partition to be flagged (see the output of theprint
command).
BIOS/MBR examples
For a minimum single primary partition using all available disk space, the following command would be used:
(parted) mkpart primary ext3 1M 100% (parted) set 1 boot on
In the following instance, a 20Gib /
partition will be created, followed by a /home
partition using all the remaining space:
(parted) mkpart primary ext3 1M 20G (parted) set 1 boot on (parted) mkpart primary ext3 20G 100%
In the final example below, separate /boot
(100MiB), /
(20Gib), swap (4GiB), and /home
(all remaining space) partitions will be created:
(parted) mkpart primary ext3 1M 100M (parted) set 1 boot on (parted) mkpart primary ext3 100M 20G (parted) mkpart primary linux-swap 20G 24G (parted) mkpart primary ext3 24G 100%
UEFI/GPT examples
In every instance, a special bootable EFI System Partition is required.
.efi
stub required to boot it.If creating a new EFI System Partition, use the following commands (the recommended size is 512MiB):
(parted) mkpart ESP fat32 1M 513M (parted) set 1 boot on
The remaining partition scheme is entirely up to you. For one other partition using 100% of remaining space:
(parted) mkpart primary ext3 513M 100%
For separate /
(20GiB) and /home
(all remaining space) partitions:
(parted) mkpart primary ext3 513M 20.5G (parted) mkpart primary ext3 20.5G 100%
And for separate /
(20GiB), swap (4Gib), and /home
(all remaining space) partitions:
(parted) mkpart primary ext3 513M 20.5G (parted) mkpart primary linux-swap 20.5G 24.5G (parted) mkpart primary ext3 24.5G 100%
Create filesystems
Once the partitions have been created, each must be formatted with an appropriate file system. All available partitions on the intended installation device can be listed with the following command:
# lsblk /dev/sdx
With the exceptions noted below, it is recommended to use the ext4
file system:
# mkfs.ext4 /dev/sdxY
.efi
stub required to boot it.- If a new UEFI system partition has been created on a UEFI/GPT system, it must be formatted with a
fat32
orvfat32
file system. Failure to do so will result in an unbootable installation:
# mkfs.vfat -F32 /dev/sdxY
- If you plan to use GRUB on a BIOS/GPT system, please note that the BIOS Boot Partition has nothing to do with the
/boot
mountpoint. It will be used by GRUB directly. Do not create a filesystem on it, and do not mount it.
Activate swap
If a swap partition has been created, it must be set up and activated with:
# mkswap /dev/sdxY # swapon /dev/sdxY
See Swap#Swap file for an alternative.
Mount the partitions
The /
(root) partition must be mounted first: this is because any directories such as /boot
or /home
that have separate partitions will have to be created in the root file system. The /mnt
directory of the live system will be used to mount the root partition, and consequently all the other partitions will stem from there. If the root partition's name is sdxR
, do:
# mount /dev/sdxR /mnt
Once the /
partition has been mounted, any remaining partitions may be mounted in any order. The general procedure is to first create the mount point, and then mount the partition to it. If using a separate /boot
partition:
# mkdir -p /mnt/boot # mount mount /dev/sdxB /mnt/boot
/boot
is recommended also for mounting the EFI System Partition on UEFI/GPT system. See EFISTUB and related articles for alternatives.If using a separate /home
partition:
# mkdir -p /mnt/home # mount mount /dev/sdxH /mnt/home
Once all the remaining partitions, if any, have been mounted, the devices are ready to install Arch.