Diskless Mode: Difference between revisions

From Alpine Linux
(Replaced the bulleted points by numbered points)
(removed commented out sections as they've been integrated in the page.)
Line 30: Line 30:
# Boot the diskless system from ISO and follow the [[Installation#Installation_Step_Details|Installation steps]] to complete the [[Installation#Base_configuration|base configuration]]. Now the pre-setup of [[#Diskless_Mode|"diskless"]] Alpine Linux system is considered complete.<br>   
# Boot the diskless system from ISO and follow the [[Installation#Installation_Step_Details|Installation steps]] to complete the [[Installation#Base_configuration|base configuration]]. Now the pre-setup of [[#Diskless_Mode|"diskless"]] Alpine Linux system is considered complete.<br>   
# If necessary partition(s) are unavailable, manually [[#Creating_partitions|create]] a partition. For the examples we will use /dev/sdXY<br>
# If necessary partition(s) are unavailable, manually [[#Creating_partitions|create]] a partition. For the examples we will use /dev/sdXY<br>
<!--
[[Setting_up_disks_manually#For_.22diskless.22_and_.22data.22_disk_mode_installs_2|"Setting up disks manually, for diskless and data disk mode installs"]].
-->
## Due to Bug: {{Issue|11589|The APKOVL loading of diskless setups doesn't work on btrfs and xfs filesystems, or nvme-based devices}}. So use only ext4 filesystem partitions on classic drives to store diskless mode states.
## Due to Bug: {{Issue|11589|The APKOVL loading of diskless setups doesn't work on btrfs and xfs filesystems, or nvme-based devices}}. So use only ext4 filesystem partitions on classic drives to store diskless mode states.
##  mkfs.ext4 creates ext4 filesystem with 64bit feature enabled by default, but extlinux may not be able to boot with that due to Issue {{Issue|14895}}. You may need to add "-O ^64bit" to mkfs.ext4 to circumvent this. The below command 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 creates ext4 filesystem with 64bit feature enabled by default, but extlinux may not be able to boot with that due to Issue {{Issue|14895}}. You may need to add "-O ^64bit" to mkfs.ext4 to circumvent this. The below command 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.  
#: {{Cmd|mkfs.ext4 -O ^has_journal,^64bit /dev/sdXY}}
#: {{Cmd|mkfs.ext4 -O ^has_journal,^64bit /dev/sdXY}}
<!--
Bug: [https://gitlab.alpinelinux.org/alpine/mkinitfs/-/issues/5 Initramfs-init does not respect apkovl device fstab entry], so the partition can not be mounted to /boot. The workaround given there does not seem to work
(e.g. <code>mkdir -p /boot/ovl_dev/cache ; touch /boot/ovl_dev/cache/.boot_repository</code>)<br>
-->
# Due to a [https://gitlab.alpinelinux.org/alpine/mkinitfs/-/issues/5 bug], the partition can not be mounted to /boot. Configure the /etc/fstab to mount the writable partition to /media/sdXY instead of /boot i.e. conforming to the hot/cold-plug mountpoints. <br>
# Due to a [https://gitlab.alpinelinux.org/alpine/mkinitfs/-/issues/5 bug], the partition can not be mounted to /boot. Configure the /etc/fstab to mount the writable partition to /media/sdXY instead of /boot i.e. conforming to the hot/cold-plug mountpoints. <br>
#: {{Cmd|mkdir /media/sdXY}}
#: {{Cmd|mkdir /media/sdXY}}
Line 56: Line 49:
#: {{cmd|nano /etc/lbu/lbu.conf }}
#: {{cmd|nano /etc/lbu/lbu.conf }}
# Finally, generate the first .apkovl file containing all the previous changes by executing <code>lbu commit</code>, so the customizations that were just made will persist a reboot.
# Finally, generate the first .apkovl file containing all the previous changes by executing <code>lbu commit</code>, so the customizations that were just made will persist a reboot.
#: {{cmd|lbu commit}}
# From now on, whenever packages are installed or newly configured, and the changes should be kept, execute <code>lbu commit</code>.
# From now on, whenever packages are installed or newly configured, and the changes should be kept, execute <code>lbu commit</code>.


Line 62: Line 56:
In the [[#Saving and loading ISO image customizations|above case]], the initial read-only installation media may remain the only boot device for the newly configured local "diskless" system.  It is possible to copy the boot system to a partition (e.g. /dev/sdXY) with <code>[[Alpine_setup_scripts#setup-bootable|setup-bootable]]</code> script and [[Create_a_Bootable_Device|create a customizable boot device]].
In the [[#Saving and loading ISO image customizations|above case]], the initial read-only installation media may remain the only boot device for the newly configured local "diskless" system.  It is possible to copy the boot system to a partition (e.g. /dev/sdXY) with <code>[[Alpine_setup_scripts#setup-bootable|setup-bootable]]</code> script and [[Create_a_Bootable_Device|create a customizable boot device]].


== Other Topics ==
<!--
{{Todo|Need to document the steps}}
The below information is partially available in LBU page [[Alpine_local_backup#Creating_and_saving_an_apkovl_from_a_remote_host]]
It's possible to load an APKOVL file from a webserver, by supplying a custom url with the <code>APKOVL</code> kernel boot parameter. If you don't have a web server you can run busybox's httpd temporarily to serve an .apkovl - <code>busybox httpd -p 127.0.0.1:80</code>.
It's possible to load an APKOVL file from a webserver, by supplying a custom url with the <code>APKOVL</code> kernel boot parameter. If you don't have a web server you can run busybox's httpd temporarily to serve an .apkovl - <code>busybox httpd -p 127.0.0.1:80</code>.
 
-->
== See Also ==
== See Also ==
* [[Alpine_local_backup|Alpine Local backup Utility - ''lbu''']]
* [[Alpine_local_backup|Alpine Local backup Utility - ''lbu''']]

Revision as of 17:41, 1 November 2024

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 Alpine Linux iso installation images. Alpine Linux can be installed and configured so that the system continue to boot like this if "disk=none" is specified while running the setup-alpine script.

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 may be preserved or "persist" across reboots by using the Alpine local backup tool lbu. It enables committing and reverting local configuration system state by using .apkovl files that are saved to a "local backup" location i.e a writable partition and loaded when booting.

Installation

Setup-alpine script stores the configs on a writable partition using lbu. Use setup-lbu script to configure a "local backup" location for the diskless system, and lbu commit to then save the local configuration state as an .apkovl file.

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

If a writable partition is available, setup-alpine can be told to store the configs and the package cache on that writable partition. As per Bug: #10473 storing local configs and the package cache on internal disks requires manual steps listed under Saving and loading ISO image customizations before running setup-alpine script.

Saving and loading ISO image customizations

To save customized running states to a .apkovl file on a writable partition on internal disks, and have these automatically loaded when booting the boot device i.e ISO image, the following steps are needed to manually prepare a specific /etc/fstab entry, and save the configuration, as follows:

  1. Boot the diskless system from ISO and follow the Installation steps to complete the base configuration. Now the pre-setup of "diskless" Alpine Linux system is considered complete.
  2. If necessary partition(s) are unavailable, manually create a partition. For the examples we will use /dev/sdXY
    1. Due to Bug: #11589. The APKOVL loading of diskless setups doesn't work on btrfs and xfs filesystems, or nvme-based devices. So use only ext4 filesystem partitions on classic drives to store diskless mode states.
    2. mkfs.ext4 creates ext4 filesystem with 64bit feature enabled by default, but extlinux may not be able to boot with that due to Issue #14895. You may need to add "-O ^64bit" to mkfs.ext4 to circumvent this. The below command 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,^64bit /dev/sdXY

  3. Due to a bug, the partition can not be mounted to /boot. Configure the /etc/fstab to mount the writable partition to /media/sdXY instead of /boot i.e. conforming to the hot/cold-plug mountpoints.

    mkdir /media/sdXY

    echo "/dev/sdXY /media/sdXY ext4 noatime,ro 0 0" >> /etc/fstab

  4. Use mount -a to load the partitions listed in /etc/fstab. Look at the output to verify that the changes have been applied correctly.
  5. If setup-alpine has not run before, it may be used and should now enable you to choose the partition for saving the local configs and package cache.
  6. If setup-alpine has already been used to configure the diskless system, the storage settings may be modified directly with

    setup-lbu sdXY

  7. Local package cache can be enabled as follows:

    mkdir /media/sdXY/cache

    setup-apkcache /media/sdXY/cache

  8. If the partition is large enough, it can be useful to edit lbu.conf to uncomment and set BACKUP_LIMIT=3. For example, to allow reverting to a previous, working state if needed.

    apk add nano

    nano /etc/lbu/lbu.conf

  9. Finally, generate the first .apkovl file containing all the previous changes by executing lbu commit, so the customizations that were just made will persist a reboot.

    lbu commit

  10. From now on, whenever packages are installed or newly configured, and the changes should be kept, execute lbu commit.

Customizable boot device

In the above case, the initial read-only installation media may remain the only boot device for the newly configured local "diskless" system. It is possible to copy the boot system to a partition (e.g. /dev/sdXY) with setup-bootable script and create a customizable boot device.

See Also