Setting up disks manually: Difference between revisions

From Alpine Linux
(Add a note about mounting esp partition on /boot/efi so that setup-disk can install a bootloader)
(fixed links, templates moved and removed sentences to reduce redundancy)
 
(61 intermediate revisions by 8 users not shown)
Line 1: Line 1:
System Disk Mode is the traditional or classic harddisk installation of Alpine Linux. This installation mode is suitable for most use cases including generic [[:Category:Desktop|desktop]], development machines etc.


The menu choices that are provided by <code>setup-alpine</code> can not cover all needs, however, it's possible to:
If an entire hard disk(s) is available for Alpine Linux, [[Installation#setup-alpine_based_System_Disk_Install|setup-alpine based install]] is the recommended way to install Alpine Linux. For all other use cases, follow the [[Alpine_setup_scripts#setup-disk|<code>setup-disk</code>]] based Installation given below.


* Call [[Alpine_setup_scripts#setup-disk|setup-disk]] directly, instead of through <code>setup-alpine</code>, and pass some specific partitioning parameters to it.
== setup-disk based Installation ==
* 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.


To perform a traditional hard-disk installation of Alpine Linux with basic to complex partitioning needs, complete the [[Installation#Base_configuration|base configuration]] first. Then [[#Creating_partitions|partition]], [[#Formatting_partitions|format]] and mount your partitions on a MOUNTPOINT {{Path|'''/mnt'''}}. Finally, run the command {{Codeline|'''<Code>setup-disk -m sys /mnt</Code>'''}} to install Alpine Linux with {{Path|'''/mnt'''}} as root.


# Follow the [[Installation#General_course_of_action|Installation guide]] to complete the [[Installation#Base_configuration|base configuration]], if not already done.
# If necessary formatted partition(s) are unavailable, manually [[#Creating_partitions|create]] them first and [[#Formatting_partitions|format]] them with appropriate [[Filesystems|filesystem]] tools.
# Mount the '''/ (root)'''  partition on a mount point i.e say {{Path|/mnt}} as follows: {{Cmd|# mount /dev/sdXY /mnt}}
# If you're using EFI, make sure you create a mount point <code>/mnt/boot</code>.  {{Cmd|# mkdir -p /mnt/boot}}
# Find the correct partition name for <code>esp</code> partition and mount it on the above mount point: {{Cmd|# mount /dev/sdXY /mnt/boot}}
# If [[Filesystems#Swap_Partition|swap]] partition is available, you can also enable it now: {{Cmd|# swapon /dev/sdXY }}
# Install Alpine Linux using the following command: {{Cmd|# setup-disk -m sys /mnt}}
# <code>setup-disk</code> will perform a traditional hard disk install of your running system, detects your file system layout and generates {{Path|/etc/fstab}} and installs a [[Bootloaders|bootloader]] based on the <Code>BOOTLOADER</Code> [[Alpine_setup_scripts#Environment_Variables|environment variable]].
# At the end of Installation, you can [[Installation#Reboot|reboot]] to boot into the newly installed Alpine Linux and [[Installation#Post-Installation|configure]] further.


== Manual partitioning ==


(Beta refenence: [https://docs.alpinelinux.org/user-handbook/0.1a/Installing/manual.html#_finalizing docs.alpinelinux.org] )
=== Partitioning tools ===


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]].


= Using setup-alpine (setup-disk) features =
=== Creating partitions ===
{{Warning|Make sure to choose the correct disk device in the below section. If you choose the wrong device, you will lose your data. Make a backup first and do not proceed, if you are unsure.}}
<code>cfdisk</code> will be used in all examples here as it is based on text menu without any dependencies. However, installing the package {{Pkg|<code>cfdisk</code>}} requires network to be available if using Standard ISO boot image. Alternately, {{Pkg|<code>sfdisk</code>}} is available and can be installed without network.


== For "diskless" and "data" disk mode installs ==
The following step installs the package {{Pkg|<code>cfdisk</code>}}:
{{cmd|# apk add cfdisk }}


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.
<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>:


How to prepare writable storage space is explained in the section [[Setting_up_disks_manually#Manual_partitioning| manual partitioning]], below.
{{cmd|# blkid}}
<pre>
/dev/sdX1: LABEL="some" UUID="..." TYPE="vfat"
/dev/sdX2: LABEL="other" UUID="..." TYPE="ext4"
</pre>


== For "sys" disk mode installs ==
When <code>cfdisk</code> is run as follows, it looks for existing partitions on the disk {{Path|/dev/sdX}} :
{{cmd|# cfdisk /dev/sdX}}


{{Draft|Some information on this page may be incomplete or outdate.}}
For Alpine Linux, only the '''(/)'''root partition is mandatory to. Even  a '''/boot''' partition and  '''swap''' are optional, when using


=== Disk layouts ===
=== Resizing an existing partition ===
{{Warning|Make sure to choose the correct disk device in the below section. If you choose the wrong device, you will lose your data. Make a backup first and do not proceed, if you are unsure.}}
 
<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.
 
[[File:Cfdisk screenshot alpine 2024-03-04 143916.png|thumb|cfdisk screenshot ]]
 
To resize disk, launch the <code>cfdisk</code>:
{{cmd|# cfdisk {{path|/dev/sda}}}}
 
# 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''
 
If a filesystem is resized with -f (online mode), then the system must be rebooted immediately after the change is made.
 
{{cmd|# resize2fs -f {{path|/dev/sda3}}
&num; reboot}}
 
=== Formatting partitions ===
 
Whenever a partition is [[#Creating_partitions|created]], the partition must be formatted first before using it.  Depending on the filesystem to be used, the necessary [[Filesystems#Filesystem_Tools|formatting tool]] for the filesystem must be installed first. Commonly used formatting tools like <code> mkfs.ext4</code>, <code>mkfs.vfat</code>, <code>mkfs.btrfs</code> are part of file system tools {{pkg|dosfstools|repo=main}}, {{pkg|e2fsprogs|repo=main}}, {{pkg|btrfs-progs|repo=main}} respectively. Install the [[Filesystems#Filesystem_Tools|filesystem tools]] first, if not done already.
 
{{Warning|The {{Path|/dev/sdXY}} is only an example. Make sure you choose the right partition to format!  If you choose the wrong partition, your will lose your data. Make a backup first and do not proceed, if you are unsure.}}
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.
{{Cmd|# mkfs.ext4 /dev/sdaXY}}
* btrfs-progs for [[btrfs]] filesystem
{{Cmd|# mkfs.btrfs /dev/sdaXY}}
*dosfstools for fat12/fat16/fat32 filesystem
{{Cmd|# mkfs.vfat /dev/sdaXY}}
* f2fs-tools for [[F2FS]] filesystem
{{Cmd|# mkfs.f2fs /dev/sdaXY}}
 
== Disk layouts ==
 
{{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.
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.
Line 75: Line 134:


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


=== RAID ===
=== RAID ===
Line 118: Line 176:


You might also need to manually tweak {{Path|$MNT/etc/fstab}}.
You might also need to manually tweak {{Path|$MNT/etc/fstab}}.


=== LVM ===
=== LVM ===
Line 145: Line 201:




 
== see also ==
 
* [[Installing Alpine on HDD dualbooting|Install to HDD with dual-boot]]
= Manual partitioning =
* [[Installing Alpine Linux in a chroot|Installing Alpine Linux in a chroot]]
 
 
== For "diskless" and "data" disk mode installs ==
 
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-Install|setting up a graphical environment]]).
 
The following example installs <code>cfdisk</code>, looks for existing partitions, and runs cfdisk against <code>/dev/sdX</code>:
# 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: [https://gitlab.alpinelinux.org/alpine/aports/-/issues/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 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.
# apk add e2fsprogs
# 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
[[Alpine_local_backup#Saving_and_loading_ISO_image_customizations|Saving_and_loading_ISO_image_customizations]].
}}
 
== For "sys" disk mode installs ==
 
<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:
 
{{Cmd|setup-disk /mnt}}
 
<code>setup-disk</code> will install your running system on the mounted root, detect your file system layout and generate an 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. 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].
 
See also [https://github.com/itoffshore/alpine-linux-scripts setup-partitions]
 
=== Dual-booting ===
See [[Installing Alpine on HDD dualbooting|Install to HDD with dual-boot]]
 
=== Other needs ===
* [[Installing Alpine Linux in a chroot]]
* [[Replacing non-Alpine Linux with Alpine remotely]]
* [[Replacing non-Alpine Linux with Alpine remotely]]
 
* [https://github.com/itoffshore/alpine-linux-scripts setup-partitions]
 
<!--
Create partition with with type "Linux" (83).
apk_add e2fsprogs rsync
mkfs.ext3 /dev/hda1
mount -t ext3 /dev/hda1 /mnt
ROOT=/mnt apk_add uclibc busybox apk-tools alpine-baselayout alpine-conf
# Install busybox links
mkdir /mnt/proc && mount --bind /proc /mnt/proc && chroot /mnt /bin/busybox --install -s && umount /mnt/proc
# Copy the apk repository
rsync -ruav /media/cdrom/apks /mnt
mkdir /mnt/etc/apk && echo "APK_PATH=file://apks" > /mnt/etc/apk/apk.conf
# Copy the hd/ext3 initramfs image, kernel and kernel modules
rsync -ruav /media/cdrom/kernel/generic/hd-ext3.gz /media/cdrom/kernel/generic/bzImage /mnt
rsync -ruav /lib/modules/* /mnt/lib/modules/
-->
 
 
<!--
== Setting up RAID ==
Set up a raid array as described [[Setting up a software RAID1 array|here]].
In this document, two raid arrays are configured: md0 for swap (512MB) and md1 for /var.
 
== Create filesystem ==
We need to install the software to create the filesystem ("format" the partition).
apk_add e2fsprogs
 
If you use an Alpine release older than 1.3.8 you will need to manually create a link to /etc/mtab.
ln -fs /proc/mounts /etc/mtab
 
Create the filesystem. The -j option makes it ext'''3'''. Without the -j option it will become non-journaling ext'''2'''. This step might take some time if your partition is big.
mke2fs -j /dev/md1
 
 
Now edit /etc/fstab and add your new partitions. Mine looks like this:
none            /proc          proc    defaults 0 0
none            /sys            sysfs  defaults 0 0
udev            /dev            tmpfs  size=100k 0 0
none            /dev/pts        devpts  defaults 0 0
tmpfs          /dev/shm        tmpfs  defaults 0 0
/dev/cdrom      /media/cdrom    iso9660 ro 0 0
/dev/fd0        /media/floppy  vfat    noauto  0 0
/dev/usba1      /media/usb      vfat    noauto  0 0
none            /proc/bus/usb  usbfs noauto 0 0
 
/dev/md0        swap            swap    defaults 0 0
/dev/md1        /var            ext3    defaults 0 0
 
== Move the data ==
Stop aall services running that put anything in /var (syslog for example). If you have booted on a clean installation and not run setup-alpine, then no services should be running. However, some packages might have created dirs in /var, so we need to backup /var, mount the new /var directory and move all backed up dirs to the raided /var.
 
mv /var /var.tmp
mkdir /var
mount /var
mv /var.tmp/* /var
rmdir /var.tmp
 
Verify that everyting looks ok with the ''df'' utility.
~ $ df
Filesystem          1k-blocks      Used Available Use% Mounted on
none                    255172    23544    231628  9% /
udev                      100        0      100  0% /dev
/dev/cdrom              142276    142276        0 100% /media/cdrom
/dev/md1              37977060    181056  35866876  1% /var
 
== Survive reboots ==
Now we have everything up and running. We need to make sure that everything will be restored during next reboot.
 
Create an initscript that will mount /var for you during boot. I call it /etc/init.d/mountdisk and it looks like this:
#!/sbin/runscript
start() {
        ebegin "Mounting /var"
        mount /var
        eend $?
}
stop() {
        ebegin "Unmounting /var"
        umount /var
        eend $?
}
 
Make it exectutable:
chmod +x /etc/init.d/mountdisk
 
'''NOTE:''' Since Alpine-1.7.3 a script named ''localmount'' is included so you will not need to create your own ''mountdisk'' script.
 
/var needs to be mounted *after* raid is created. The -k option will make alpine unmount the /var partition during boot. Add start swap to boot:
rc_add -k -s 06 mountdisk
rc_add -k -s 06 swap
 
The /dev/md* device nodes will not be created automatically, so we need to put them on floppy too.
lbu include /dev/md*
 
If you have users on the server and want /home to be permanent, you can create a directory /var/home and create links to /var/home.
mkdir /var/home
mv /home/* /var/home/
ln -s /var/home/* /home/
 
'''NOTE:''' You cannot just replace /home with a link that points to /var/home since the base has a /home directory. When the system tries to copy the config from floppy it will fail because of the already existing /home directory.
 
Make sure the links are stored to floppy:
lbu include /home/*
 
Also remember to move any newly created users to /var/home and create a link:
adduser bob
mv /home/bob /var/home/
ln -s /var/home/bob /home/bob
lbu include /home/bob
 
Save to floppy:
lbu commit floppy
 
== Operational Test ==
Reboot computer. Now the raid should start and /var should be mounted. Check with df:
~ $ df
Filesystem          1k-blocks      Used Available Use% Mounted on
none                    255172    23976    231196  9% /
mdev                      100        0      100  0% /dev
/dev/cdrom              140932    140932        0 100% /media/cdrom
/dev/md1              37977060    180984  35866948  1% /var
 
== Upgrades ==
Since the package database is on disk, you cannot update by simply replacing the CDROM. You will have to either run the upgrade on the new CDROM or run ''apk_add -u ... && update-conf'' manually.
-->
 
== Setting up swap ==
 
# 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 <code>lvcreate</code> that instead.)
# <code>mkswap /dev/sda2</code>
# <code>echo -e "/dev/sda2 none swap sw 0 0" >> /mnt/etc/fstab</code>
# <code>swapon /dev/sda2</code> (or <code>rc-service swap start</code>)
 
{{Cmd|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?}}
 
 
[[Category:Installation]]
[[Category:Installation]]
[[Category:Storage]]
[[Category:Storage]]

Latest revision as of 11:37, 9 November 2024

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 with basic to complex partitioning needs, complete the base configuration first. Then partition, format and mount your partitions on a MOUNTPOINT /mnt. Finally, run the command setup-disk -m sys /mnt to install Alpine Linux with /mnt as root.

  1. Follow the Installation guide to complete the base configuration, if not already done.
  2. If necessary formatted partition(s) are unavailable, manually create them first and format them with appropriate filesystem tools.
  3. Mount the / (root) partition on a mount point i.e say /mnt as follows:

    # mount /dev/sdXY /mnt

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

    # mkdir -p /mnt/boot

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

    # mount /dev/sdXY /mnt/boot

  6. If swap partition is available, you can also enable it now:

    # swapon /dev/sdXY

  7. Install Alpine Linux using the following command:

    # setup-disk -m sys /mnt

  8. setup-disk will perform a traditional hard disk install of your running system, detects your file system layout and generates /etc/fstab and installs a bootloader based on the BOOTLOADER environment variable.
  9. 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. 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.

Creating partitions

Warning: Make sure to choose the correct disk device in the below section. If you choose the wrong device, you will lose your data. Make a backup first and do not proceed, if you are unsure.


cfdisk will be used in all examples here as it is based on text menu without any dependencies. However, installing the package cfdisk requires network to be available if using Standard ISO boot image. Alternately, sfdisk is available and can be installed without network.

The following step installs the package cfdisk:

# apk add cfdisk

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

For Alpine Linux, only the (/)root partition is mandatory to. Even a /boot partition and swap are optional, when using

Resizing an existing partition

Warning: Make sure to choose the correct disk device in the below section. If you choose the wrong device, you will lose your data. Make a backup first and do not proceed, if you are unsure.


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

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. Commonly used formatting tools like mkfs.ext4, mkfs.vfat, mkfs.btrfs are part of file system tools dosfstools, e2fsprogs, btrfs-progs respectively. Install the filesystem tools first, if not done already.

Warning: The /dev/sdXY is only an example. Make sure you choose the right partition to format! If you choose the wrong partition, your will lose your data. Make a backup first and do not proceed, if you are unsure.


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.

# mkfs.ext4 /dev/sdaXY

  • btrfs-progs for btrfs filesystem

# mkfs.btrfs /dev/sdaXY

  • dosfstools for fat12/fat16/fat32 filesystem

# mkfs.vfat /dev/sdaXY

  • f2fs-tools for F2FS filesystem

# mkfs.f2fs /dev/sdaXY

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 9 Nov 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