Diskless Mode: Difference between revisions

From Alpine Linux
(rephrased the introductory lines to add clarity)
m (→‎Installation: Fix casing)
 
(28 intermediate revisions by 2 users not shown)
Line 1: Line 1:
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 <Code>iso</Code> 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 <code>[[Alpine_setup_scripts#setup-alpine|setup-alpine]]</code> script.  
In Diskless mode, the entire operating system with all applications are first loaded into RAM and then only run from there. This is also the method used to boot the Alpine Linux <Code>iso</Code> installation media. Alpine Linux can be installed and configured so that the system continue to boot like this if "disk=none" is specified while running the <code>[[Alpine_setup_scripts#setup-alpine|setup-alpine]]</code> 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.  
The mode is extremely fast and can save on unnecessary disk spin-ups, power, and wear and suitable for servers. It is similar to what other linux distributions may call a "frugal" install or boot using a "toram" option.


Custom configurations may be preserved or "persist" across reboots by using the Alpine local backup tool <code>[[Alpine_local_backup|lbu]]</code>. 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.  
You can continue using your [[Installation#Preparing_installation_media|installation media]] as a [[#Boot Device|boot device]] without installing alpine to the device's internal disk, but it is also possible to install Alpine Linux to a device's internal disk and configure it so that it boots into "diskless mode"  .
<!--
 
* The initial and possibly read-only installation media can remain the only boot device for the "diskless" system.  
== Apkovl ==
{{Seealso|Alpine local backup}}
 
When you boot an alpine installation into diskless mode, it will initialize a fresh new root (<Code>/</Code>) and any customisations you make (such as changing the password, adding users, etc.) will be lost when you reboot. However, any custom configurations may be preserved or "persist" across reboots by using the Alpine Linux tool named <code>[[Alpine_local_backup|Local Backup Utility]](lbu)</code>. The initial and possibly read-only installation media can remain the only boot device for the "diskless" system by saving the running state to an [[#Apkovl|<Code>.apkovl</Code>]] file, and have these automatically loaded when booting from the boot device.
 
An '''Apkovl''' (APK Overlay file) is a file used for storing local configuration state when running Alpine Linux in [[Diskless Mode]]. It stores all configuration files that have changed from the default ones. The filename is <Code><hostname>.apkovl.tar.gz</Code> and is stored in a location whose path is defined in {{Path|/etc/lbu/lbu.conf}}. The contents from the Apkovl file are overlaid on top of the contents of the apks that are loaded on boot.
 
The backup tool <code>[[Alpine_local_backup|lbu]]</code> enables committing and reverting local configuration system state by using '''.apkovl''' files that are saved to a backup location and loaded when booting. In Diskless mode, for every change made to the running system to persist across reboot, the command <code>[[Alpine_local_backup|lbu commit]]</code> must be issued before rebooting the system to update the .apkovl file.
 
== Local Package Cache ==
 
When Alpine Linux boots in Diskless Mode, the remote repositories will not be available until after networking has started. That means extra packages newer not in your local boot media would not be available after a reboot, unless they were made to persistent [[Alpine_Package_Keeper#Local_Cache|local package cache]] available on a local, writable, storage device. The local package cache can be stored on the same partition as the .apkovl file.


* Using the <code>[[Alpine_setup_scripts#setup-bootable|setup-bootable]]</code> script, it is also possible to [[Create_a_Bootable_Device|create a customizable boot device]] i.e a writable filesystem by copying the boot system from the read-only installation media to a writable partition (e.g. /dev/sdXY).
-->
== Installation  ==
== Installation  ==
{{Seealso|Create a Bootable Device}}


<code>Setup-alpine</code> script stores the configs on a writable partition using <code>[[Alpine_local_backup|lbu]]</code>.
Alpine Linux setup script <code>setup-alpine</code> uses <code>[[Alpine_setup_scripts#setup-lbu|setup-lbu]]</code> script to save the config and package cache to any available writable filesystem on any media other than the read-only [[Installation#Preparing_installation_media|installation media]].
Use <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 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 [[Alpine_Package_Keeper#Local_Cache|local package cache]] on the writable storage.
Due to Bug: [https://gitlab.alpinelinux.org/alpine/alpine-conf/-/issues/10473 #10473] storing local configs and package cache on '''internal disks''' requires manual steps, i.e making an entry in {{Path|/etc/fstab}}, create mountpoint, and mount the partition before running <code>setup-alpine</code> script.  


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. As per Bug: [https://gitlab.alpinelinux.org/alpine/alpine-conf/-/issues/10473 #10473] storing local configs and the package cache on '''internal disks''' requires manual steps listed under [[#Saving_and_loading_ISO_image_customizations| Saving and loading ISO image customizations]] '''before''' running <code>[[Alpine_setup_scripts#setup-alpine|setup-alpine]]</code> script.
# In this case, boot the target diskless system from the [[Installation#Preparing_installation_media|installation media]] and do not proceed after the [[Installation#Boot_Process|boot process]] stage.
# If necessary partition(s) are unavailable, manually [[Setting_up_disks_manually#Creating_partitions|create]] a partition using <Code>fdisk</Code>. In the below steps, we will use /dev/sdXY as partition number. Adjust the partition identifier as per the output of {{Codeline|<Code>blkid</Code>}}<br>
#* 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. Install package {{pkg|<Code>e2fsprogs</code>}} using command {{Codeline|<Code>apk add e2fsprogs</Code>}}, if the command <Code>mkfs.ext4</Code> is not available.
#: {{Cmd|mkfs.ext4 -O ^has_journal,^64bit /dev/sdXY}}
# 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.
#: {{Cmd|mkdir /media/sdXY}}
#: {{cmd|echo "/dev/sdXY /media/sdXY ext4 noatime,ro 0 0" >> /etc/fstab}}
<!-- Mounting read-only is possible, because the [[Alpine_local_backup|lbu tools]] can temporarily remount it writable for their operation. -->
# Mount the partitions listed in {{Path|/etc/fstab}}.
#: {{Cmd|<code>mount -a</code>}} Look at the output of {{Codeline|<code>mount</code>}} to verify that the changes have been applied correctly.<br>
# If <code>setup-alpine</code> has not run before, follow the [[Installation#Installation_Step_Details|Installation steps]] to complete the [[Installation#Base_configuration|base configuration]]. The above changes should now enable you to choose the partition for saving the local configs and package cache. If asked, there is no need to first unmount the partition, that would only be needed to allow installing on its parent disk.
# If <code>setup-alpine</code> has already been used to configure the diskless system, the storage settings may be modified directly with
#: {{cmd|setup-lbu sdXY}}
# [[Alpine_Package_Keeper#Local_Cache|Local package cache]] can be enabled as follows:
#: {{cmd|mkdir /media/sdXY/cache}}
#: {{cmd|setup-apkcache /media/sdXY/cache}}
# If the partition is large enough, it can be useful to edit {{Path|lbu.conf}} to uncomment and set {{Codeline|BACKUP_LIMIT{{=}}3}}. For example, to allow reverting to a previous, working state if needed.
#: {{cmd|apk add nano}}
#: {{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.
#: {{cmd|lbu commit}}
# From now on, whenever packages are installed or newly configured, and the changes should be kept, execute <code>lbu commit</code>.


== Saving and loading ISO image customizations ==
== Boot Device ==  
<!--
Besides supporting a boot parameter to load customizations from a web server, Alpine's "diskless mode" ISO images try to load an .apkovl volume from system partitions. It is therefore possible to save customized running states to a .apkovl file on a writable partition, and have these automatically loaded when booting the ISO image.


{{Note|When the machine reboots, the remote repositories will not be available until after networking has started. That means packages newer than on your local boot media would not be available after a reboot, unless they were made to persistent, by having a [[#Local Cache|local package cache]] available on a local, writable, storage device.}}
{{Main|Create a Bootable Device}}


The local package cache, which enables additional and updated packages to automatically be copied into RAM during boot, may be stored on the same partition as the .apkovl file.
The initial ISO9660 filesystem based read-only [[Installation#Preparing_installation_media|installation media]] may remain the only boot device for the newly configured Alpine Linux '''Diskless''' system.  
-->


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:
Alpine Linux running Diskless mode can also boot from a partition with a writable filesystem on USB-Stick/CompactFlash/SDCard or SSD/NVMe harddisk. This boot device is known as [[Create_a_Bootable_Device|customizable boot device]] to differentiate against [[Installation#Preparing_installation_media|installation media]]. Local customizations like apkovl files and cached packages can be stored in this customizable boot device, which also allows to upgrade the kernel with its modules and firmware with the <code>update-kernel</Code> script.
* 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>
<!--
[[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"]].
-->
** 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.
**  mkfs.ext4 creates ext4 fs 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. ("^" means "not").
{{Cmd|mkfs.ext4 -O ^has_journal,^64bit /dev/sdXY}}
* The above 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.
<!--
** 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>
{{Cmd|mkdir /media/sdXY
echo "/dev/sdXY /media/sdXY ext4 noatime,ro 0 0" >> /etc/fstab}}
* Mounting read-only is possible, because the [[Alpine_local_backup|lbu tools]] can temporarily remount it writable for their operation. Use {{Codeline|<code>mount -a</code>}} to load the partitions listed in {{Path|/etc/fstab}}. Look at the output to verify that the changes have been applied correctly.<br>
* 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. (If asked, there is no need to first unmount the partition, that would only be needed to allow installing on its parent disk.)<br>
* If setup-alpine has already been used to configure the diskless system, the storage settings may be modified directly with
{{cmd|setup-lbu sdXY}}
* [[Alpine_Package_Keeper#Local_Cache|Local package cache]] can be enabled as follows:
{{cmd|mkdir /media/sdXY/cache
setup-apkcache /media/sdXY/cache}}
* If the partition is large enough, it can be useful to edit {{Path|lbu.conf}} to uncomment and set {{Codeline|BACKUP_LIMIT{{=}}3}}. For example, to allow reverting to a previous, working state if needed.
{{cmd|apk add nano
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.


From then on, whenever packages are installed or newly configured, and the changes should be kept, execute <code>lbu commit</code> again.
== Loading apkovl from webserver ==


== Customizable boot device ==
Alpine's "diskless mode" ISO boot images support boot parameters to load customizations files i.e [[Alpine_local_backup#Creating_and_saving_an_apkovl_from_a_remote_host|apkovl from a webserver]].  
{{Main|Create a Bootable 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}}
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>.


== Upgrading a Diskless System ==
When Alping Linux runs in "diskless" or "data" disk mode, Upgrading requires few extra steps in addition to the regular [[Alpine_Package_Keeper#Upgrade_a_Running_System|upgrade steps]].
If booting a "diskless" system from a read-only device, or as an iso image on writable media, it's not possible to update the boot files (kernel, modules, firmware, ...) that reside on that device.
For [[Create_a_Bootable_Device|customizable boot device]], It is possible to update the boot files. However, even then, the kernel, with its modules and firmware files, can still not be updated directly through regular packages updates. Instead, there is the <code>update-kernel</code> script that can generate initfs images and install them together with upgraded kernels.
Upgrading can be done as follows.
{{cmd|apk add mkinitfs
}}
This package is required for the generation of the initial filesystem used during boot.
* Additional initfs features that are missing in the default configuration, like the [[Btrfs|btrfs]] filesystem support (at the time of writing, to allow loading .apkovl configs and package cache during boot), may be enabled in <code>/etc/mkinitfs/mkinitfs.conf</code>.
* Available initfs features may be listed with <code>ls /etc/mkinitfs/features.d</code>
{{cmd|ls /etc/mkinitfs/features.d
apk add nano
nano /etc/mkinitfs/mkinitfs.conf
lbu commit
}}
Finally update the kernel and its boot environment.
{{cmd|update-kernel /media/sdXY/boot/
}}
* An <code>update-kernel</code> run needs at least 8 GB free ram memory to avoid a broken modloop-image.
* See <code>update-kernel --help</code> for options to manually add additional module or firmware packages.
== Kernel Options ==
Documentation about kernel command line options regarding diskless mode will be available after installing the documentation sub-package {{Pkg|mkinitfs-doc}}: 
{{Cmd|man mkinitfs-bootparam}} <Pre>
      If no root= parameter is given, the initramfs will build a live system
      in memory from scratch. This is also called diskless mode.
      When booting in diskless mode, the following options are also
      available:
      alpine_repo=(URL | PATH)
              If set, /etc/apk/repositories will be filled with this. May be a
              comma-separated list of URLs.
      apkovl=(URL | [DEVICE[:FS_TYPE]:]PATH)
              A HTTP, HTTPS or FTP URL to an apkovl.tar.gz file which will be
              retrieved and applied. Can also be a filesystem path, optionally
              prepended with the device name without the /dev/ prefix.
      autodetect_serial=no
              Disable automatic detection and setup of serial console.
      ds=OPTIONS
              Data source for tiny-cloud. If OPTIONS starts with nocloud,
              tiny-cloud will be enabled.
      nokeep_apk_new
              Setup a fresh system, ignore any apkovl.
      pkgs=PACKAGE{,PACKAGE}
              Comma-separated list of packages to be installed.
      ssh_key=(URL | SSH_KEY)
              This setting installs openssh and places the public key given as
              value in /root/.ssh/authorized_keys.  If the value is an HTTP or
              FTP url, its fetches the key(s) from there.
      splash Enable splash screen.
      usbdelay=NUMBER
              Wait NUMBER seconds for USB devices to show up before searching
              for boot media.
      wireguard=INTERFACE;IP_ADDRESS{,IP_ADDRESS,...}[;WG_CONFIG_FILE]
              Set up a wireguard interface named INTERFACE with the addresses
              IP_ADDRESS and use /etc/wireguard/initrd.conf or WG_CONFIG_FILE
              as a classic wg (not wg-quick) config.
      zfs_force=NUMBER
              Enable force importing the root zpool on boot, even if it was
              previously mounted from a different system/OS.
</Pre>
== See Also ==
== See Also ==
* [[Alpine_local_backup|Alpine Local backup Utility - ''lbu''']]
* [[Alpine_local_backup|Alpine Local backup Utility - ''lbu''']]
Line 71: Line 145:
* [[Manually editing a existing apkovl]]
* [[Manually editing a existing apkovl]]
* [[Back Up a Flash Memory Installation]]
* [[Back Up a Flash Memory Installation]]
* [[Alpine_Package_Keeper#Upgrading_"diskless"_and_"data"_disk_mode_installs|Upgrading Diskless Packages including Kernel upgrade]]
* [[Upgrading_Alpine#Upgrading_Alpine_Linux_on_other_removable_media_(such_as_CF/USB)|Upgrading Diskless to New Alpine Linux Release]]
* [[Upgrading_Alpine#Upgrading_Alpine_Linux_on_other_removable_media_(such_as_CF/USB)|Upgrading Diskless to New Alpine Linux Release]]
* [[PXE boot#Specifying an apkovl|Diskless PXE Boot]]
* [[PXE boot#Specifying an apkovl|Diskless PXE Boot]]
Line 78: Line 151:
* [[Alpine local backup#Include special files.2Ffolders to the apkovl|Include special files section]] - To include custom files outside of <code>/etc</code> in .apkovl file.
* [[Alpine local backup#Include special files.2Ffolders to the apkovl|Include special files section]] - To include custom files outside of <code>/etc</code> in .apkovl file.


[[Category:Diskless]] [[Category:LBU]]
[[Category:Diskless]]

Latest revision as of 06:51, 20 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 also the method used to boot the Alpine Linux iso installation media. 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 and suitable for servers. It is similar to what other linux distributions may call a "frugal" install or boot using a "toram" option.

You can continue using your installation media as a boot device without installing alpine to the device's internal disk, but it is also possible to install Alpine Linux to a device's internal disk and configure it so that it boots into "diskless mode" .

Apkovl

When you boot an alpine installation into diskless mode, it will initialize a fresh new root (/) and any customisations you make (such as changing the password, adding users, etc.) will be lost when you reboot. However, any custom configurations may be preserved or "persist" across reboots by using the Alpine Linux tool named Local Backup Utility(lbu). The initial and possibly read-only installation media can remain the only boot device for the "diskless" system by saving the running state to an .apkovl file, and have these automatically loaded when booting from the boot device.

An Apkovl (APK Overlay file) is a file used for storing local configuration state when running Alpine Linux in Diskless Mode. It stores all configuration files that have changed from the default ones. The filename is <hostname>.apkovl.tar.gz and is stored in a location whose path is defined in /etc/lbu/lbu.conf. The contents from the Apkovl file are overlaid on top of the contents of the apks that are loaded on boot.

The backup tool lbu enables committing and reverting local configuration system state by using .apkovl files that are saved to a backup location and loaded when booting. In Diskless mode, for every change made to the running system to persist across reboot, the command lbu commit must be issued before rebooting the system to update the .apkovl file.

Local Package Cache

When Alpine Linux boots in Diskless Mode, the remote repositories will not be available until after networking has started. That means extra packages newer not in your local boot media would not be available after a reboot, unless they were made to persistent local package cache available on a local, writable, storage device. The local package cache can be stored on the same partition as the .apkovl file.

Installation

Alpine Linux setup script setup-alpine uses setup-lbu script to save the config and package cache to any available writable filesystem on any media other than the read-only installation media.

Due to Bug: #10473 storing local configs and package cache on internal disks requires manual steps, i.e making an entry in /etc/fstab, create mountpoint, and mount the partition before running setup-alpine script.

  1. In this case, boot the target diskless system from the installation media and do not proceed after the boot process stage.
  2. If necessary partition(s) are unavailable, manually create a partition using fdisk. In the below steps, we will use /dev/sdXY as partition number. Adjust the partition identifier as per the output of blkid
    • 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.
    • 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. Install package e2fsprogs using command apk add e2fsprogs, if the command mkfs.ext4 is not available.

    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. Mount the partitions listed in /etc/fstab.

    mount -a

    Look at the output of mount to verify that the changes have been applied correctly.
  5. If setup-alpine has not run before, follow the Installation steps to complete the base configuration. The above changes should now enable you to choose the partition for saving the local configs and package cache. If asked, there is no need to first unmount the partition, that would only be needed to allow installing on its parent disk.
  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.

Boot Device

The initial ISO9660 filesystem based read-only installation media may remain the only boot device for the newly configured Alpine Linux Diskless system.

Alpine Linux running Diskless mode can also boot from a partition with a writable filesystem on USB-Stick/CompactFlash/SDCard or SSD/NVMe harddisk. This boot device is known as customizable boot device to differentiate against installation media. Local customizations like apkovl files and cached packages can be stored in this customizable boot device, which also allows to upgrade the kernel with its modules and firmware with the update-kernel script.

Loading apkovl from webserver

Alpine's "diskless mode" ISO boot images support boot parameters to load customizations files i.e apkovl from a webserver.

It's possible to load an APKOVL file from a webserver, by supplying a custom url with the APKOVL kernel boot parameter. If you don't have a web server you can run busybox's httpd temporarily to serve an .apkovl - busybox httpd -p 127.0.0.1:80.

Upgrading a Diskless System

When Alping Linux runs in "diskless" or "data" disk mode, Upgrading requires few extra steps in addition to the regular upgrade steps.

If booting a "diskless" system from a read-only device, or as an iso image on writable media, it's not possible to update the boot files (kernel, modules, firmware, ...) that reside on that device.

For customizable boot device, It is possible to update the boot files. However, even then, the kernel, with its modules and firmware files, can still not be updated directly through regular packages updates. Instead, there is the update-kernel script that can generate initfs images and install them together with upgraded kernels.

Upgrading can be done as follows.

apk add mkinitfs

This package is required for the generation of the initial filesystem used during boot.

  • Additional initfs features that are missing in the default configuration, like the btrfs filesystem support (at the time of writing, to allow loading .apkovl configs and package cache during boot), may be enabled in /etc/mkinitfs/mkinitfs.conf.
  • Available initfs features may be listed with ls /etc/mkinitfs/features.d

ls /etc/mkinitfs/features.d apk add nano nano /etc/mkinitfs/mkinitfs.conf lbu commit

Finally update the kernel and its boot environment.

update-kernel /media/sdXY/boot/

  • An update-kernel run needs at least 8 GB free ram memory to avoid a broken modloop-image.
  • See update-kernel --help for options to manually add additional module or firmware packages.

Kernel Options

Documentation about kernel command line options regarding diskless mode will be available after installing the documentation sub-package mkinitfs-doc:

man mkinitfs-bootparam

       If no root= parameter is given, the initramfs will build a live system
       in memory from scratch. This is also called diskless mode.

       When booting in diskless mode, the following options are also
       available:

       alpine_repo=(URL | PATH)
              If set, /etc/apk/repositories will be filled with this. May be a
              comma-separated list of URLs.

       apkovl=(URL | [DEVICE[:FS_TYPE]:]PATH)
              A HTTP, HTTPS or FTP URL to an apkovl.tar.gz file which will be
              retrieved and applied. Can also be a filesystem path, optionally
              prepended with the device name without the /dev/ prefix.

       autodetect_serial=no
              Disable automatic detection and setup of serial console.

       ds=OPTIONS
              Data source for tiny-cloud. If OPTIONS starts with nocloud,
              tiny-cloud will be enabled.

       nokeep_apk_new
              Setup a fresh system, ignore any apkovl.

       pkgs=PACKAGE{,PACKAGE}
              Comma-separated list of packages to be installed.
       ssh_key=(URL | SSH_KEY)
              This setting installs openssh and places the public key given as
              value in /root/.ssh/authorized_keys.  If the value is an HTTP or
              FTP url, its fetches the key(s) from there.

       splash Enable splash screen.

       usbdelay=NUMBER
              Wait NUMBER seconds for USB devices to show up before searching
              for boot media.

       wireguard=INTERFACE;IP_ADDRESS{,IP_ADDRESS,...}[;WG_CONFIG_FILE]
              Set up a wireguard interface named INTERFACE with the addresses
              IP_ADDRESS and use /etc/wireguard/initrd.conf or WG_CONFIG_FILE
              as a classic wg (not wg-quick) config.

       zfs_force=NUMBER
              Enable force importing the root zpool on boot, even if it was
              previously mounted from a different system/OS.

See Also