Setting up disks manually

System Disk Mode is the traditional or classic harddisk installation of Alpine Linux. This installation mode is suitable for most use cases including generic desktop, development machines etc. 
If an entire hard disk(s) is available for Alpine Linux, setup-alpine based install is the recommended way to install Alpine Linux. For all other use cases, follow the setup-disk based Installation given below.
== setup-disk based Installation ==
To perform a traditional hard-disk installation of Alpine Linux, after completing the base configuration, proceed to create, format and mount your partitions with MOUNTPOINT as root and run the command .
# Follow the Installation guide to complete the base configuration, if not already done. A working Internet access is mandatory to complete this installation.
# If necessary formatted partition(s) are unavailable, manually create them first and format them including swap partition(if used). If you're using legacy BIOS mode, use DOS i.e MBR partition table and ensure that proper partition is bootable for extlinux.
# Mount the / (root) partition on a mount point i.e say as follows: 
# If you're using EFI, create a mount point /mnt/boot and mount the EFI system partition(ESP) on it. 
# If swap partition is available, you can also enable it now: 
# Install Alpine Linux using the following command: 
# setup-disk will perform a traditional hard disk install of your running system, detects your file system layout and generates and installs a bootloader based on the <Code>BOOTLOADER</Code> environment variable.
# At the end of Installation, you can reboot to boot into the newly installed Alpine Linux and configure further.
== Manual partitioning ==
=== Partitioning tools ===
The installation image enviroment may have only the very basic busybox built-in fdisk command available. Busybox fdisk is rather limited for edit operations (e.g.: it can read but not modify GPT). Instead, alpine allows you to install more complete partitioning tool packages:
*
 Partitioning tools 
Command	Package name	Features 	Limitations
fdisk 	Inbuilt 	can read GPT, Modify MBR 	Cannot modify GPT
gdisk 	 	text mode, supports MBR/GPT bidirectional conversion, best for managing GPT partition tables	None
cgdisk 	 	menu driven curses interface for gdisk 	None
sgdisk 	 	scriptable gdisk 	Non-interactive
fdisk 	 	text mode, supports both gpt and MBR, best for managing MBR partition tables 	None except size due to other tools
cfdisk 	 	menu driven curses interface for fdisk 	None
sfdisk 	 	scriptable fdisk 	Non-interactive
parted 	 	text mode, supports both gpt and MBR 	cannot convert MBR to GPT, different interface from above tools
All the above tools can be installed during Installation immediately after setting up base configuration.
Graphical tools like and can be used only after setting up a graphical environment.
=== Creating partitions ===
For Alpine Linux, only the (/)root partition is mandatory. Even a /boot partition and swap are optional.
cfdisk will be used in all examples here as it is based on text menu without any dependencies. However, installing the package requires network to be available if using Standard ISO boot image. 
cgdisk is also recommended for its excellent support for GPT partitions and conversion from MBR to GPT. 
Alternately, is available in Standard ISO boot image and can be installed without network.
The following step installs the package : 
cfdisk will be used to create partitions. Before using cfdisk, the disk name must be identified by using blkid:
/dev/sdX1: LABEL="some" UUID="..." TYPE="vfat"
/dev/sdX2: LABEL="other" UUID="..." TYPE="ext4"
When cfdisk is run as follows, it looks for existing partitions on the disk :
=== Resizing an existing partition ===
cfdisk and resize2fs can be used to resize existing partitions of ext2/3/4 filsystem on the disk. For other filsystems, the necessary filesystem tools must be installed. This can be done while booted. 
To resize disk, launch the cfdisk: 
# Select the target partition, here as per image 
# Select Resize from the bottom menu.
# Enter the new Size at the prompt.
# Select Write, then Quit
If a filesystem is resized with -f (online mode), then the system must be rebooted immediately after the change is made.
=== Formatting partitions ===
Whenever a partition is created, the partition must be formatted first before using it. Depending on the filesystem to be used, the necessary formatting tool for the filesystem must be installed first.
Install the filesystem tools first, if not done already. The following examples show how to use the formatting tools for different filesystems:
* e2fsprogs for ext4,ext3 and ext2. ext4 is the default filesystem in Alpine Linux: 
* btrfs-progs for btrfs filesystem. 
* dosfstools for fat12/fat16/fat32 filesystem. This is also used for EFI system partition(ESP). 
* f2fs-tools for F2FS filesystem. 
== Disk layouts ==
It is possible to have one or more of RAID, encrypted, and/or Logical Volume on your (root) volume. However, the Alpine init script only knows how to handle them when they're layered in that order, and your initram and extlinux.conf files in the partition are configured properly.
Your directory cannot reside on an encrypted or LVM volume, at least not with Alpine's default bootloader (extlinux). (Grub2 can deal with being on an LVM volume.) The usual practice is to create a small partition for , then devote the rest of your disk to a separate partition on which you layer one or more of RAID, encryption, and/or Logical Volumes.
Sometimes is also set up as a mirrored (RAID1) volume. However, this is just for post-init access. That way, when you write a new kernel or bootloader config file to , it gets written to multiple physical partitions. During the pre-init, bootloader phase, only one of those partitions will be read from.
A typical setup might look like this:
One-disk system
---------------
 +------------------------------------------------+
 | small partition (32--100M), holding |
 | only /boot, filesystem needn't be journaled |
 +------------------------------------------------+
 | rest of disk in second partition |
 | +------------------------------------------+ |
 | | cryptsetup volume | |
 | | +-------------------------------------+ | |
 | | | LVM PV, containing single VG, | | |
 | | | containing multiple LVs, holding | | |
 | | | /, /home, swap, etc | | |
 | | +-------------------------------------+ | |
 | +------------------------------------------+ |
 +------------------------------------------------+
Two-disk system
---------------
 +------------------------------------------------+ +------------------------------------------------+
 | small partition (32--100M), holding | | small partition (32--100M), holding | These 2 partitions might
 | only /boot, filesystem needn't be journaled | | only /boot, filesystem needn't be journaled | form a mirrored (RAID1)
 +------------------------------------------------+ +------------------------------------------------+ volume
 | rest of disk in second partition | | rest of disk in second partition |
 | T================================================================================================T | These 2 partitions form
 | T +--------------------------------------------------------------------------------------------+ T | a second mirrored
 | T | cryptsetup volume | T | (RAID1) volume
 | T | +---------------------------------------------------------------------------------------+ | T |
 | T | | LVM PV, containing single VG, | | T |
 | T | | containing multiple LVs, holding | | T |
 | T | | /, /home, swap, etc | | T |
 | T | +---------------------------------------------------------------------------------------+ | T |
 | T +--------------------------------------------------------------------------------------------+ T |
 | T================================================================================================T |
 | | | |
 +------------------------------------------------+ +------------------------------------------------+
In a three-disk system, the would still be RAID1, but the larger partition might, in that case, be RAID5.
=== RAID ===
setup-disk will automatically build a RAID array if you supply the -r switch, or if you specify more than one device.
If you want to build your RAID array manually, see Setting up a software RAID array. Then you can add additional layers of encryption and/or Logical Volumes, or just assemble the RAID array, and supply the device directly to setup-disk. When you're finished, be sure to disassemble the RAID array before rebooting.
If setup-disk sees that you're using RAID, either because you gave it the -r switch, or multiple devices, or a device, then it will set up your initramfs and extlinux.conf file properly. However, in other cases, such as when you're also using encryption, or you invoke setup-disk with a mounted directory argument, these might not be properly set up for RAID. In that case, you may need to manually edit/rebuild them. The following assumes that $MNT holds the root directory you're installing into:
You might also need to manually tweak . And you might need to copy to your disk's MBR.
=== Encryption ===
See Setting up encrypted volumes with LUKS. You can add an additional Logical Volume layer, or just unlock the volume you've created (using cryptsetup luksOpen ...), and supply the device directly to setup-disk. When you're finished, be sure to relock the volume (using cryptsetup luksClose ...) before rebooting.
If you install your (root) on an encrypted volume, you'll need to manually edit/rebuild your initram and your extlinux.conf file. The following assumes that $MNT holds the root directory you're installing into, that you've created the cryptvolume on the device , and that you want to unlock the encrypted volume into a virtual volume named "crypt":
You might also need to manually tweak .
=== LVM ===
setup-disk will automatically build and use volumes in a LVM group if you supply the -L switch.
If you instead want to build your LVM system manually, see Setting up Logical Volumes with LVM. Then vgchange -ay, format and mount your volumes, and supply the root mountpoint to setup-disk. When you're finished, be sure to
before rebooting.
If setup-disk sees that you're using LVM, perhaps because you gave it the -L switch, then it will set up your initram and extlinux.conf file properly. However, in other cases, these might not be properly set up. In that case, you may need to manually edit/rebuild them. The following assumes that $MNT holds the root directory you're installing into:
You might also need to manually tweak .
== Troubleshooting ==
=== Mounting on /dev/sdXY sysroot failed ===
The error message appears as follows with variations in /dev/sda8 depending on the partition number and SSD/HDD etc:
mounting /dev/sda8 on /sysroot failed: No such file or directory
mounting root: failed
initramfs emergency recovery shell launched. Type 'exit' to continue boot
sh: can't access tty: job control turned off
The above error message can be caused by various reasons. Follow the below steps in the emergency shell to identify one possible cause.
# Verify that the partition name in which Alpine Linux was installed matches the above error by issuing the command and also note down the filesystem type of that partition (say TYPE="ext4") : 
# Ensure that sysroot exists by issuing the command. 
# Check if the above error message apears when issuing the command. 
# If the error message matched in step 4, check whether filesystem modules are loaded by issuing the command. 
# If there is no output, then it confirms that the above issue is caused by missing filesystem module.
==== Missing filesystem modules in the kernel cmdline ====
BusyBox mount command does not autoload modules, so need to add filesystem modules to the kernel cmdline. Even though alpine installer does this automatically, this has to be taken care of in case of manual disk install, particularly for dualboot installations.
# To resolve, issue the command to load the appropriate filesystem module(say TYPE="ext4").
# To verify if the issue is resolved, reissue the command. 
# If mount succeeded, issue the following command to boot into Alpine Linux. 
Choose the appropriate solution based on your use case for a permanent fix:
*If you are using grub, then ensure that line in the file has the appropriate filesystem module ext4 and rootfstype=ext4 as follows: 
*If you are using Syslinux, then ensure that line in the file has the appropriate filesystem module ext4 as follows: 
 
*For a solution independent of bootloaders, ensure that the file has the necessary filesystem module in it. Refer Initramfs page for more information and recreate initramfs image.
== See also ==
* Bootloaders - For information on GRUB, Syslinux and rEFInd
* Install to HDD with dual-boot
* Installing Alpine Linux in a chroot
* Replacing non-Alpine Linux with Alpine remotely
* setup-partitions
* Gdisk official website walkthroughs available for gdisk,cgdisk and sgdisk
Category:Installation
Category:Storage