Setting up disks manually: Difference between revisions

From Alpine Linux
m (added reference to hard disk install)
 
(19 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Alpine Linux modes ==


The menu choices that are provided by <code>setup-alpine</code> might not cover all needs, however, it's possible to:
Alpine Linux can be installed and run in following three modes [[#Diskless_Mode|Diskless Mode]], [[#Data_Disk_Mode|Data Disk Mode]] and [[#System_Disk_Mode|System Disk Mode]]. For traditional or classic '''harddisk''' install, refer [[#System_Disk_Mode_Installation|System Disk Mode Installation]].


* Call [[Alpine_setup_scripts#setup-disk|setup-disk]] directly, instead of through <code>setup-alpine</code>, and pass some specific partitioning parameters to it.
==='''Diskless Mode'''===
* Set up the partitions and filesystems manually (to the desired details) and [[Alpine_setup_scripts#Partitioning|tell setup-disk]] to install to the prepared target mountpoint.
In Diskless mode the entire operating system with all applications are first loaded into RAM and then only run from there. This is the method already used to boot the .iso installation images, however <code>[[Alpine_setup_scripts#setup-alpine|setup-alpine]]</code> can also configure the installed system to continue to boot like this if "disk=none" is specified. The mode is extremely fast and can save on unnecessary disk spin-ups, power, and wear. It is similar to what other linux distributions may call a "frugal" install or boot into with a "toram" option.  


(Beta reference: [https://docs.alpinelinux.org/user-handbook/0.1a/Installing/manual.html#_finalizing docs.alpinelinux.org] )
Custom configurations and package installations may optionally still be preserved or "persist" across reboots by using the Alpine local backup tool <code>[[Alpine_local_backup|lbu]]</code>. It enables committing and reverting system states by using .apkovl files that are saved to writable storage and loaded when booting. If additional or updated packages have been added to the system, these may also be made available for automatic (re)installation during the boot phase without any (re)downloading, by enabling a [[Alpine_Package_Keeper#Local_Cache|local package cache]] on the writable storage.
 
==== Diskless Mode Installation  ====
 
Following the [[Installation#Installation_Step_Details|Installation steps]] to complete the [[#Base_configuration|base configuration]] completes the pre-setup of [[#Diskless_Mode|"diskless"]] Alpine Linux system.
 
If a writable partition is available, <code>setup-alpine</code> can be told to store the configs and the package cache on that writable partition. (Later, another directory on that same partition or another available partition may also be mounted as /home, or for example, for selected important applications to keep their run-time and user data on it.)
Alternately, use the <code>[[Alpine_setup_scripts#setup-lbu|setup-lbu]]</code> script to configure a "local backup" location for the [[#Diskless Mode|diskless]] system, and <code>[[Alpine_local_backup|lbu commit]]</code> to then save the local configuration state.
 
The boot device of the newly configured local "diskless" system may remain the initial (and possibly read-only) installation media. But it is also possible to copy the boot system to a partition (e.g. /dev/sdXY) with <code>[[Alpine_setup_scripts#setup-bootable|setup-bootable]]</code>. Refer [[Create_a_Bootable_Device|Creating a bootable device]] for creating a bootable medium to boot the Diskless Mode Installation of your Alpine Linux.


== Using setup-alpine (setup-disk) features ==
This requires some manual steps, as the setup-scripts auto-detect usable partitions only on '''removable''' devices (not internal harddisks). They do not support creating new, writable partitions to be used by Alpine. To prepare writable storage refer [[Setting_up_disks_manually#Manual_partitioning| manual partitioning]].


=== For "diskless" and "data" disk mode installs ===
Refer [[Alpine_local_backup#Saving_and_loading_ISO_image_customizations|Saving and loading ISO image customizations]] related to loading an .apkovl volume from system partitions.


This requires some manual steps, as long as the setup-scripts auto-detect usable partitions only on '''removable''' devices (not internal harddisks). They do not support creating new, writable partitions to be used by Alpine.
As per Issue {{Issue|10473}} Storing local configs and the package cache on '''internal disks requires''' [[Alpine_local_backup#Saving_and_loading_ISO_image_customizations|manual steps]]}} to have the partition listed, i.e. making a /etc/fstab entry, mountpoint, and mount, *before* running setup-alpine. The linked workaround also still requires to commit these configurations to disk manually before rebooting.]


How to prepare writable storage space is explained in the section [[Setting_up_disks_manually#Manual_partitioning| manual partitioning]], below.
* Be aware of this Bug: {{Issue|11589|The APKOVL loading of diskless setups doesn't work on btrfs and xfs filesystems, or nvme-based devices}} => So, for the moment, use only ext4 filesystem partitions on classic drives to store diskless mode states.


=== For "sys" disk mode installs ===
{{Note| mkfs.ext4 creates ext4 fs with 64bit feature enabled by default, but extlinux may not be able to boot with that, see Issue {{Issue|14895}}. You may need to add "-O ^has_journal,^64bit" to mkfs.ext4 to circumvent this.}}


{{Draft|Some information on this page may be incomplete or outdate.}}
* The following creates an ext4 partition with disabled journaling, to reduce write operations and allow the disk to spin down after the .apkovl and the packages have been read from the partition during the boot.


==== Disk layouts ====
# mkfs.ext4 -O ^has_journal /dev/sdXY  # the "-O ^has_journal" DISABLES journaling ("^" means "not")


It is possible to have one or more of RAID, encrypted, and/or Logical Volume on your {{Path|/}} (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 {{Path|/boot}} partition are configured properly.
==='''Data Disk Mode'''===
In Data Disk mode also the operating system runs from system RAM, thus it enjoys the same accelerated operation speed as "diskless" mode. However, swap storage and the entire {{Path|/var}} directory tree get mounted from a persistent storage device (two newly created partitions). The directory {{Path|/var}} holds e.g. all log files, mailspools, databases, etc., as well as <code>[[Alpine_local_backup|lbu]]</code> backup commits and the package cache. This mode is useful for having RAM accelerated servers with variable amounts of user-data that exceed the available RAM size. It enables the entire current system state (not just the boot state) to survive a system crash in accordance with the particular filesystem guarantees.  


Your {{Path|/boot}} directory cannot reside on an encrypted or LVM volume, at least not with Alpine's default bootloader (extlinux). (Grub2 can deal with {{Path|/boot}} being on an LVM volume.) The usual practice is to create a small partition for {{Path|/boot}}, 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.
==== Data Disk Mode Installation  ====


Sometimes {{Path|/boot}} 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 {{Path|/boot}}, it gets written to multiple physical partitions. During the pre-init, bootloader phase, only one of those partitions will be read from.
Following the [[Installation#Installation_Step_Details|Installation steps]] to complete the [[#Base_configuration|base configuration]] completes the pre-setup of [[#Diskless_Mode|"diskless"]] Alpine Linux system.


A typical setup might look like this:
In data disk mode, the boot device may also remain the initial (and possibly read-only) installation media, or be copied to a partition (e.g. /dev/sdXY) with <code>[[Alpine_setup_scripts#setup-bootable|setup-bootable]]</code>. Refer [[Create_a_Bootable_Device|Creating a bootable device]] for creating a bootable medium to boot the Data Disk Mode Installation.


<pre>
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                | |  |
  |  |  +-------------------------------------+ |  |
  |  +------------------------------------------+  |
  +------------------------------------------------+


As per Issue {{Issue|10474}}  Setup-alpine will create the data partition and mount it as /var, but '''setup-alpine's "data" disk mode can not yet configure lbu config storage settings automatically'''. The '''current workaround''', is to select "none" at the 'where to store configs' prompt (as the new data partition is not listed anyway) and configure lbu manually after <code>[[Alpine_setup_scripts#setup-alpine|setup-alpine]]</code> exits, and before rebooting:


Two-disk system
# Identify the created data partition, e.g. <code>/dev/sd''XY''</code>, and its filesystemtype, e.g. using <code>''lsblk''</code>
---------------
# Manually edit the lbu backups location in <code>/etc/lbu/lbu.conf</code> and configure <code>LBU_MEDIA=sd''XY''</code> (according to the previous findings).
  +------------------------------------------------+  +------------------------------------------------+
# Save the configuration on that partition for the next boot with <code>lbu commit</code>.
  |  small partition (32--100M), holding          |  |  small partition (32--100M), holding          | These 2 partitions might
# If (a new) partition fails to get mounted, execute: <code>mkdir /media/''sdXY'' ; echo "/dev/sd''XY'' /media/sd''XY'' ''fstype'' noauto,rw 0 0" >> /etc/fstab</code>, and try <code>lbu commit</code> again.
  |  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 |
  |                                                |  |                                                |
  +------------------------------------------------+  +------------------------------------------------+


</pre>


In a three-disk system, the {{Path|/boot}} would still be RAID1, but the larger partition might, in that case, be RAID5.
==='''System Disk Mode'''===


==== RAID ====
System Disk Mode is the traditional hard-disk install. If this mode is selected, the <code>[[Alpine_setup_scripts#setup-alpine|setup-alpine]]</code> script deletes the existing partitions and creates three partitions on the selected storage device, {{Path|/boot}}, {{Path|swap}} and {{Path|/}} (the filesystem root). This mode may, for example, be used for generic [[:Category:Desktop|desktop]] and development machines.


<code>setup-disk</code> will automatically build a RAID array if you supply the '''-r''' switch, or if you specify more than one device.
==== System Disk Mode Installation ====


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 {{Path|/dev/md<i>i</i>}} device directly to [[setup-disk]]. When you're finished, be sure to disassemble the RAID array before rebooting.
[[#System_Disk_mode|System Disk Mode]] Installation in Alpine Linux is the equivalent of traditional harddisk installation.


If <code>setup-disk</code> sees that you're using RAID, either because you gave it the <code>-r</code> switch, or multiple devices, or a {{Path|/dev/md<i>i</i>}} 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 <code>setup-disk</code> 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 <code>$MNT</code> holds the root directory you're installing into:
The menu choices that are provided by <code>setup-alpine</code> might not cover all needs, however, it's possible to:
* If an entire hard disk is available for Alpine Linux and [[Setting_up_disks_manually#Default_Layout|default layout]] is sufficient, follow the [[Installation#Installation_Step_Details|Installation steps]] to complete the [[#Base_configuration|base configuration]]. Then use '''environment variables''' to customize filesystems, bootloaders, boot and swap partition size, then call <code>setup-disk</code> to install Alpine Linux.


{{Cmd|1=echo "/sbin/mdadm" > $MNT/etc/mkinitfs/files.d/raid
Environment variables can be set as follows before calling  <code>setup-disk</code>:
echo "/etc/mdadm.conf" >> $MNT/etc/mkinitfs/files.d/raid
{{cmd|<nowiki>
&#35; edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features="..."
# BOOTFS=vfat
&#35; includes raid (this field is space-separated and quoted)
# ROOTFS=btrfs
mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT
# setup-disk
&#35; edit $MNT/etc/update-extlinux.conf to make sure modules=... contains
</nowiki>
&#35; raid1 or raid456 (whichever your / is on; this field is comma-separated)
&#35; also check the root= setting
extlinux --raid --install $MNT/boot --update
}}
}}


{{Todo|Does adding the <code>--update</code> option to <code>extlinux ...</code> suffice to make {{Path|/boot/extlinux.conf}} be regenerated? Or do we need to manually tweak that file, or run <code>update-extlinux</code>, as well?}}
* If custom partitioning is needed, then [[#Manual_partitioning|Manually partition]] the disk and use [[Setting_up_disks_manually#Custom_Layout|Custom Layout]] to install Alpine Linux.
(Beta reference: [https://docs.alpinelinux.org/user-handbook/0.1a/Installing/manual.html#_finalizing docs.alpinelinux.org] )
===== Default Layout  =====
 
The <code>setup-alpine</code> script based [[Installation#System_Disk_mode_Install|installation]] supports only this default layout. When [[Installation#System_Disk_mode_Install|System Disk mode Install]] is chosen, from within <code>setup-alpine</code> script, Alpine Linux is installed on an entire harddisk as per default layout by <code>setup-disk</code>. This mode is also referred as DISKDEV mode in the man pages.
 
<code>setup-disk</code> will delete all existing partitions on the chosen DISKDEV or hard disk, and creates 3 partitions i.e  '''(/)'''root partition, a '''/boot''' partition and a '''swap''' partition without asking further questions to the user.


You might also need to manually tweak {{Path|$MNT/etc/fstab}}. And you might need to copy {{Path|/usr/share/syslinux/mbr.bin}} to your disk's MBR.
{{Cmd|setup-disk /dev/sdX}}


==== Encryption ====
When <code>setup-disk</code> is called with DISKDEV, where multiple disks are specified, then <code>setup-disk</code> sets them up in a [[#RAID|RAID]] array. If there are more than 2 disks, then raid level 5 is used instead of [[#RAID|RAID]] level 1. Refer [[#RAID|RAID]] for more options.


See [[Setting up encrypted volumes with LUKS]]. You can add an additional Logical Volume layer, or just unlock the volume you've created (using <code>cryptsetup luksOpen ...</code>), and supply the {{Path|/dev/mapper/<i>something</i>}} device directly to [[setup-disk]]. When you're finished, be sure to relock the volume (using <code>cryptsetup luksClose ...</code>) before rebooting.
===== Custom Layout =====
<code>setup-disk</code> must be called with a MOUNTPOINT for any layout different from the default layout. Then <code>setup-disk</code> will perform a traditional harddisk or [[#System_Disk_mode|System Disk mode]] install with MOUNTPOINT as root and any custom partiotioning layout can be used.  


If you install your {{Path|/}} (root) on an encrypted volume, you'll need to manually edit/rebuild your initram and your extlinux.conf file. The following assumes that <code>$MNT</code> holds the root directory you're installing into, that you've created the cryptvolume on the device {{Path|/dev/md2}}, and that you want to unlock the encrypted volume into a virtual volume named "crypt":
To install Alpine Linux in [[Setting_up_disks_manually#System_Disk_Mode|System Disk Mode]] using  custom layout, atleaset one partition is required. If necessary partition(s) are unavailable, manually [[#Creating_partitions|create partitions]], [[#Formatting_partitions|format]] them and mount them on {{Path|/mnt}} (or any other mount point) as follows:


{{Cmd|1=&#35; edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features="..."
{{Cmd|# mount /dev/sdXY /mnt}}
&#35; includes cryptsetup (this field is space-separated and quoted)
mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT
&#35; edit $MNT/etc/update-extlinux.conf to make sure default_kernel_opts="..."
&#35; contains cryptroot=/dev/md1 and cryptdm=crypt (this field is also space-separated and quoted)
&#35; also check the root= setting
extlinux --install $MNT/boot --update
}}


{{Todo|Does adding the <code>--update</code> option to <code>extlinux ...</code> suffice to make {{Path|/boot/extlinux.conf}} be regenerated? Or do we need to manually tweak that file, or run <code>update-extlinux</code>, as well?}}
If you're using EFI, make sure you create a mount point <code>/mnt/boot/efi</code>


You might also need to manually tweak {{Path|$MNT/etc/fstab}}.
{{Cmd|# mkdir -p /mnt/boot/efi}}


==== LVM ====
Find the correct partition name for <code>esp</code> partition and mount it on the above mount point :


<code>setup-disk</code> will automatically build and use volumes in a LVM group if you supply the '''-L''' switch.
{{Cmd|# mount /dev/esp /mnt/boot/efi}}


If you instead want to build your LVM system manually, see [[Setting up Logical Volumes with LVM]]. Then <code>vgchange -ay</code>, format and mount your volumes, and supply the root mountpoint to [[setup-disk]]. When you're finished, be sure to
Additional partitions like /home, /var etc can be created and mounted inside the mountpoint(/mnt) as per requirements.
{{Cmd|umount ...
vgchange -an}}
before rebooting.


Then install Alpine Linux using the following command:
{{Cmd|# setup-disk -m sys /mnt}}


If <code>setup-disk</code> sees that you're using LVM, perhaps because you gave it the <code>-L</code> 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 <code>$MNT</code> holds the root directory you're installing into:
<code>setup-disk</code> will install Alpine Linux system on the mounted root, uses your [[Filesystems|filesystem]] on the presented layout and generates fstab automatically and also installs an appropriate [[Bootloaders|bootloader]]. In most cases, you can just [[Installation#Reboot|reboot]] to boot into newly installed Alpine Linux. You can also choose to [[Installation#Post-Installation|customize]] further.


{{Cmd|1=&#35; edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features="..."
<!--  
&#35; includes lvm (this field is space-separated and quoted)
mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT
&#35; edit $MNT/etc/update-extlinux.conf to make sure root= is set correctly
extlinux --install $MNT/boot --update
}}


{{Todo|Does adding the <code>--update</code> option to <code>extlinux ...</code> suffice to make {{Path|/boot/extlinux.conf}} be regenerated? Or do we need to manually tweak that file, or run <code>update-extlinux</code>, as well?}}
To be arranged properly


You might also need to manually tweak {{Path|$MNT/etc/fstab}}.
If you're using the MBR, you are responsible for making the proper partition bootable and make sure the MBR is OK for extlinux. and set <code>BOOTLOADER=grub</code> and <code>USE_EFI=1</code>, and that {{Pkg|grub-efi}} and {{Pkg|efibootmgr}} are installed before running <code>setup-disk</code>. If your system still does not boot, you can try to manually create a boot entry with {{Pkg|efibootmgr}}, for which instructions can be found at [https://wiki.alpinelinux.org/wiki/Bootloaders#efibootmgr EFI Boot Stub].
-->


== Manual partitioning ==
== Manual partitioning ==


=== For "diskless" and "data" disk mode installs ===
=== Partitioning tools ===


The installation image enviroment may have only the very basic busybox built-in <code>fdisk</code> command available. However, alpine allows you to install more complete partitioning tool packages like <code>sfdisk</code> (scriptable fdisk), <code>gptfdisk</code>, <code>parted</code> (CLI), <code>cfdisk</code> (text menus), or even <code>gparted</code> (after [[Installation#Post-Installation|setting up a graphical environment]]).
The installation image enviroment may have only the very basic busybox built-in <code>fdisk</code> command available. Busybox `fdisk` is rather limited for edit operations.  Instead, alpine allows you to install more complete partitioning tool packages like <code>sfdisk</code> (scriptable fdisk), <code>gptfdisk</code>, <code>parted</code> (CLI), <code>cfdisk</code> (text menus), or even <code>gparted</code> (after [[Installation#Post-Installation|setting up a graphical environment]]).
These tools can be installed even during [[Installation]] immediately after setting up [[Installation#Base_configuration|base configuration]].


The following example installs <code>cfdisk</code>, looks for existing partitions, and runs cfdisk against <code>/dev/sdX</code>:
<code>cfdisk</code> will be used in all examples here as it is based on text menu without any dependencies:
# apk add cfdisk
# blkid
/dev/sdX1: LABEL="some" UUID="..." TYPE="vfat"
/dev/sdX2: LABEL="other" UUID="..." TYPE="ext4"
# cfdisk /dev/sdX


* Be aware of this Bug: {{Issue|11589|The APKOVL loading of diskless setups doesn't work on btrfs and xfs filesystems, or nvme-based devices}} => So, for the moment, use only ext4 filesystem partitions on classic drives to store diskless mode states.
The following step installs <code>cfdisk</code>:  
{{cmd|# apk add cfdisk }}


The following creates an ext4 partition with disabled journaling, to reduce write operations and allow the disk to spin down after the .apkovl and the packages have been read from the partition during the boot.
=== Creating partitions ===
# apk add e2fsprogs
<code>cfdisk</code> will be used to create partitions. Before using <code>cfdisk</code>, the disk name must be identified by using <code>blkid</code>:
# mkfs.ext4 -O ^has_journal /dev/sdXY  # the "-O ^has_journal" DISABLES journaling ("^" means "not")


{{Note|IMPORTANT! There may be additional steps necessary to make proper use of the partition, see
{{cmd|# blkid}}
[[Alpine_local_backup#Saving_and_loading_ISO_image_customizations|Saving and loading ISO image customizations]].
<pre>
}}
/dev/sdX1: LABEL="some" UUID="..." TYPE="vfat"
/dev/sdX2: LABEL="other" UUID="..." TYPE="ext4"
</pre>


{{Note| mkfs.ext4 creates ext4 fs with 64bit feature enabled by default, but extlinux may not be able to boot with that, see Issue {{Issue|14895}}. You may need to add "-O ^has_journal,^64bit" to mkfs.ext4 to circumvent this.
When <code>cfdisk</code> is run as follows, it looks for existing partitions on the disk {{Path|/dev/sdX}} :
}}
{{cmd|# cfdisk /dev/sdX}}


=== For "sys" disk mode installs ===
=== Resizing an existing partition ===


<code>setup-disk</code> will by default set up a root partition, a separate /boot partition and a swap partition. If you want a different layout, you can manually create the partitions, filesystems and mount them on {{Path|/mnt}} (or any other mount point) then run:
<code>cfdisk</code> and <code>resize2fs</code> can be used to resize existing partitions of ext2/3/4 filsystem on the disk. For other filsystems, the necessary [[Filesystems#Filesystem_Tools|filesystem tools]] must be installed. This can be done while booted.


{{Cmd|setup-disk /mnt}}
[[File:Cfdisk screenshot alpine 2024-03-04 143916.png|thumb|cfdisk screenshot ]]


<code>setup-disk</code> will install your running system on the mounted root, detect your file system layout and generate an fstab.
To resize disk, launch the <code>cfdisk</code>:
{{cmd|# cfdisk {{path|/dev/sda}}}}


If you're using the MBR, you are responsible for making the proper partition bootable and make sure the MBR is OK for extlinux. If you're going to use EFI, make sure you mount <code>esp</code> partition on <code>/boot/efi</code> and set <code>BOOTLOADER=grub</code> and <code>USE_EFI=1</code>, and that {{Pkg|grub-efi}} and {{Pkg|efibootmgr}} are installed before running <code>setup-disk</code>. If your system still does not boot, you can try to manually create a boot entry with {{Pkg|efibootmgr}}, for which instructions can be found at [https://wiki.alpinelinux.org/wiki/Bootloaders#efibootmgr EFI Boot Stub].
# Select the target partition, here as per image {{path|/dev/sda3}}
# Select ''Resize'' from the bottom menu.
# Enter the new ''Size'' at the prompt.
# Select ''Write'', then ''Quit''


See also [https://github.com/itoffshore/alpine-linux-scripts setup-partitions]
If a filesystem is resized with -f (online mode), then the system must be rebooted immediately after the change is made.


==== Dual-booting ====
{{cmd|# resize2fs -f {{path|/dev/sda3}}
See [[Installing Alpine on HDD dualbooting|Install to HDD with dual-boot]]
&num; reboot}}
 
==== Other needs ====
* [[Installing Alpine Linux in a chroot]]
* [[Replacing non-Alpine Linux with Alpine remotely]]


=== Formatting partitions ===
Refer [[Filesystems]] page to install the necessary [[Filesystems#Filesystem_Tools|filesystem tools]] and to [[Filesystems#Formatting_Partitions|format paritions]].
<!--
<!--
  Create partition with with type "Linux" (83).
  Create partition with with type "Linux" (83).
Line 325: Line 299:
Executing {{ic|export BOOT_SIZE{{=}}512}} before running {{ic|setup-disk}} will result in a 512MB boot partition.
Executing {{ic|export BOOT_SIZE{{=}}512}} before running {{ic|setup-disk}} will result in a 512MB boot partition.


== Expanding an existing disk ==
== Disk layouts ==
Unlike gnu `fdisk`, busybox `fdisk` is rather limited in edit operations. Instead, use `cfdisk` and `resize2fs` to resize the disk. This can be done while booted.  
 
{{Draft|This entire section including RAID, Encryption and LVM needs to be updated.}}
 
It is possible to have one or more of RAID, encrypted, and/or Logical Volume on your {{Path|/}} (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 {{Path|/boot}} partition are configured properly.
 
Your {{Path|/boot}} directory cannot reside on an encrypted or LVM volume, at least not with Alpine's default bootloader (extlinux). (Grub2 can deal with {{Path|/boot}} being on an LVM volume.) The usual practice is to create a small partition for {{Path|/boot}}, 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 {{Path|/boot}} 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 {{Path|/boot}}, 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:


Install tools:
<pre>
[[File:Cfdisk screenshot alpine 2024-03-04 143916.png|thumb|cfdisk screenshot ]]
One-disk system
{{cmd|# apk add {{pkg|cfdisk|arch=}} {{pkg|e2fsprogs-extra|arch=}}}}
---------------
resize disk
  +------------------------------------------------+
{{cmd|# cfdisk {{path|/dev/sda}}}}
  |  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 |
  |                                                |  |                                                |
  +------------------------------------------------+  +------------------------------------------------+
 
</pre>
 
In a three-disk system, the {{Path|/boot}} would still be RAID1, but the larger partition might, in that case, be RAID5.
 
=== RAID ===
 
<code>setup-disk</code> 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 {{Path|/dev/md<i>i</i>}} device directly to [[setup-disk]]. When you're finished, be sure to disassemble the RAID array before rebooting.
 
If <code>setup-disk</code> sees that you're using RAID, either because you gave it the <code>-r</code> switch, or multiple devices, or a {{Path|/dev/md<i>i</i>}} 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 <code>setup-disk</code> 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 <code>$MNT</code> holds the root directory you're installing into:
 
{{Cmd|1=echo "/sbin/mdadm" > $MNT/etc/mkinitfs/files.d/raid
echo "/etc/mdadm.conf" >> $MNT/etc/mkinitfs/files.d/raid
&#35; edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features="..."
&#35; includes raid (this field is space-separated and quoted)
mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT
&#35; edit $MNT/etc/update-extlinux.conf to make sure modules=... contains
&#35; raid1 or raid456 (whichever your / is on; this field is comma-separated)
&#35; also check the root= setting
extlinux --raid --install $MNT/boot --update
}}
 
{{Todo|Does adding the <code>--update</code> option to <code>extlinux ...</code> suffice to make {{Path|/boot/extlinux.conf}} be regenerated? Or do we need to manually tweak that file, or run <code>update-extlinux</code>, as well?}}
 
You might also need to manually tweak {{Path|$MNT/etc/fstab}}. And you might need to copy {{Path|/usr/share/syslinux/mbr.bin}} 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 <code>cryptsetup luksOpen ...</code>), and supply the {{Path|/dev/mapper/<i>something</i>}} device directly to [[setup-disk]]. When you're finished, be sure to relock the volume (using <code>cryptsetup luksClose ...</code>) before rebooting.
 
If you install your {{Path|/}} (root) on an encrypted volume, you'll need to manually edit/rebuild your initram and your extlinux.conf file. The following assumes that <code>$MNT</code> holds the root directory you're installing into, that you've created the cryptvolume on the device {{Path|/dev/md2}}, and that you want to unlock the encrypted volume into a virtual volume named "crypt":
 
{{Cmd|1=&#35; edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features="..."
&#35; includes cryptsetup (this field is space-separated and quoted)
mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT
&#35; edit $MNT/etc/update-extlinux.conf to make sure default_kernel_opts="..."
&#35; contains cryptroot=/dev/md1 and cryptdm=crypt (this field is also space-separated and quoted)
&#35; also check the root= setting
extlinux --install $MNT/boot --update
}}
 
{{Todo|Does adding the <code>--update</code> option to <code>extlinux ...</code> suffice to make {{Path|/boot/extlinux.conf}} be regenerated? Or do we need to manually tweak that file, or run <code>update-extlinux</code>, as well?}}
 
You might also need to manually tweak {{Path|$MNT/etc/fstab}}.
 
=== LVM ===
 
<code>setup-disk</code> 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 <code>vgchange -ay</code>, format and mount your volumes, and supply the root mountpoint to [[setup-disk]]. When you're finished, be sure to
{{Cmd|umount ...
vgchange -an}}
before rebooting.
 
 
If <code>setup-disk</code> sees that you're using LVM, perhaps because you gave it the <code>-L</code> 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 <code>$MNT</code> holds the root directory you're installing into:
 
{{Cmd|1=&#35; edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features="..."
&#35; includes lvm (this field is space-separated and quoted)
mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT
&#35; edit $MNT/etc/update-extlinux.conf to make sure root= is set correctly
extlinux --install $MNT/boot --update
}}
 
{{Todo|Does adding the <code>--update</code> option to <code>extlinux ...</code> suffice to make {{Path|/boot/extlinux.conf}} be regenerated? Or do we need to manually tweak that file, or run <code>update-extlinux</code>, as well?}}


# Select the target partition, often {{path|/dev/sda3}}
You might also need to manually tweak {{Path|$MNT/etc/fstab}}.
# Select ''Resize'' from the bottom menu
# Select ''Write'', then ''Quit''


resize filesystem with -f (online mode), then reboot
{{cmd|# resize2fs -f {{path|/dev/sda3}}
&num; reboot}}


== see also ==
* [[Installing Alpine on HDD dualbooting|Install to HDD with dual-boot]]
* [[Installing Alpine Linux in a chroot|Installing Alpine Linux in a chroot]]
* [[Replacing non-Alpine Linux with Alpine remotely]]
* [https://github.com/itoffshore/alpine-linux-scripts setup-partitions]
[[Category:Installation]]
[[Category:Installation]]
[[Category:Storage]]
[[Category:Storage]]

Latest revision as of 11:18, 18 September 2024

Alpine Linux modes

Alpine Linux can be installed and run in following three modes Diskless Mode, Data Disk Mode and System Disk Mode. For traditional or classic harddisk install, refer System Disk Mode Installation.

Diskless Mode

In Diskless mode the entire operating system with all applications are first loaded into RAM and then only run from there. This is the method already used to boot the .iso installation images, however setup-alpine can also configure the installed system to continue to boot like this if "disk=none" is specified. The mode is extremely fast and can save on unnecessary disk spin-ups, power, and wear. It is similar to what other linux distributions may call a "frugal" install or boot into with a "toram" option.

Custom configurations and package installations may optionally still be preserved or "persist" across reboots by using the Alpine local backup tool lbu. It enables committing and reverting system states by using .apkovl files that are saved to writable storage and loaded when booting. If additional or updated packages have been added to the system, these may also be made available for automatic (re)installation during the boot phase without any (re)downloading, by enabling a local package cache on the writable storage.

Diskless Mode Installation

Following the Installation steps to complete the base configuration completes the pre-setup of "diskless" Alpine Linux system.

If a writable partition is available, setup-alpine can be told to store the configs and the package cache on that writable partition. (Later, another directory on that same partition or another available partition may also be mounted as /home, or for example, for selected important applications to keep their run-time and user data on it.)

Alternately, use the setup-lbu script to configure a "local backup" location for the diskless system, and lbu commit to then save the local configuration state.

The boot device of the newly configured local "diskless" system may remain the initial (and possibly read-only) installation media. But it is also possible to copy the boot system to a partition (e.g. /dev/sdXY) with setup-bootable. Refer Creating a bootable device for creating a bootable medium to boot the Diskless Mode Installation of your Alpine Linux.

This requires some manual steps, as the setup-scripts auto-detect usable partitions only on removable devices (not internal harddisks). They do not support creating new, writable partitions to be used by Alpine. To prepare writable storage refer manual partitioning.

Refer Saving and loading ISO image customizations related to loading an .apkovl volume from system partitions.

As per Issue #10473 Storing local configs and the package cache on internal disks requires manual steps}} to have the partition listed, i.e. making a /etc/fstab entry, mountpoint, and mount, *before* running setup-alpine. The linked workaround also still requires to commit these configurations to disk manually before rebooting.]

Note: mkfs.ext4 creates ext4 fs with 64bit feature enabled by default, but extlinux may not be able to boot with that, see Issue #14895. You may need to add "-O ^has_journal,^64bit" to mkfs.ext4 to circumvent this.
  • The following creates an ext4 partition with disabled journaling, to reduce write operations and allow the disk to spin down after the .apkovl and the packages have been read from the partition during the boot.
# mkfs.ext4 -O ^has_journal /dev/sdXY   # the "-O ^has_journal" DISABLES journaling ("^" means "not")

Data Disk Mode

In Data Disk mode also the operating system runs from system RAM, thus it enjoys the same accelerated operation speed as "diskless" mode. However, swap storage and the entire /var directory tree get mounted from a persistent storage device (two newly created partitions). The directory /var holds e.g. all log files, mailspools, databases, etc., as well as lbu backup commits and the package cache. This mode is useful for having RAM accelerated servers with variable amounts of user-data that exceed the available RAM size. It enables the entire current system state (not just the boot state) to survive a system crash in accordance with the particular filesystem guarantees.

Data Disk Mode Installation

Following the Installation steps to complete the base configuration completes the pre-setup of "diskless" Alpine Linux system.

In data disk mode, the boot device may also remain the initial (and possibly read-only) installation media, or be copied to a partition (e.g. /dev/sdXY) with setup-bootable. Refer Creating a bootable device for creating a bootable medium to boot the Data Disk Mode Installation.


As per Issue #10474 Setup-alpine will create the data partition and mount it as /var, but setup-alpine's "data" disk mode can not yet configure lbu config storage settings automatically. The current workaround, is to select "none" at the 'where to store configs' prompt (as the new data partition is not listed anyway) and configure lbu manually after setup-alpine exits, and before rebooting:

  1. Identify the created data partition, e.g. /dev/sdXY, and its filesystemtype, e.g. using lsblk
  2. Manually edit the lbu backups location in /etc/lbu/lbu.conf and configure LBU_MEDIA=sdXY (according to the previous findings).
  3. Save the configuration on that partition for the next boot with lbu commit.
  4. If (a new) partition fails to get mounted, execute: mkdir /media/sdXY ; echo "/dev/sdXY /media/sdXY fstype noauto,rw 0 0" >> /etc/fstab, and try lbu commit again.


System Disk Mode

System Disk Mode is the traditional hard-disk install. If this mode is selected, the setup-alpine script deletes the existing partitions and creates three partitions on the selected storage device, /boot, swap and / (the filesystem root). This mode may, for example, be used for generic desktop and development machines.

System Disk Mode Installation

System Disk Mode Installation in Alpine Linux is the equivalent of traditional harddisk installation.

The menu choices that are provided by setup-alpine might not cover all needs, however, it's possible to:

  • If an entire hard disk is available for Alpine Linux and default layout is sufficient, follow the Installation steps to complete the base configuration. Then use environment variables to customize filesystems, bootloaders, boot and swap partition size, then call setup-disk to install Alpine Linux.

Environment variables can be set as follows before calling setup-disk:

# BOOTFS=vfat # ROOTFS=btrfs # setup-disk

(Beta reference: docs.alpinelinux.org )

Default Layout

The setup-alpine script based installation supports only this default layout. When System Disk mode Install is chosen, from within setup-alpine script, Alpine Linux is installed on an entire harddisk as per default layout by setup-disk. This mode is also referred as DISKDEV mode in the man pages.

setup-disk will delete all existing partitions on the chosen DISKDEV or hard disk, and creates 3 partitions i.e (/)root partition, a /boot partition and a swap partition without asking further questions to the user.

setup-disk /dev/sdX

When setup-disk is called with DISKDEV, where multiple disks are specified, then setup-disk sets them up in a RAID array. If there are more than 2 disks, then raid level 5 is used instead of RAID level 1. Refer RAID for more options.

Custom Layout

setup-disk must be called with a MOUNTPOINT for any layout different from the default layout. Then setup-disk will perform a traditional harddisk or System Disk mode install with MOUNTPOINT as root and any custom partiotioning layout can be used.

To install Alpine Linux in System Disk Mode using custom layout, atleaset one partition is required. If necessary partition(s) are unavailable, manually create partitions, format them and mount them on /mnt (or any other mount point) as follows:

# mount /dev/sdXY /mnt

If you're using EFI, make sure you create a mount point /mnt/boot/efi.

# mkdir -p /mnt/boot/efi

Find the correct partition name for esp partition and mount it on the above mount point :

# mount /dev/esp /mnt/boot/efi

Additional partitions like /home, /var etc can be created and mounted inside the mountpoint(/mnt) as per requirements.

Then install Alpine Linux using the following command:

# setup-disk -m sys /mnt

setup-disk will install Alpine Linux system on the mounted root, uses your filesystem on the presented layout and generates fstab automatically and also installs an appropriate bootloader. In most cases, you can just reboot to boot into newly installed Alpine Linux. You can also choose to customize 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. Instead, alpine allows you to install more complete partitioning tool packages like sfdisk (scriptable fdisk), gptfdisk, parted (CLI), cfdisk (text menus), or even gparted (after setting up a graphical environment). These tools can be installed even during Installation immediately after setting up base configuration.

cfdisk will be used in all examples here as it is based on text menu without any dependencies:

The following step installs cfdisk:

# apk add cfdisk

Creating partitions

cfdisk will be used to create partitions. Before using cfdisk, the disk name must be identified by using blkid:

# 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 /dev/sdX :

# cfdisk /dev/sdX

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.

cfdisk screenshot

To resize disk, launch the cfdisk:

# cfdisk /dev/sda

  1. Select the target partition, here as per image /dev/sda3
  2. Select Resize from the bottom menu.
  3. Enter the new Size at the prompt.
  4. 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.

# resize2fs -f /dev/sda3 # reboot

Formatting partitions

Refer Filesystems page to install the necessary filesystem tools and to format paritions.


Setting up swap

  1. create a partition with the type set to "linux swap" (82) (If you're going to use a logical volume for swap, skip this step and lvcreate that instead.)
  2. mkswap /dev/sda2
  3. echo -e "/dev/sda2 none swap sw 0 0" >> /mnt/etc/fstab
  4. swapon /dev/sda2 (or rc-service swap start)

free -m

will show how much swap space is available (in MB).

If you prefer maximum speed, you don't need configure any raid devices for swap. Just add 2 swap partitions on different disks and linux will stripe them automatically. The downside is that the moment one disk fails, the system will go down. For better reliability, put swap on RAID1.

Todo: Instructions for cryptswap?


Custom boot partition size

The default boot partition size is under 40MB. This can cause errors if package updates require additional space on /boot. Executing export BOOT_SIZE=512 before running setup-disk will result in a 512MB boot partition.

Disk layouts

This material is work-in-progress ...

This entire section including RAID, Encryption and LVM needs to be updated.
(Last edited by Prabuanand on 18 Sep 2024.)

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 /boot partition are configured properly.

Your /boot directory cannot reside on an encrypted or LVM volume, at least not with Alpine's default bootloader (extlinux). (Grub2 can deal with /boot being on an LVM volume.) The usual practice is to create a small partition for /boot, 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 /boot 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 /boot, 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 /boot 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 /dev/mdi 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 /dev/mdi 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:

echo "/sbin/mdadm" > $MNT/etc/mkinitfs/files.d/raid echo "/etc/mdadm.conf" >> $MNT/etc/mkinitfs/files.d/raid # edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features="..." # includes raid (this field is space-separated and quoted) mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT # edit $MNT/etc/update-extlinux.conf to make sure modules=... contains # raid1 or raid456 (whichever your / is on; this field is comma-separated) # also check the root= setting extlinux --raid --install $MNT/boot --update

Todo: Does adding the --update option to extlinux ... suffice to make /boot/extlinux.conf be regenerated? Or do we need to manually tweak that file, or run update-extlinux, as well?


You might also need to manually tweak $MNT/etc/fstab. And you might need to copy /usr/share/syslinux/mbr.bin 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 /dev/mapper/something 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 /dev/md2, and that you want to unlock the encrypted volume into a virtual volume named "crypt":

# edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features="..." # includes cryptsetup (this field is space-separated and quoted) mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT # edit $MNT/etc/update-extlinux.conf to make sure default_kernel_opts="..." # contains cryptroot=/dev/md1 and cryptdm=crypt (this field is also space-separated and quoted) # also check the root= setting extlinux --install $MNT/boot --update

Todo: Does adding the --update option to extlinux ... suffice to make /boot/extlinux.conf be regenerated? Or do we need to manually tweak that file, or run update-extlinux, as well?


You might also need to manually tweak $MNT/etc/fstab.

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

umount ... vgchange -an

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:

# edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features="..." # includes lvm (this field is space-separated and quoted) mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT # edit $MNT/etc/update-extlinux.conf to make sure root= is set correctly extlinux --install $MNT/boot --update

Todo: Does adding the --update option to extlinux ... suffice to make /boot/extlinux.conf be regenerated? Or do we need to manually tweak that file, or run update-extlinux, as well?


You might also need to manually tweak $MNT/etc/fstab.


see also