Diskless Mode: Difference between revisions
Prabuanand (talk | contribs) (changed heading rephrased sentence related to apkvol, lbu etc) |
Prabuanand (talk | contribs) (removed redundant info about installation. cleaned up sentences to make understanding easier. fixed grammar issues) |
||
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 | 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 using a "toram" option. | 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 using a "toram" option. | ||
Custom configurations may be preserved or "persist" across reboots by using the Alpine Linux tool named <code>[[Alpine_local_backup| | 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 the boot device. | ||
In addition to the installation media, it is also possible to boot the "diskless" Alpine Linux from a [[Create_a_Bootable_Device|customizable boot device]]. | |||
<!-- | <!-- | ||
Later, another directory on that same partition or another available partition may also be mounted as /home, for selected important applications to keep their run-time and user data on it. | |||
--> | --> | ||
== Apkovl == | == Apkovl == | ||
Apkovl 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 | Apkovl 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. | 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 == | == Local Package Cache == | ||
When Alpine Linux boots in Diskless, 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 [[Alpine_Package_Keeper#Local_Cache|local package cache]] available on a local, writable, storage device. | When Alpine Linux boots in Diskless Mode, 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 [[Alpine_Package_Keeper#Local_Cache|local package cache]] available on a local, writable, storage device. | ||
If additional or updated packages have been added to the system, these may also be made available for automatic (re)installation and copied into RAM during the boot phase without any (re)downloading, by enabling a [[Alpine_Package_Keeper#Local_Cache|local package cache]] on a writable storage. The local package cache can be stored on the same partition as the .apkovl file. | If additional or updated packages have been added to the system, these may also be made available for automatic (re)installation and copied into RAM during the boot phase without any (re)downloading, by enabling a [[Alpine_Package_Keeper#Local_Cache|local package cache]] on a writable storage. The local package cache can be stored on the same partition as the .apkovl file. | ||
Line 26: | Line 25: | ||
During [[Installation]], Alpine Linux Setup script <code>Setup-alpine</code> uses <code>[[Alpine_setup_scripts#setup-lbu|setup-lbu]]</code> script to configure a "local backup" location to save the initial local configuration state as an [[#Apkovl|.apkovl]] file using <code>[[Alpine_local_backup|lbu]]</code> tool. If subsequent changes are made to the running system, the command <code>[[Alpine_local_backup|lbu commit]]</code> must be used to update the .apkovl file. | During [[Installation]], Alpine Linux Setup script <code>Setup-alpine</code> uses <code>[[Alpine_setup_scripts#setup-lbu|setup-lbu]]</code> script to configure a "local backup" location to save the initial local configuration state as an [[#Apkovl|.apkovl]] file using <code>[[Alpine_local_backup|lbu]]</code> tool. If subsequent changes are made to the running system, the command <code>[[Alpine_local_backup|lbu commit]]</code> must be used to update the .apkovl file. | ||
Boot the diskless system from | Boot the diskless system from the [[Installation#Preparing_installation_media|installation media]]. Due to Bug: [https://gitlab.alpinelinux.org/alpine/alpine-conf/-/issues/10473 #10473] storing local configs and package cache on '''internal disks''' requires [[#Apkovl on internal disk|manual steps]] listed below before running <code>setup-alpine</code> script. | ||
== Apkovl on internal disk == | == Apkovl on internal disk == | ||
To save customized running states to an .apkovl file on a writable partition on internal disks, the following steps are needed to be manually done i.e. create a filesystem, making an entry in {{Path|/etc/fstab}}, create mountpoint, and mount , as follows: | |||
# If necessary partition(s) are unavailable, manually [[Setting_up_disks_manually#Creating_partitions|create]] a partition. In the below steps, we will use /dev/sdXY as partition number. Adjust the partition identifier as per {{Codeline|blkid}}<br> | |||
To save customized running states to | #* 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. | |||
# If necessary partition(s) are unavailable, manually [[Setting_up_disks_manually#Creating_partitions|create]] a partition. | |||
# | |||
# | |||
#: {{Cmd|mkfs.ext4 -O ^has_journal,^64bit /dev/sdXY}} | #: {{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. | # 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|mkdir /media/sdXY}} | ||
#: {{cmd|echo "/dev/sdXY /media/sdXY ext4 noatime,ro 0 0" >> /etc/fstab}} | #: {{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. --> | <!-- 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}}. | ||
# If | #: {{Cmd|<code>mount -a</code>}} Look at the output 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 | # 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}} | #: {{cmd|setup-lbu sdXY}} | ||
# [[Alpine_Package_Keeper#Local_Cache|Local package cache]] can be enabled as follows: | # [[Alpine_Package_Keeper#Local_Cache|Local package cache]] can be enabled as follows: |
Revision as of 10:07, 2 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. 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 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 the boot device.
In addition to the installation media, it is also possible to boot the "diskless" Alpine Linux from a customizable boot device.
Apkovl
Apkovl 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 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 package cache available on a local, writable, storage device.
If additional or updated packages have been added to the system, these may also be made available for automatic (re)installation and copied into RAM during the boot phase without any (re)downloading, by enabling a local package cache on a writable storage. The local package cache can be stored on the same partition as the .apkovl file.
Installation
During Installation, Alpine Linux Setup script Setup-alpine
uses setup-lbu
script to configure a "local backup" location to save the initial local configuration state as an .apkovl file using lbu
tool. If subsequent changes are made to the running system, the command lbu commit
must be used to update the .apkovl file.
Boot the diskless system from the installation media. Due to Bug: #10473 storing local configs and package cache on internal disks requires manual steps listed below before running setup-alpine
script.
Apkovl on internal disk
To save customized running states to an .apkovl file on a writable partition on internal disks, the following steps are needed to be manually done i.e. create a filesystem, making an entry in /etc/fstab, create mountpoint, and mount , as follows:
- If necessary partition(s) are unavailable, manually create a partition. In the below steps, we will use /dev/sdXY as partition number. Adjust the partition identifier as per 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.
mkfs.ext4 -O ^has_journal,^64bit /dev/sdXY
- 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
- Mount the partitions listed in /etc/fstab.
Look at the output to verify that the changes have been applied correctly.mount -a
- 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. - If
Setup-alpine
has already been used to configure the diskless system, the storage settings may be modified directly withsetup-lbu sdXY
- Local package cache can be enabled as follows:
mkdir /media/sdXY/cache
setup-apkcache /media/sdXY/cache
- 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
- 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
- From now on, whenever packages are installed or newly configured, and the changes should be kept, execute
lbu commit
.
Customizable boot device
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 iso9660 filesystem based read only Installation Media based boot device. Local customizations like apkovl files and cached packages can be stored in this customizable boot device, which also allows to also upgrade the kernel with its modules and firmware with the update-kernel
script.
For the newly configured local "diskless" system, it is possible to copy the boot system from a read-only installation media to a writable vfat partition (e.g. /dev/sdXY) with setup-bootable
script or manually to any writable partition and create a customizable boot device.
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
.
See Also
- Alpine Local backup Utility - lbu'
- Local package cache
- Manually editing a existing apkovl
- Back Up a Flash Memory Installation
- Upgrading Diskless Packages including Kernel upgrade
- Upgrading Diskless to New Alpine Linux Release
- Diskless PXE Boot
- How to make a custom ISO image with mkimage
- QEMU Diskless example
- Include special files section - To include custom files outside of
/etc
in .apkovl file.