<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Garo</id>
	<title>Alpine Linux - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Garo"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Garo"/>
	<updated>2026-04-27T12:44:10Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Installation&amp;diff=22677</id>
		<title>Installation</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Installation&amp;diff=22677"/>
		<updated>2022-11-20T00:00:55Z</updated>

		<summary type="html">&lt;p&gt;Garo: /* Data Disk Mode */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
[[Image:hdd_mount.png|left|link=]]&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This page explains the basics to get started. But before actually installing, it can also help to skim through the [[Alpine_Linux:FAQ| Frequenty Asked Questions (FAQ)]].&lt;br /&gt;
&lt;br /&gt;
{{Tip|This is a wiki!&lt;br /&gt;
If something isn&#039;t correct (anymore), or still incomplete, you will have to try figuring it out, or ask for the correct solution in the [https://alpinelinux.org/community/ community].&lt;br /&gt;
&lt;br /&gt;
And then carefully edit the wiki page.&lt;br /&gt;
&lt;br /&gt;
Just as those before you did it for you.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Minimal Hardware Requirements ==&lt;br /&gt;
&lt;br /&gt;
* At least 100 MB of RAM. [A graphical desktop system may require up to 1 GB minimum.]&lt;br /&gt;
* At least 0-700 MB space on a writable storage device. [Only required in &amp;quot;sys&amp;quot; or &amp;quot;data&amp;quot; mode installations (explained below). It is optional in &amp;quot;diskless&amp;quot; mode, where it may be used to save newer data and configurations states of a running system.]&lt;br /&gt;
&lt;br /&gt;
For more information please check [[Requirements]]&lt;br /&gt;
&lt;br /&gt;
== Installation Overview ==&lt;br /&gt;
&lt;br /&gt;
=== The general course of action ===&lt;br /&gt;
{{Note|For single-board-computer (SBC) architectures which can not boot .iso images, see [[Alpine_on_ARM|Alpine on ARM]] for peculiarities.}}&lt;br /&gt;
&lt;br /&gt;
As usual, the regular installation procedure starts with three basic steps (additional details for all the steps follow [[Installation#additional details|below]]):&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Downloading and verifying the proper [http://alpinelinux.org/downloads stable-release ISO installation image-file] for the computer&#039;s architecture, and the corresponding &amp;lt;code&amp;gt;sha256&amp;lt;/code&amp;gt; (checksum) and &amp;lt;code&amp;gt;GPG&amp;lt;/code&amp;gt; (signature) files. &lt;br /&gt;
# Either burning the ISO image-file onto a blank CD/DVD/Blu-ray disk with disk burning software, or flashing the installation image onto a bootable storage device (USB-device, CF-/MMC-/SD-card, floppy, ...). Optionally to setup a headless system, a bootstrapping configuration overlay file [https://github.com/macmpi/alpine-linux-headless-bootstrap  headless.apkovl.tar.gz] may be added to enable basic networking, so that following configuration steps can be performed under &amp;lt;code&amp;gt;ssh&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Booting the computer from the prepared disk or storage device.&lt;br /&gt;
&lt;br /&gt;
The boot process of the installation image first copies the entire operating system into the RAM memory, and then already starts a complete Alpine Linux system from there. It will initially only provide a basic command line environment that does not depend on reading from any (possibly slow) initial boot media, anymore.&lt;br /&gt;
&lt;br /&gt;
Log-in is possible as the user &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt;. Initially, the root user has no password.&lt;br /&gt;
&lt;br /&gt;
At the command prompt, an interactive script named &amp;lt;code&amp;gt;[[Alpine_setup_scripts#setup-alpine|setup-alpine]]&amp;lt;/code&amp;gt; is available to configure and install the initial Alpine Linux system.&lt;br /&gt;
&lt;br /&gt;
The question-and-answer dialog of &amp;lt;code&amp;gt;[[Alpine_setup_scripts#setup-alpine|setup-alpine]]&amp;lt;/code&amp;gt; takes care of the base configuration and allows to configure the system to&amp;lt;/br&amp;gt;&lt;br /&gt;
boot into one of three different &#039;&#039;&#039;Alpine Linux disk modes&#039;&#039;&#039;: &#039;&#039;&#039;&amp;quot;diskless&amp;quot;&#039;&#039;&#039;, &#039;&#039;&#039;&amp;quot;data&amp;quot;&#039;&#039;&#039;, or &#039;&#039;&#039;&amp;quot;sys&amp;quot;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
These modes are explained in more detail in the following subsections.&lt;br /&gt;
&lt;br /&gt;
{{Note|It can be helpful to know that it is possible to first only complete a base configuration of the initial &amp;quot;diskless&amp;quot; installation system in order to to prepare the system. For example, to download and install some specific driver or software tool. And then use more specific [[Alpine_setup_scripts|setup-scripts]] afterwards, to proceed with the final installation. The base configuration of the &amp;quot;diskless&amp;quot; system may be completed by running &amp;lt;code&amp;gt;[[Alpine_setup_scripts#setup-alpine|setup-alpine]]&amp;lt;/code&amp;gt; and answering &amp;quot;none&amp;quot; when asked for the disk to use, and where to store configs, as well as for the location for the package cache.&lt;br /&gt;
&lt;br /&gt;
Examples of preparation options:&lt;br /&gt;
&lt;br /&gt;
* Preparing a custom partitioning or filesystem scheme that avoids to use and/or overwrite an entire disk ([[Installation#Custom_partitioning_of_the_harddisk|details below]]).&lt;br /&gt;
* Installing something that may be missing in the live system to configure the hardware, e.g. by using the alpine package manager &amp;lt;code&amp;gt;[[Alpine_Linux_package_management|apk]]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Examples of proceeding options:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;[[Alpine_setup_scripts#setup-lbu|setup-lbu]]&amp;lt;/code&amp;gt; to configure a &amp;quot;local backup&amp;quot; location for the diskless system, and &amp;lt;code&amp;gt;[[Alpine_local_backup|lbu commit]]&amp;lt;/code&amp;gt; to then save the local configuration state.&lt;br /&gt;
* &amp;lt;code&amp;gt;[[Alpine_setup_scripts#setup-apkcache|setup-apkcache]]&amp;lt;/code&amp;gt; to configure a local package cache storage location.&lt;br /&gt;
* &amp;lt;code&amp;gt;[[Alpine_setup_scripts#setup-disk|setup-disk]]&amp;lt;/code&amp;gt; to add a &amp;quot;data&amp;quot; mode partition, or do a classic full install of the &amp;quot;diskless&amp;quot; system onto a &amp;quot;sys&amp;quot; disk or partition.&lt;br /&gt;
&lt;br /&gt;
There are many more [[Alpine_setup_scripts|setup-scripts]] available. All these tools may also be run later to adjust specific configurations. For example, to set up a graphical environment as covered under [[Installation#Post-Install|Post-Install]] below.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
===&#039;&#039;&#039;Diskless Mode&#039;&#039;&#039;=== &lt;br /&gt;
This means the entire operating system with all applications are first loaded into RAM and then only run from there. This is the method used to boot for the .iso installation images. It&#039;s 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 &amp;quot;frugal&amp;quot; install and boot into with a &amp;quot;toram&amp;quot; option. However, &amp;lt;code&amp;gt;[[Alpine_setup_scripts#setup-alpine|setup-alpine]]&amp;lt;/code&amp;gt; can also configure the installed system to boot like this if &amp;quot;disk=none&amp;quot; is specified.&lt;br /&gt;
&lt;br /&gt;
Custom configurations and package selections may optionally still be preserved or &amp;quot;persist&amp;quot; across reboots by using the Alpine local backup tool &amp;lt;code&amp;gt;[[Alpine_local_backup|lbu]]&amp;lt;/code&amp;gt;. It enables committing and reverting system states by using .apkovl files that are saved to writable storage and loaded when booting. If additional or updated packages have been added to the system, these may also be made available for automatic (re)installation during the boot phase without any (re)downloading, by enabling a [[Alpine_Linux_package_management#Local_Cache|local package cache]] on the writable storage.&lt;br /&gt;
&lt;br /&gt;
[[https://gitlab.alpinelinux.org/alpine/alpine-conf/-/issues/10473 FIXME-1]: Storing local configs and the package cache on an &#039;&#039;internal&#039;&#039; disk still requires [[Alpine_local_backup#Saving_and_loading_ISO_image_customizations|some manual steps]] to have the partition listed, i.e. making a /etc/fstab entry, mountpoint, and mount, *before* running setup-alpine. The linked workaround also still requires to commit these configurations to disk manually before rebooting.]&lt;br /&gt;
&lt;br /&gt;
If a writable partition is available, &amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt; can be told to store the configs and the package cache on that writable partition. (Later, another directory on that same partition or another available partition may also be mounted as /home, or for example, for selected important applications to keep their run-time and user data on it.)&lt;br /&gt;
&lt;br /&gt;
The boot device of the newly configured local &amp;quot;diskless&amp;quot; system may remain the initial (and possibly read-only) installation media. But it is also possible to copy the boot system to a partition (e.g. /dev/sdXY) with &amp;lt;code&amp;gt;[[Alpine_setup_scripts#setup-bootable|setup-bootable]]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===&#039;&#039;&#039;Data Disk Mode&#039;&#039;&#039;=== &lt;br /&gt;
This mode also runs from system RAM, thus it enjoys the same accelerated operation speed as &amp;quot;diskless&amp;quot; mode. However, swap storage and the entire {{Path|/var}} directory tree get mounted from a persistent storage device (two newly created partitions). The directory {{Path|/var}} holds e.g. all log files, mailspools, databases, etc., as well as &amp;lt;code&amp;gt;[[Alpine_local_backup|lbu]]&amp;lt;/code&amp;gt; backup commits and the package cache. This mode is useful for having RAM accelerated servers with variable amounts of user-data that exceed the available RAM size. It enables the entire current system state (not just the boot state) to survive a system crash in accordance with the particular filesystem guarantees. &lt;br /&gt;
&lt;br /&gt;
[[https://gitlab.alpinelinux.org/alpine/alpine-conf/-/issues/10474 FIXME-2]]: Setup-alpine will create the data partition and mount it as /var, but can not yet configure lbu storage settings automatically. It is currently necessary to select &amp;quot;none&amp;quot; at the &#039;where to store configs&#039; prompt (the new data partition is not listed) and configure lbu manually. For example, after running &amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt; and before rebooting:&lt;br /&gt;
&lt;br /&gt;
# Create a partition &amp;lt;code&amp;gt;/dev/sd&#039;&#039;XY&#039;&#039;&amp;lt;/code&amp;gt; with filesystemtype &amp;lt;code&amp;gt;&#039;&#039;filesystemtype&#039;&#039;&amp;lt;/code&amp;gt;&lt;br /&gt;
# Tell lbu where to save it by setting  &amp;lt;code&amp;gt;LBU_MEDIA=sd&#039;&#039;XY&#039;&#039;&amp;lt;/code&amp;gt; in  &amp;lt;code&amp;gt;/etc/lbu/lbu.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
# Make sure it can be mounted with: &amp;lt;code&amp;gt;mkdir /media/&#039;&#039;sdXY&#039;&#039; ; echo &amp;quot;/dev/sd&#039;&#039;XY&#039;&#039; /media/sd&#039;&#039;XY&#039;&#039; &#039;&#039;fstype&#039;&#039; noauto,rw 0 0&amp;quot; &amp;gt;&amp;gt; /etc/fstab&amp;lt;/code&amp;gt;&lt;br /&gt;
# Save the configuration on that partition for the next boot with &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In data disk mode, the boot device may also remain the initial (and possibly read-only) installation media, or be copied to a partition (e.g. /dev/sdXY) with &amp;lt;code&amp;gt;[[Alpine_setup_scripts#setup-bootable|setup-bootable]]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===&#039;&#039;&#039;System Disk Mode&#039;&#039;&#039;=== &lt;br /&gt;
This is a traditional hard-disk install.&lt;br /&gt;
&lt;br /&gt;
If this mode is selected, the &amp;lt;code&amp;gt;[[setup-alpine]]&amp;lt;/code&amp;gt; script creates three partitions on the selected storage device, {{Path|/boot}}, {{Path|swap}} and {{Path|/}} (the filesystem root). This mode may, for example, be used for generic [[Desktops|desktop]] and development machines.&lt;br /&gt;
&lt;br /&gt;
For custom partitioning, see [[Setting_up_disks_manually]].&lt;br /&gt;
&lt;br /&gt;
To install along side another operating systems, see [[Installing_Alpine_on_HDD_dualbooting]].&lt;br /&gt;
&lt;br /&gt;
== Basic Installation Step Details ==&lt;br /&gt;
&lt;br /&gt;
{{Expand|  }}&lt;br /&gt;
&lt;br /&gt;
This &amp;quot;Additional Details&amp;quot; section needs to be consolidated with the work at &#039;&#039;&#039;[https://docs.alpinelinux.org https://docs.alpinelinux.org] (not finished)&#039;&#039;&#039; &lt;br /&gt;
(Restructuring things there, moving and linking from here or there?). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Verifying the downloaded image-file ===&lt;br /&gt;
&lt;br /&gt;
{|  class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width:95%; align=center&amp;quot;&lt;br /&gt;
|+ Commands to verify the checksum and GPG signature of a downloaded image-file on different systems.&lt;br /&gt;
|-&lt;br /&gt;
! width=100px |  OS type&lt;br /&gt;
!  &amp;lt;code&amp;gt;SHA256&amp;lt;/code&amp;gt; check !! &amp;lt;code&amp;gt;SHA256&amp;lt;/code&amp;gt; calculation (to be compared manually) !! &amp;lt;code&amp;gt;GPG&amp;lt;/code&amp;gt; signature verification&lt;br /&gt;
|-&lt;br /&gt;
! Linux&lt;br /&gt;
| &amp;lt;code&amp;gt;sha256sum -c alpine-*.iso.sha256&amp;lt;/code&amp;gt; ||        || &amp;lt;code&amp;gt;curl https://alpinelinux.org/keys/ncopa.asc &amp;amp;#124; gpg --import ;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt; gpg --verify alpine-&amp;lt;version&amp;gt;.iso.asc alpine-&amp;lt;version&amp;gt;.iso&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! MACOS  &lt;br /&gt;
| - ? -  || &amp;lt;code&amp;gt;shasum -a 256 alpine-*.iso&amp;lt;/code&amp;gt; || - ? -&lt;br /&gt;
|-&lt;br /&gt;
! OpenBSD  &lt;br /&gt;
| &amp;lt;code&amp;gt;sha256 -C alpine-*.sha256 alpine-*.iso&amp;lt;/code&amp;gt; ||        || &amp;lt;code&amp;gt;doas pkg_add gnupg;&lt;br /&gt;
ftp -o - https://alpinelinux.org/keys/ncopa.asc &amp;amp;#124; gpg --import ;&lt;br /&gt;
gpg --verify alpine-&amp;lt;version&amp;gt;.iso.asc alpine-&amp;lt;version&amp;gt;.iso&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! FreeBSD  &lt;br /&gt;
| - ? - || &amp;lt;code&amp;gt;/usr/local/bin/shasum -a 256 alpine-*.iso&amp;lt;/code&amp;gt; || - ? -&lt;br /&gt;
|-&lt;br /&gt;
! NetBSD  &lt;br /&gt;
| - ? - || &amp;lt;code&amp;gt;/usr/local/bin/shasum -a 256 alpine-*.iso&amp;lt;/code&amp;gt; || - ? -&lt;br /&gt;
|-&lt;br /&gt;
! Windows (PowerShell installed)&lt;br /&gt;
|                 - ? -             || &amp;lt;code&amp;gt;Get-FileHash .\alpine-&amp;lt;image-version&amp;gt;.iso -Algorithm SHA256&amp;lt;/code&amp;gt; || - ? -&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Flashing (direct data writing) the installation image-file onto a device or media  ===&lt;br /&gt;
&lt;br /&gt;
==== Unix/Linux ====&lt;br /&gt;
&lt;br /&gt;
Under Unix (and thus Linux), &amp;quot;everything is a file&amp;quot; and the data in the image-file can be written to a device or media with the &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; command. Afterward, executing the &amp;lt;code&amp;gt;eject&amp;lt;/code&amp;gt; command removes the target device from the system and ensures the write cache is completely flushed.&lt;br /&gt;
&lt;br /&gt;
 dd if=&amp;lt;iso-file-to-read-in&amp;gt; of=&amp;lt;target-device-node-to-write-out-to&amp;gt; bs=4M oflag=sync status=progress; eject &amp;lt;target-device-node-to-write-to&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Be careful to correctly identify the target device as any data on it &#039;&#039;&#039;will&#039;&#039;&#039; be lost! All connected &amp;quot;bulk storage devices&amp;quot; can be listed with &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;lsblk&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;blkid&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 # lsblk&lt;br /&gt;
 NAME            MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT&lt;br /&gt;
 sdX               0:0    0  64,0G  0 disk  &lt;br /&gt;
 ├─sdX1            0:1    0     2G  0 part  &lt;br /&gt;
 └─sdX2            0:2    0    30G  0 part  /mnt/sdX2&lt;br /&gt;
 &lt;br /&gt;
 # blkid&lt;br /&gt;
 /dev/sdX1: LABEL=&amp;quot;some&amp;quot; UUID=&amp;quot;...&amp;quot; TYPE=&amp;quot;vfat&amp;quot;&lt;br /&gt;
 /dev/sdX2: LABEL=&amp;quot;other&amp;quot; UUID=&amp;quot;...&amp;quot; TYPE=&amp;quot;ext4&amp;quot;&lt;br /&gt;
&lt;br /&gt;
For example, if /dev/sdX is the desired target device, first make sure you un-mount all mounted partitions of the target device. For example sdX1 and sdX2:&lt;br /&gt;
&lt;br /&gt;
 umount  /dev/sdX1  /dev/sdX2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;&#039;s output-file (&amp;lt;code&amp;gt;of=&amp;lt;/code&amp;gt;), however, do &#039;&#039;&#039;not&#039;&#039;&#039; specify a partition number. For example, write to sdX, &#039;&#039;&#039;not&#039;&#039;&#039; sdX1:&lt;br /&gt;
&lt;br /&gt;
Warning: &#039;&#039;&#039;This will overwrite the target device /dev/sdX&#039;&#039;&#039;, so before executing, make sure you have a backup of the data if you can&#039;t afford to lose it.&lt;br /&gt;
&lt;br /&gt;
 dd if=~/Downloads/alpine-standard-3.00.0-x86_64.iso of=/dev/sdX bs=4M oflag=sync status=progress; eject /dev/sdX&lt;br /&gt;
&lt;br /&gt;
==== Windows ====&lt;br /&gt;
&lt;br /&gt;
For example, there is the [https://rufus.ie/ Rufus] program. Rufus will enable you to create bootable USB flash drives under Windows. &lt;br /&gt;
&lt;br /&gt;
Rufus has been tested and works for Alpine Linux 3.12.x with the following settings:&lt;br /&gt;
* &#039;&#039;&#039;Partition scheme&#039;&#039;&#039;: &amp;lt;code&amp;gt;MBR&amp;lt;/code&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;Target system&#039;&#039;&#039;: &amp;lt;code&amp;gt;BIOS or UEFI&amp;lt;/code&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;File system&#039;&#039;&#039;: &amp;lt;code&amp;gt;FAT32&amp;lt;/code&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;Cluster size&#039;&#039;&#039;: &amp;lt;code&amp;gt;4096 bytes (default)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===  Verifying the written installation media ===&lt;br /&gt;
&lt;br /&gt;
After detaching and re-attaching the device, a bit-wise comparison can verify the data written to the device (instead of just data buffered in RAM). If the comparison terminates with an end-of-file error on the .iso file side, all the contents from the image have been written (and re-read) successfully:&lt;br /&gt;
&lt;br /&gt;
 # cmp ~/Downloads/alpine-standard-3.00.0-x86_64.iso /dev/sdX&lt;br /&gt;
 cmp: EOF on alpine-standard-3.00.0-x86_64.iso&lt;br /&gt;
&lt;br /&gt;
=== Booting from external devices ===&lt;br /&gt;
&lt;br /&gt;
Insert the boot media to a proper drive or port of the computer and turn the machine on, or restart it, if already running.&lt;br /&gt;
&lt;br /&gt;
If the computer does not automatically boot from the desired device, one needs to bring up the boot menu and choose the media to boot from. Depending on the computer, the menu may be accessed by repeatedly pressing a key quickly when booting starts. Some computers require that you press the button &#039;&#039;before&#039;&#039; starting the computer and hold it down while the computer boots. Typical keys are:  `F9`-`F12`, sometimes `F7` or `F8`. If these don&#039;t bring up the boot menu, it may be necessary to enter the BIOS configuration and adjust the boot settings, for which typical keys are: `Del.` `F1` `F2` `F6` or `Esc.`&lt;br /&gt;
&lt;br /&gt;
=== Custom partitioning of the harddisk ===&lt;br /&gt;
&lt;br /&gt;
It is possible to specify configurations for RAID, encryption, LVM, etc. as well as manual partitioning.&lt;br /&gt;
&lt;br /&gt;
For &amp;quot;diskless&amp;quot; or &amp;quot;data disk&amp;quot; mode installs, manual partitioning may be needed to prepare the harddisk for committing local backups of the system state with &amp;lt;code&amp;gt;[[Alpine_local_backup|lbu commit]]&amp;lt;/code&amp;gt;, to have a place for a package cache, or to use it for a /var mount. &lt;br /&gt;
&lt;br /&gt;
For a &amp;quot;sys&amp;quot; install, custom partitioning is needed only if the desired scheme differs from overwriting an entire disk, or using the default set of a /boot, swap and root partition on the disk.&lt;br /&gt;
&lt;br /&gt;
See [[Setting_up_disks_manually]] for the alpine options for RAID, encryption, LVM, etc. and manual partitioning.&lt;br /&gt;
&lt;br /&gt;
=== Questions asked by &amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt; ===&lt;br /&gt;
[[File:Installation-alpine-alpine-setup-3-setup-scripts.png|350px|thumb|right|Example &amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt; session]]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;[[setup-alpine]]&amp;lt;/code&amp;gt; script offers the following configuration options:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Keyboard Layout&#039;&#039;&#039; (Local keyboard language and usage mode, e.g. &#039;&#039;us&#039;&#039; and variant of &#039;&#039;us-nodeadkeys&#039;&#039;.)&lt;br /&gt;
* &#039;&#039;&#039;Hostname&#039;&#039;&#039; (The name for the computer.)&lt;br /&gt;
* &#039;&#039;&#039;Network&#039;&#039;&#039; (For example, automatic IP address discovery with the &amp;quot;DHCP&amp;quot; protocol.)&lt;br /&gt;
* &#039;&#039;&#039;DNS Servers&#039;&#039;&#039; (Domain Name Servers to query. For privacy reasons it is NOT recommended to route every local request to servers like google&#039;s &amp;lt;s&amp;gt;8.8.8.8&amp;lt;/s&amp;gt; .)&lt;br /&gt;
* &#039;&#039;&#039;Timezone&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Proxy&#039;&#039;&#039; (Proxy server to use for accessing the web. Use &amp;quot;none&amp;quot; for direct connections to the internet.)&lt;br /&gt;
* &#039;&#039;&#039;Mirror&#039;&#039;&#039; (From where to download packages. Choose the organization you trust giving your usage patterns to.)&lt;br /&gt;
* &#039;&#039;&#039;SSH&#039;&#039;&#039; (Secure SHell remote access server. &amp;quot;Openssh&amp;quot; is part of the default install image. Use &amp;quot;none&amp;quot; to disable remote login, e.g. on laptops.)&lt;br /&gt;
* &#039;&#039;&#039;NTP&#039;&#039;&#039; (Network Time Protocol client used for keeping the system clock in sync with a time server. Package &amp;quot;chrony&amp;quot; is part of the default install image.)&lt;br /&gt;
* &#039;&#039;&#039;Disk Mode&#039;&#039;&#039; (Select between diskless (disk=&amp;quot;none&amp;quot;), &amp;quot;data&amp;quot; or &amp;quot;sys&amp;quot;, as described above.) &lt;br /&gt;
  {{Warning|The data on a chosen device will be overwritten!}}&lt;br /&gt;
&lt;br /&gt;
=== Preparing for the first boot ===&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt; has finished configuring the &amp;quot;sys&amp;quot; disk mode, the system should be ready to reboot right away (see next subsection).&lt;br /&gt;
&lt;br /&gt;
If the new local system was configured to run in &amp;quot;diskless&amp;quot; or &amp;quot;data&amp;quot; mode, and you do not want keep booting from the initial (and possibly read-only) installation media, the boot system needs to be copied to another device or partition.&lt;br /&gt;
&lt;br /&gt;
The target partition may be identified using &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;lsblk&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; (after installing it with &amp;lt;code&amp;gt;apk add lsblk&amp;lt;/code&amp;gt;) and/or &amp;lt;code&amp;gt;blkid&amp;lt;/code&amp;gt;, similar to previously identifying the initial installation media device.&lt;br /&gt;
&lt;br /&gt;
The procedure to copy the boot system is explained at &amp;lt;code&amp;gt;[[Alpine_setup_scripts#setup-bootable|setup-bootable]]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once everything is in place, save your customized configuration with &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt; before rebooting.&lt;br /&gt;
&lt;br /&gt;
=== Rebooting and testing the new system ===&lt;br /&gt;
&lt;br /&gt;
First, remove the initial installation media from the boot drive, or detach it fron the port it&#039;s connected to.&lt;br /&gt;
&lt;br /&gt;
The system may now be power-cycled or rebooted to confirm everything is working correctly.&lt;br /&gt;
&lt;br /&gt;
The relevant commands for this are &amp;lt;code&amp;gt;poweroff&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;reboot&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Completing the installation ===&lt;br /&gt;
&lt;br /&gt;
The installation script installs only the base operating system. &#039;&#039;&#039;No&#039;&#039;&#039; applications e.g. web server, mail server, desktop environment, or web browser are installed, and &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; is the only user.&lt;br /&gt;
&lt;br /&gt;
Please look under &amp;quot;Post-Install&amp;quot; below, for some common things to do after installation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Further Installation Instructions =&lt;br /&gt;
&lt;br /&gt;
{{Note| Specific topics should be kept on separate, individually manageable topic-pages and only get listed with a direct reference (link) on this general page.}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
&lt;br /&gt;
* [[Kernels]] &#039;&#039;(kernel selection, e.g. for VMs or RPi)&#039;&#039;&lt;br /&gt;
* [[How to make a custom ISO image with mkimage]] &#039;&#039;(installation media with its own configuration)&#039;&#039;&lt;br /&gt;
* [[Directly booting an ISO file]] &#039;&#039;(without flashing it to a disk or device)&#039;&#039;&lt;br /&gt;
* [[Dualbooting|Dual/multi-boot install to HDD partition]]&lt;br /&gt;
* [[Netboot Alpine Linux using iPXE]]&lt;br /&gt;
Also see other [[:Category:Installation|Installation Category]] pages.&lt;br /&gt;
&lt;br /&gt;
=== Post-Installation ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- COMMENT FOR EDITORS&lt;br /&gt;
&lt;br /&gt;
If you edit Post-Install,&lt;br /&gt;
&lt;br /&gt;
  * Consider that there are already [[Tutorials_and_Howtos#Post-Install]], [[Developer_Documentation#Package_management]] and the Handbook, please work towards reducing duplication and providing an overview, and maintaining topic details of considerable size on their own pages.&lt;br /&gt;
  * Here, only the most relevant jumping off points are listed, not exact list duplicates!!!&lt;br /&gt;
  * Keep short-list of links here, as overview to more detailed topic specific pages.&lt;br /&gt;
  * Don&#039;t aggregate different topics at yet another place.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* [[Setting up a new user]] &#039;&#039;(to allow remote, console, or graphical logins)&#039;&#039;&lt;br /&gt;
* [[Tutorials_and_Howtos#Networking|Setting up Networking]] &#039;&#039;(including non-standard configurations)&#039;&#039;&lt;br /&gt;
* [[Package_management|Package Management (apk)]] &#039;&#039;(how to search/add/del packages etc.)&#039;&#039;&lt;br /&gt;
** [[Package_management#Upgrade_a_Running_System|Upgrading Alpine]] &#039;&#039;(checking for and installing updates)&#039;&#039;&lt;br /&gt;
** [[Repositories#Enabling_the_community_repository|Enabling the community repository]] &#039;&#039;(access to additional packages)&#039;&#039;&lt;br /&gt;
* [[FAQ#Why_don.27t_I_have_man_pages_or_where_is_the_.27man.27_command.3F|man command/man pages]]&lt;br /&gt;
* [[Change default shell]]&lt;br /&gt;
* [[Running glibc programs]] &#039;&#039;(installation and development)&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Alpine_local_backup|Local backup utility &amp;lt;code&amp;gt;lbu&amp;lt;/code&amp;gt;]] &#039;&#039;(persisting RAM system configurations)&#039;&#039;&lt;br /&gt;
** [[Back Up a Flash Memory Installation]] &#039;&#039;(&amp;quot;diskless mode&amp;quot; systems)&#039;&#039;&lt;br /&gt;
** [[Manually_editing_a_existing_apkovl]] &#039;&#039;(the stored custom configs)&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[OpenRC|Init System (OpenRC)]] &#039;&#039;(configure a service to automatically boot at next reboot)&#039;&#039;&lt;br /&gt;
** [[Writing Init Scripts]]&lt;br /&gt;
** [[Multiple Instances of Services]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Alpine setup scripts#setup-xorg-base|&amp;lt;code&amp;gt;setup-xorg-base&amp;lt;/code&amp;gt;]] &#039;&#039;(setup graphical base environment)&#039;&#039;&lt;br /&gt;
** [[Tutorials_and_Howtos#Desktop|Desktop Environments]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Hosting services on Alpine]] &#039;&#039;(links to several mail/web/ssh server setup pages)&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[How to get regular stuff working]] &#039;&#039;(things one may miss in a too lightweight installation )&#039;&#039;&lt;br /&gt;
* Running applications and services in their own [[Firejail Security Sandbox]]&lt;br /&gt;
&lt;br /&gt;
=== Broader Usage Guides ===&lt;br /&gt;
&lt;br /&gt;
* See: [[Tutorials and Howtos]]&lt;br /&gt;
&lt;br /&gt;
= General Documentation =&lt;br /&gt;
&lt;br /&gt;
{{Tip| Alpine Linux packages stay close to the upstream design. Therefore, all upstream documentation about configuring a software package, as well as good configuration guides from other distributions that stay close to upstream, e.g. those in the [https://wiki.archlinux.org/ Arch Wiki], are to a large degree, also applicable to configuring the software on Alpine Linux, thus can be very useful.}}&lt;br /&gt;
&lt;br /&gt;
* [[FAQ|FAQs]]&lt;br /&gt;
&lt;br /&gt;
* [[Contribute|How to Contribute]]&lt;br /&gt;
* [[Developer Documentation]]&lt;br /&gt;
* [[Alpine_Linux:Wiki_etiquette|Wiki etiquette]] &#039;&#039;(to collaborate on this documentation)&#039;&#039;&lt;br /&gt;
* [[Comparison with other distros]] &#039;&#039;(how common things are done on Alpine)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Garo</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_local_backup&amp;diff=22676</id>
		<title>Alpine local backup</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_local_backup&amp;diff=22676"/>
		<updated>2022-11-19T18:32:32Z</updated>

		<summary type="html">&lt;p&gt;Garo: /* Saving and loading ISO image customizations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;When Alpine Linux boots in diskless mode, it initially only loads a few required packages from the boot device.&lt;br /&gt;
&lt;br /&gt;
However, local adjustments to what-gets-loaded-into-RAM are possible, e.g. by [[Alpine_Package_Keeper|installing a package]] or adjusting the configuration files in {{path|/etc}}. The modifications can be saved to an overlay file (.apkovl) that can be automatically loaded when booting, to restore the saved state.&lt;br /&gt;
&lt;br /&gt;
The .apkovl file that contains the custom configuration can be saved to writable storage with Alpine&#039;s local backup utility &amp;lt;code&amp;gt;lbu&amp;lt;/code&amp;gt;. By configuring a [[Alpine_Linux_package_management#Local_Cache|local package cache]] the additional packages the configuration depends on, can also be kept available on local, writable storage.&lt;br /&gt;
&lt;br /&gt;
{{Note|If you installed Alpine in &amp;quot;sys&amp;quot; disk mode, you don&#039;t need to use &amp;lt;code&amp;gt;lbu&amp;lt;/code&amp;gt; to save the system state. With a system disk, all modifications are&lt;br /&gt;
written directly to disk. Nevertheless, &amp;lt;code&amp;gt;lbu&amp;lt;/code&amp;gt; can be useful for some maintenance tasks.}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Warning|&lt;br /&gt;
&#039;&#039;&#039;By default, an &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt; only stores modifications below {{Path|/etc}}&#039;&#039;&#039;, with the exception of the {{Path|/etc/init.d/}} directory.&lt;br /&gt;
&lt;br /&gt;
However, [[#Include_special_files.2Ffolders_to_the_apkovl|lbu include]] enables modifying that set of included files, and can be used to specify additional files or folders.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Saving and loading ISO image customizations ==&lt;br /&gt;
&lt;br /&gt;
Besides supporting a boot parameter to load customizations from a web server, Alpine&#039;s &amp;quot;diskless mode&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
{{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.}}&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
To use partitions on &#039;&#039;&#039;internal disks&#039;&#039;&#039;, however, you need to prepare a specific /etc/fstab entry manually, and save the configuration, as follows (setup-alpine does not list them for saving configs or package cache):&lt;br /&gt;
&lt;br /&gt;
1. Boot the diskless system from ISO (as shown at [[Installation]])&amp;lt;br&amp;gt;&lt;br /&gt;
2. If necessary, create and format a partition as explained in [[Setting_up_disks_manually#For_.22diskless.22_and_.22data.22_disk_mode_installs_2|&amp;quot;Setting up disks manually, for diskless and data disk mode installs&amp;quot;]]. For the examples we will use /dev/sdXY&amp;lt;br&amp;gt;&lt;br /&gt;
* 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. &amp;lt;code&amp;gt;mkdir -p /boot/ovl_dev/cache ; touch /boot/ovl_dev/cache/.boot_repository&amp;lt;/code&amp;gt;)&amp;lt;br&amp;gt;&lt;br /&gt;
=&amp;gt; Alternative: Configure the /etc/fstab to mount the writable partition to /media/sdXY instead of /boot (i.e. conforming to the hot/cold-plug mountpoints):&amp;lt;br&amp;gt;&lt;br /&gt;
3. &amp;lt;code&amp;gt;mkdir /media/sdXY&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
4. &amp;lt;code&amp;gt;echo &amp;quot;/dev/sdXY /media/sdXY ext4 noatime,ro 0 0&amp;quot; &amp;gt;&amp;gt; /etc/fstab&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; (Mounting read-only is possible, because the tools temporarily remount it writable for their operation.)&amp;lt;br&amp;gt;&lt;br /&gt;
5. Use &amp;lt;code&amp;gt;mount -a&amp;lt;/code&amp;gt; to load the partitions listed in /etc/fstab. Look at the output of &amp;lt;code&amp;gt;mount&amp;lt;/code&amp;gt; to verify that the /etc/fstab changes have been applied correctly.&amp;lt;br&amp;gt;&lt;br /&gt;
6. 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.)&amp;lt;br&amp;gt;&lt;br /&gt;
If setup-alpine has already been used to configure the diskless system, the storage settings may be modified directly with &amp;lt;code&amp;gt;setup-lbu sdXY&amp;lt;/code&amp;gt; and  &amp;lt;code&amp;gt;mkdir /media/sdXY/cache ; setup-apkcache /media/sdXY/cache&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
7. If the partition is large enough, it can be useful to edit lbu.conf to uncomment and set &amp;lt;code&amp;gt;BACKUP_LIMIT=3&amp;lt;/code&amp;gt;. For example, to allow reverting to a previous, working state if needed.&lt;br /&gt;
{{cmd| # apk add nano&lt;br /&gt;
 # nano /etc/lbu/lbu.conf&lt;br /&gt;
}}&lt;br /&gt;
8. Finally, generate the first .apkovl file containing all the previous changes by executing &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt;, so the customizations that were just made will persist a reboot.&lt;br /&gt;
&lt;br /&gt;
From then on, whenever packages are installed or newly configured, and the changes should be kept, execute &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt; again.&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
&lt;br /&gt;
* For a virtual machine, the &#039;&#039;&#039;[[QEMU#Live_mode|QEMU example]]&#039;&#039;&#039; shows how an ISO image can automatically boot with .apkovl customizations.&lt;br /&gt;
* The [[Alpine_local_backup#Include_special_files.2Ffolders_to_the_apkovl|Include special files section]] explains how to include custom files outside of &amp;lt;code&amp;gt;/etc&amp;lt;/code&amp;gt; in the .apkovl file.&lt;br /&gt;
* [[Alpine_Linux_package_management#Local_Cache]] covers managing a local package cache.&lt;br /&gt;
** The packages get listed in /etc/apk/world which gets saved with the lbu, for them to be automatically installed when the live system boots.&lt;br /&gt;
* It&#039;s possible to load an APKOVL file from a webserver, by supplying a custom url with the &amp;lt;code&amp;gt;APKOVL&amp;lt;/code&amp;gt; kernel boot parameter.&lt;br /&gt;
** If you don&#039;t have a web server you can run busybox&#039;s httpd temporarily to serve an .apkovl - &amp;lt;code&amp;gt;busybox httpd -p 127.0.0.1:80&amp;lt;/code&amp;gt;.&lt;br /&gt;
* To customize the boot sequence further, one may refer to [[PXE_boot#Specifying_an_apkovl]] and [[How_to_make_a_custom_ISO_image_with_mkimage]].&lt;br /&gt;
&lt;br /&gt;
== Committing changes ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;lbu&amp;lt;/code&amp;gt; tool has several subcommands to manage the .apkovl:&lt;br /&gt;
* lbu&lt;br /&gt;
* lbu commit &#039;&#039;(Same as &#039;lbu ci&#039;)&#039;&#039;&lt;br /&gt;
* lbu package &#039;&#039;(Same as &#039;lbu pkg&#039;)&#039;&#039;&lt;br /&gt;
* lbu status &#039;&#039;(Same as &#039;lbu st&#039;)&#039;&#039;&lt;br /&gt;
* lbu list &#039;&#039;(Same as &#039;lbu ls&#039;)&#039;&#039;&lt;br /&gt;
* lbu diff&lt;br /&gt;
* lbu include &#039;&#039;(Same as &#039;lbu inc&#039; or &#039;lbu add&#039;)&#039;&#039;&lt;br /&gt;
* lbu exclude &#039;&#039;(Same as &#039;lbu ex&#039; or &#039;lbu delete&#039;)&#039;&#039;&lt;br /&gt;
* lbu list-backup &#039;&#039;(Same as &#039;lbu lb&#039;)&#039;&#039;&lt;br /&gt;
* lbu revert&lt;br /&gt;
&lt;br /&gt;
In the examples below, you will find some characters with special meaning:&lt;br /&gt;
* &#039;&#039;&#039;|&#039;&#039;&#039; = &#039;&#039;&#039;or&#039;&#039;&#039; &#039;&#039;(&#039;lbu commit|ci&#039; means that you can type ether &#039;lbu commit&#039; or &#039;lbu ci&#039;)&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;[ ]&#039;&#039;&#039; = &#039;&#039;&#039;optional&#039;&#039;&#039; &#039;&#039;(In &#039;lbu commit|ci [-nv]&#039; you can skip the &#039;-n&#039;, &#039;-v&#039; or &#039;-nv&#039; part if you don&#039;t want it)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Basic &amp;quot;commit&amp;quot; command ===&lt;br /&gt;
When you &amp;quot;commit&amp;quot; or save changes you&#039;ve made to your system, &amp;lt;code&amp;gt;lbu&amp;lt;/code&amp;gt; will generate a file named something like {{Path|&amp;lt;var&amp;gt;myboxname&amp;lt;/var&amp;gt;.apkovl.tar.gz}} &#039;&#039;(&#039;myboxname&#039; will be the same as the hostname)&#039;&#039;.&lt;br /&gt;
The file (which contains your modifications) is called your &amp;quot;apkovl&amp;quot;.&lt;br /&gt;
You will need to save your apkovl on suitable media (floppy, usb, cf, etc.).&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
usage: lbu commit|ci [-nv] [&amp;lt;media&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
  -d	Remove old apk overlay files.&lt;br /&gt;
  -e	Protect configuration with a password.&lt;br /&gt;
  -n	Don&#039;t commit, just show what would have been committed.&lt;br /&gt;
  -p &amp;lt;password&amp;gt;	Give encryption password on the command-line&lt;br /&gt;
  -v	Verbose mode.&lt;br /&gt;
&lt;br /&gt;
The following values for &amp;lt;media&amp;gt; are supported: floppy usb&lt;br /&gt;
If &amp;lt;media&amp;gt; is not specified, the environment variable LBU_MEDIA will be used.&lt;br /&gt;
&lt;br /&gt;
Password protection will use aes-256-cbc encryption. Other ciphers can be&lt;br /&gt;
used by setting the DEFAULT_CIPHER or ENCRYPTION environment variables.&lt;br /&gt;
For possible ciphers, try: openssl -v&lt;br /&gt;
&lt;br /&gt;
The password used to encrypt the file, can be specified with the -p&lt;br /&gt;
option or by using the PASSWORD environment variable.&lt;br /&gt;
&lt;br /&gt;
The environment variable can also be set in /etc/lbu/lbu.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Creating an .apkovl &amp;quot;package&amp;quot; elsewhere than on the configured media ===&lt;br /&gt;
&lt;br /&gt;
To &amp;quot;commit&amp;quot; changes, but override the destination of the generated apkovl file, use &amp;lt;code&amp;gt;lbu package&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
usage: lbu package|pkg -v [&amp;lt;dirname&amp;gt;|&amp;lt;filename&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
  -v   Verbose mode.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;dirname&amp;gt; is a directory, a package named &amp;lt;hostname&amp;gt;.apkovl.tar.gz will&lt;br /&gt;
be created in the specified directory.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;filename&amp;gt; is specified, and is not a directory, a package with the&lt;br /&gt;
specified name will be created.&lt;br /&gt;
&lt;br /&gt;
If neither &amp;lt;dirname&amp;gt; nor &amp;lt;filename&amp;gt; is specified, a package named&lt;br /&gt;
&amp;lt;hostname&amp;gt;.apkovl.tar.gz will be created in the current working directory.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Creating and saving an apkovl from a remote host ===&lt;br /&gt;
&lt;br /&gt;
To create an apkovl from a client on a remote server, it&#039;s possible to use &amp;lt;code&amp;gt;lbu package&amp;lt;/code&amp;gt; via SSH with {{Path|-}} as the apkovl name:&lt;br /&gt;
&lt;br /&gt;
On the server:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ssh root@client &amp;quot;lbu package -&amp;quot; &amp;gt;client.apkovl.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Checking what will be added to your apkovl ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;lbu status&amp;lt;/code&amp;gt; lists what will be saved the next time you run &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt;. Its default output is incremental, that is, it shows&lt;br /&gt;
only the files that have changed since the last commit. &amp;lt;br&amp;gt;&lt;br /&gt;
This can be overridden with the &amp;lt;code&amp;gt;-a&amp;lt;/code&amp;gt; flag:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
usage: lbu status|st [-av]&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
  -a    Compare all files, not just since last commit.&lt;br /&gt;
  -v    show include and exclude lists.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another option is &amp;lt;code&amp;gt;lbu list&amp;lt;/code&amp;gt;. This works like &amp;lt;code&amp;gt;lbu status -a&amp;lt;/code&amp;gt; but the format of the output is a bit different. (It&#039;s strictly equivalent to &amp;lt;code&amp;gt;lbu package -v /dev/null&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
 usage: lbu list|ls&lt;br /&gt;
&lt;br /&gt;
A third option is &amp;lt;code&amp;gt;lbu diff&amp;lt;/code&amp;gt;. This shows the same incremental changes that &amp;lt;code&amp;gt;lbu status&amp;lt;/code&amp;gt; (without &amp;lt;code&amp;gt;-a&amp;lt;/code&amp;gt;) does, but in a different format.&lt;br /&gt;
&lt;br /&gt;
  usage: lbu diff&lt;br /&gt;
&lt;br /&gt;
== Include special files/folders to the apkovl ==&lt;br /&gt;
Assume you have some files you want to save permanently, but they are not located in {{Path|/etc}}.&amp;lt;BR&amp;gt;&lt;br /&gt;
e.g. {{Path|/root/.ssh/authorized_keys}} (used by &amp;lt;code&amp;gt;sshd&amp;lt;/code&amp;gt; to authenticate ssh-users). Such files/folders can be added to lbu&#039;s &#039;&#039;include&#039;&#039; list with the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
usage: lbu include|inc|add [-rv] &amp;lt;file&amp;gt; ...&lt;br /&gt;
       lbu include|inc|add [-v] -l&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
  -l	List contents of include list.&lt;br /&gt;
  -r	Remove specified file(s) from include list.&lt;br /&gt;
  -v	Verbose mode.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|This information used to be maintained in {{Path|/etc/lbu/include}}. Now it&#039;s maintained together with the &#039;&#039;exclude&#039;&#039; list in {{Path|/etc/apk/protected_paths.d/lbu.list}}. Either way, the command &amp;lt;code&amp;gt;lbu include&amp;lt;/code&amp;gt; only modifies lbu&#039;s configuration.&lt;br /&gt;
You will need to run &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt; to actually create/modify your apkovl.}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Exclude specific files/folders from the apkovl ==&lt;br /&gt;
Assume you have some files located in {{Path|/etc}} or one of its subfolders you &#039;&#039;do not&#039;&#039; want to save.&lt;br /&gt;
It could be a log file or status file that for some reason isn&#039;t in {{Path|/var/log/}} but in a location that would otherwise be tracked by &amp;lt;code&amp;gt;lbu&amp;lt;/code&amp;gt;.&lt;br /&gt;
Such files/folders can be added to lbu&#039;s &#039;&#039;exclude&#039;&#039; list by manually editing the file or using the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
usage: lbu exclude|ex|delete [-rv] &amp;lt;file&amp;gt; ...&lt;br /&gt;
       lbu exclude|ex|delete [-v] -l&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
  -l	List contents of exclude list.&lt;br /&gt;
  -r	Remove specified file(s) from exclude list.&lt;br /&gt;
  -v	Verbose mode.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{Note|As stated above, this information is now maintained in {{Path|/etc/apk/protected_paths.d/lbu.list}}. The command &amp;lt;code&amp;gt;lbu exclude&amp;lt;/code&amp;gt; also only modifies lbu&#039;s configuration. &amp;lt;br&amp;gt;&lt;br /&gt;
You will need to run &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt; to actually create/modify your apkovl.}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Execute a script as part of a backup ==&lt;br /&gt;
&lt;br /&gt;
Sometimes it&#039;s necessary to run a script before or after a backup.  Scripts in two optional directories enable that:&lt;br /&gt;
&lt;br /&gt;
 /etc/lbu/pre-package.d&lt;br /&gt;
 /etc/lbu/post-package.d&lt;br /&gt;
&lt;br /&gt;
Files in those directories are run using run-script rules (meaning they must have the executable bit set, they are run in alphabetical order, and cannot contain an extension. e.g. {{Path|runme}} works, but {{Path|runme.sh}} does not. Also the shebang line on the first line should be indicated, e.g. #!/bin/sh .)&lt;br /&gt;
&lt;br /&gt;
The scripts in {{Path|pre-package.d}} are run before apkovl is created. Scripts in {{Path|post-package.d}} are run after apkovl is created.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&lt;br /&gt;
Rather than adding the raw database directories to {{Path|/etc/lbu/include}}, you can do a &amp;quot;database dump&amp;quot;.    e.g. {{Pkg|postgresql}}:&lt;br /&gt;
&lt;br /&gt;
* Create {{Path|/etc/lbu/pre-package.d/sqldump}} with the following contents: &amp;lt;pre&amp;gt;pg_dumpall -U postgres | gzip -c &amp;gt;/root/pgdatabases.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Mark the file executable: &amp;lt;code&amp;gt;chmod +x /etc/lbu/pre-package.d/sqldump&amp;lt;/code&amp;gt;&lt;br /&gt;
* Create {{Path|/etc/lbu/post-package.d/sqldumpdelete}} with the following contents: &amp;lt;pre&amp;gt;rm -f /root/pgdatabases.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Mark the file executable: &amp;lt;code&amp;gt;chmod +x /etc/lbu/post-package.d/sqldumpdelete&amp;lt;/code&amp;gt;&lt;br /&gt;
* Finally, add the database dump file to the list of files to back up: &amp;lt;code&amp;gt;lbu include root/pgdatabases.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now when you do a &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt;, the sql databases are dumped and gzipped to {{Path|/root/pgdatabases.gz}}.&lt;br /&gt;
The temporary file is deleted at the end of the lbu commit.&lt;br /&gt;
&lt;br /&gt;
On a catastrophic restore, the databases are not automatically restored (that&#039;s not lbu&#039;s job), but you will find a complete database dump in the {{Path|/root}} directory, where it can be restored manually.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
P.s. These scripts are also launched when starting the commands: diff, list-backup, package, revert, status.&lt;br /&gt;
&lt;br /&gt;
== Multiple backup versions ==&lt;br /&gt;
Lbu can now keep multiple backups so you can revert back to older configurations.&lt;br /&gt;
Set BACKUP_LIMIT in {{Path|/etc/lbu/lbu.conf}} to the number of backups you want&lt;br /&gt;
to keep.&lt;br /&gt;
&lt;br /&gt;
If you&#039;ve set BACKUP_LIMIT, then the previously active .apkovl will be renamed before creating the new file.&lt;br /&gt;
&lt;br /&gt;
You can list the currently available backups with:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|lbu list-backup [&amp;lt;media&amp;gt;]}}&lt;br /&gt;
&lt;br /&gt;
and you can revert to an older one with:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|lbu revert &amp;lt;filename&amp;gt; [&amp;lt;media&amp;gt;]}}&lt;br /&gt;
&lt;br /&gt;
NOTE: Nothing is changed on your running system when &amp;quot;reverting&amp;quot;, it only affects which apkovl is considered active at the next boot.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Back Up a Flash Memory Installation]]&lt;br /&gt;
* [[Manually editing a existing apkovl]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Booting]]&lt;br /&gt;
[[Category:Package Manager]]&lt;br /&gt;
[[category: LBU]]&lt;/div&gt;</summary>
		<author><name>Garo</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_local_backup&amp;diff=22675</id>
		<title>Alpine local backup</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_local_backup&amp;diff=22675"/>
		<updated>2022-11-19T18:16:48Z</updated>

		<summary type="html">&lt;p&gt;Garo: /* Saving and loading ISO image customizations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;When Alpine Linux boots in diskless mode, it initially only loads a few required packages from the boot device.&lt;br /&gt;
&lt;br /&gt;
However, local adjustments to what-gets-loaded-into-RAM are possible, e.g. by [[Alpine_Package_Keeper|installing a package]] or adjusting the configuration files in {{path|/etc}}. The modifications can be saved to an overlay file (.apkovl) that can be automatically loaded when booting, to restore the saved state.&lt;br /&gt;
&lt;br /&gt;
The .apkovl file that contains the custom configuration can be saved to writable storage with Alpine&#039;s local backup utility &amp;lt;code&amp;gt;lbu&amp;lt;/code&amp;gt;. By configuring a [[Alpine_Linux_package_management#Local_Cache|local package cache]] the additional packages the configuration depends on, can also be kept available on local, writable storage.&lt;br /&gt;
&lt;br /&gt;
{{Note|If you installed Alpine in &amp;quot;sys&amp;quot; disk mode, you don&#039;t need to use &amp;lt;code&amp;gt;lbu&amp;lt;/code&amp;gt; to save the system state. With a system disk, all modifications are&lt;br /&gt;
written directly to disk. Nevertheless, &amp;lt;code&amp;gt;lbu&amp;lt;/code&amp;gt; can be useful for some maintenance tasks.}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Warning|&lt;br /&gt;
&#039;&#039;&#039;By default, an &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt; only stores modifications below {{Path|/etc}}&#039;&#039;&#039;, with the exception of the {{Path|/etc/init.d/}} directory.&lt;br /&gt;
&lt;br /&gt;
However, [[#Include_special_files.2Ffolders_to_the_apkovl|lbu include]] enables modifying that set of included files, and can be used to specify additional files or folders.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Saving and loading ISO image customizations ==&lt;br /&gt;
&lt;br /&gt;
Besides supporting a boot parameter to load customizations from a web server, Alpine&#039;s &amp;quot;diskless mode&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
{{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.}}&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
To use partitions on &#039;&#039;&#039;internal disks&#039;&#039;&#039;, however, you need to prepare a specific /etc/fstab entry manually, and save the configuration, as follows (setup-alpine does not list them for saving configs or package cache):&lt;br /&gt;
&lt;br /&gt;
1. Boot the diskless system from ISO (as shown at [[Installation]])&amp;lt;br&amp;gt;&lt;br /&gt;
2. If necessary, create and format a partition as explained in [[Setting_up_disks_manually#For_.22diskless.22_and_.22data.22_disk_mode_installs_2|&amp;quot;Setting up disks manually, for diskless and data disk mode installs&amp;quot;]]. For the examples we will use /dev/sdXY&amp;lt;br&amp;gt;&lt;br /&gt;
* 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. &amp;lt;code&amp;gt;mkdir -p /boot/ovl_dev/cache ; touch /boot/ovl_dev/cache/.boot_repository&amp;lt;/code&amp;gt;)&amp;lt;br&amp;gt;&lt;br /&gt;
=&amp;gt; Alternative: Configure the /etc/fstab to mount the writable partition to /media/sdXY instead of /boot (i.e. conforming to the hot/cold-plug mountpoints):&amp;lt;br&amp;gt;&lt;br /&gt;
3. &amp;lt;code&amp;gt;mkdir /media/sdXY&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
4. &amp;lt;code&amp;gt;echo &amp;quot;/dev/sdXY /media/sdXY ext4 noatime,ro 0 0&amp;quot; &amp;gt;&amp;gt; /etc/fstab&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; (Mounting read-only is possible, because the tools temporarily remount it writable for their operation.)&amp;lt;br&amp;gt;&lt;br /&gt;
5. Use &amp;lt;code&amp;gt;mount -a&amp;lt;/code&amp;gt; to load the partitions listed in /etc/fstab. Look at the output of &amp;lt;code&amp;gt;mount&amp;lt;/code&amp;gt; to verify that the /etc/fstab changes have been applied correctly.&amp;lt;br&amp;gt;&lt;br /&gt;
6. 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.)&amp;lt;br&amp;gt;&lt;br /&gt;
If setup-alpine has already been used to configure the diskless system, the storage settings may be modified directly with &amp;lt;code&amp;gt;setup-lbu sdXY&amp;lt;/code&amp;gt; and  &amp;lt;code&amp;gt;mkdir /media/sdXY/cache ; setup-apkcache /media/sdXY/cache&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
7. If the partition is large enough, it can be useful to edit lbu.conf to uncomment and set &amp;lt;code&amp;gt;BACKUP_LIMIT=3&amp;lt;/code&amp;gt;. For example, to allow reverting to a previous, working state if needed.&lt;br /&gt;
{{cmd| # apk add nano&lt;br /&gt;
 # nano /etc/lbu/lbu.conf&lt;br /&gt;
}}&lt;br /&gt;
8. Finally, generate the first .apkovl file containing all the previous changes with [https://wiki.alpinelinux.org/wiki/Alpine_local_backup Alpine_local_backup], by executing &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt;, so the customizations that were just made will persist a reboot.&lt;br /&gt;
&lt;br /&gt;
From then on, whenever packages are installed or newly configured, and the changes should be kept, execute &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt; again.&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
&lt;br /&gt;
* For a virtual machine, the &#039;&#039;&#039;[[QEMU#Live_mode|QEMU example]]&#039;&#039;&#039; shows how an ISO image can automatically boot with .apkovl customizations.&lt;br /&gt;
* The [[Alpine_local_backup#Include_special_files.2Ffolders_to_the_apkovl|Include special files section]] explains how to include custom files outside of &amp;lt;code&amp;gt;/etc&amp;lt;/code&amp;gt; in the .apkovl file.&lt;br /&gt;
* [[Alpine_Linux_package_management#Local_Cache]] covers managing a local package cache.&lt;br /&gt;
** The packages get listed in /etc/apk/world which gets saved with the lbu, for them to be automatically installed when the live system boots.&lt;br /&gt;
* It&#039;s possible to load an APKOVL file from a webserver, by supplying a custom url with the &amp;lt;code&amp;gt;APKOVL&amp;lt;/code&amp;gt; kernel boot parameter.&lt;br /&gt;
** If you don&#039;t have a web server you can run busybox&#039;s httpd temporarily to serve an .apkovl - &amp;lt;code&amp;gt;busybox httpd -p 127.0.0.1:80&amp;lt;/code&amp;gt;.&lt;br /&gt;
* To customize the boot sequence further, one may refer to [[PXE_boot#Specifying_an_apkovl]] and [[How_to_make_a_custom_ISO_image_with_mkimage]].&lt;br /&gt;
&lt;br /&gt;
== Committing changes ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;lbu&amp;lt;/code&amp;gt; tool has several subcommands to manage the .apkovl:&lt;br /&gt;
* lbu&lt;br /&gt;
* lbu commit &#039;&#039;(Same as &#039;lbu ci&#039;)&#039;&#039;&lt;br /&gt;
* lbu package &#039;&#039;(Same as &#039;lbu pkg&#039;)&#039;&#039;&lt;br /&gt;
* lbu status &#039;&#039;(Same as &#039;lbu st&#039;)&#039;&#039;&lt;br /&gt;
* lbu list &#039;&#039;(Same as &#039;lbu ls&#039;)&#039;&#039;&lt;br /&gt;
* lbu diff&lt;br /&gt;
* lbu include &#039;&#039;(Same as &#039;lbu inc&#039; or &#039;lbu add&#039;)&#039;&#039;&lt;br /&gt;
* lbu exclude &#039;&#039;(Same as &#039;lbu ex&#039; or &#039;lbu delete&#039;)&#039;&#039;&lt;br /&gt;
* lbu list-backup &#039;&#039;(Same as &#039;lbu lb&#039;)&#039;&#039;&lt;br /&gt;
* lbu revert&lt;br /&gt;
&lt;br /&gt;
In the examples below, you will find some characters with special meaning:&lt;br /&gt;
* &#039;&#039;&#039;|&#039;&#039;&#039; = &#039;&#039;&#039;or&#039;&#039;&#039; &#039;&#039;(&#039;lbu commit|ci&#039; means that you can type ether &#039;lbu commit&#039; or &#039;lbu ci&#039;)&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;[ ]&#039;&#039;&#039; = &#039;&#039;&#039;optional&#039;&#039;&#039; &#039;&#039;(In &#039;lbu commit|ci [-nv]&#039; you can skip the &#039;-n&#039;, &#039;-v&#039; or &#039;-nv&#039; part if you don&#039;t want it)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Basic &amp;quot;commit&amp;quot; command ===&lt;br /&gt;
When you &amp;quot;commit&amp;quot; or save changes you&#039;ve made to your system, &amp;lt;code&amp;gt;lbu&amp;lt;/code&amp;gt; will generate a file named something like {{Path|&amp;lt;var&amp;gt;myboxname&amp;lt;/var&amp;gt;.apkovl.tar.gz}} &#039;&#039;(&#039;myboxname&#039; will be the same as the hostname)&#039;&#039;.&lt;br /&gt;
The file (which contains your modifications) is called your &amp;quot;apkovl&amp;quot;.&lt;br /&gt;
You will need to save your apkovl on suitable media (floppy, usb, cf, etc.).&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
usage: lbu commit|ci [-nv] [&amp;lt;media&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
  -d	Remove old apk overlay files.&lt;br /&gt;
  -e	Protect configuration with a password.&lt;br /&gt;
  -n	Don&#039;t commit, just show what would have been committed.&lt;br /&gt;
  -p &amp;lt;password&amp;gt;	Give encryption password on the command-line&lt;br /&gt;
  -v	Verbose mode.&lt;br /&gt;
&lt;br /&gt;
The following values for &amp;lt;media&amp;gt; are supported: floppy usb&lt;br /&gt;
If &amp;lt;media&amp;gt; is not specified, the environment variable LBU_MEDIA will be used.&lt;br /&gt;
&lt;br /&gt;
Password protection will use aes-256-cbc encryption. Other ciphers can be&lt;br /&gt;
used by setting the DEFAULT_CIPHER or ENCRYPTION environment variables.&lt;br /&gt;
For possible ciphers, try: openssl -v&lt;br /&gt;
&lt;br /&gt;
The password used to encrypt the file, can be specified with the -p&lt;br /&gt;
option or by using the PASSWORD environment variable.&lt;br /&gt;
&lt;br /&gt;
The environment variable can also be set in /etc/lbu/lbu.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Creating an .apkovl &amp;quot;package&amp;quot; elsewhere than on the configured media ===&lt;br /&gt;
&lt;br /&gt;
To &amp;quot;commit&amp;quot; changes, but override the destination of the generated apkovl file, use &amp;lt;code&amp;gt;lbu package&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
usage: lbu package|pkg -v [&amp;lt;dirname&amp;gt;|&amp;lt;filename&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
  -v   Verbose mode.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;dirname&amp;gt; is a directory, a package named &amp;lt;hostname&amp;gt;.apkovl.tar.gz will&lt;br /&gt;
be created in the specified directory.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;filename&amp;gt; is specified, and is not a directory, a package with the&lt;br /&gt;
specified name will be created.&lt;br /&gt;
&lt;br /&gt;
If neither &amp;lt;dirname&amp;gt; nor &amp;lt;filename&amp;gt; is specified, a package named&lt;br /&gt;
&amp;lt;hostname&amp;gt;.apkovl.tar.gz will be created in the current working directory.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Creating and saving an apkovl from a remote host ===&lt;br /&gt;
&lt;br /&gt;
To create an apkovl from a client on a remote server, it&#039;s possible to use &amp;lt;code&amp;gt;lbu package&amp;lt;/code&amp;gt; via SSH with {{Path|-}} as the apkovl name:&lt;br /&gt;
&lt;br /&gt;
On the server:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ssh root@client &amp;quot;lbu package -&amp;quot; &amp;gt;client.apkovl.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Checking what will be added to your apkovl ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;lbu status&amp;lt;/code&amp;gt; lists what will be saved the next time you run &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt;. Its default output is incremental, that is, it shows&lt;br /&gt;
only the files that have changed since the last commit. &amp;lt;br&amp;gt;&lt;br /&gt;
This can be overridden with the &amp;lt;code&amp;gt;-a&amp;lt;/code&amp;gt; flag:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
usage: lbu status|st [-av]&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
  -a    Compare all files, not just since last commit.&lt;br /&gt;
  -v    show include and exclude lists.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another option is &amp;lt;code&amp;gt;lbu list&amp;lt;/code&amp;gt;. This works like &amp;lt;code&amp;gt;lbu status -a&amp;lt;/code&amp;gt; but the format of the output is a bit different. (It&#039;s strictly equivalent to &amp;lt;code&amp;gt;lbu package -v /dev/null&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
 usage: lbu list|ls&lt;br /&gt;
&lt;br /&gt;
A third option is &amp;lt;code&amp;gt;lbu diff&amp;lt;/code&amp;gt;. This shows the same incremental changes that &amp;lt;code&amp;gt;lbu status&amp;lt;/code&amp;gt; (without &amp;lt;code&amp;gt;-a&amp;lt;/code&amp;gt;) does, but in a different format.&lt;br /&gt;
&lt;br /&gt;
  usage: lbu diff&lt;br /&gt;
&lt;br /&gt;
== Include special files/folders to the apkovl ==&lt;br /&gt;
Assume you have some files you want to save permanently, but they are not located in {{Path|/etc}}.&amp;lt;BR&amp;gt;&lt;br /&gt;
e.g. {{Path|/root/.ssh/authorized_keys}} (used by &amp;lt;code&amp;gt;sshd&amp;lt;/code&amp;gt; to authenticate ssh-users). Such files/folders can be added to lbu&#039;s &#039;&#039;include&#039;&#039; list with the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
usage: lbu include|inc|add [-rv] &amp;lt;file&amp;gt; ...&lt;br /&gt;
       lbu include|inc|add [-v] -l&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
  -l	List contents of include list.&lt;br /&gt;
  -r	Remove specified file(s) from include list.&lt;br /&gt;
  -v	Verbose mode.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|This information used to be maintained in {{Path|/etc/lbu/include}}. Now it&#039;s maintained together with the &#039;&#039;exclude&#039;&#039; list in {{Path|/etc/apk/protected_paths.d/lbu.list}}. Either way, the command &amp;lt;code&amp;gt;lbu include&amp;lt;/code&amp;gt; only modifies lbu&#039;s configuration.&lt;br /&gt;
You will need to run &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt; to actually create/modify your apkovl.}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Exclude specific files/folders from the apkovl ==&lt;br /&gt;
Assume you have some files located in {{Path|/etc}} or one of its subfolders you &#039;&#039;do not&#039;&#039; want to save.&lt;br /&gt;
It could be a log file or status file that for some reason isn&#039;t in {{Path|/var/log/}} but in a location that would otherwise be tracked by &amp;lt;code&amp;gt;lbu&amp;lt;/code&amp;gt;.&lt;br /&gt;
Such files/folders can be added to lbu&#039;s &#039;&#039;exclude&#039;&#039; list by manually editing the file or using the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
usage: lbu exclude|ex|delete [-rv] &amp;lt;file&amp;gt; ...&lt;br /&gt;
       lbu exclude|ex|delete [-v] -l&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
  -l	List contents of exclude list.&lt;br /&gt;
  -r	Remove specified file(s) from exclude list.&lt;br /&gt;
  -v	Verbose mode.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{Note|As stated above, this information is now maintained in {{Path|/etc/apk/protected_paths.d/lbu.list}}. The command &amp;lt;code&amp;gt;lbu exclude&amp;lt;/code&amp;gt; also only modifies lbu&#039;s configuration. &amp;lt;br&amp;gt;&lt;br /&gt;
You will need to run &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt; to actually create/modify your apkovl.}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Execute a script as part of a backup ==&lt;br /&gt;
&lt;br /&gt;
Sometimes it&#039;s necessary to run a script before or after a backup.  Scripts in two optional directories enable that:&lt;br /&gt;
&lt;br /&gt;
 /etc/lbu/pre-package.d&lt;br /&gt;
 /etc/lbu/post-package.d&lt;br /&gt;
&lt;br /&gt;
Files in those directories are run using run-script rules (meaning they must have the executable bit set, they are run in alphabetical order, and cannot contain an extension. e.g. {{Path|runme}} works, but {{Path|runme.sh}} does not. Also the shebang line on the first line should be indicated, e.g. #!/bin/sh .)&lt;br /&gt;
&lt;br /&gt;
The scripts in {{Path|pre-package.d}} are run before apkovl is created. Scripts in {{Path|post-package.d}} are run after apkovl is created.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&lt;br /&gt;
Rather than adding the raw database directories to {{Path|/etc/lbu/include}}, you can do a &amp;quot;database dump&amp;quot;.    e.g. {{Pkg|postgresql}}:&lt;br /&gt;
&lt;br /&gt;
* Create {{Path|/etc/lbu/pre-package.d/sqldump}} with the following contents: &amp;lt;pre&amp;gt;pg_dumpall -U postgres | gzip -c &amp;gt;/root/pgdatabases.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Mark the file executable: &amp;lt;code&amp;gt;chmod +x /etc/lbu/pre-package.d/sqldump&amp;lt;/code&amp;gt;&lt;br /&gt;
* Create {{Path|/etc/lbu/post-package.d/sqldumpdelete}} with the following contents: &amp;lt;pre&amp;gt;rm -f /root/pgdatabases.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Mark the file executable: &amp;lt;code&amp;gt;chmod +x /etc/lbu/post-package.d/sqldumpdelete&amp;lt;/code&amp;gt;&lt;br /&gt;
* Finally, add the database dump file to the list of files to back up: &amp;lt;code&amp;gt;lbu include root/pgdatabases.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now when you do a &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt;, the sql databases are dumped and gzipped to {{Path|/root/pgdatabases.gz}}.&lt;br /&gt;
The temporary file is deleted at the end of the lbu commit.&lt;br /&gt;
&lt;br /&gt;
On a catastrophic restore, the databases are not automatically restored (that&#039;s not lbu&#039;s job), but you will find a complete database dump in the {{Path|/root}} directory, where it can be restored manually.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
P.s. These scripts are also launched when starting the commands: diff, list-backup, package, revert, status.&lt;br /&gt;
&lt;br /&gt;
== Multiple backup versions ==&lt;br /&gt;
Lbu can now keep multiple backups so you can revert back to older configurations.&lt;br /&gt;
Set BACKUP_LIMIT in {{Path|/etc/lbu/lbu.conf}} to the number of backups you want&lt;br /&gt;
to keep.&lt;br /&gt;
&lt;br /&gt;
If you&#039;ve set BACKUP_LIMIT, then the previously active .apkovl will be renamed before creating the new file.&lt;br /&gt;
&lt;br /&gt;
You can list the currently available backups with:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|lbu list-backup [&amp;lt;media&amp;gt;]}}&lt;br /&gt;
&lt;br /&gt;
and you can revert to an older one with:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|lbu revert &amp;lt;filename&amp;gt; [&amp;lt;media&amp;gt;]}}&lt;br /&gt;
&lt;br /&gt;
NOTE: Nothing is changed on your running system when &amp;quot;reverting&amp;quot;, it only affects which apkovl is considered active at the next boot.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Back Up a Flash Memory Installation]]&lt;br /&gt;
* [[Manually editing a existing apkovl]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Booting]]&lt;br /&gt;
[[Category:Package Manager]]&lt;br /&gt;
[[category: LBU]]&lt;/div&gt;</summary>
		<author><name>Garo</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_local_backup&amp;diff=22674</id>
		<title>Alpine local backup</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_local_backup&amp;diff=22674"/>
		<updated>2022-11-19T18:16:24Z</updated>

		<summary type="html">&lt;p&gt;Garo: /* Saving and loading ISO image customizations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;When Alpine Linux boots in diskless mode, it initially only loads a few required packages from the boot device.&lt;br /&gt;
&lt;br /&gt;
However, local adjustments to what-gets-loaded-into-RAM are possible, e.g. by [[Alpine_Package_Keeper|installing a package]] or adjusting the configuration files in {{path|/etc}}. The modifications can be saved to an overlay file (.apkovl) that can be automatically loaded when booting, to restore the saved state.&lt;br /&gt;
&lt;br /&gt;
The .apkovl file that contains the custom configuration can be saved to writable storage with Alpine&#039;s local backup utility &amp;lt;code&amp;gt;lbu&amp;lt;/code&amp;gt;. By configuring a [[Alpine_Linux_package_management#Local_Cache|local package cache]] the additional packages the configuration depends on, can also be kept available on local, writable storage.&lt;br /&gt;
&lt;br /&gt;
{{Note|If you installed Alpine in &amp;quot;sys&amp;quot; disk mode, you don&#039;t need to use &amp;lt;code&amp;gt;lbu&amp;lt;/code&amp;gt; to save the system state. With a system disk, all modifications are&lt;br /&gt;
written directly to disk. Nevertheless, &amp;lt;code&amp;gt;lbu&amp;lt;/code&amp;gt; can be useful for some maintenance tasks.}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Warning|&lt;br /&gt;
&#039;&#039;&#039;By default, an &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt; only stores modifications below {{Path|/etc}}&#039;&#039;&#039;, with the exception of the {{Path|/etc/init.d/}} directory.&lt;br /&gt;
&lt;br /&gt;
However, [[#Include_special_files.2Ffolders_to_the_apkovl|lbu include]] enables modifying that set of included files, and can be used to specify additional files or folders.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Saving and loading ISO image customizations ==&lt;br /&gt;
&lt;br /&gt;
Besides supporting a boot parameter to load customizations from a web server, Alpine&#039;s &amp;quot;diskless mode&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
{{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.}}&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
To use partitions on &#039;&#039;&#039;internal disks&#039;&#039;&#039;, however, you need to prepare a specific /etc/fstab entry manually, and save the configuration, as follows (setup-alpine does not list them for saving configs or package cache):&lt;br /&gt;
&lt;br /&gt;
1. Boot the diskless system from ISO (as shown at [[Installation]])&amp;lt;br&amp;gt;&lt;br /&gt;
2. If necessary, create and format a partition as explained in [[Setting_up_disks_manually#For_.22diskless.22_and_.22data.22_disk_mode_installs_2|&amp;quot;Setting up_disks manually, for diskless and data disk mode installs&amp;quot;]]. For the examples we will use /dev/sdXY&amp;lt;br&amp;gt;&lt;br /&gt;
* 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. &amp;lt;code&amp;gt;mkdir -p /boot/ovl_dev/cache ; touch /boot/ovl_dev/cache/.boot_repository&amp;lt;/code&amp;gt;)&amp;lt;br&amp;gt;&lt;br /&gt;
=&amp;gt; Alternative: Configure the /etc/fstab to mount the writable partition to /media/sdXY instead of /boot (i.e. conforming to the hot/cold-plug mountpoints):&amp;lt;br&amp;gt;&lt;br /&gt;
3. &amp;lt;code&amp;gt;mkdir /media/sdXY&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
4. &amp;lt;code&amp;gt;echo &amp;quot;/dev/sdXY /media/sdXY ext4 noatime,ro 0 0&amp;quot; &amp;gt;&amp;gt; /etc/fstab&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; (Mounting read-only is possible, because the tools temporarily remount it writable for their operation.)&amp;lt;br&amp;gt;&lt;br /&gt;
5. Use &amp;lt;code&amp;gt;mount -a&amp;lt;/code&amp;gt; to load the partitions listed in /etc/fstab. Look at the output of &amp;lt;code&amp;gt;mount&amp;lt;/code&amp;gt; to verify that the /etc/fstab changes have been applied correctly.&amp;lt;br&amp;gt;&lt;br /&gt;
6. 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.)&amp;lt;br&amp;gt;&lt;br /&gt;
If setup-alpine has already been used to configure the diskless system, the storage settings may be modified directly with &amp;lt;code&amp;gt;setup-lbu sdXY&amp;lt;/code&amp;gt; and  &amp;lt;code&amp;gt;mkdir /media/sdXY/cache ; setup-apkcache /media/sdXY/cache&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
7. If the partition is large enough, it can be useful to edit lbu.conf to uncomment and set &amp;lt;code&amp;gt;BACKUP_LIMIT=3&amp;lt;/code&amp;gt;. For example, to allow reverting to a previous, working state if needed.&lt;br /&gt;
{{cmd| # apk add nano&lt;br /&gt;
 # nano /etc/lbu/lbu.conf&lt;br /&gt;
}}&lt;br /&gt;
8. Finally, generate the first .apkovl file containing all the previous changes with [https://wiki.alpinelinux.org/wiki/Alpine_local_backup Alpine_local_backup], by executing &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt;, so the customizations that were just made will persist a reboot.&lt;br /&gt;
&lt;br /&gt;
From then on, whenever packages are installed or newly configured, and the changes should be kept, execute &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt; again.&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
&lt;br /&gt;
* For a virtual machine, the &#039;&#039;&#039;[[QEMU#Live_mode|QEMU example]]&#039;&#039;&#039; shows how an ISO image can automatically boot with .apkovl customizations.&lt;br /&gt;
* The [[Alpine_local_backup#Include_special_files.2Ffolders_to_the_apkovl|Include special files section]] explains how to include custom files outside of &amp;lt;code&amp;gt;/etc&amp;lt;/code&amp;gt; in the .apkovl file.&lt;br /&gt;
* [[Alpine_Linux_package_management#Local_Cache]] covers managing a local package cache.&lt;br /&gt;
** The packages get listed in /etc/apk/world which gets saved with the lbu, for them to be automatically installed when the live system boots.&lt;br /&gt;
* It&#039;s possible to load an APKOVL file from a webserver, by supplying a custom url with the &amp;lt;code&amp;gt;APKOVL&amp;lt;/code&amp;gt; kernel boot parameter.&lt;br /&gt;
** If you don&#039;t have a web server you can run busybox&#039;s httpd temporarily to serve an .apkovl - &amp;lt;code&amp;gt;busybox httpd -p 127.0.0.1:80&amp;lt;/code&amp;gt;.&lt;br /&gt;
* To customize the boot sequence further, one may refer to [[PXE_boot#Specifying_an_apkovl]] and [[How_to_make_a_custom_ISO_image_with_mkimage]].&lt;br /&gt;
&lt;br /&gt;
== Committing changes ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;lbu&amp;lt;/code&amp;gt; tool has several subcommands to manage the .apkovl:&lt;br /&gt;
* lbu&lt;br /&gt;
* lbu commit &#039;&#039;(Same as &#039;lbu ci&#039;)&#039;&#039;&lt;br /&gt;
* lbu package &#039;&#039;(Same as &#039;lbu pkg&#039;)&#039;&#039;&lt;br /&gt;
* lbu status &#039;&#039;(Same as &#039;lbu st&#039;)&#039;&#039;&lt;br /&gt;
* lbu list &#039;&#039;(Same as &#039;lbu ls&#039;)&#039;&#039;&lt;br /&gt;
* lbu diff&lt;br /&gt;
* lbu include &#039;&#039;(Same as &#039;lbu inc&#039; or &#039;lbu add&#039;)&#039;&#039;&lt;br /&gt;
* lbu exclude &#039;&#039;(Same as &#039;lbu ex&#039; or &#039;lbu delete&#039;)&#039;&#039;&lt;br /&gt;
* lbu list-backup &#039;&#039;(Same as &#039;lbu lb&#039;)&#039;&#039;&lt;br /&gt;
* lbu revert&lt;br /&gt;
&lt;br /&gt;
In the examples below, you will find some characters with special meaning:&lt;br /&gt;
* &#039;&#039;&#039;|&#039;&#039;&#039; = &#039;&#039;&#039;or&#039;&#039;&#039; &#039;&#039;(&#039;lbu commit|ci&#039; means that you can type ether &#039;lbu commit&#039; or &#039;lbu ci&#039;)&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;[ ]&#039;&#039;&#039; = &#039;&#039;&#039;optional&#039;&#039;&#039; &#039;&#039;(In &#039;lbu commit|ci [-nv]&#039; you can skip the &#039;-n&#039;, &#039;-v&#039; or &#039;-nv&#039; part if you don&#039;t want it)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Basic &amp;quot;commit&amp;quot; command ===&lt;br /&gt;
When you &amp;quot;commit&amp;quot; or save changes you&#039;ve made to your system, &amp;lt;code&amp;gt;lbu&amp;lt;/code&amp;gt; will generate a file named something like {{Path|&amp;lt;var&amp;gt;myboxname&amp;lt;/var&amp;gt;.apkovl.tar.gz}} &#039;&#039;(&#039;myboxname&#039; will be the same as the hostname)&#039;&#039;.&lt;br /&gt;
The file (which contains your modifications) is called your &amp;quot;apkovl&amp;quot;.&lt;br /&gt;
You will need to save your apkovl on suitable media (floppy, usb, cf, etc.).&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
usage: lbu commit|ci [-nv] [&amp;lt;media&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
  -d	Remove old apk overlay files.&lt;br /&gt;
  -e	Protect configuration with a password.&lt;br /&gt;
  -n	Don&#039;t commit, just show what would have been committed.&lt;br /&gt;
  -p &amp;lt;password&amp;gt;	Give encryption password on the command-line&lt;br /&gt;
  -v	Verbose mode.&lt;br /&gt;
&lt;br /&gt;
The following values for &amp;lt;media&amp;gt; are supported: floppy usb&lt;br /&gt;
If &amp;lt;media&amp;gt; is not specified, the environment variable LBU_MEDIA will be used.&lt;br /&gt;
&lt;br /&gt;
Password protection will use aes-256-cbc encryption. Other ciphers can be&lt;br /&gt;
used by setting the DEFAULT_CIPHER or ENCRYPTION environment variables.&lt;br /&gt;
For possible ciphers, try: openssl -v&lt;br /&gt;
&lt;br /&gt;
The password used to encrypt the file, can be specified with the -p&lt;br /&gt;
option or by using the PASSWORD environment variable.&lt;br /&gt;
&lt;br /&gt;
The environment variable can also be set in /etc/lbu/lbu.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Creating an .apkovl &amp;quot;package&amp;quot; elsewhere than on the configured media ===&lt;br /&gt;
&lt;br /&gt;
To &amp;quot;commit&amp;quot; changes, but override the destination of the generated apkovl file, use &amp;lt;code&amp;gt;lbu package&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
usage: lbu package|pkg -v [&amp;lt;dirname&amp;gt;|&amp;lt;filename&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
  -v   Verbose mode.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;dirname&amp;gt; is a directory, a package named &amp;lt;hostname&amp;gt;.apkovl.tar.gz will&lt;br /&gt;
be created in the specified directory.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;filename&amp;gt; is specified, and is not a directory, a package with the&lt;br /&gt;
specified name will be created.&lt;br /&gt;
&lt;br /&gt;
If neither &amp;lt;dirname&amp;gt; nor &amp;lt;filename&amp;gt; is specified, a package named&lt;br /&gt;
&amp;lt;hostname&amp;gt;.apkovl.tar.gz will be created in the current working directory.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Creating and saving an apkovl from a remote host ===&lt;br /&gt;
&lt;br /&gt;
To create an apkovl from a client on a remote server, it&#039;s possible to use &amp;lt;code&amp;gt;lbu package&amp;lt;/code&amp;gt; via SSH with {{Path|-}} as the apkovl name:&lt;br /&gt;
&lt;br /&gt;
On the server:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ssh root@client &amp;quot;lbu package -&amp;quot; &amp;gt;client.apkovl.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Checking what will be added to your apkovl ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;lbu status&amp;lt;/code&amp;gt; lists what will be saved the next time you run &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt;. Its default output is incremental, that is, it shows&lt;br /&gt;
only the files that have changed since the last commit. &amp;lt;br&amp;gt;&lt;br /&gt;
This can be overridden with the &amp;lt;code&amp;gt;-a&amp;lt;/code&amp;gt; flag:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
usage: lbu status|st [-av]&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
  -a    Compare all files, not just since last commit.&lt;br /&gt;
  -v    show include and exclude lists.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another option is &amp;lt;code&amp;gt;lbu list&amp;lt;/code&amp;gt;. This works like &amp;lt;code&amp;gt;lbu status -a&amp;lt;/code&amp;gt; but the format of the output is a bit different. (It&#039;s strictly equivalent to &amp;lt;code&amp;gt;lbu package -v /dev/null&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
 usage: lbu list|ls&lt;br /&gt;
&lt;br /&gt;
A third option is &amp;lt;code&amp;gt;lbu diff&amp;lt;/code&amp;gt;. This shows the same incremental changes that &amp;lt;code&amp;gt;lbu status&amp;lt;/code&amp;gt; (without &amp;lt;code&amp;gt;-a&amp;lt;/code&amp;gt;) does, but in a different format.&lt;br /&gt;
&lt;br /&gt;
  usage: lbu diff&lt;br /&gt;
&lt;br /&gt;
== Include special files/folders to the apkovl ==&lt;br /&gt;
Assume you have some files you want to save permanently, but they are not located in {{Path|/etc}}.&amp;lt;BR&amp;gt;&lt;br /&gt;
e.g. {{Path|/root/.ssh/authorized_keys}} (used by &amp;lt;code&amp;gt;sshd&amp;lt;/code&amp;gt; to authenticate ssh-users). Such files/folders can be added to lbu&#039;s &#039;&#039;include&#039;&#039; list with the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
usage: lbu include|inc|add [-rv] &amp;lt;file&amp;gt; ...&lt;br /&gt;
       lbu include|inc|add [-v] -l&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
  -l	List contents of include list.&lt;br /&gt;
  -r	Remove specified file(s) from include list.&lt;br /&gt;
  -v	Verbose mode.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|This information used to be maintained in {{Path|/etc/lbu/include}}. Now it&#039;s maintained together with the &#039;&#039;exclude&#039;&#039; list in {{Path|/etc/apk/protected_paths.d/lbu.list}}. Either way, the command &amp;lt;code&amp;gt;lbu include&amp;lt;/code&amp;gt; only modifies lbu&#039;s configuration.&lt;br /&gt;
You will need to run &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt; to actually create/modify your apkovl.}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Exclude specific files/folders from the apkovl ==&lt;br /&gt;
Assume you have some files located in {{Path|/etc}} or one of its subfolders you &#039;&#039;do not&#039;&#039; want to save.&lt;br /&gt;
It could be a log file or status file that for some reason isn&#039;t in {{Path|/var/log/}} but in a location that would otherwise be tracked by &amp;lt;code&amp;gt;lbu&amp;lt;/code&amp;gt;.&lt;br /&gt;
Such files/folders can be added to lbu&#039;s &#039;&#039;exclude&#039;&#039; list by manually editing the file or using the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
usage: lbu exclude|ex|delete [-rv] &amp;lt;file&amp;gt; ...&lt;br /&gt;
       lbu exclude|ex|delete [-v] -l&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
  -l	List contents of exclude list.&lt;br /&gt;
  -r	Remove specified file(s) from exclude list.&lt;br /&gt;
  -v	Verbose mode.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{Note|As stated above, this information is now maintained in {{Path|/etc/apk/protected_paths.d/lbu.list}}. The command &amp;lt;code&amp;gt;lbu exclude&amp;lt;/code&amp;gt; also only modifies lbu&#039;s configuration. &amp;lt;br&amp;gt;&lt;br /&gt;
You will need to run &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt; to actually create/modify your apkovl.}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Execute a script as part of a backup ==&lt;br /&gt;
&lt;br /&gt;
Sometimes it&#039;s necessary to run a script before or after a backup.  Scripts in two optional directories enable that:&lt;br /&gt;
&lt;br /&gt;
 /etc/lbu/pre-package.d&lt;br /&gt;
 /etc/lbu/post-package.d&lt;br /&gt;
&lt;br /&gt;
Files in those directories are run using run-script rules (meaning they must have the executable bit set, they are run in alphabetical order, and cannot contain an extension. e.g. {{Path|runme}} works, but {{Path|runme.sh}} does not. Also the shebang line on the first line should be indicated, e.g. #!/bin/sh .)&lt;br /&gt;
&lt;br /&gt;
The scripts in {{Path|pre-package.d}} are run before apkovl is created. Scripts in {{Path|post-package.d}} are run after apkovl is created.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&lt;br /&gt;
Rather than adding the raw database directories to {{Path|/etc/lbu/include}}, you can do a &amp;quot;database dump&amp;quot;.    e.g. {{Pkg|postgresql}}:&lt;br /&gt;
&lt;br /&gt;
* Create {{Path|/etc/lbu/pre-package.d/sqldump}} with the following contents: &amp;lt;pre&amp;gt;pg_dumpall -U postgres | gzip -c &amp;gt;/root/pgdatabases.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Mark the file executable: &amp;lt;code&amp;gt;chmod +x /etc/lbu/pre-package.d/sqldump&amp;lt;/code&amp;gt;&lt;br /&gt;
* Create {{Path|/etc/lbu/post-package.d/sqldumpdelete}} with the following contents: &amp;lt;pre&amp;gt;rm -f /root/pgdatabases.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Mark the file executable: &amp;lt;code&amp;gt;chmod +x /etc/lbu/post-package.d/sqldumpdelete&amp;lt;/code&amp;gt;&lt;br /&gt;
* Finally, add the database dump file to the list of files to back up: &amp;lt;code&amp;gt;lbu include root/pgdatabases.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now when you do a &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt;, the sql databases are dumped and gzipped to {{Path|/root/pgdatabases.gz}}.&lt;br /&gt;
The temporary file is deleted at the end of the lbu commit.&lt;br /&gt;
&lt;br /&gt;
On a catastrophic restore, the databases are not automatically restored (that&#039;s not lbu&#039;s job), but you will find a complete database dump in the {{Path|/root}} directory, where it can be restored manually.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
P.s. These scripts are also launched when starting the commands: diff, list-backup, package, revert, status.&lt;br /&gt;
&lt;br /&gt;
== Multiple backup versions ==&lt;br /&gt;
Lbu can now keep multiple backups so you can revert back to older configurations.&lt;br /&gt;
Set BACKUP_LIMIT in {{Path|/etc/lbu/lbu.conf}} to the number of backups you want&lt;br /&gt;
to keep.&lt;br /&gt;
&lt;br /&gt;
If you&#039;ve set BACKUP_LIMIT, then the previously active .apkovl will be renamed before creating the new file.&lt;br /&gt;
&lt;br /&gt;
You can list the currently available backups with:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|lbu list-backup [&amp;lt;media&amp;gt;]}}&lt;br /&gt;
&lt;br /&gt;
and you can revert to an older one with:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|lbu revert &amp;lt;filename&amp;gt; [&amp;lt;media&amp;gt;]}}&lt;br /&gt;
&lt;br /&gt;
NOTE: Nothing is changed on your running system when &amp;quot;reverting&amp;quot;, it only affects which apkovl is considered active at the next boot.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Back Up a Flash Memory Installation]]&lt;br /&gt;
* [[Manually editing a existing apkovl]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Booting]]&lt;br /&gt;
[[Category:Package Manager]]&lt;br /&gt;
[[category: LBU]]&lt;/div&gt;</summary>
		<author><name>Garo</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_local_backup&amp;diff=22673</id>
		<title>Alpine local backup</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_local_backup&amp;diff=22673"/>
		<updated>2022-11-19T15:41:27Z</updated>

		<summary type="html">&lt;p&gt;Garo: Link became a redirect&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;When Alpine Linux boots in diskless mode, it initially only loads a few required packages from the boot device.&lt;br /&gt;
&lt;br /&gt;
However, local adjustments to what-gets-loaded-into-RAM are possible, e.g. by [[Alpine_Package_Keeper|installing a package]] or adjusting the configuration files in {{path|/etc}}. The modifications can be saved to an overlay file (.apkovl) that can be automatically loaded when booting, to restore the saved state.&lt;br /&gt;
&lt;br /&gt;
The .apkovl file that contains the custom configuration can be saved to writable storage with Alpine&#039;s local backup utility &amp;lt;code&amp;gt;lbu&amp;lt;/code&amp;gt;. By configuring a [[Alpine_Linux_package_management#Local_Cache|local package cache]] the additional packages the configuration depends on, can also be kept available on local, writable storage.&lt;br /&gt;
&lt;br /&gt;
{{Note|If you installed Alpine in &amp;quot;sys&amp;quot; disk mode, you don&#039;t need to use &amp;lt;code&amp;gt;lbu&amp;lt;/code&amp;gt; to save the system state. With a system disk, all modifications are&lt;br /&gt;
written directly to disk. Nevertheless, &amp;lt;code&amp;gt;lbu&amp;lt;/code&amp;gt; can be useful for some maintenance tasks.}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Warning|&lt;br /&gt;
&#039;&#039;&#039;By default, an &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt; only stores modifications below {{Path|/etc}}&#039;&#039;&#039;, with the exception of the {{Path|/etc/init.d/}} directory.&lt;br /&gt;
&lt;br /&gt;
However, [[#Include_special_files.2Ffolders_to_the_apkovl|lbu include]] enables modifying that set of included files, and can be used to specify additional files or folders.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Saving and loading ISO image customizations ==&lt;br /&gt;
&lt;br /&gt;
Besides supporting a boot parameter to load customizations from a web server, Alpine&#039;s &amp;quot;diskless mode&amp;quot; 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.&lt;br /&gt;
&lt;br /&gt;
{{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.}}&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
To use partitions on &#039;&#039;&#039;internal disks&#039;&#039;&#039;, however, you need to prepare a specific /etc/fstab entry manually, and save the configuration, as follows (setup-alpine does not list them for saving configs or package cache):&lt;br /&gt;
&lt;br /&gt;
1. Boot the diskless system from ISO (as shown at [[Installation]])&amp;lt;br&amp;gt;&lt;br /&gt;
2. If necessary, create and format a partition as in [[Setting_up_disks_manually#For_.22diskless.22_and_.22data.22_disk_mode_installs_2]]. For the examples we will use /dev/sdXY&amp;lt;br&amp;gt;&lt;br /&gt;
* 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. &amp;lt;code&amp;gt;mkdir -p /boot/ovl_dev/cache ; touch /boot/ovl_dev/cache/.boot_repository&amp;lt;/code&amp;gt;)&amp;lt;br&amp;gt;&lt;br /&gt;
=&amp;gt; Alternative: Configure the /etc/fstab to mount the writable partition to /media/sdXY instead of /boot (i.e. conforming to the hot/cold-plug mountpoints):&amp;lt;br&amp;gt;&lt;br /&gt;
3. &amp;lt;code&amp;gt;mkdir /media/sdXY&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
4. &amp;lt;code&amp;gt;echo &amp;quot;/dev/sdXY /media/sdXY ext4 noatime,ro 0 0&amp;quot; &amp;gt;&amp;gt; /etc/fstab&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt; (Mounting read-only is possible, because the tools temporarily remount it writable for their operation.)&amp;lt;br&amp;gt;&lt;br /&gt;
5. Use &amp;lt;code&amp;gt;mount -a&amp;lt;/code&amp;gt; to load the partitions listed in /etc/fstab. Look at the output of &amp;lt;code&amp;gt;mount&amp;lt;/code&amp;gt; to verify that the /etc/fstab changes have been applied correctly.&amp;lt;br&amp;gt;&lt;br /&gt;
6. 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.)&amp;lt;br&amp;gt;&lt;br /&gt;
If setup-alpine has already been used to configure the diskless system, the storage settings may be modified directly with &amp;lt;code&amp;gt;setup-lbu sdXY&amp;lt;/code&amp;gt; and  &amp;lt;code&amp;gt;mkdir /media/sdXY/cache ; setup-apkcache /media/sdXY/cache&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
7. If the partition is large enough, it can be useful to edit lbu.conf to uncomment and set &amp;lt;code&amp;gt;BACKUP_LIMIT=3&amp;lt;/code&amp;gt;. For example, to allow reverting to a previous, working state if needed.&lt;br /&gt;
{{cmd| # apk add nano&lt;br /&gt;
 # nano /etc/lbu/lbu.conf&lt;br /&gt;
}}&lt;br /&gt;
8. Finally, generate the first .apkovl file containing all the previous changes with [https://wiki.alpinelinux.org/wiki/Alpine_local_backup Alpine_local_backup], by executing &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt;, so the customizations that were just made will persist a reboot.&lt;br /&gt;
&lt;br /&gt;
From then on, whenever packages are installed or newly configured, and the changes should be kept, execute &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt; again.&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
&lt;br /&gt;
* For a virtual machine, the &#039;&#039;&#039;[[QEMU#Live_mode|QEMU example]]&#039;&#039;&#039; shows how an ISO image can automatically boot with .apkovl customizations.&lt;br /&gt;
* The [[Alpine_local_backup#Include_special_files.2Ffolders_to_the_apkovl|Include special files section]] explains how to include custom files outside of &amp;lt;code&amp;gt;/etc&amp;lt;/code&amp;gt; in the .apkovl file.&lt;br /&gt;
* [[Alpine_Linux_package_management#Local_Cache]] covers managing a local package cache.&lt;br /&gt;
** The packages get listed in /etc/apk/world which gets saved with the lbu, for them to be automatically installed when the live system boots.&lt;br /&gt;
* It&#039;s possible to load an APKOVL file from a webserver, by supplying a custom url with the &amp;lt;code&amp;gt;APKOVL&amp;lt;/code&amp;gt; kernel boot parameter.&lt;br /&gt;
** If you don&#039;t have a web server you can run busybox&#039;s httpd temporarily to serve an .apkovl - &amp;lt;code&amp;gt;busybox httpd -p 127.0.0.1:80&amp;lt;/code&amp;gt;.&lt;br /&gt;
* To customize the boot sequence further, one may refer to [[PXE_boot#Specifying_an_apkovl]] and [[How_to_make_a_custom_ISO_image_with_mkimage]].&lt;br /&gt;
&lt;br /&gt;
== Committing changes ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;lbu&amp;lt;/code&amp;gt; tool has several subcommands to manage the .apkovl:&lt;br /&gt;
* lbu&lt;br /&gt;
* lbu commit &#039;&#039;(Same as &#039;lbu ci&#039;)&#039;&#039;&lt;br /&gt;
* lbu package &#039;&#039;(Same as &#039;lbu pkg&#039;)&#039;&#039;&lt;br /&gt;
* lbu status &#039;&#039;(Same as &#039;lbu st&#039;)&#039;&#039;&lt;br /&gt;
* lbu list &#039;&#039;(Same as &#039;lbu ls&#039;)&#039;&#039;&lt;br /&gt;
* lbu diff&lt;br /&gt;
* lbu include &#039;&#039;(Same as &#039;lbu inc&#039; or &#039;lbu add&#039;)&#039;&#039;&lt;br /&gt;
* lbu exclude &#039;&#039;(Same as &#039;lbu ex&#039; or &#039;lbu delete&#039;)&#039;&#039;&lt;br /&gt;
* lbu list-backup &#039;&#039;(Same as &#039;lbu lb&#039;)&#039;&#039;&lt;br /&gt;
* lbu revert&lt;br /&gt;
&lt;br /&gt;
In the examples below, you will find some characters with special meaning:&lt;br /&gt;
* &#039;&#039;&#039;|&#039;&#039;&#039; = &#039;&#039;&#039;or&#039;&#039;&#039; &#039;&#039;(&#039;lbu commit|ci&#039; means that you can type ether &#039;lbu commit&#039; or &#039;lbu ci&#039;)&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;[ ]&#039;&#039;&#039; = &#039;&#039;&#039;optional&#039;&#039;&#039; &#039;&#039;(In &#039;lbu commit|ci [-nv]&#039; you can skip the &#039;-n&#039;, &#039;-v&#039; or &#039;-nv&#039; part if you don&#039;t want it)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Basic &amp;quot;commit&amp;quot; command ===&lt;br /&gt;
When you &amp;quot;commit&amp;quot; or save changes you&#039;ve made to your system, &amp;lt;code&amp;gt;lbu&amp;lt;/code&amp;gt; will generate a file named something like {{Path|&amp;lt;var&amp;gt;myboxname&amp;lt;/var&amp;gt;.apkovl.tar.gz}} &#039;&#039;(&#039;myboxname&#039; will be the same as the hostname)&#039;&#039;.&lt;br /&gt;
The file (which contains your modifications) is called your &amp;quot;apkovl&amp;quot;.&lt;br /&gt;
You will need to save your apkovl on suitable media (floppy, usb, cf, etc.).&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
usage: lbu commit|ci [-nv] [&amp;lt;media&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
  -d	Remove old apk overlay files.&lt;br /&gt;
  -e	Protect configuration with a password.&lt;br /&gt;
  -n	Don&#039;t commit, just show what would have been committed.&lt;br /&gt;
  -p &amp;lt;password&amp;gt;	Give encryption password on the command-line&lt;br /&gt;
  -v	Verbose mode.&lt;br /&gt;
&lt;br /&gt;
The following values for &amp;lt;media&amp;gt; are supported: floppy usb&lt;br /&gt;
If &amp;lt;media&amp;gt; is not specified, the environment variable LBU_MEDIA will be used.&lt;br /&gt;
&lt;br /&gt;
Password protection will use aes-256-cbc encryption. Other ciphers can be&lt;br /&gt;
used by setting the DEFAULT_CIPHER or ENCRYPTION environment variables.&lt;br /&gt;
For possible ciphers, try: openssl -v&lt;br /&gt;
&lt;br /&gt;
The password used to encrypt the file, can be specified with the -p&lt;br /&gt;
option or by using the PASSWORD environment variable.&lt;br /&gt;
&lt;br /&gt;
The environment variable can also be set in /etc/lbu/lbu.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Creating an .apkovl &amp;quot;package&amp;quot; elsewhere than on the configured media ===&lt;br /&gt;
&lt;br /&gt;
To &amp;quot;commit&amp;quot; changes, but override the destination of the generated apkovl file, use &amp;lt;code&amp;gt;lbu package&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
usage: lbu package|pkg -v [&amp;lt;dirname&amp;gt;|&amp;lt;filename&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
  -v   Verbose mode.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;dirname&amp;gt; is a directory, a package named &amp;lt;hostname&amp;gt;.apkovl.tar.gz will&lt;br /&gt;
be created in the specified directory.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;filename&amp;gt; is specified, and is not a directory, a package with the&lt;br /&gt;
specified name will be created.&lt;br /&gt;
&lt;br /&gt;
If neither &amp;lt;dirname&amp;gt; nor &amp;lt;filename&amp;gt; is specified, a package named&lt;br /&gt;
&amp;lt;hostname&amp;gt;.apkovl.tar.gz will be created in the current working directory.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Creating and saving an apkovl from a remote host ===&lt;br /&gt;
&lt;br /&gt;
To create an apkovl from a client on a remote server, it&#039;s possible to use &amp;lt;code&amp;gt;lbu package&amp;lt;/code&amp;gt; via SSH with {{Path|-}} as the apkovl name:&lt;br /&gt;
&lt;br /&gt;
On the server:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ssh root@client &amp;quot;lbu package -&amp;quot; &amp;gt;client.apkovl.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Checking what will be added to your apkovl ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;lbu status&amp;lt;/code&amp;gt; lists what will be saved the next time you run &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt;. Its default output is incremental, that is, it shows&lt;br /&gt;
only the files that have changed since the last commit. &amp;lt;br&amp;gt;&lt;br /&gt;
This can be overridden with the &amp;lt;code&amp;gt;-a&amp;lt;/code&amp;gt; flag:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
usage: lbu status|st [-av]&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
  -a    Compare all files, not just since last commit.&lt;br /&gt;
  -v    show include and exclude lists.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another option is &amp;lt;code&amp;gt;lbu list&amp;lt;/code&amp;gt;. This works like &amp;lt;code&amp;gt;lbu status -a&amp;lt;/code&amp;gt; but the format of the output is a bit different. (It&#039;s strictly equivalent to &amp;lt;code&amp;gt;lbu package -v /dev/null&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
 usage: lbu list|ls&lt;br /&gt;
&lt;br /&gt;
A third option is &amp;lt;code&amp;gt;lbu diff&amp;lt;/code&amp;gt;. This shows the same incremental changes that &amp;lt;code&amp;gt;lbu status&amp;lt;/code&amp;gt; (without &amp;lt;code&amp;gt;-a&amp;lt;/code&amp;gt;) does, but in a different format.&lt;br /&gt;
&lt;br /&gt;
  usage: lbu diff&lt;br /&gt;
&lt;br /&gt;
== Include special files/folders to the apkovl ==&lt;br /&gt;
Assume you have some files you want to save permanently, but they are not located in {{Path|/etc}}.&amp;lt;BR&amp;gt;&lt;br /&gt;
e.g. {{Path|/root/.ssh/authorized_keys}} (used by &amp;lt;code&amp;gt;sshd&amp;lt;/code&amp;gt; to authenticate ssh-users). Such files/folders can be added to lbu&#039;s &#039;&#039;include&#039;&#039; list with the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
usage: lbu include|inc|add [-rv] &amp;lt;file&amp;gt; ...&lt;br /&gt;
       lbu include|inc|add [-v] -l&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
  -l	List contents of include list.&lt;br /&gt;
  -r	Remove specified file(s) from include list.&lt;br /&gt;
  -v	Verbose mode.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|This information used to be maintained in {{Path|/etc/lbu/include}}. Now it&#039;s maintained together with the &#039;&#039;exclude&#039;&#039; list in {{Path|/etc/apk/protected_paths.d/lbu.list}}. Either way, the command &amp;lt;code&amp;gt;lbu include&amp;lt;/code&amp;gt; only modifies lbu&#039;s configuration.&lt;br /&gt;
You will need to run &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt; to actually create/modify your apkovl.}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Exclude specific files/folders from the apkovl ==&lt;br /&gt;
Assume you have some files located in {{Path|/etc}} or one of its subfolders you &#039;&#039;do not&#039;&#039; want to save.&lt;br /&gt;
It could be a log file or status file that for some reason isn&#039;t in {{Path|/var/log/}} but in a location that would otherwise be tracked by &amp;lt;code&amp;gt;lbu&amp;lt;/code&amp;gt;.&lt;br /&gt;
Such files/folders can be added to lbu&#039;s &#039;&#039;exclude&#039;&#039; list by manually editing the file or using the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
usage: lbu exclude|ex|delete [-rv] &amp;lt;file&amp;gt; ...&lt;br /&gt;
       lbu exclude|ex|delete [-v] -l&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
  -l	List contents of exclude list.&lt;br /&gt;
  -r	Remove specified file(s) from exclude list.&lt;br /&gt;
  -v	Verbose mode.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{Note|As stated above, this information is now maintained in {{Path|/etc/apk/protected_paths.d/lbu.list}}. The command &amp;lt;code&amp;gt;lbu exclude&amp;lt;/code&amp;gt; also only modifies lbu&#039;s configuration. &amp;lt;br&amp;gt;&lt;br /&gt;
You will need to run &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt; to actually create/modify your apkovl.}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Execute a script as part of a backup ==&lt;br /&gt;
&lt;br /&gt;
Sometimes it&#039;s necessary to run a script before or after a backup.  Scripts in two optional directories enable that:&lt;br /&gt;
&lt;br /&gt;
 /etc/lbu/pre-package.d&lt;br /&gt;
 /etc/lbu/post-package.d&lt;br /&gt;
&lt;br /&gt;
Files in those directories are run using run-script rules (meaning they must have the executable bit set, they are run in alphabetical order, and cannot contain an extension. e.g. {{Path|runme}} works, but {{Path|runme.sh}} does not. Also the shebang line on the first line should be indicated, e.g. #!/bin/sh .)&lt;br /&gt;
&lt;br /&gt;
The scripts in {{Path|pre-package.d}} are run before apkovl is created. Scripts in {{Path|post-package.d}} are run after apkovl is created.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&lt;br /&gt;
Rather than adding the raw database directories to {{Path|/etc/lbu/include}}, you can do a &amp;quot;database dump&amp;quot;.    e.g. {{Pkg|postgresql}}:&lt;br /&gt;
&lt;br /&gt;
* Create {{Path|/etc/lbu/pre-package.d/sqldump}} with the following contents: &amp;lt;pre&amp;gt;pg_dumpall -U postgres | gzip -c &amp;gt;/root/pgdatabases.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Mark the file executable: &amp;lt;code&amp;gt;chmod +x /etc/lbu/pre-package.d/sqldump&amp;lt;/code&amp;gt;&lt;br /&gt;
* Create {{Path|/etc/lbu/post-package.d/sqldumpdelete}} with the following contents: &amp;lt;pre&amp;gt;rm -f /root/pgdatabases.gz&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Mark the file executable: &amp;lt;code&amp;gt;chmod +x /etc/lbu/post-package.d/sqldumpdelete&amp;lt;/code&amp;gt;&lt;br /&gt;
* Finally, add the database dump file to the list of files to back up: &amp;lt;code&amp;gt;lbu include root/pgdatabases.gz&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now when you do a &amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt;, the sql databases are dumped and gzipped to {{Path|/root/pgdatabases.gz}}.&lt;br /&gt;
The temporary file is deleted at the end of the lbu commit.&lt;br /&gt;
&lt;br /&gt;
On a catastrophic restore, the databases are not automatically restored (that&#039;s not lbu&#039;s job), but you will find a complete database dump in the {{Path|/root}} directory, where it can be restored manually.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
P.s. These scripts are also launched when starting the commands: diff, list-backup, package, revert, status.&lt;br /&gt;
&lt;br /&gt;
== Multiple backup versions ==&lt;br /&gt;
Lbu can now keep multiple backups so you can revert back to older configurations.&lt;br /&gt;
Set BACKUP_LIMIT in {{Path|/etc/lbu/lbu.conf}} to the number of backups you want&lt;br /&gt;
to keep.&lt;br /&gt;
&lt;br /&gt;
If you&#039;ve set BACKUP_LIMIT, then the previously active .apkovl will be renamed before creating the new file.&lt;br /&gt;
&lt;br /&gt;
You can list the currently available backups with:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|lbu list-backup [&amp;lt;media&amp;gt;]}}&lt;br /&gt;
&lt;br /&gt;
and you can revert to an older one with:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|lbu revert &amp;lt;filename&amp;gt; [&amp;lt;media&amp;gt;]}}&lt;br /&gt;
&lt;br /&gt;
NOTE: Nothing is changed on your running system when &amp;quot;reverting&amp;quot;, it only affects which apkovl is considered active at the next boot.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Back Up a Flash Memory Installation]]&lt;br /&gt;
* [[Manually editing a existing apkovl]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Booting]]&lt;br /&gt;
[[Category:Package Manager]]&lt;br /&gt;
[[category: LBU]]&lt;/div&gt;</summary>
		<author><name>Garo</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=How_to_make_a_custom_ISO_image_with_mkimage&amp;diff=15610</id>
		<title>How to make a custom ISO image with mkimage</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=How_to_make_a_custom_ISO_image_with_mkimage&amp;diff=15610"/>
		<updated>2018-12-18T16:34:39Z</updated>

		<summary type="html">&lt;p&gt;Garo: /* Prerequisite */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document explains how to build a custom ISO image using the new mkimage scripts located in [[aports]] directory.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
First make sure we have the needed tools&lt;br /&gt;
{{Cmd|apk add alpine-sdk build-base apk-tools alpine-conf busybox fakeroot syslinux xorriso squashfs_tools}}&lt;br /&gt;
For efi you should add&lt;br /&gt;
{{Cmd|mtools dosfstools grub-efi}}&lt;br /&gt;
&lt;br /&gt;
Create a user (e.g. build) and add it to abuild group:&lt;br /&gt;
{{Cmd|adduser build -G abuild}}&lt;br /&gt;
&lt;br /&gt;
Then create signing keys (-i installs them in /etc/apk/keys which is required for later)&lt;br /&gt;
{{Cmd|abuild-keygen -i -a}}&lt;br /&gt;
&lt;br /&gt;
{{Tip| Make sure your public keys are placed in /etc/apk/keys/ (example: build-xxxxxxxx.rsa.pub)}}&lt;br /&gt;
{{Cmd|ls /etc/apk/keys/}}&lt;br /&gt;
&lt;br /&gt;
Clone (or update) the [http://git.alpinelinux.org/cgit/aports/ git repository].&lt;br /&gt;
{{Cmd|git clone git://git.alpinelinux.org/aports}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Make sure the apk index is up to date (so apk finds the packages):&lt;br /&gt;
{{Cmd|apk update}}&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
The mkimg scripts are shipped with pre-configured profiles.&lt;br /&gt;
&lt;br /&gt;
The format is &#039;&#039;&#039;mkimg.$PROFILENAME.sh&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
So, in order to have a custom ISO, you should create your own &#039;&#039;&#039;mkimg.$PROFILENAME.sh&#039;&#039;&#039; script.&lt;br /&gt;
&lt;br /&gt;
This is an example used to have ZFS module, overlayfs (which allows to have /lib/modules in r/w), a serial console output and some other useful apks to build a simple NAS:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;export PROFILENAME=nas&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt; EOF &amp;gt; ~/aports/scripts/mkimg.$PROFILENAME.sh&lt;br /&gt;
profile_$PROFILENAME() {&lt;br /&gt;
        profile_standard&lt;br /&gt;
        kernel_cmdline=&amp;quot;unionfs_size=512M console=tty0 console=ttyS0,115200&amp;quot;&lt;br /&gt;
        syslinux_serial=&amp;quot;0 115200&amp;quot;&lt;br /&gt;
        kernel_addons=&amp;quot;zfs spl&amp;quot;&lt;br /&gt;
        apks=&amp;quot;\$apks iscsi-scst zfs-scripts zfs zfs-utils-py&lt;br /&gt;
                cciss_vol_status lvm2 mdadm mkinitfs mtools nfs-utils&lt;br /&gt;
                parted rsync sfdisk syslinux unrar util-linux xfsprogs&lt;br /&gt;
                dosfstools ntfs-3g&lt;br /&gt;
                &amp;quot;&lt;br /&gt;
        local _k _a&lt;br /&gt;
        for _k in \$kernel_flavors; do&lt;br /&gt;
                apks=&amp;quot;\$apks linux-\$_k&amp;quot;&lt;br /&gt;
                for _a in \$kernel_addons; do&lt;br /&gt;
                        apks=&amp;quot;\$apks \$_a-\$_k&amp;quot;&lt;br /&gt;
                done&lt;br /&gt;
        done&lt;br /&gt;
        apks=&amp;quot;\$apks linux-firmware&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set the script as executable:&lt;br /&gt;
{{Cmd|chmod +x mkimg.$PROFILENAME.sh}}&lt;br /&gt;
&lt;br /&gt;
== Create the ISO ==&lt;br /&gt;
&lt;br /&gt;
{{Cmd|mkimage.sh	[--tag RELEASE] [--outdir OUTDIR] [--workdir WORKDIR]&lt;br /&gt;
		[--arch ARCH] [--profile PROFILE] [--hostkeys] [--simulate]&lt;br /&gt;
		[--repository REPO] [--extra-repository REPO] [--yaml FILE]&lt;br /&gt;
mkimage.sh	--help&lt;br /&gt;
&lt;br /&gt;
options:&lt;br /&gt;
--arch			Specify which architecture images to build&lt;br /&gt;
			(default: x86_64)&lt;br /&gt;
--hostkeys		Copy system apk signing keys to created images&lt;br /&gt;
--outdir		Specify directory for the created images&lt;br /&gt;
--profile		Specify which profiles to build&lt;br /&gt;
--repository		Package repository to use for the image create&lt;br /&gt;
--extra-repository	Add repository to search packages from&lt;br /&gt;
--simulate		Don&#039;t execute commands&lt;br /&gt;
--tag			Build images for tag RELEASE&lt;br /&gt;
--workdir		Specify temporary working directory (cache)&lt;br /&gt;
--yaml&lt;br /&gt;
&lt;br /&gt;
known profiles: ali rpi uboot base minirootfs standard vanilla extended virt xen}}&lt;br /&gt;
&lt;br /&gt;
Create a iso directory in your home dir:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|mkdir -p ~/iso}}&lt;br /&gt;
&lt;br /&gt;
Then create the actual ISO.&lt;br /&gt;
In this example we will use the edge version x86_64:&lt;br /&gt;
{{Cmd|sh mkimage.sh --tag edge \&lt;br /&gt;
	--outdir ~/iso \&lt;br /&gt;
	--arch x86_64 \&lt;br /&gt;
	--repository http://dl-cdn.alpinelinux.org/alpine/edge/main \&lt;br /&gt;
	--profile $PROFILENAME&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Of course, several passages of this doc can be automated with a script, like the repository/arch/outdir settings.&lt;br /&gt;
This steps are left to you and to your imagination :)&lt;br /&gt;
&lt;br /&gt;
== Testing your ISO image ==&lt;br /&gt;
&lt;br /&gt;
[[Qemu#Live_mode| Qemu]] is useful for a quick test of your created ISO image.&lt;br /&gt;
&lt;br /&gt;
[[Category:Package Manager]]&lt;br /&gt;
[[Category:ISO]]&lt;/div&gt;</summary>
		<author><name>Garo</name></author>
	</entry>
</feed>