https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&user=Etothepii&feedformat=atomAlpine Linux - User contributions [en]2024-03-29T07:18:31ZUser contributionsMediaWiki 1.40.0https://wiki.alpinelinux.org/w/index.php?title=Upgrading_Alpine&diff=19728Upgrading Alpine2021-06-29T22:40:07Z<p>Etothepii: Per suggestion on irc, move sha256sum call onto a different line so users copy-pasting will be more likely to run it.</p>
<hr />
<div>This page covers upgrading to newer releases.<br />
<br />
Doing regular security updates with the package manager is shown at [[Alpine_Linux_package_management#Upgrade_a_Running_System|Upgrading a running system]].<br />
<br />
<br />
<br />
{{Warning|Before actually upgrading your system, make sure that you have a backup of your important data.}}<br />
<br />
<br />
== Upgrading an Alpine Linux Hard-disk installation ==<br />
<br />
=== Upgrading Alpine v2.x to v3.x ===<br />
<br />
{{Warning|Alpine Linux 3.x switched to a different libc implementation compared to previous versions. Because the new Musl libc is not ABI compatible with uClibc, there are additional steps required for an upgrade.}}<br />
<br />
==== Installing statically linked tools ====<br />
<br />
Statically linked version of apk-tools is needed, because the old musl version would stop working after a libc change (possibly in the middle of upgrade). Static version of busybox can be handy in case of the recovery from a failure.<br />
<br />
{{Cmd|apk add busybox-static apk-tools-static}}<br />
<br />
==== Changing repositories to v3.x ====<br />
<br />
To begin, you need to update your {{Path|/etc/apk/repositories}} file. Here are some shortcuts for doing so:<br />
:* Launch {{Cmd|setup-apkrepos}} Enter {{Key|e}} to edit {{Path|/etc/apk/repositories}}. Change the version number by hand.<br />
:* Or, edit the file in place. This is how you'd change <var>v2.7</var> to <var>v3.0</var>: {{Cmd|sed -i -e 's/<var>v2\.7</var>/<var>v3.0</var>/g' /etc/apk/repositories}}<br />
<br />
==== Upgrading system ====<br />
<br />
Use statically linked version of apk to update content of repository:<br />
<br />
{{Cmd|apk.static update}}<br />
<br />
Simulating upgrade is recommended in order to detect issues beforehand:<br />
<br />
{{Cmd|apk.static upgrade --no-self-upgrade --available --simulate}}<br />
<br />
With no problems encountered or after resolving them, start proper upgrade:<br />
<br />
{{Cmd|apk.static upgrade --no-self-upgrade --available}}<br />
<br />
=== Upgrading to latest release ===<br />
{{:Include:Upgrading to latest release}}<br />
<br />
=== Upgrading to Edge ===<br />
{{:Include:Upgrading to Edge}}<br />
<br />
=== Upgrading from older versions ===<br />
<br />
See [[Upgrading from older versions]].<br />
<br />
== Upgrading Alpine Linux on CD ==<br />
<br />
You may have an installation where the boot media being used (such as a CD, for example) is separate from the media used to store the configuration information. In this case, simply download the latest ISO, and replace the boot media contents with the contents of the latest ISO. If you are booting from a CD, this would simply mean replacing the CD with a CD made from the new image and rebooting the Alpine Linux box. <br />
<br />
=== Update remaining packages from Web repository ===<br />
<br />
If you are using [[How_to_enable_APK_caching|APK caching]] you should also perform the following steps.<br />
{{:Include:Using_Internet_Repositories_for_apk-tools}}<br />
<br />
If you're upgrading from a version of Alpine before 2.3.0_rc1, ensure you have the latest available version of the Alpine Linux Package Manager first before upgrading anything else:<br />
{{Cmd|apk add --upgrade apk-tools}}<br />
<br />
Next, upgrade all your packages:<br />
<br />
{{Cmd|apk upgrade --available<br />
sync}}<br />
<br />
The <code>--available</code> switch is used to force all packages to be upgraded, even if they have the same version numbers. Sometimes changes in uClibc require doing this.<br />
<br />
After upgrading packages, save any configuration changes (you should have backed up your earlier configuration prior to upgrading).<br />
{{Cmd|lbu ci}}<br />
<br />
<br />
== Upgrading Alpine Linux on other removable media (such as CF/USB) ==<br />
<br />
The following instructions are for run-from-RAM Alpine installations running on Compact Flash or USB media. Updating your repositories using [[#Upgrading_an_Alpine_Linux_Hard-disk_installation|the procedures detailed above]], then running:<br />
{{Cmd|apk upgrade --update-cache --available}}<br />
will suffice for some purposes. (If you want the new packages to be used after a reboot, you should [[How_to_enable_APK_caching|enable APK caching]].)<br />
<br />
However, this is not an adequate general solution because it won't honor any kernel upgrades and the like. For the general solution, you'll need to upgrade your boot medium (Compact Flash or USB). That is what the following steps describe how to do.<br />
<br />
{{:Include:Upgrading_Alpine_environmentvars}}<br />
<br />
=== Upgrade Operating System ===<br />
<br />
Start by checking that you have enough space on your media. For a '''standard''' Alpine image, you need at least 400MB available space.<br />
{{Cmd|df -h {{!}} grep "Filesystem\{{!}}$LBU_MEDIA"}}<br />
<br />
==== Download and verify new release ====<br />
<br />
Make sure the media that holds your Alpine system is mounted readwrite.<br />
{{Cmd|mount -oremount,rw /media/$LBU_MEDIA}}<br />
<br />
'''If using Alpine Linux 2.2.3 or newer''': Download the latest release, {{Cmd|wget https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/<arch>/<image>.iso}} and then use the following command to mount and copy files as needed for you: {{Cmd|setup-bootable -u alpine-extended-<version>-<arch>.iso /media/$LBU_MEDIA}} Once the command completes, proceed to the [[#Save changes|Save changes]] section.<br />
<br />
==== For older versions of Alpine ====<br />
Start downloading a new '.iso' and a '.sha1' file <br />
{{Cmd|cd /media/$LBU_MEDIA<br />
wget -c {{#latestalp:alpine|url}}<br />
wget {{#latestalp:alpine|url}}.sha1}}<br />
<br />
Check integrity of the downloaded files ''(it might take some time)'':<br />
{{Cmd|sha1sum -c {{#latestalp:alpine|file}}.sha1}}<br />
''The output of the above command should say 'OK'.<BR>''<br />
''If says 'FAILED', delete the iso file and download it again.''<br />
<br />
'''If using Alpine Linux 1.10.4 or newer''': there is a tool ''setup-bootable'' that will mount and copy the image you just downloaded to your boot medium. With this tool simply do: {{Cmd|setup-bootable -u {{#latestalp:alpine|file}} /media/$LBU_MEDIA}}<br />
<br />
[[Upgrading from older versions#Upgrading_a_removable_medium_from_Alpine_before_1.10.4|Instructions for older versions of Alpine]] are located elsewhere.<br />
<br />
=== Save changes ===<br />
Now that all upgrades are done, we should save our settings to our media (which you hopefully have backed up prior to doing this upgrade).<br />
{{Cmd|lbu ci}}<br />
<br />
=== Load new kernel ===<br />
In most cases you will need to reboot Alpine Linux (especially if there are changes in the kernel):<br />
{{Cmd|sync<br />
reboot}}<br />
<br />
{{Note|If you know what you are doing, you might not need to reboot. But make sure that all services affected by the upgrade are restarted.}}<br />
<br />
=== Update to latest kernel on armhf (eg. Raspberry Pi 0 or 1) ===<br />
On Alpine 3.X and newer, kernel is not upgraded when using <code>apk upgrade</code> and <code>setup-bootable</code> does not work properly.<br />
<br />
If you want to upgrade your kernel, you will need to get it from the latest release, but first you must have and run :<br />
{{Cmd|apk update; apk version -l '<';<br />
apk upgrade;<br />
lbu ci;}}<br />
<br />
So now all your packages are upgraded, you can upgrade your kernel.<br />
<br />
1. We need to get some variables :<br />
{{Cmd|. /etc/os-release;<br />
. /etc/lbu/lbu.conf;}}<br />
<br />
2. You '''must''' verify if they are correctly set, using this :<br />
{{Cmd|echo "alpine version : $VERSION_ID";<br />
echo "lbu media : $LBU_MEDIA";}}<br />
<br />
3. And it will output something like this (if not, do not continue this process) :<br />
{{Cmd|alpine version : 3.13.5<br />
lbu media : mmcblk0p1}}<br />
<br />
4. Then you can run this script :<br />
{{Cmd|cd /media/$LBU_MEDIA;<br />
mount -oremount,rw /media/$LBU_MEDIA;<br />
wget https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/armhf/alpine-rpi-$VERSION_ID-armhf.tar.gz;<br />
wget https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/armhf/alpine-rpi-$VERSION_ID-armhf.tar.gz.sha256;<br />
sha256sum -c *.sha256;<br />
tar xzf alpine-rpi-$VERSION_ID-armhf.tar.gz;<br />
rm alpine-rpi-$VERSION_ID-armhf.tar.gz alpine-rpi-$VERSION_ID-armhf.tar.gz.sha256;<br />
sync;<br />
reboot;}}<br />
<br />
5. Test-it !<br />
{{Cmd|uname -a}}<br />
<br />
=== Update remaining packages from Web repository ===<br />
If you are using [[How_to_enable_APK_caching|APK caching]] you should follow the instructions to [[#Update_remaining_packages_from_Web_repository|Update remaining packages from Web repository]], above.<br />
<br />
== Updating a USB/CF diskless install without setup-bootable ==<br />
It is possible to update a diskless install of Alpine from another system, or without using the setup-bootable script. This was tested for the 3.13 to the 3.14 upgrade on a Raspberry Pi.<br />
<br />
Before starting, update /etc/apk/repositories file to retrieve packages for the new release. Then update all packages with:<br />
{{Cmd|apk update && apk upgrade -i -a --update-cache}}<br />
<br />
We can then use update-conf to check for changes to configurations from the new packages.<br />
{{Cmd|# check apk-new config changes<br />
update-conf -a -l<br />
update-conf -a<br />
}}<br />
<br />
We now need to prepare to update the kernel and boot materials. To do this, we stop the modloop (which is the loopback mount providing kernel modules) and remount the SD media as read/write.<br />
<br />
We can also shutdown the system, eject the media, and perform the next steps on another machine (if so, skip this command block)<br />
<br />
{{Cmd|/etc/init.d/modloop stop<br />
mount /media/mmcblk0p1 -o remount,rw<br />
cd /media/mmcblk0p1<br />
}}<br />
<br />
At this point, remove all files from the SD media '''except for /cache, *.apkvol.tar.gz, usercfg.txt, and config.txt''' Rename config.txt to config.txt.bak temporarily, as extracting the new tar file will overwrite the file.<br />
<br />
We can now download the new release and extract it. This example is for an Alpine Raspberry Pi release, so feel free to adjust the URLs for your system. <br />
<br />
{{Cmd|wget https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/aarch64/alpine-rpi-3.13.0-aarch64.tar.gz.sha256<br />
wget https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/aarch64/alpine-rpi-3.13.0-aarch64.tar.gz<br />
sha256sum -c *.sha256<br />
tar zxf *-aarch64.tar.gz && sync<br />
rm alpine-rpi-*<br />
}}<br />
<br />
Restore the original config.txt:<br />
{{Cmd|mv config.txt.bak config.txt}}<br />
<br />
Update the persistent storage using lbu:<br />
{{Cmd|lbu ci -d}}<br />
<br />
We can now reboot, and this should boot into the new kernel. Once this is done, we can clean up and re-download apk caches:<br />
{{Cmd|mount /media/mmcblk0p1 -o remount,rw<br />
rm /media/mmcblk0p1/cache/*<br />
sync && apk update && apk cache -v download<br />
mount /media/mmcblk0p1 -o remount,ro<br />
}}<br />
<br />
[[Category:Installation]]<br />
[[Category:Package Manager]]</div>Etothepiihttps://wiki.alpinelinux.org/w/index.php?title=Upgrading_Alpine&diff=19727Upgrading Alpine2021-06-29T22:34:10Z<p>Etothepii: Fix typo - restore original usercfg should be restore original config.txt</p>
<hr />
<div>This page covers upgrading to newer releases.<br />
<br />
Doing regular security updates with the package manager is shown at [[Alpine_Linux_package_management#Upgrade_a_Running_System|Upgrading a running system]].<br />
<br />
<br />
<br />
{{Warning|Before actually upgrading your system, make sure that you have a backup of your important data.}}<br />
<br />
<br />
== Upgrading an Alpine Linux Hard-disk installation ==<br />
<br />
=== Upgrading Alpine v2.x to v3.x ===<br />
<br />
{{Warning|Alpine Linux 3.x switched to a different libc implementation compared to previous versions. Because the new Musl libc is not ABI compatible with uClibc, there are additional steps required for an upgrade.}}<br />
<br />
==== Installing statically linked tools ====<br />
<br />
Statically linked version of apk-tools is needed, because the old musl version would stop working after a libc change (possibly in the middle of upgrade). Static version of busybox can be handy in case of the recovery from a failure.<br />
<br />
{{Cmd|apk add busybox-static apk-tools-static}}<br />
<br />
==== Changing repositories to v3.x ====<br />
<br />
To begin, you need to update your {{Path|/etc/apk/repositories}} file. Here are some shortcuts for doing so:<br />
:* Launch {{Cmd|setup-apkrepos}} Enter {{Key|e}} to edit {{Path|/etc/apk/repositories}}. Change the version number by hand.<br />
:* Or, edit the file in place. This is how you'd change <var>v2.7</var> to <var>v3.0</var>: {{Cmd|sed -i -e 's/<var>v2\.7</var>/<var>v3.0</var>/g' /etc/apk/repositories}}<br />
<br />
==== Upgrading system ====<br />
<br />
Use statically linked version of apk to update content of repository:<br />
<br />
{{Cmd|apk.static update}}<br />
<br />
Simulating upgrade is recommended in order to detect issues beforehand:<br />
<br />
{{Cmd|apk.static upgrade --no-self-upgrade --available --simulate}}<br />
<br />
With no problems encountered or after resolving them, start proper upgrade:<br />
<br />
{{Cmd|apk.static upgrade --no-self-upgrade --available}}<br />
<br />
=== Upgrading to latest release ===<br />
{{:Include:Upgrading to latest release}}<br />
<br />
=== Upgrading to Edge ===<br />
{{:Include:Upgrading to Edge}}<br />
<br />
=== Upgrading from older versions ===<br />
<br />
See [[Upgrading from older versions]].<br />
<br />
== Upgrading Alpine Linux on CD ==<br />
<br />
You may have an installation where the boot media being used (such as a CD, for example) is separate from the media used to store the configuration information. In this case, simply download the latest ISO, and replace the boot media contents with the contents of the latest ISO. If you are booting from a CD, this would simply mean replacing the CD with a CD made from the new image and rebooting the Alpine Linux box. <br />
<br />
=== Update remaining packages from Web repository ===<br />
<br />
If you are using [[How_to_enable_APK_caching|APK caching]] you should also perform the following steps.<br />
{{:Include:Using_Internet_Repositories_for_apk-tools}}<br />
<br />
If you're upgrading from a version of Alpine before 2.3.0_rc1, ensure you have the latest available version of the Alpine Linux Package Manager first before upgrading anything else:<br />
{{Cmd|apk add --upgrade apk-tools}}<br />
<br />
Next, upgrade all your packages:<br />
<br />
{{Cmd|apk upgrade --available<br />
sync}}<br />
<br />
The <code>--available</code> switch is used to force all packages to be upgraded, even if they have the same version numbers. Sometimes changes in uClibc require doing this.<br />
<br />
After upgrading packages, save any configuration changes (you should have backed up your earlier configuration prior to upgrading).<br />
{{Cmd|lbu ci}}<br />
<br />
<br />
== Upgrading Alpine Linux on other removable media (such as CF/USB) ==<br />
<br />
The following instructions are for run-from-RAM Alpine installations running on Compact Flash or USB media. Updating your repositories using [[#Upgrading_an_Alpine_Linux_Hard-disk_installation|the procedures detailed above]], then running:<br />
{{Cmd|apk upgrade --update-cache --available}}<br />
will suffice for some purposes. (If you want the new packages to be used after a reboot, you should [[How_to_enable_APK_caching|enable APK caching]].)<br />
<br />
However, this is not an adequate general solution because it won't honor any kernel upgrades and the like. For the general solution, you'll need to upgrade your boot medium (Compact Flash or USB). That is what the following steps describe how to do.<br />
<br />
{{:Include:Upgrading_Alpine_environmentvars}}<br />
<br />
=== Upgrade Operating System ===<br />
<br />
Start by checking that you have enough space on your media. For a '''standard''' Alpine image, you need at least 400MB available space.<br />
{{Cmd|df -h {{!}} grep "Filesystem\{{!}}$LBU_MEDIA"}}<br />
<br />
==== Download and verify new release ====<br />
<br />
Make sure the media that holds your Alpine system is mounted readwrite.<br />
{{Cmd|mount -oremount,rw /media/$LBU_MEDIA}}<br />
<br />
'''If using Alpine Linux 2.2.3 or newer''': Download the latest release, {{Cmd|wget https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/<arch>/<image>.iso}} and then use the following command to mount and copy files as needed for you: {{Cmd|setup-bootable -u alpine-extended-<version>-<arch>.iso /media/$LBU_MEDIA}} Once the command completes, proceed to the [[#Save changes|Save changes]] section.<br />
<br />
==== For older versions of Alpine ====<br />
Start downloading a new '.iso' and a '.sha1' file <br />
{{Cmd|cd /media/$LBU_MEDIA<br />
wget -c {{#latestalp:alpine|url}}<br />
wget {{#latestalp:alpine|url}}.sha1}}<br />
<br />
Check integrity of the downloaded files ''(it might take some time)'':<br />
{{Cmd|sha1sum -c {{#latestalp:alpine|file}}.sha1}}<br />
''The output of the above command should say 'OK'.<BR>''<br />
''If says 'FAILED', delete the iso file and download it again.''<br />
<br />
'''If using Alpine Linux 1.10.4 or newer''': there is a tool ''setup-bootable'' that will mount and copy the image you just downloaded to your boot medium. With this tool simply do: {{Cmd|setup-bootable -u {{#latestalp:alpine|file}} /media/$LBU_MEDIA}}<br />
<br />
[[Upgrading from older versions#Upgrading_a_removable_medium_from_Alpine_before_1.10.4|Instructions for older versions of Alpine]] are located elsewhere.<br />
<br />
=== Save changes ===<br />
Now that all upgrades are done, we should save our settings to our media (which you hopefully have backed up prior to doing this upgrade).<br />
{{Cmd|lbu ci}}<br />
<br />
=== Load new kernel ===<br />
In most cases you will need to reboot Alpine Linux (especially if there are changes in the kernel):<br />
{{Cmd|sync<br />
reboot}}<br />
<br />
{{Note|If you know what you are doing, you might not need to reboot. But make sure that all services affected by the upgrade are restarted.}}<br />
<br />
=== Update to latest kernel on armhf (eg. Raspberry Pi 0 or 1) ===<br />
On Alpine 3.X and newer, kernel is not upgraded when using <code>apk upgrade</code> and <code>setup-bootable</code> does not work properly.<br />
<br />
If you want to upgrade your kernel, you will need to get it from the latest release, but first you must have and run :<br />
{{Cmd|apk update; apk version -l '<';<br />
apk upgrade;<br />
lbu ci;}}<br />
<br />
So now all your packages are upgraded, you can upgrade your kernel.<br />
<br />
1. We need to get some variables :<br />
{{Cmd|. /etc/os-release;<br />
. /etc/lbu/lbu.conf;}}<br />
<br />
2. You '''must''' verify if they are correctly set, using this :<br />
{{Cmd|echo "alpine version : $VERSION_ID";<br />
echo "lbu media : $LBU_MEDIA";}}<br />
<br />
3. And it will output something like this (if not, do not continue this process) :<br />
{{Cmd|alpine version : 3.13.5<br />
lbu media : mmcblk0p1}}<br />
<br />
4. Then you can run this script :<br />
{{Cmd|cd /media/$LBU_MEDIA;<br />
mount -oremount,rw /media/$LBU_MEDIA;<br />
wget https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/armhf/alpine-rpi-$VERSION_ID-armhf.tar.gz;<br />
wget https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/armhf/alpine-rpi-$VERSION_ID-armhf.tar.gz.sha256;<br />
sha256sum -c *.sha256;<br />
tar xzf alpine-rpi-$VERSION_ID-armhf.tar.gz;<br />
rm alpine-rpi-$VERSION_ID-armhf.tar.gz alpine-rpi-$VERSION_ID-armhf.tar.gz.sha256;<br />
sync;<br />
reboot;}}<br />
<br />
5. Test-it !<br />
{{Cmd|uname -a}}<br />
<br />
=== Update remaining packages from Web repository ===<br />
If you are using [[How_to_enable_APK_caching|APK caching]] you should follow the instructions to [[#Update_remaining_packages_from_Web_repository|Update remaining packages from Web repository]], above.<br />
<br />
== Updating a USB/CF diskless install without setup-bootable ==<br />
It is possible to update a diskless install of Alpine from another system, or without using the setup-bootable script. This was tested for the 3.13 to the 3.14 upgrade on a Raspberry Pi.<br />
<br />
Before starting, update /etc/apk/repositories file to retrieve packages for the new release. Then update all packages with:<br />
{{Cmd|apk update && apk upgrade -i -a --update-cache}}<br />
<br />
We can then use update-conf to check for changes to configurations from the new packages.<br />
{{Cmd|# check apk-new config changes<br />
update-conf -a -l<br />
update-conf -a<br />
}}<br />
<br />
We now need to prepare to update the kernel and boot materials. To do this, we stop the modloop (which is the loopback mount providing kernel modules) and remount the SD media as read/write.<br />
<br />
We can also shutdown the system, eject the media, and perform the next steps on another machine (if so, skip this command block)<br />
<br />
{{Cmd|/etc/init.d/modloop stop<br />
mount /media/mmcblk0p1 -o remount,rw<br />
cd /media/mmcblk0p1<br />
}}<br />
<br />
At this point, remove all files from the SD media '''except for /cache, *.apkvol.tar.gz, usercfg.txt, and config.txt''' Rename config.txt to config.txt.bak temporarily, as extracting the new tar file will overwrite the file.<br />
<br />
We can now download the new release and extract it. This example is for an Alpine Raspberry Pi release, so feel free to adjust the URLs for your system. <br />
<br />
{{Cmd|wget https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/aarch64/alpine-rpi-3.13.0-aarch64.tar.gz.sha256<br />
wget https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/aarch64/alpine-rpi-3.13.0-aarch64.tar.gz && sha256sum -c *.sha256<br />
tar zxf *-aarch64.tar.gz && sync<br />
rm alpine-rpi-*<br />
}}<br />
<br />
Restore the original config.txt:<br />
{{Cmd|mv config.txt.bak config.txt}}<br />
<br />
Update the persistent storage using lbu:<br />
{{Cmd|lbu ci -d}}<br />
<br />
We can now reboot, and this should boot into the new kernel. Once this is done, we can clean up and re-download apk caches:<br />
{{Cmd|mount /media/mmcblk0p1 -o remount,rw<br />
rm /media/mmcblk0p1/cache/*<br />
sync && apk update && apk cache -v download<br />
mount /media/mmcblk0p1 -o remount,ro<br />
}}<br />
<br />
[[Category:Installation]]<br />
[[Category:Package Manager]]</div>Etothepiihttps://wiki.alpinelinux.org/w/index.php?title=Upgrading_Alpine&diff=19726Upgrading Alpine2021-06-29T22:32:37Z<p>Etothepii: Remove extra sha1 check on images.</p>
<hr />
<div>This page covers upgrading to newer releases.<br />
<br />
Doing regular security updates with the package manager is shown at [[Alpine_Linux_package_management#Upgrade_a_Running_System|Upgrading a running system]].<br />
<br />
<br />
<br />
{{Warning|Before actually upgrading your system, make sure that you have a backup of your important data.}}<br />
<br />
<br />
== Upgrading an Alpine Linux Hard-disk installation ==<br />
<br />
=== Upgrading Alpine v2.x to v3.x ===<br />
<br />
{{Warning|Alpine Linux 3.x switched to a different libc implementation compared to previous versions. Because the new Musl libc is not ABI compatible with uClibc, there are additional steps required for an upgrade.}}<br />
<br />
==== Installing statically linked tools ====<br />
<br />
Statically linked version of apk-tools is needed, because the old musl version would stop working after a libc change (possibly in the middle of upgrade). Static version of busybox can be handy in case of the recovery from a failure.<br />
<br />
{{Cmd|apk add busybox-static apk-tools-static}}<br />
<br />
==== Changing repositories to v3.x ====<br />
<br />
To begin, you need to update your {{Path|/etc/apk/repositories}} file. Here are some shortcuts for doing so:<br />
:* Launch {{Cmd|setup-apkrepos}} Enter {{Key|e}} to edit {{Path|/etc/apk/repositories}}. Change the version number by hand.<br />
:* Or, edit the file in place. This is how you'd change <var>v2.7</var> to <var>v3.0</var>: {{Cmd|sed -i -e 's/<var>v2\.7</var>/<var>v3.0</var>/g' /etc/apk/repositories}}<br />
<br />
==== Upgrading system ====<br />
<br />
Use statically linked version of apk to update content of repository:<br />
<br />
{{Cmd|apk.static update}}<br />
<br />
Simulating upgrade is recommended in order to detect issues beforehand:<br />
<br />
{{Cmd|apk.static upgrade --no-self-upgrade --available --simulate}}<br />
<br />
With no problems encountered or after resolving them, start proper upgrade:<br />
<br />
{{Cmd|apk.static upgrade --no-self-upgrade --available}}<br />
<br />
=== Upgrading to latest release ===<br />
{{:Include:Upgrading to latest release}}<br />
<br />
=== Upgrading to Edge ===<br />
{{:Include:Upgrading to Edge}}<br />
<br />
=== Upgrading from older versions ===<br />
<br />
See [[Upgrading from older versions]].<br />
<br />
== Upgrading Alpine Linux on CD ==<br />
<br />
You may have an installation where the boot media being used (such as a CD, for example) is separate from the media used to store the configuration information. In this case, simply download the latest ISO, and replace the boot media contents with the contents of the latest ISO. If you are booting from a CD, this would simply mean replacing the CD with a CD made from the new image and rebooting the Alpine Linux box. <br />
<br />
=== Update remaining packages from Web repository ===<br />
<br />
If you are using [[How_to_enable_APK_caching|APK caching]] you should also perform the following steps.<br />
{{:Include:Using_Internet_Repositories_for_apk-tools}}<br />
<br />
If you're upgrading from a version of Alpine before 2.3.0_rc1, ensure you have the latest available version of the Alpine Linux Package Manager first before upgrading anything else:<br />
{{Cmd|apk add --upgrade apk-tools}}<br />
<br />
Next, upgrade all your packages:<br />
<br />
{{Cmd|apk upgrade --available<br />
sync}}<br />
<br />
The <code>--available</code> switch is used to force all packages to be upgraded, even if they have the same version numbers. Sometimes changes in uClibc require doing this.<br />
<br />
After upgrading packages, save any configuration changes (you should have backed up your earlier configuration prior to upgrading).<br />
{{Cmd|lbu ci}}<br />
<br />
<br />
== Upgrading Alpine Linux on other removable media (such as CF/USB) ==<br />
<br />
The following instructions are for run-from-RAM Alpine installations running on Compact Flash or USB media. Updating your repositories using [[#Upgrading_an_Alpine_Linux_Hard-disk_installation|the procedures detailed above]], then running:<br />
{{Cmd|apk upgrade --update-cache --available}}<br />
will suffice for some purposes. (If you want the new packages to be used after a reboot, you should [[How_to_enable_APK_caching|enable APK caching]].)<br />
<br />
However, this is not an adequate general solution because it won't honor any kernel upgrades and the like. For the general solution, you'll need to upgrade your boot medium (Compact Flash or USB). That is what the following steps describe how to do.<br />
<br />
{{:Include:Upgrading_Alpine_environmentvars}}<br />
<br />
=== Upgrade Operating System ===<br />
<br />
Start by checking that you have enough space on your media. For a '''standard''' Alpine image, you need at least 400MB available space.<br />
{{Cmd|df -h {{!}} grep "Filesystem\{{!}}$LBU_MEDIA"}}<br />
<br />
==== Download and verify new release ====<br />
<br />
Make sure the media that holds your Alpine system is mounted readwrite.<br />
{{Cmd|mount -oremount,rw /media/$LBU_MEDIA}}<br />
<br />
'''If using Alpine Linux 2.2.3 or newer''': Download the latest release, {{Cmd|wget https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/<arch>/<image>.iso}} and then use the following command to mount and copy files as needed for you: {{Cmd|setup-bootable -u alpine-extended-<version>-<arch>.iso /media/$LBU_MEDIA}} Once the command completes, proceed to the [[#Save changes|Save changes]] section.<br />
<br />
==== For older versions of Alpine ====<br />
Start downloading a new '.iso' and a '.sha1' file <br />
{{Cmd|cd /media/$LBU_MEDIA<br />
wget -c {{#latestalp:alpine|url}}<br />
wget {{#latestalp:alpine|url}}.sha1}}<br />
<br />
Check integrity of the downloaded files ''(it might take some time)'':<br />
{{Cmd|sha1sum -c {{#latestalp:alpine|file}}.sha1}}<br />
''The output of the above command should say 'OK'.<BR>''<br />
''If says 'FAILED', delete the iso file and download it again.''<br />
<br />
'''If using Alpine Linux 1.10.4 or newer''': there is a tool ''setup-bootable'' that will mount and copy the image you just downloaded to your boot medium. With this tool simply do: {{Cmd|setup-bootable -u {{#latestalp:alpine|file}} /media/$LBU_MEDIA}}<br />
<br />
[[Upgrading from older versions#Upgrading_a_removable_medium_from_Alpine_before_1.10.4|Instructions for older versions of Alpine]] are located elsewhere.<br />
<br />
=== Save changes ===<br />
Now that all upgrades are done, we should save our settings to our media (which you hopefully have backed up prior to doing this upgrade).<br />
{{Cmd|lbu ci}}<br />
<br />
=== Load new kernel ===<br />
In most cases you will need to reboot Alpine Linux (especially if there are changes in the kernel):<br />
{{Cmd|sync<br />
reboot}}<br />
<br />
{{Note|If you know what you are doing, you might not need to reboot. But make sure that all services affected by the upgrade are restarted.}}<br />
<br />
=== Update to latest kernel on armhf (eg. Raspberry Pi 0 or 1) ===<br />
On Alpine 3.X and newer, kernel is not upgraded when using <code>apk upgrade</code> and <code>setup-bootable</code> does not work properly.<br />
<br />
If you want to upgrade your kernel, you will need to get it from the latest release, but first you must have and run :<br />
{{Cmd|apk update; apk version -l '<';<br />
apk upgrade;<br />
lbu ci;}}<br />
<br />
So now all your packages are upgraded, you can upgrade your kernel.<br />
<br />
1. We need to get some variables :<br />
{{Cmd|. /etc/os-release;<br />
. /etc/lbu/lbu.conf;}}<br />
<br />
2. You '''must''' verify if they are correctly set, using this :<br />
{{Cmd|echo "alpine version : $VERSION_ID";<br />
echo "lbu media : $LBU_MEDIA";}}<br />
<br />
3. And it will output something like this (if not, do not continue this process) :<br />
{{Cmd|alpine version : 3.13.5<br />
lbu media : mmcblk0p1}}<br />
<br />
4. Then you can run this script :<br />
{{Cmd|cd /media/$LBU_MEDIA;<br />
mount -oremount,rw /media/$LBU_MEDIA;<br />
wget https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/armhf/alpine-rpi-$VERSION_ID-armhf.tar.gz;<br />
wget https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/armhf/alpine-rpi-$VERSION_ID-armhf.tar.gz.sha256;<br />
sha256sum -c *.sha256;<br />
tar xzf alpine-rpi-$VERSION_ID-armhf.tar.gz;<br />
rm alpine-rpi-$VERSION_ID-armhf.tar.gz alpine-rpi-$VERSION_ID-armhf.tar.gz.sha256;<br />
sync;<br />
reboot;}}<br />
<br />
5. Test-it !<br />
{{Cmd|uname -a}}<br />
<br />
=== Update remaining packages from Web repository ===<br />
If you are using [[How_to_enable_APK_caching|APK caching]] you should follow the instructions to [[#Update_remaining_packages_from_Web_repository|Update remaining packages from Web repository]], above.<br />
<br />
== Updating a USB/CF diskless install without setup-bootable ==<br />
It is possible to update a diskless install of Alpine from another system, or without using the setup-bootable script. This was tested for the 3.13 to the 3.14 upgrade on a Raspberry Pi.<br />
<br />
Before starting, update /etc/apk/repositories file to retrieve packages for the new release. Then update all packages with:<br />
{{Cmd|apk update && apk upgrade -i -a --update-cache}}<br />
<br />
We can then use update-conf to check for changes to configurations from the new packages.<br />
{{Cmd|# check apk-new config changes<br />
update-conf -a -l<br />
update-conf -a<br />
}}<br />
<br />
We now need to prepare to update the kernel and boot materials. To do this, we stop the modloop (which is the loopback mount providing kernel modules) and remount the SD media as read/write.<br />
<br />
We can also shutdown the system, eject the media, and perform the next steps on another machine (if so, skip this command block)<br />
<br />
{{Cmd|/etc/init.d/modloop stop<br />
mount /media/mmcblk0p1 -o remount,rw<br />
cd /media/mmcblk0p1<br />
}}<br />
<br />
At this point, remove all files from the SD media '''except for /cache, *.apkvol.tar.gz, usercfg.txt, and config.txt''' Rename config.txt to config.txt.bak temporarily, as extracting the new tar file will overwrite the file.<br />
<br />
We can now download the new release and extract it. This example is for an Alpine Raspberry Pi release, so feel free to adjust the URLs for your system. <br />
<br />
{{Cmd|wget https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/aarch64/alpine-rpi-3.13.0-aarch64.tar.gz.sha256<br />
wget https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/aarch64/alpine-rpi-3.13.0-aarch64.tar.gz && sha256sum -c *.sha256<br />
tar zxf *-aarch64.tar.gz && sync<br />
rm alpine-rpi-*<br />
}}<br />
<br />
Restore the original usercfg.txt:<br />
{{Cmd|mv config.txt.bak config.txt}}<br />
<br />
Update the persistent storage using lbu:<br />
{{Cmd|lbu ci -d}}<br />
<br />
We can now reboot, and this should boot into the new kernel. Once this is done, we can clean up and re-download apk caches:<br />
{{Cmd|mount /media/mmcblk0p1 -o remount,rw<br />
rm /media/mmcblk0p1/cache/*<br />
sync && apk update && apk cache -v download<br />
mount /media/mmcblk0p1 -o remount,ro<br />
}}<br />
<br />
[[Category:Installation]]<br />
[[Category:Package Manager]]</div>Etothepiihttps://wiki.alpinelinux.org/w/index.php?title=Upgrading_Alpine&diff=19725Upgrading Alpine2021-06-29T22:28:30Z<p>Etothepii: Add the wget call to the actual image in the diskless without setup-bootable section (it was missing)</p>
<hr />
<div>This page covers upgrading to newer releases.<br />
<br />
Doing regular security updates with the package manager is shown at [[Alpine_Linux_package_management#Upgrade_a_Running_System|Upgrading a running system]].<br />
<br />
<br />
<br />
{{Warning|Before actually upgrading your system, make sure that you have a backup of your important data.}}<br />
<br />
<br />
== Upgrading an Alpine Linux Hard-disk installation ==<br />
<br />
=== Upgrading Alpine v2.x to v3.x ===<br />
<br />
{{Warning|Alpine Linux 3.x switched to a different libc implementation compared to previous versions. Because the new Musl libc is not ABI compatible with uClibc, there are additional steps required for an upgrade.}}<br />
<br />
==== Installing statically linked tools ====<br />
<br />
Statically linked version of apk-tools is needed, because the old musl version would stop working after a libc change (possibly in the middle of upgrade). Static version of busybox can be handy in case of the recovery from a failure.<br />
<br />
{{Cmd|apk add busybox-static apk-tools-static}}<br />
<br />
==== Changing repositories to v3.x ====<br />
<br />
To begin, you need to update your {{Path|/etc/apk/repositories}} file. Here are some shortcuts for doing so:<br />
:* Launch {{Cmd|setup-apkrepos}} Enter {{Key|e}} to edit {{Path|/etc/apk/repositories}}. Change the version number by hand.<br />
:* Or, edit the file in place. This is how you'd change <var>v2.7</var> to <var>v3.0</var>: {{Cmd|sed -i -e 's/<var>v2\.7</var>/<var>v3.0</var>/g' /etc/apk/repositories}}<br />
<br />
==== Upgrading system ====<br />
<br />
Use statically linked version of apk to update content of repository:<br />
<br />
{{Cmd|apk.static update}}<br />
<br />
Simulating upgrade is recommended in order to detect issues beforehand:<br />
<br />
{{Cmd|apk.static upgrade --no-self-upgrade --available --simulate}}<br />
<br />
With no problems encountered or after resolving them, start proper upgrade:<br />
<br />
{{Cmd|apk.static upgrade --no-self-upgrade --available}}<br />
<br />
=== Upgrading to latest release ===<br />
{{:Include:Upgrading to latest release}}<br />
<br />
=== Upgrading to Edge ===<br />
{{:Include:Upgrading to Edge}}<br />
<br />
=== Upgrading from older versions ===<br />
<br />
See [[Upgrading from older versions]].<br />
<br />
== Upgrading Alpine Linux on CD ==<br />
<br />
You may have an installation where the boot media being used (such as a CD, for example) is separate from the media used to store the configuration information. In this case, simply download the latest ISO, and replace the boot media contents with the contents of the latest ISO. If you are booting from a CD, this would simply mean replacing the CD with a CD made from the new image and rebooting the Alpine Linux box. <br />
<br />
=== Update remaining packages from Web repository ===<br />
<br />
If you are using [[How_to_enable_APK_caching|APK caching]] you should also perform the following steps.<br />
{{:Include:Using_Internet_Repositories_for_apk-tools}}<br />
<br />
If you're upgrading from a version of Alpine before 2.3.0_rc1, ensure you have the latest available version of the Alpine Linux Package Manager first before upgrading anything else:<br />
{{Cmd|apk add --upgrade apk-tools}}<br />
<br />
Next, upgrade all your packages:<br />
<br />
{{Cmd|apk upgrade --available<br />
sync}}<br />
<br />
The <code>--available</code> switch is used to force all packages to be upgraded, even if they have the same version numbers. Sometimes changes in uClibc require doing this.<br />
<br />
After upgrading packages, save any configuration changes (you should have backed up your earlier configuration prior to upgrading).<br />
{{Cmd|lbu ci}}<br />
<br />
<br />
== Upgrading Alpine Linux on other removable media (such as CF/USB) ==<br />
<br />
The following instructions are for run-from-RAM Alpine installations running on Compact Flash or USB media. Updating your repositories using [[#Upgrading_an_Alpine_Linux_Hard-disk_installation|the procedures detailed above]], then running:<br />
{{Cmd|apk upgrade --update-cache --available}}<br />
will suffice for some purposes. (If you want the new packages to be used after a reboot, you should [[How_to_enable_APK_caching|enable APK caching]].)<br />
<br />
However, this is not an adequate general solution because it won't honor any kernel upgrades and the like. For the general solution, you'll need to upgrade your boot medium (Compact Flash or USB). That is what the following steps describe how to do.<br />
<br />
{{:Include:Upgrading_Alpine_environmentvars}}<br />
<br />
=== Upgrade Operating System ===<br />
<br />
Start by checking that you have enough space on your media. For a '''standard''' Alpine image, you need at least 400MB available space.<br />
{{Cmd|df -h {{!}} grep "Filesystem\{{!}}$LBU_MEDIA"}}<br />
<br />
==== Download and verify new release ====<br />
<br />
Make sure the media that holds your Alpine system is mounted readwrite.<br />
{{Cmd|mount -oremount,rw /media/$LBU_MEDIA}}<br />
<br />
'''If using Alpine Linux 2.2.3 or newer''': Download the latest release, {{Cmd|wget https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/<arch>/<image>.iso}} and then use the following command to mount and copy files as needed for you: {{Cmd|setup-bootable -u alpine-extended-<version>-<arch>.iso /media/$LBU_MEDIA}} Once the command completes, proceed to the [[#Save changes|Save changes]] section.<br />
<br />
==== For older versions of Alpine ====<br />
Start downloading a new '.iso' and a '.sha1' file <br />
{{Cmd|cd /media/$LBU_MEDIA<br />
wget -c {{#latestalp:alpine|url}}<br />
wget {{#latestalp:alpine|url}}.sha1}}<br />
<br />
Check integrity of the downloaded files ''(it might take some time)'':<br />
{{Cmd|sha1sum -c {{#latestalp:alpine|file}}.sha1}}<br />
''The output of the above command should say 'OK'.<BR>''<br />
''If says 'FAILED', delete the iso file and download it again.''<br />
<br />
'''If using Alpine Linux 1.10.4 or newer''': there is a tool ''setup-bootable'' that will mount and copy the image you just downloaded to your boot medium. With this tool simply do: {{Cmd|setup-bootable -u {{#latestalp:alpine|file}} /media/$LBU_MEDIA}}<br />
<br />
[[Upgrading from older versions#Upgrading_a_removable_medium_from_Alpine_before_1.10.4|Instructions for older versions of Alpine]] are located elsewhere.<br />
<br />
=== Save changes ===<br />
Now that all upgrades are done, we should save our settings to our media (which you hopefully have backed up prior to doing this upgrade).<br />
{{Cmd|lbu ci}}<br />
<br />
=== Load new kernel ===<br />
In most cases you will need to reboot Alpine Linux (especially if there are changes in the kernel):<br />
{{Cmd|sync<br />
reboot}}<br />
<br />
{{Note|If you know what you are doing, you might not need to reboot. But make sure that all services affected by the upgrade are restarted.}}<br />
<br />
=== Update to latest kernel on armhf (eg. Raspberry Pi 0 or 1) ===<br />
On Alpine 3.X and newer, kernel is not upgraded when using <code>apk upgrade</code> and <code>setup-bootable</code> does not work properly.<br />
<br />
If you want to upgrade your kernel, you will need to get it from the latest release, but first you must have and run :<br />
{{Cmd|apk update; apk version -l '<';<br />
apk upgrade;<br />
lbu ci;}}<br />
<br />
So now all your packages are upgraded, you can upgrade your kernel.<br />
<br />
1. We need to get some variables :<br />
{{Cmd|. /etc/os-release;<br />
. /etc/lbu/lbu.conf;}}<br />
<br />
2. You '''must''' verify if they are correctly set, using this :<br />
{{Cmd|echo "alpine version : $VERSION_ID";<br />
echo "lbu media : $LBU_MEDIA";}}<br />
<br />
3. And it will output something like this (if not, do not continue this process) :<br />
{{Cmd|alpine version : 3.13.5<br />
lbu media : mmcblk0p1}}<br />
<br />
4. Then you can run this script :<br />
{{Cmd|cd /media/$LBU_MEDIA;<br />
mount -oremount,rw /media/$LBU_MEDIA;<br />
wget https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/armhf/alpine-rpi-$VERSION_ID-armhf.tar.gz;<br />
wget https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/armhf/alpine-rpi-$VERSION_ID-armhf.tar.gz.sha256;<br />
sha256sum -c *.sha256;<br />
tar xzf alpine-rpi-$VERSION_ID-armhf.tar.gz;<br />
rm alpine-rpi-$VERSION_ID-armhf.tar.gz alpine-rpi-$VERSION_ID-armhf.tar.gz.sha256;<br />
sync;<br />
reboot;}}<br />
<br />
5. Test-it !<br />
{{Cmd|uname -a}}<br />
<br />
=== Update remaining packages from Web repository ===<br />
If you are using [[How_to_enable_APK_caching|APK caching]] you should follow the instructions to [[#Update_remaining_packages_from_Web_repository|Update remaining packages from Web repository]], above.<br />
<br />
== Updating a USB/CF diskless install without setup-bootable ==<br />
It is possible to update a diskless install of Alpine from another system, or without using the setup-bootable script. This was tested for the 3.13 to the 3.14 upgrade on a Raspberry Pi.<br />
<br />
Before starting, update /etc/apk/repositories file to retrieve packages for the new release. Then update all packages with:<br />
{{Cmd|apk update && apk upgrade -i -a --update-cache}}<br />
<br />
We can then use update-conf to check for changes to configurations from the new packages.<br />
{{Cmd|# check apk-new config changes<br />
update-conf -a -l<br />
update-conf -a<br />
}}<br />
<br />
We now need to prepare to update the kernel and boot materials. To do this, we stop the modloop (which is the loopback mount providing kernel modules) and remount the SD media as read/write.<br />
<br />
We can also shutdown the system, eject the media, and perform the next steps on another machine (if so, skip this command block)<br />
<br />
{{Cmd|/etc/init.d/modloop stop<br />
mount /media/mmcblk0p1 -o remount,rw<br />
cd /media/mmcblk0p1<br />
}}<br />
<br />
At this point, remove all files from the SD media '''except for /cache, *.apkvol.tar.gz, usercfg.txt, and config.txt''' Rename config.txt to config.txt.bak temporarily, as extracting the new tar file will overwrite the file.<br />
<br />
We can now download the new release and extract it. This example is for an Alpine Raspberry Pi release, so feel free to adjust the URLs for your system. <br />
<br />
{{Cmd|wget https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/aarch64/alpine-rpi-3.13.0-aarch64.tar.gz.sha256<br />
wget https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/aarch64/alpine-rpi-3.13.0-aarch64.tar.gz && sha256sum -c *.sha256<br />
sha256sum -c *.sha256<br />
tar zxf *-aarch64.tar.gz && sync<br />
rm alpine-rpi-*<br />
}}<br />
<br />
Restore the original usercfg.txt:<br />
{{Cmd|mv config.txt.bak config.txt}}<br />
<br />
Update the persistent storage using lbu:<br />
{{Cmd|lbu ci -d}}<br />
<br />
We can now reboot, and this should boot into the new kernel. Once this is done, we can clean up and re-download apk caches:<br />
{{Cmd|mount /media/mmcblk0p1 -o remount,rw<br />
rm /media/mmcblk0p1/cache/*<br />
sync && apk update && apk cache -v download<br />
mount /media/mmcblk0p1 -o remount,ro<br />
}}<br />
<br />
[[Category:Installation]]<br />
[[Category:Package Manager]]</div>Etothepiihttps://wiki.alpinelinux.org/w/index.php?title=Upgrading_Alpine&diff=19724Upgrading Alpine2021-06-29T22:26:41Z<p>Etothepii: Update instructions on diskless without setup-bootable to remove credit (as requested), adjust config file names, and remove extra lbu calls.</p>
<hr />
<div>This page covers upgrading to newer releases.<br />
<br />
Doing regular security updates with the package manager is shown at [[Alpine_Linux_package_management#Upgrade_a_Running_System|Upgrading a running system]].<br />
<br />
<br />
<br />
{{Warning|Before actually upgrading your system, make sure that you have a backup of your important data.}}<br />
<br />
<br />
== Upgrading an Alpine Linux Hard-disk installation ==<br />
<br />
=== Upgrading Alpine v2.x to v3.x ===<br />
<br />
{{Warning|Alpine Linux 3.x switched to a different libc implementation compared to previous versions. Because the new Musl libc is not ABI compatible with uClibc, there are additional steps required for an upgrade.}}<br />
<br />
==== Installing statically linked tools ====<br />
<br />
Statically linked version of apk-tools is needed, because the old musl version would stop working after a libc change (possibly in the middle of upgrade). Static version of busybox can be handy in case of the recovery from a failure.<br />
<br />
{{Cmd|apk add busybox-static apk-tools-static}}<br />
<br />
==== Changing repositories to v3.x ====<br />
<br />
To begin, you need to update your {{Path|/etc/apk/repositories}} file. Here are some shortcuts for doing so:<br />
:* Launch {{Cmd|setup-apkrepos}} Enter {{Key|e}} to edit {{Path|/etc/apk/repositories}}. Change the version number by hand.<br />
:* Or, edit the file in place. This is how you'd change <var>v2.7</var> to <var>v3.0</var>: {{Cmd|sed -i -e 's/<var>v2\.7</var>/<var>v3.0</var>/g' /etc/apk/repositories}}<br />
<br />
==== Upgrading system ====<br />
<br />
Use statically linked version of apk to update content of repository:<br />
<br />
{{Cmd|apk.static update}}<br />
<br />
Simulating upgrade is recommended in order to detect issues beforehand:<br />
<br />
{{Cmd|apk.static upgrade --no-self-upgrade --available --simulate}}<br />
<br />
With no problems encountered or after resolving them, start proper upgrade:<br />
<br />
{{Cmd|apk.static upgrade --no-self-upgrade --available}}<br />
<br />
=== Upgrading to latest release ===<br />
{{:Include:Upgrading to latest release}}<br />
<br />
=== Upgrading to Edge ===<br />
{{:Include:Upgrading to Edge}}<br />
<br />
=== Upgrading from older versions ===<br />
<br />
See [[Upgrading from older versions]].<br />
<br />
== Upgrading Alpine Linux on CD ==<br />
<br />
You may have an installation where the boot media being used (such as a CD, for example) is separate from the media used to store the configuration information. In this case, simply download the latest ISO, and replace the boot media contents with the contents of the latest ISO. If you are booting from a CD, this would simply mean replacing the CD with a CD made from the new image and rebooting the Alpine Linux box. <br />
<br />
=== Update remaining packages from Web repository ===<br />
<br />
If you are using [[How_to_enable_APK_caching|APK caching]] you should also perform the following steps.<br />
{{:Include:Using_Internet_Repositories_for_apk-tools}}<br />
<br />
If you're upgrading from a version of Alpine before 2.3.0_rc1, ensure you have the latest available version of the Alpine Linux Package Manager first before upgrading anything else:<br />
{{Cmd|apk add --upgrade apk-tools}}<br />
<br />
Next, upgrade all your packages:<br />
<br />
{{Cmd|apk upgrade --available<br />
sync}}<br />
<br />
The <code>--available</code> switch is used to force all packages to be upgraded, even if they have the same version numbers. Sometimes changes in uClibc require doing this.<br />
<br />
After upgrading packages, save any configuration changes (you should have backed up your earlier configuration prior to upgrading).<br />
{{Cmd|lbu ci}}<br />
<br />
<br />
== Upgrading Alpine Linux on other removable media (such as CF/USB) ==<br />
<br />
The following instructions are for run-from-RAM Alpine installations running on Compact Flash or USB media. Updating your repositories using [[#Upgrading_an_Alpine_Linux_Hard-disk_installation|the procedures detailed above]], then running:<br />
{{Cmd|apk upgrade --update-cache --available}}<br />
will suffice for some purposes. (If you want the new packages to be used after a reboot, you should [[How_to_enable_APK_caching|enable APK caching]].)<br />
<br />
However, this is not an adequate general solution because it won't honor any kernel upgrades and the like. For the general solution, you'll need to upgrade your boot medium (Compact Flash or USB). That is what the following steps describe how to do.<br />
<br />
{{:Include:Upgrading_Alpine_environmentvars}}<br />
<br />
=== Upgrade Operating System ===<br />
<br />
Start by checking that you have enough space on your media. For a '''standard''' Alpine image, you need at least 400MB available space.<br />
{{Cmd|df -h {{!}} grep "Filesystem\{{!}}$LBU_MEDIA"}}<br />
<br />
==== Download and verify new release ====<br />
<br />
Make sure the media that holds your Alpine system is mounted readwrite.<br />
{{Cmd|mount -oremount,rw /media/$LBU_MEDIA}}<br />
<br />
'''If using Alpine Linux 2.2.3 or newer''': Download the latest release, {{Cmd|wget https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/<arch>/<image>.iso}} and then use the following command to mount and copy files as needed for you: {{Cmd|setup-bootable -u alpine-extended-<version>-<arch>.iso /media/$LBU_MEDIA}} Once the command completes, proceed to the [[#Save changes|Save changes]] section.<br />
<br />
==== For older versions of Alpine ====<br />
Start downloading a new '.iso' and a '.sha1' file <br />
{{Cmd|cd /media/$LBU_MEDIA<br />
wget -c {{#latestalp:alpine|url}}<br />
wget {{#latestalp:alpine|url}}.sha1}}<br />
<br />
Check integrity of the downloaded files ''(it might take some time)'':<br />
{{Cmd|sha1sum -c {{#latestalp:alpine|file}}.sha1}}<br />
''The output of the above command should say 'OK'.<BR>''<br />
''If says 'FAILED', delete the iso file and download it again.''<br />
<br />
'''If using Alpine Linux 1.10.4 or newer''': there is a tool ''setup-bootable'' that will mount and copy the image you just downloaded to your boot medium. With this tool simply do: {{Cmd|setup-bootable -u {{#latestalp:alpine|file}} /media/$LBU_MEDIA}}<br />
<br />
[[Upgrading from older versions#Upgrading_a_removable_medium_from_Alpine_before_1.10.4|Instructions for older versions of Alpine]] are located elsewhere.<br />
<br />
=== Save changes ===<br />
Now that all upgrades are done, we should save our settings to our media (which you hopefully have backed up prior to doing this upgrade).<br />
{{Cmd|lbu ci}}<br />
<br />
=== Load new kernel ===<br />
In most cases you will need to reboot Alpine Linux (especially if there are changes in the kernel):<br />
{{Cmd|sync<br />
reboot}}<br />
<br />
{{Note|If you know what you are doing, you might not need to reboot. But make sure that all services affected by the upgrade are restarted.}}<br />
<br />
=== Update to latest kernel on armhf (eg. Raspberry Pi 0 or 1) ===<br />
On Alpine 3.X and newer, kernel is not upgraded when using <code>apk upgrade</code> and <code>setup-bootable</code> does not work properly.<br />
<br />
If you want to upgrade your kernel, you will need to get it from the latest release, but first you must have and run :<br />
{{Cmd|apk update; apk version -l '<';<br />
apk upgrade;<br />
lbu ci;}}<br />
<br />
So now all your packages are upgraded, you can upgrade your kernel.<br />
<br />
1. We need to get some variables :<br />
{{Cmd|. /etc/os-release;<br />
. /etc/lbu/lbu.conf;}}<br />
<br />
2. You '''must''' verify if they are correctly set, using this :<br />
{{Cmd|echo "alpine version : $VERSION_ID";<br />
echo "lbu media : $LBU_MEDIA";}}<br />
<br />
3. And it will output something like this (if not, do not continue this process) :<br />
{{Cmd|alpine version : 3.13.5<br />
lbu media : mmcblk0p1}}<br />
<br />
4. Then you can run this script :<br />
{{Cmd|cd /media/$LBU_MEDIA;<br />
mount -oremount,rw /media/$LBU_MEDIA;<br />
wget https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/armhf/alpine-rpi-$VERSION_ID-armhf.tar.gz;<br />
wget https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/armhf/alpine-rpi-$VERSION_ID-armhf.tar.gz.sha256;<br />
sha256sum -c *.sha256;<br />
tar xzf alpine-rpi-$VERSION_ID-armhf.tar.gz;<br />
rm alpine-rpi-$VERSION_ID-armhf.tar.gz alpine-rpi-$VERSION_ID-armhf.tar.gz.sha256;<br />
sync;<br />
reboot;}}<br />
<br />
5. Test-it !<br />
{{Cmd|uname -a}}<br />
<br />
=== Update remaining packages from Web repository ===<br />
If you are using [[How_to_enable_APK_caching|APK caching]] you should follow the instructions to [[#Update_remaining_packages_from_Web_repository|Update remaining packages from Web repository]], above.<br />
<br />
== Updating a USB/CF diskless install without setup-bootable ==<br />
It is possible to update a diskless install of Alpine from another system, or without using the setup-bootable script. This was tested for the 3.13 to the 3.14 upgrade on a Raspberry Pi.<br />
<br />
Before starting, update /etc/apk/repositories file to retrieve packages for the new release. Then update all packages with:<br />
{{Cmd|apk update && apk upgrade -i -a --update-cache}}<br />
<br />
We can then use update-conf to check for changes to configurations from the new packages.<br />
{{Cmd|# check apk-new config changes<br />
update-conf -a -l<br />
update-conf -a<br />
}}<br />
<br />
We now need to prepare to update the kernel and boot materials. To do this, we stop the modloop (which is the loopback mount providing kernel modules) and remount the SD media as read/write.<br />
<br />
We can also shutdown the system, eject the media, and perform the next steps on another machine (if so, skip this command block)<br />
<br />
{{Cmd|/etc/init.d/modloop stop<br />
mount /media/mmcblk0p1 -o remount,rw<br />
cd /media/mmcblk0p1<br />
}}<br />
<br />
At this point, remove all files from the SD media '''except for /cache, *.apkvol.tar.gz, usercfg.txt, and config.txt''' Rename config.txt to config.txt.bak temporarily, as extracting the new tar file will overwrite the file.<br />
<br />
We can now download the new release and extract it. This example is for an Alpine Raspberry Pi release, so feel free to adjust the URLs for your system. <br />
<br />
{{Cmd|wget https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/aarch64/alpine-rpi-3.13.0-aarch64.tar.gz.sha256<br />
sha256sum -c *.sha256<br />
tar zxf *-aarch64.tar.gz && sync<br />
rm alpine-rpi-*<br />
}}<br />
<br />
Restore the original usercfg.txt:<br />
{{Cmd|mv config.txt.bak config.txt}}<br />
<br />
Update the persistent storage using lbu:<br />
{{Cmd|lbu ci -d}}<br />
<br />
We can now reboot, and this should boot into the new kernel. Once this is done, we can clean up and re-download apk caches:<br />
{{Cmd|mount /media/mmcblk0p1 -o remount,rw<br />
rm /media/mmcblk0p1/cache/*<br />
sync && apk update && apk cache -v download<br />
mount /media/mmcblk0p1 -o remount,ro<br />
}}<br />
<br />
[[Category:Installation]]<br />
[[Category:Package Manager]]</div>Etothepiihttps://wiki.alpinelinux.org/w/index.php?title=Upgrading_Alpine&diff=19723Upgrading Alpine2021-06-29T22:17:21Z<p>Etothepii: Provide instructions to manually upgrade the system, or from another machine</p>
<hr />
<div>This page covers upgrading to newer releases.<br />
<br />
Doing regular security updates with the package manager is shown at [[Alpine_Linux_package_management#Upgrade_a_Running_System|Upgrading a running system]].<br />
<br />
<br />
<br />
{{Warning|Before actually upgrading your system, make sure that you have a backup of your important data.}}<br />
<br />
<br />
== Upgrading an Alpine Linux Hard-disk installation ==<br />
<br />
=== Upgrading Alpine v2.x to v3.x ===<br />
<br />
{{Warning|Alpine Linux 3.x switched to a different libc implementation compared to previous versions. Because the new Musl libc is not ABI compatible with uClibc, there are additional steps required for an upgrade.}}<br />
<br />
==== Installing statically linked tools ====<br />
<br />
Statically linked version of apk-tools is needed, because the old musl version would stop working after a libc change (possibly in the middle of upgrade). Static version of busybox can be handy in case of the recovery from a failure.<br />
<br />
{{Cmd|apk add busybox-static apk-tools-static}}<br />
<br />
==== Changing repositories to v3.x ====<br />
<br />
To begin, you need to update your {{Path|/etc/apk/repositories}} file. Here are some shortcuts for doing so:<br />
:* Launch {{Cmd|setup-apkrepos}} Enter {{Key|e}} to edit {{Path|/etc/apk/repositories}}. Change the version number by hand.<br />
:* Or, edit the file in place. This is how you'd change <var>v2.7</var> to <var>v3.0</var>: {{Cmd|sed -i -e 's/<var>v2\.7</var>/<var>v3.0</var>/g' /etc/apk/repositories}}<br />
<br />
==== Upgrading system ====<br />
<br />
Use statically linked version of apk to update content of repository:<br />
<br />
{{Cmd|apk.static update}}<br />
<br />
Simulating upgrade is recommended in order to detect issues beforehand:<br />
<br />
{{Cmd|apk.static upgrade --no-self-upgrade --available --simulate}}<br />
<br />
With no problems encountered or after resolving them, start proper upgrade:<br />
<br />
{{Cmd|apk.static upgrade --no-self-upgrade --available}}<br />
<br />
=== Upgrading to latest release ===<br />
{{:Include:Upgrading to latest release}}<br />
<br />
=== Upgrading to Edge ===<br />
{{:Include:Upgrading to Edge}}<br />
<br />
=== Upgrading from older versions ===<br />
<br />
See [[Upgrading from older versions]].<br />
<br />
== Upgrading Alpine Linux on CD ==<br />
<br />
You may have an installation where the boot media being used (such as a CD, for example) is separate from the media used to store the configuration information. In this case, simply download the latest ISO, and replace the boot media contents with the contents of the latest ISO. If you are booting from a CD, this would simply mean replacing the CD with a CD made from the new image and rebooting the Alpine Linux box. <br />
<br />
=== Update remaining packages from Web repository ===<br />
<br />
If you are using [[How_to_enable_APK_caching|APK caching]] you should also perform the following steps.<br />
{{:Include:Using_Internet_Repositories_for_apk-tools}}<br />
<br />
If you're upgrading from a version of Alpine before 2.3.0_rc1, ensure you have the latest available version of the Alpine Linux Package Manager first before upgrading anything else:<br />
{{Cmd|apk add --upgrade apk-tools}}<br />
<br />
Next, upgrade all your packages:<br />
<br />
{{Cmd|apk upgrade --available<br />
sync}}<br />
<br />
The <code>--available</code> switch is used to force all packages to be upgraded, even if they have the same version numbers. Sometimes changes in uClibc require doing this.<br />
<br />
After upgrading packages, save any configuration changes (you should have backed up your earlier configuration prior to upgrading).<br />
{{Cmd|lbu ci}}<br />
<br />
<br />
== Upgrading Alpine Linux on other removable media (such as CF/USB) ==<br />
<br />
The following instructions are for run-from-RAM Alpine installations running on Compact Flash or USB media. Updating your repositories using [[#Upgrading_an_Alpine_Linux_Hard-disk_installation|the procedures detailed above]], then running:<br />
{{Cmd|apk upgrade --update-cache --available}}<br />
will suffice for some purposes. (If you want the new packages to be used after a reboot, you should [[How_to_enable_APK_caching|enable APK caching]].)<br />
<br />
However, this is not an adequate general solution because it won't honor any kernel upgrades and the like. For the general solution, you'll need to upgrade your boot medium (Compact Flash or USB). That is what the following steps describe how to do.<br />
<br />
{{:Include:Upgrading_Alpine_environmentvars}}<br />
<br />
=== Upgrade Operating System ===<br />
<br />
Start by checking that you have enough space on your media. For a '''standard''' Alpine image, you need at least 400MB available space.<br />
{{Cmd|df -h {{!}} grep "Filesystem\{{!}}$LBU_MEDIA"}}<br />
<br />
==== Download and verify new release ====<br />
<br />
Make sure the media that holds your Alpine system is mounted readwrite.<br />
{{Cmd|mount -oremount,rw /media/$LBU_MEDIA}}<br />
<br />
'''If using Alpine Linux 2.2.3 or newer''': Download the latest release, {{Cmd|wget https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/<arch>/<image>.iso}} and then use the following command to mount and copy files as needed for you: {{Cmd|setup-bootable -u alpine-extended-<version>-<arch>.iso /media/$LBU_MEDIA}} Once the command completes, proceed to the [[#Save changes|Save changes]] section.<br />
<br />
==== For older versions of Alpine ====<br />
Start downloading a new '.iso' and a '.sha1' file <br />
{{Cmd|cd /media/$LBU_MEDIA<br />
wget -c {{#latestalp:alpine|url}}<br />
wget {{#latestalp:alpine|url}}.sha1}}<br />
<br />
Check integrity of the downloaded files ''(it might take some time)'':<br />
{{Cmd|sha1sum -c {{#latestalp:alpine|file}}.sha1}}<br />
''The output of the above command should say 'OK'.<BR>''<br />
''If says 'FAILED', delete the iso file and download it again.''<br />
<br />
'''If using Alpine Linux 1.10.4 or newer''': there is a tool ''setup-bootable'' that will mount and copy the image you just downloaded to your boot medium. With this tool simply do: {{Cmd|setup-bootable -u {{#latestalp:alpine|file}} /media/$LBU_MEDIA}}<br />
<br />
[[Upgrading from older versions#Upgrading_a_removable_medium_from_Alpine_before_1.10.4|Instructions for older versions of Alpine]] are located elsewhere.<br />
<br />
=== Save changes ===<br />
Now that all upgrades are done, we should save our settings to our media (which you hopefully have backed up prior to doing this upgrade).<br />
{{Cmd|lbu ci}}<br />
<br />
=== Load new kernel ===<br />
In most cases you will need to reboot Alpine Linux (especially if there are changes in the kernel):<br />
{{Cmd|sync<br />
reboot}}<br />
<br />
{{Note|If you know what you are doing, you might not need to reboot. But make sure that all services affected by the upgrade are restarted.}}<br />
<br />
=== Update to latest kernel on armhf (eg. Raspberry Pi 0 or 1) ===<br />
On Alpine 3.X and newer, kernel is not upgraded when using <code>apk upgrade</code> and <code>setup-bootable</code> does not work properly.<br />
<br />
If you want to upgrade your kernel, you will need to get it from the latest release, but first you must have and run :<br />
{{Cmd|apk update; apk version -l '<';<br />
apk upgrade;<br />
lbu ci;}}<br />
<br />
So now all your packages are upgraded, you can upgrade your kernel.<br />
<br />
1. We need to get some variables :<br />
{{Cmd|. /etc/os-release;<br />
. /etc/lbu/lbu.conf;}}<br />
<br />
2. You '''must''' verify if they are correctly set, using this :<br />
{{Cmd|echo "alpine version : $VERSION_ID";<br />
echo "lbu media : $LBU_MEDIA";}}<br />
<br />
3. And it will output something like this (if not, do not continue this process) :<br />
{{Cmd|alpine version : 3.13.5<br />
lbu media : mmcblk0p1}}<br />
<br />
4. Then you can run this script :<br />
{{Cmd|cd /media/$LBU_MEDIA;<br />
mount -oremount,rw /media/$LBU_MEDIA;<br />
wget https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/armhf/alpine-rpi-$VERSION_ID-armhf.tar.gz;<br />
wget https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/armhf/alpine-rpi-$VERSION_ID-armhf.tar.gz.sha256;<br />
sha256sum -c *.sha256;<br />
tar xzf alpine-rpi-$VERSION_ID-armhf.tar.gz;<br />
rm alpine-rpi-$VERSION_ID-armhf.tar.gz alpine-rpi-$VERSION_ID-armhf.tar.gz.sha256;<br />
sync;<br />
reboot;}}<br />
<br />
5. Test-it !<br />
{{Cmd|uname -a}}<br />
<br />
=== Update remaining packages from Web repository ===<br />
If you are using [[How_to_enable_APK_caching|APK caching]] you should follow the instructions to [[#Update_remaining_packages_from_Web_repository|Update remaining packages from Web repository]], above.<br />
<br />
== Updating a USB/CF diskless install without setup-bootable ==<br />
It is possible to update a diskless install of Alpine from another system, or without using the setup-bootable script. This was tested for the 3.13 to the 3.14 upgrade on a Raspberry Pi and provided by user 'MY-R'. <br />
<br />
Before starting, update /etc/apk/repositories file to retrieve packages for the new release. Then update all packages with:<br />
{{Cmd|apk update && apk upgrade -i -a --update-cache}}<br />
<br />
We can then use update-conf to check for changes to configurations from the new packages.<br />
{{Cmd|# check apk-new config changes<br />
update-conf -a -l<br />
update-conf -a<br />
}}<br />
<br />
We now need to prepare to update the kernel and boot materials. To do this, we stop the modloop (which is the loopback mount providing kernel modules) and remount the SD media as read/write.<br />
<br />
We can also shutdown the system, eject the media, and perform the next steps on another machine (if so, skip this command block)<br />
<br />
{{Cmd|/etc/init.d/modloop stop<br />
mount /media/mmcblk0p1 -o remount,rw<br />
cd /media/mmcblk0p1<br />
}}<br />
<br />
At this point, remove all files from the SD media '''except for /cache, *.apkvol.tar.gz, and usercfg.txt''' Rename usercfg.txt to usercfg.txt.bak temporarily, as extracting the new tar file will overwrite the file.<br />
<br />
We can now download the new release and extract it. This example is for an Alpine Raspberry Pi release, so feel free to adjust the URLs for your system. <br />
<br />
{{Cmd|wget https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/aarch64/alpine-rpi-3.13.0-aarch64.tar.gz.sha256<br />
sha256sum -c *.sha256<br />
tar zxf *-aarch64.tar.gz && sync<br />
rm alpine-rpi-*<br />
}}<br />
<br />
Restore the original usercfg.txt:<br />
{{Cmd|mv usercfg.txt.bak usercfg.txt}}<br />
<br />
Update the persistent storage using lbu:<br />
{{Cmd|lbu ci -d}}<br />
<br />
We can now reboot, and this should boot into the new kernel. Once this is done, we can clean up and re-download apk caches:<br />
{{Cmd|mount /media/mmcblk0p1 -o remount,rw<br />
rm /media/mmcblk0p1/cache/*<br />
sync && apk update && apk cache -v download<br />
lbu ci -d<br />
mount /media/mmcblk0p1 -o remount,ro<br />
}}<br />
<br />
[[Category:Installation]]<br />
[[Category:Package Manager]]</div>Etothepiihttps://wiki.alpinelinux.org/w/index.php?title=LXC&diff=19720LXC2021-06-29T02:47:10Z<p>Etothepii: To load a module at boot, it should be added to /etc/modules. Adding it into a file under modprobe will result in "ignoring bad line starting with 'dummy'" error.</p>
<hr />
<div>[https://linuxcontainers.org/ Linux Containers (LXC)] provides containers similar BSD Jails, Linux VServer and Solaris Zones. It gives the impression of virtualization, but shares the kernel and resources with the "host". You can use lxc directly or through [[LXD]].<br />
<br />
== Installation ==<br />
Install the required packages:<br />
{{Cmd|apk add lxc bridge lxcfs}}<br />
<br />
If you want to create containers other than alpine you will need lxc-templates:<br />
<br />
{{Cmd|apk add lxc-templates}}<br />
<br />
== Upgrading from 2.x ==<br />
<br />
Since Alpine 3.9 we ship LXC version 3.1.<br />
LXC 3.x has major changes which will/can break your current setup.<br />
LXC 3.x will NOT ship with legacy container templates. Check your current container configs to see if you have any includes pointing to files that don't exist (shipped by legacy templates).<br />
For example if you use Alpine containers created with the alpine template you will need to install:<br />
<br />
apk add lxc-templates-legacy-alpine<br />
<br />
Also make sure you convert your LXC config files to the new 2.x format (this is now required).<br />
<br />
lxc-update-config -c /var/lib/lxc/container-name/config<br />
<br />
Make sure you have removed '''cgroup_enable''' from your cmdline as this will fail to mount cgroups and fail LXC service.<br />
<br />
== Prepare network on host ==<br />
Set up a [[bridge]] on the host. Example ''/etc/network/interfaces'':<br />
<pre><br />
auto br0<br />
iface br0 inet dhcp<br />
bridge-ports eth0<br />
</pre><br />
<br />
Create a network configuration template for the guests, ''/etc/lxc/default.conf'':<br />
<pre><br />
lxc.net.0.type = veth<br />
lxc.net.0.link = br0<br />
lxc.net.0.flags = up<br />
lxc.net.0.hwaddr = fe:xx:xx:xx:xx:xx<br />
</pre><br />
<br />
== Grsecurity restrictions ==<br />
<br />
'''NOTE''': since alpine 3.8 we no longer ship grsecurity and it should not be used in lxc setup.<br />
<br />
Some restrictions will be applied when using a grsecurity kernel (Alpine Linux default kernel).<br />
The most notable is the use of lxc-attach which will not be allowed because of GRKERNSEC_CHROOT_CAPS.<br />
To solve this we will have to disable this grsec restriction by creating a sysctl profile for lxc.<br />
Create the following file ''/etc/sysctl.d/10-lxc.conf'' and add:<br />
<pre><br />
kernel.grsecurity.chroot_caps = 0<br />
</pre><br />
<br />
There are a few other restrictions that can prevent proper container functionality. <br />
When things do not work as expected always check the kernel log with dmesg to see if grsec prevented things from happening.<br />
<br />
Other possible restrictions are:<br />
<br />
<pre><br />
kernel.grsecurity.chroot_deny_chroot = 0<br />
kernel.grsecurity.chroot_deny_mount = 0<br />
kernel.grsecurity.chroot_deny_mknod = 0<br />
kernel.grsecurity.chroot_deny_chmod = 0<br />
</pre><br />
<br />
When you finished creating your new sysctl profile you can apply it by restarting sysctl service<br />
<br />
<pre><br />
rc-service sysctl restart<br />
</pre><br />
<br />
NOTE: Always consult the [https://en.wikibooks.org/wiki/Grsecurity/Appendix/Grsecurity_and_PaX_Configuration_Options Grsecurity documentation] before applying these settings.<br />
<br />
== Create a guest ==<br />
<br />
=== Alpine Template ===<br />
<br />
{{Cmd|lxc-create -n guest1 -f /etc/lxc/default.conf -t alpine}}<br />
<br />
This will create a ''/var/lib/lxc/guest1'' directory with a ''config'' file and a ''rootfs'' directory.<br />
<br />
Note that by default alpine template '''does not have networking service on''', you will need to add it using lxc-console<br />
<br />
<br />
If running on x86_64 architecture, it is possible to create a 32bit guest:<br />
<br />
{{Cmd|lxc-create -n guest1 -f /etc/lxc/default.conf -t alpine -- --arch x86}}<br />
<br />
=== Debian template ===<br />
<br />
In order to create a debian template container you will need to install some packages:<br />
<br />
{{Cmd|apk add debootstrap rsync}}<br />
<br />
Also you will need to turn off some grsecurity chroot options otherwise the debootstrap will fail:<br />
<br />
{{Cmd|echo 0 > /proc/sys/kernel/grsecurity/chroot_caps<br />
echo 0 > /proc/sys/kernel/grsecurity/chroot_deny_chroot<br />
echo 0 > /proc/sys/kernel/grsecurity/chroot_deny_mount<br />
echo 0 > /proc/sys/kernel/grsecurity/chroot_deny_mknod<br />
echo 0 > /proc/sys/kernel/grsecurity/chroot_deny_chmod<br />
}}<br />
<br />
Please remember to turn them back on, or just simply reboot the system.<br />
<br />
Now you can run:<br />
{{Cmd|SUITE{{=}}wheezy lxc-create -n guest1 -f /etc/lxc/default.conf -t debian}}<br />
<br />
=== Ubuntu template ===<br />
<br />
In order to create an ubuntu template container you will need to turn off some grsecurity chroot options:<br />
<br />
{{Cmd|echo 0 > /proc/sys/kernel/grsecurity/chroot_caps<br />
echo 0 > /proc/sys/kernel/grsecurity/chroot_deny_chroot<br />
echo 0 > /proc/sys/kernel/grsecurity/chroot_deny_mount<br />
echo 0 > /proc/sys/kernel/grsecurity/chroot_deny_mknod<br />
echo 0 > /proc/sys/kernel/grsecurity/chroot_deny_chmod<br />
}}<br />
<br />
Please remember to turn them back on, or just simply reboot the system.<br />
<br />
Now you can run (replace %MIRROR% with the actual hostname, for example: http://us.archive.ubuntu.com/ubuntu/)<br />
<br />
{{Cmd|lxc-create -n guest2 -f /etc/lxc/default.conf -t ubuntu -- -r xenial -a amd64 -u user --password secretpassword --mirror $MIRROR }}<br />
<br />
{{Warning|Be sure to set systemd_container to yes in /etc/conf.d/lxc.CONTAINER. Otherwise most functionality will be broken}}<br />
<br />
=== Unprivileged LXC images (Alpine / Debian / Ubuntu / Centos etc..) ===<br />
<br />
To enable unprivileged containers, one must create a uidgid map:<br />
<br />
echo root:1000000:65536 | tee -a /etc/subuid <br />
echo root:1000000:65536 | tee -a /etc/subgid<br />
<br />
This creates a uid and gid map for the root user starting at 1000000 with a size of 65536.<br />
<br />
To configure containers to use this mapping, add the following lines to the configuration:<br />
<br />
lxc.idmap = u 0 1000000 65536<br />
lxc.idmap = g 0 1000000 65536<br />
<br />
This can be in the global or container-specific configuration.<br />
<br />
To create an unprivileged lxc container, you need to use the download template. The download template must be installed.<br />
<br />
Then:<br />
<br />
{{Cmd|apk add gnupg xz lxc-download<br />
lxc-create -n container-name -t download}}<br />
& choose the Distribution | Release | Architecture.<br />
<br />
To be able to login to a Debian container you currently need to:<br />
{{Cmd|rm /lib/systemd/system/container-getty\@.service}}<br />
<br />
You can also [http://without-systemd.org/wiki/index.php/How_to_remove_systemd_from_a_Debian_jessie/sid_installationers remove Systemd from the container].<br />
<br />
== Starting/Stopping the guest ==<br />
<br />
At first, you should enable the cgroup script:<br />
<br />
{{Cmd|rc-update add cgroups}}<br />
<br />
If you don't want to reboot, you can start the service now:<br />
<br />
{{Cmd|rc-service cgroups start}}<br />
<br />
Create a symlink to the ''/etc/init.d/lxc'' script for your guest.<br />
{{Cmd|ln -s lxc /etc/init.d/lxc.guest1}}<br />
<br />
You can start your guest with:<br />
{{Cmd|/etc/init.d/lxc.guest1 start}}<br />
<br />
Stop it with:<br />
{{Cmd|/etc/init.d/lxc.guest1 stop}}<br />
<br />
Make it autostart on boot up with:<br />
{{Cmd| rc-update add lxc.guest1}}<br />
<br />
You can also add to the container config: <code>lxc.start.auto = 1</code><br />
<br />
& {{Cmd|rc-update add lxc}}<br />
<br />
to autostart containers by the lxc service only.<br />
<br />
== Connecting to the guest ==<br />
By default sshd is not installed, so you will have to attach to the container or connect to the virtual console. This is done with:<br />
<br />
=== Attach to container ===<br />
<br />
{{Cmd|lxc-attach -n guest1}}<br />
<br />
Just type exit to detach the container again (please do check the grsec notes above)<br />
<br />
=== Connect to virtual console ===<br />
<br />
{{Cmd|lxc-console -n guest1}}<br />
<br />
To disconnect from it, press {{key|Ctrl}}+{{key|a}} {{key|q}}<br />
<br />
== Deleting a guest ==<br />
Make sure the guest is stopped and run:<br />
{{Cmd|lxc-destroy -n guest1}}<br />
This will erase everything, without asking any questions. It is equivalent to: {{Cmd|rm -r /var/lib/lxc/guest1}}<br />
<br />
== Advanced ==<br />
<br />
=== Creating a LXC container without modifying your network interfaces ===<br />
<br />
The problem with bridging is that the interface you bridge gets replaced with your new bridge interface.<br />
That is to say that say you have an interface eth0 that you want to bridge, your eth0 interface gets replaced with the br0 interface that you create. It also means that the interface you use needs to be placed into promiscuous mode to catch all the traffic that could de destined to the other side of the bridge, which again may not be what you want.<br />
<br />
The solution is to create a dummy network interface, bridge that, and set up NAT so that traffic out of your bridge interface gets pushed through the interface of your choice.<br />
<br />
So, first, lets create that dummy interface (thanks to ncopa for talking me out of macvlan and pointing out the dummy interface kernel module)<br />
<br />
{{Cmd|modprobe dummy}}<br />
<br />
This will create a dummy interface called dummy0 on your host. To create this interface on every boot, append "dummy" to /etc/modules:<br />
<br />
Now we will create a bridge called br0<br />
<br />
{{Cmd |brctl addbr br0<br />
brctl setfd br0 0 }}<br />
<br />
and then make that dummy interface one end of the bridge<br />
<br />
{{Cmd | brctl addif br0 dummy0 }}<br />
<br />
Next, let's give that bridged interface a reason to exists<br />
<br />
{{ Cmd | ifconfig br0 192.168.1.1 netmask 255.255.255.0 up}}<br />
<br />
Create a file for your container, let's say /etc/lxc/bridgenat.conf, with the following settings.<br />
<br />
<pre><br />
lxc.net.0.type = veth<br />
lxc.net.0.flags = up<br />
lxc.net.0.link = br0<br />
lxc.net.0.name = eth1<br />
lxc.net.0.ipv4.address = 192.168.1.2/24 192.168.1.255<br />
lxc.net.0.ipv4.gateway = 192.168.1.1<br />
lxc.net.0.veth.pair = veth-if-0<br />
</pre><br />
<br />
and build your container with that file<br />
<br />
{{ Cmd | lxc-create -n alpine -f /etc/lxc/bridgenat.conf -t alpine }}<br />
<br />
You should now be able to ping your container from your hosts, and your host from your container.<br />
<br />
Your container needs to know where to push traffic that isn't within it's subnet. To do so, we tell the container to route through the bridge interface br0<br />
From inside the container run<br />
<br />
{{ Cmd | route add default gw 192.168.1.1 }}<br />
<br />
The next step is you push the traffic coming from your private subnet over br0 out through your internet facing interface, or any interface you chose<br />
<br />
We are messing with your IP tables here, so make sure these settings don't conflict with anything you may have already set up, obviously.<br />
<br />
Say eth0 was your internet facing network interface, and br0 is the name of the bridge you made earlier, we'd do this:<br />
<br />
{{ Cmd | echo 1 > /proc/sys/net/ipv4/ip_forward<br />
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE<br />
iptables --append FORWARD --in-interface br0 -j ACCEPT<br />
}}<br />
<br />
Now you should be able to route through your bridge interface to the internet facing interface of your host from your container, just like at home!<br />
<br />
You could also have a dhcp server running on your host, and set it up to give IP addresses from your private subnet to any container that requests it, and then have one template for multiple alpine LXC containers, perfect for alpine development :)<br />
<br />
=== Using static IP ===<br />
<br />
If you're using static IP, you need to configure this properly on guest's /etc/network/interfaces. To stay on the above example, modify ''/var/lib/lxc/guest1/rootfs/etc/network/interfaces'' <br />
<br />
from<br />
<br />
#auto lo<br />
iface lo inet loopback<br />
auto eth0<br />
iface eth0 inet '''dhcp'''<br />
<br />
to <br />
<br />
#auto lo<br />
iface lo inet loopback<br />
auto eth0<br />
iface eth0 inet '''static'''<br />
address <lxc-container-ip> # IP which the lxc container should use<br />
gateway <gateway-ip> # IP of gateway to use, mostly same as on lxc-host<br />
netmask <netmask><br />
<br />
=== mem and swap ===<br />
<br />
{{Cmd|vim /boot/extlinux.conf}}<br />
<br />
{{Cmd|<br />
APPEND initrd{{=}}initramfs-3.10.13-1-grsec root{{=}}UUID{{=}}7cd8789f-5659-40f8-9548-ae8f89c918ab modules{{=}}sd-mod,usb-storage,ext4 quiet cgroup_enable{{=}}memory swapaccount{{=}}1<br />
}}<br />
<br />
=== checkconfig ===<br />
{{Cmd|lxc-checkconfig}}<br />
<br />
{{Cmd|<br />
Kernel configuration not found at /proc/config.gz; searching...<br />
Kernel configuration found at /boot/config-3.10.13-1-grsec<br />
--- Namespaces ---<br />
Namespaces: enabled<br />
Utsname namespace: enabled<br />
Ipc namespace: enabled<br />
Pid namespace: enabled<br />
User namespace: missing<br />
Network namespace: enabled<br />
Multiple /dev/pts instances: enabled<br />
<br />
--- Control groups ---<br />
Cgroup: enabled<br />
Cgroup clone_children flag: enabled<br />
Cgroup device: enabled<br />
Cgroup sched: enabled<br />
Cgroup cpu account: enabled<br />
Cgroup memory controller: missing<br />
Cgroup cpuset: enabled<br />
<br />
--- Misc ---<br />
Veth pair device: enabled<br />
Macvlan: enabled<br />
Vlan: enabled<br />
File capabilities: enabled<br />
<br />
Note : Before booting a new kernel, you can check its configuration<br />
usage : CONFIG{{=}}/path/to/config /usr/bin/lxc-checkconfig<br />
<br />
}}<br />
<br />
=== VirtualBox ===<br />
<br />
In order for network to work on containers you need to set "Promiscuous Mode" to "Allow All" in VirtualBox settings for the network adapter.<br />
<br />
[[File:VirtualBoxNetworkAdapter.jpg]]<br />
<br />
[[Category:Virtualization]]<br />
<br />
=== postgreSQL ===<br />
<br />
Inside the container run: {{Cmd|chmod go+w /dev/null}} to fix {{Cmd|rc-service postgresql start}}<br />
<br />
=== openVPN ===<br />
<br />
see [[Setting_up_a_OpenVPN_server#openVPN_and_LXC]]<br />
<br />
== LXC 1.0 Additional information ==<br />
<br />
Some info regarding new features in LXC 1.0<br />
<br />
https://www.stgraber.org/2013/12/20/lxc-1-0-blog-post-series/<br />
<br />
== See also ==<br />
* [[Howto-lxc-simple]]</div>Etothepiihttps://wiki.alpinelinux.org/w/index.php?title=Talk:Raspberry_Pi&diff=19708Talk:Raspberry Pi2021-06-28T02:15:12Z<p>Etothepii: Add signature/date to proposal.</p>
<hr />
<div>== Known Bugs ==<br />
Added a warning since I wasted more than an hour trying to boot.<br />
-- [[User:Lucid|Lucid]] Thu, 11 Feb 2021 15:01:24 -0500<br />
<br />
== Entropy ==<br />
<br />
Added a troubleshooting section since I ran into a few issues that weren't immediately obvious. I'll update the section a bit more later but for the entropy issue I haven't yet found a good solution (appropriate package? haveged with runlevel default didn't help) so put in the best short term fix I could find for now.<br />
<br />
It might be a good idea to add a note about tmpfs being ram-limited. On a 3A+ only ~200M is available for / on a basic installation which severely limits the amount of packages that can be installed.<br />
<br />
== Persistence ==<br />
Wouldn't it be more reasonable to partition the SD-Card accordingly? That way, you could have FS > 2GB, too. --[[User:Kurushiyama|Kurushiyama]] ([[User talk:Kurushiyama|talk]]) 10:53, 8 October 2016 (UTC)<br />
<br />
I have read that using a journalling fs is not a good idea for SD cards as it shortens their life by multiplying the read/writes. Wouldn't ext2 thus be a better fs for persistent overlays? -- [[User:Nevarmaor|Nevarmaor]] ([[User talk:Nevarmaor|talk]]) 21:56, 20 February 2017 (UTC)<br />
<br />
Having burned holes in far too many SD Cards I'm writing up some notes to setup a persistent storage running off of [https://en.wikipedia.org/wiki/F2FS F2FS]. I think that should be the default.<br />
-- [[User:Lucid|Lucid]] Thu, 11 Feb 2021 15:01:24 -0500<br />
<br />
== Installing Alpine- Linux on raspberry pi zero w (udhcpc fail problem) ==<br />
<br />
The existing tutorial for raspberry pi is followed except on the reboot, the udhcpc attempts to connect and fails. I managed to fix this problem by editing the /etc/network/interfaces file and add the line:<br />
<br />
iface wlan0 inet dhcp<br />
pre-up wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf #<--This is the line added to pre-start the wpa_supplicant daemon and log on correctly. <br />
<br />
I learned this with the help of the tutorial by Jack Wallen: How to Configure Wireless... on linux.com website<br />
<br />
== Which version should I use? ==<br />
<br />
There are now three versions of Alpine to choose from (armv7, armhf, aarch64), it might be useful to have a table indicating which version is supported on which hardware. (I'm already unclear on why armv7 and armhf, I assume both are 32 bits and armv7 has soft-float-point instead of hard-float-point, but don't all RPi devices have hard-float-point capabilities? It would be useful to have a little text about this.)<br />
<br />
As I understand aarch64 only applies to BCM2837 and above chips (ARMv8 and above), which means it can only run on RPi 3 and above (but I believe RPi 3 and above should be able to use the other images since they also support the 32 bits mode).<br />
<br />
Conversely I assume armhf should be usable on all RPi.<br />
<br />
== New Install on RPi Zero W ==<br />
<br />
I finally got my Pi Zero W installation done and encountered during setup and subsequent boots very sketchy network performance in the form of very high packet loss. I overcame this by switching from static IP address (which seemed to break networking scripts) to dhcp by editing the /etc/network/interfaces file. I also edited the /etc/wpa_supplicant/wpa_supplicant.conf file using vi to delete duplicated entries which accumulated while trying to get a decent network connection via wireless. <br />
<br />
I then went on to try to install the software which is the purpose of using Alpine for me, mosquitto. This had me stumped as I am using armhf, V3.12, have the 3.12 main, community, edge main and community and testing repos and can see mosquito and mosquito-clients packages in the repository listing but consistently get errors on install. I tried to resolve dependencies by hand via installation on required packages with the result I can install some but not all of these packages. I can install other software such as sshd and nmap but get an almost meaningless to me error about unsatisfiable contraints, mosquito (missing), which I am guessing means it is not really in the repo or the entry in the repo does not work. <br />
<br />
This is an added comment about overlooking the obvious - I was mispelling mosquitto (yes, I was trying to install something I typed as mosquito, missing one 't'). It worked much better with the correct spelling and now I can take back most of those things I was saying about the maintainer of the repo. <br />
<br />
I notice no activity on these wiki pages for over a year. Anybody actually use this section of the Wiki?<br />
<br />
== Proposal: Consolidating Disk Installation Materials ==<br />
It looks like the material on disk-based installation is currently spread between this page and another dedicated page [[Classic install or sys mode on Raspberry Pi|sys-mode install page]]. I would like to propose merging it with the sys-install instructions, so there's only one copy. That will lower the maintenance burden when the procedure changes. --[[User:Etothepii|Etothepii]] June 27, 2021.</div>Etothepiihttps://wiki.alpinelinux.org/w/index.php?title=Talk:Raspberry_Pi&diff=19707Talk:Raspberry Pi2021-06-28T02:12:12Z<p>Etothepii: Add notes on proposing removing the sys-install section and folding it into the sys-install page for Raspi.</p>
<hr />
<div>== Known Bugs ==<br />
Added a warning since I wasted more than an hour trying to boot.<br />
-- [[User:Lucid|Lucid]] Thu, 11 Feb 2021 15:01:24 -0500<br />
<br />
== Entropy ==<br />
<br />
Added a troubleshooting section since I ran into a few issues that weren't immediately obvious. I'll update the section a bit more later but for the entropy issue I haven't yet found a good solution (appropriate package? haveged with runlevel default didn't help) so put in the best short term fix I could find for now.<br />
<br />
It might be a good idea to add a note about tmpfs being ram-limited. On a 3A+ only ~200M is available for / on a basic installation which severely limits the amount of packages that can be installed.<br />
<br />
== Persistence ==<br />
Wouldn't it be more reasonable to partition the SD-Card accordingly? That way, you could have FS > 2GB, too. --[[User:Kurushiyama|Kurushiyama]] ([[User talk:Kurushiyama|talk]]) 10:53, 8 October 2016 (UTC)<br />
<br />
I have read that using a journalling fs is not a good idea for SD cards as it shortens their life by multiplying the read/writes. Wouldn't ext2 thus be a better fs for persistent overlays? -- [[User:Nevarmaor|Nevarmaor]] ([[User talk:Nevarmaor|talk]]) 21:56, 20 February 2017 (UTC)<br />
<br />
Having burned holes in far too many SD Cards I'm writing up some notes to setup a persistent storage running off of [https://en.wikipedia.org/wiki/F2FS F2FS]. I think that should be the default.<br />
-- [[User:Lucid|Lucid]] Thu, 11 Feb 2021 15:01:24 -0500<br />
<br />
== Installing Alpine- Linux on raspberry pi zero w (udhcpc fail problem) ==<br />
<br />
The existing tutorial for raspberry pi is followed except on the reboot, the udhcpc attempts to connect and fails. I managed to fix this problem by editing the /etc/network/interfaces file and add the line:<br />
<br />
iface wlan0 inet dhcp<br />
pre-up wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf #<--This is the line added to pre-start the wpa_supplicant daemon and log on correctly. <br />
<br />
I learned this with the help of the tutorial by Jack Wallen: How to Configure Wireless... on linux.com website<br />
<br />
== Which version should I use? ==<br />
<br />
There are now three versions of Alpine to choose from (armv7, armhf, aarch64), it might be useful to have a table indicating which version is supported on which hardware. (I'm already unclear on why armv7 and armhf, I assume both are 32 bits and armv7 has soft-float-point instead of hard-float-point, but don't all RPi devices have hard-float-point capabilities? It would be useful to have a little text about this.)<br />
<br />
As I understand aarch64 only applies to BCM2837 and above chips (ARMv8 and above), which means it can only run on RPi 3 and above (but I believe RPi 3 and above should be able to use the other images since they also support the 32 bits mode).<br />
<br />
Conversely I assume armhf should be usable on all RPi.<br />
<br />
== New Install on RPi Zero W ==<br />
<br />
I finally got my Pi Zero W installation done and encountered during setup and subsequent boots very sketchy network performance in the form of very high packet loss. I overcame this by switching from static IP address (which seemed to break networking scripts) to dhcp by editing the /etc/network/interfaces file. I also edited the /etc/wpa_supplicant/wpa_supplicant.conf file using vi to delete duplicated entries which accumulated while trying to get a decent network connection via wireless. <br />
<br />
I then went on to try to install the software which is the purpose of using Alpine for me, mosquitto. This had me stumped as I am using armhf, V3.12, have the 3.12 main, community, edge main and community and testing repos and can see mosquito and mosquito-clients packages in the repository listing but consistently get errors on install. I tried to resolve dependencies by hand via installation on required packages with the result I can install some but not all of these packages. I can install other software such as sshd and nmap but get an almost meaningless to me error about unsatisfiable contraints, mosquito (missing), which I am guessing means it is not really in the repo or the entry in the repo does not work. <br />
<br />
This is an added comment about overlooking the obvious - I was mispelling mosquitto (yes, I was trying to install something I typed as mosquito, missing one 't'). It worked much better with the correct spelling and now I can take back most of those things I was saying about the maintainer of the repo. <br />
<br />
I notice no activity on these wiki pages for over a year. Anybody actually use this section of the Wiki?<br />
<br />
== Proposal: Consolidating Disk Installation Materials ==<br />
It looks like the material on disk-based installation is currently spread between this page and another dedicated page [[Classic install or sys mode on Raspberry Pi|sys-mode install page]]. I would like to propose merging it with the sys-install instructions, so there's only one copy. That will lower the maintenance burden when the procedure changes.</div>Etothepiihttps://wiki.alpinelinux.org/w/index.php?title=Raspberry_Pi&diff=19706Raspberry Pi2021-06-28T02:09:23Z<p>Etothepii: Add merge proposal for section on disk-based install</p>
<hr />
<div>{{TOC right}}<br />
<br />
This tutorial will help you install Alpine Linux on your Raspberry Pi.<br />
<br />
{{warning | 11 Feb 2021 - There is currently a known bug upstream <br />[https://github.com/raspberrypi/firmware/issues/1529 kernel/initramfs cannot be loaded from subdirectory with same name as volume label] }}<br />
<br />
== Preparation ==<br />
<br />
# [http://alpinelinux.org/downloads/ Download] the Alpine for Raspberry Pi tarball. You should be safe using the '''armhf''' build on all versions of Raspberry Pi (including Pi Zero and Compute Modules); but it may perform less optimally on recent versions of Raspberry Pi. The '''armv7''' build is compatible with Raspberry Pi 2 Model B. The '''aarch64''' build should be compatible with Raspberry Pi 2 Model v1.2, Raspberry Pi 3 and Compute Module 3, and Raspberry Pi 4 model B.<br />
# [[Create a Bootable USB#Format USB stick|Create a bootable FAT32 partition on your SD card.]] The partition type should be <code>W95 FAT32 (LBA)</code>. (The current type can be found in the "Type" column in the output of <code>fdisk -l</code>.) You can use a partitioning tool such as [https://en.wikipedia.org/wiki/GNOME_Disks gnome-disks] or [http://linux.die.net/man/8/fdisk fdisk].<br />
# Create a filesystem on the partition with <code>mkdosfs -F 32 /dev/sdX1</code> (Replace sdX1 with the correct reference to the partition you just created.)<br />
# Mount the partition and extract the tarball contents unto it.<br />
<br />
Optionally create a '''usercfg.txt''' file on the partition to configure low-level system settings. Specifications can be found [https://www.raspberrypi.org/documentation/configuration/config-txt here]. Note, however, that some settings can only be set directly in '''config.txt'''. In particular, <code>gpu_mem</code> will have no effect when specified in '''usercfg.txt''' [https://github.com/raspberrypi/firmware/issues/1332 source]. Some interesting values include:<br />
* To enable audio: <code>dtparam=audio=on</code><br />
* If you see black edges around your screen after booting the Pi, you can add <code>disable_overscan=1</code><br />
<br />
Recent versions include Broadcom firmware files. If you're using an older Alpine version, see [[#Wireless_support_with_older_Alpine_images|section below]].<br />
<br />
== Installation ==<br />
<br />
Alpine Linux will be installed as [[Installation#Installation_Handbook|diskless mode]], hence you need to use [[Alpine local backup|Alpine Local Backup (lbu)]] to save your modifications between reboots.<br />
<br />
For users who will be using their Raspberry Pi in scenarios where there is not expected to be significant changes to disk after setup (like running a static HTTP server), this is likely preferable, as running the entire system from memory will help improve performance (by avoiding the slow SD card) and improve the SD card life (by reducing the writes to the card, as all logging will happen in memory). Diskless installations still allow you to install packages, save local files, and tune the system to your needs. <br />
<br />
However, if you:<br />
* Expect there will be constant changes to the disk after initial setup (for example, if you expect people to login and save files in their home directories)<br />
* Need logs to reliably persist after reboot<br />
* Plan to install packages which consume more space than can be loaded into RAM<br />
* Want to install kernel modules (such as ZFS or Wireguard)<br />
<br />
Then may be better served by a [[Classic install or sys mode on Raspberry Pi|sys-mode installation]]. <br />
<br />
Follow these steps to install Alpine Linux in Diskless Mode:<br />
<br />
# Insert the SD card into the Raspberry Pi and turn it on<br />
# Login into the Alpine system as root. Leave the password empty.<br />
# Type <code>setup-alpine</code><br />
# Once the installation is complete, commit the changes by typing <code>lbu commit -d</code><br />
<br />
Type <code>reboot</code> to verify that the installation was indeed successful.<br />
<br />
== Post Installation ==<br />
<br />
=== Update the System ===<br />
<br />
Upon installation, make sure that your system is up-to-date:<br />
<br />
{{cmd|apk update<br />
apk upgrade}}<br />
<br />
Don't forget to save the changes:<br />
<br />
{{cmd|lbu commit -d}}<br />
<br />
Note that this does not upgrade the kernel. In order to upgrade the kernel, a full upgrade of the Alpine Linux version must be performed as described in [[Upgrading Alpine#Upgrading Alpine Linux on other removable media (such as CF/USB)|upgrading Alpine Linux for removable media]].<br />
<br />
=== Clock-related error messages ===<br />
<br />
During the booting time, you might notice errors related to the hardware clock. The Raspberry Pi does not have<br />
a hardware clock and therefore you need to disable the hwclock daemon and enable swclock:<br />
<br />
{{cmd|rc-update add swclock boot # enable the software clock<br />
rc-update del hwclock boot # disable the hardware clock}}<br />
<br />
Since Raspberry Pi does not have a clock, the Alpine Linux needs to know what the time is by using a<br />
[https://en.wikipedia.org/wiki/Network_Time_Protocol Network Time Protocol (NTP)] daemon. Make sure that you a<br />
NTP daemon installed and running. If you are not sure, then you can install NTP client by running the following<br />
command:<br />
<br />
{{cmd|setup-ntp}}<br />
<br />
The Busybox NTP client might be the most lightweight solution. Save the changes and reboot, once the NTP software is<br />
installed and running:<br />
<br />
{{cmd|lbu commit -d<br />
reboot}}<br />
<br />
After reboot, make sure that the <code>date</code> command outputs the correct date and time.<br />
<br />
=== WiFi on boot ===<br />
If you have already [[Connecting_to_a_wireless_access_point|configured WiFi]] during the setup, the connection will not return on reboot.<br />
You will need to start up a service to automatically connect to the wireless access point.<br />
# Run <code>rc-update add wpa_supplicant boot</code> to connect to the wireless access point on boot.<br />
# Run it manually with <code>/etc/init.d/wpa_supplicant start</code>.<br />
<br />
=== Enable OpenGL (Raspberry Pi 3) ===<br />
<br />
Remount the boot partition writeable (ie. /media/mmcblk0p1):<br />
<br />
{{cmd|mount -o remount,rw /media/mmcblk0p1}}<br />
<br />
Add the following lines to /media/mmcblk0p1/config.txt <br />
<br />
dtoverlay=vc4-kms-v3d<br />
gpu_mem=128<br />
<br />
256MB gpu_mem is also possible<br />
<br />
Install mesa-dri-vc4:<br />
{{cmd|apk add mesa-dri-vc4}}<br />
<br />
Reboot:<br />
<br />
{{cmd|lbu_commit -d; reboot}}<br />
<br />
== Persistent storage ==<br />
<br />
=== Loopback image with overlayfs ===<br />
<br />
When you install Alpine in diskless mode, the entire system is loaded into memory at boot. If you want additional storage (for example, if you need more space than offered by your RAM) we need to create loop-back storage onto the SD mounted with overlayfs.<br />
<br />
First make the SD card writable again and change fstab to always do so:<br />
{{cmd|mount /media/mmcblk0p1 -o rw,remount<br />
sed -i 's/vfat\ ro,/vfat\ rw,/' /etc/fstab}}<br />
<br />
Create the loop-back file, this example is 1 GB:<br />
<br />
{{cmd|dd if&#61;/dev/zero of&#61;/media/mmcblk0p1/persist.img bs&#61;1024 count&#61;0 seek&#61;1048576}}<br />
<br />
Install the ext utilities:<br />
<br />
{{cmd|apk add e2fsprogs}}<br />
<br />
Format the loop-back file:<br />
<br />
{{cmd|mkfs.ext4 /media/mmcblk0p1/persist.img}}<br />
<br />
Mount the storage: <br />
<br />
{{cmd|echo "/media/mmcblk0p1/persist.img /media/persist ext4 rw,relatime,errors&#61;remount-ro 0 0" >> /etc/fstab<br />
mkdir /media/persist <br />
mount -a}}<br />
<br />
Make the overlay folders, we are doing /usr here, but you can do /home or anything else:<br />
<br />
{{cmd|mkdir /media/persist/usr <br />
mkdir /media/persist/.work <br />
echo "overlay /usr overlay lowerdir&#61;/usr,upperdir&#61;/media/persist/usr,workdir&#61;/media/persist/.work 0 0" >> /etc/fstab <br />
mount -a}}<br />
<br />
Your /etc/fstab should look something like this:<br />
{{Cmd|/dev/cdrom /media/cdrom iso9660 noauto,ro 0 0<br />
/dev/usbdisk /media/usb vfat noauto,ro 0 0<br />
/dev/mmcblk0p1 /media/mmcblk0p1 vfat rw,relatime,fmask&#61;0022,dmask&#61;0022,errors&#61;remount-ro 0 0<br />
/media/mmcblk0p1/persist.img /media/persist ext4 rw,relatime,errors&#61;remount-ro 0 0<br />
overlay /usr overlay lowerdir&#61;/usr,upperdir&#61;/media/persist/usr,workdir&#61;/media/persist/.work 0 0}}<br />
<br />
Now commit the changes: (optionally remove the e2fsprogs, but it does contain repair tools)<br />
{{cmd|lbu_commit -d}}<br />
<br />
Remember with this setup, if you install things and you have done this overlay for /usr, you must not commit the 'apk add', otherwise while it boots it will try and install it to memory and not to the persist storage.<br />
<br />
If you do want to install something small at boot you can use `apk add` and `lbu commit -d`.<br />
<br />
If it is something a bit bigger then you can use `apk add` but then not commit it, it will be persistent (in /user), but do check everything you need is in that directory and not in folders you have not made persistent.<br />
<br />
=== Traditional disk-based (sys) installation ===<br />
<br />
{{Warning|This isn't yet supported by the Alpine setup scripts for Raspberry Pi. It requires manual intervention, and might break.}}<br />
{{Merge|Classic install or sys mode on Raspberry Pi|There's an existing page for sys-installations on Raspi.}}<br />
<br />
It is also possible to switch to a fully disk-based installation: this is not yet formally supported, but can be done somewhat manually. This frees all the memory otherwise needed for the root filesystem, allowing more installed packages.<br />
<br />
Split your SD card into two partitions: the FAT32 boot partition described above (in this example it'll be <code>mmcblk0p1</code>) , and a second partition to hold the root filesystem (here it'll be <code>mmcblk0p2</code>). Boot and configure your diskless system as above, then create a root filesystem:<br />
<br />
{{cmd|apk add e2fsprogs<br />
mkfs.ext4 /dev/mmcblk0p2}}<br />
<br />
Now do a disk install via a mountpoint. The <code>setup-disk</code> script will give some errors about syslinux/extlinux, but you can ignore these: the Raspberry Pi doesn't need this to boot anyway.<br />
<br />
{{cmd|<nowiki>mkdir /stage<br />
mount /dev/mmcblk0p2 /stage<br />
setup-disk -o /media/mmcblk0p1/MYHOSTNAME.apkovl.tar.gz /stage<br />
# (ignore errors about syslinux/extlinux)</nowiki>}}<br />
<br />
Add a line to <code>/stage/etc/fstab</code> to mount the Pi's boot partition again:<br />
<br />
{{cmd|/dev/mmcblk0p1 /media/mmcblk0p1 vfat defaults 0 0}}<br />
<br />
Now add a <code>root=/dev/mmcblk0p2</code> parameter to the Pi's boot command line, either <code>cmdline-rpi2.txt</code> or <code>cmdline-rpi.txt</code> depending on model:<br />
<br />
{{cmd|<nowiki>mount -o remount,rw /media/mmcblk0p1<br />
sed -i '$ s/$/ root=\/dev\/mmcblk0p2/' /media/mmcblk0p1/cmdline-rpi2.txt</nowiki>}}<br />
<br />
You might also consider <code>overlaytmpfs=yes</code> here, which will cause the underlying SD card root filesystem to be mounted read-only, with an overlayed tmpfs for modifications which will be discarded on shutdown.<br />
<br />
Beware, though, that <b>the contents of /boot will be ignored when the Pi boots</b>: it will use the kernel, initramfs, and modloop images from the FAT32 boot partition. To update the kernel, initfs or modules, you will need to manually (generate and) copy these to the boot partition or you could use bind mount so that manually copy the files to boot partition is not needed.<br />
<br />
{{cmd|<nowiki>echo /media/mmcblk0p1/boot /boot none defaults,bind 0 0 >> /etc/fstab</nowiki>}}<br />
<br />
=== Persistent Installation on Raspberry Pi 3 ===<br />
<br />
See this page : https://wiki.alpinelinux.org/wiki/Classic_install_or_sys_mode_on_Raspberry_Pi<br />
<br />
See https://web.archive.org/web/20171125115835/https://forum.alpinelinux.org/comment/1084#comment-1084<br />
<br />
== Troubleshooting ==<br />
<br />
=== Long boot time when running headless ===<br />
<br />
If no peripherals are connected the system might hang for an exceptionally long period of time while it attempts to accumulate entropy.<br />
<br />
If this is the case simply plugging in any USB device should work around this issue.<br />
<br />
'''Alternatively''', installing haveged, the random numbers generator, would speed up the process : <br />
<br />
apk update <br />
apk add haveged<br />
rc-update add haveged boot<br />
lbu commit -d<br />
service haveged start<br />
<br />
(Tested on a raspberry pi zero W headless mode, no USB connected, Alpine 3.10.3)<br />
<br />
=== apk indicating 'No space left on device' ===<br />
<br />
Note some models of the Raspberry Pi such as the 3A+ only have 512M of RAM, which on fresh Alpine deployment will only leave around 200M for tmpfs root. It's important to keep this limitation in mind when using these boards.<br />
<br />
=== Wireless support with older Alpine images ===<br />
<br />
If you need WiFi to work, you have to [https://github.com/RPi-Distro/firmware-nonfree/tree/master/brcm download] the latest Broadcom drivers to your SD card. (Replace /mnt/sdcard with the correct mount point.)<br />
<br />
git clone --depth 1 https://github.com/RPi-Distro/firmware-nonfree.git<br />
cp firmware-nonfree/brcm/* /mnt/sdcard/firmware/brcm<br />
<br />
== See Also ==<br />
<br />
* [[Classic install or sys mode on Raspberry Pi]] - a variant.<br />
* [[Raspberry Pi 3 - Setting Up Bluetooth]]<br />
* [[Raspberry Pi 3 - Configuring it as wireless access point -AP Mode]]<br />
* [[Raspberry Pi 3 - Browser Client]]<br />
* [[Linux Router with VPN on a Raspberry Pi]]<br />
* [[Create a bootable SDHC from a Mac]]<br />
* Build custom Raspberry Pi images based on Alpine via [https://github.com/tolstoyevsky/pieman Pieman]<br />
<br />
* [[Tutorials_and_Howtos#Raspberry_Pi]]<br />
<br />
<br />
[[Category:Installation]]<br />
[[Category: Raspberry]]</div>Etothepiihttps://wiki.alpinelinux.org/w/index.php?title=Raspberry_Pi&diff=19700Raspberry Pi2021-06-27T04:08:53Z<p>Etothepii: Explain benefits of diskless install, and explain cases where users may be better served by going to a sys-based install.</p>
<hr />
<div>{{TOC right}}<br />
<br />
This tutorial will help you install Alpine Linux on your Raspberry Pi.<br />
<br />
{{warning | 11 Feb 2021 - There is currently a known bug upstream <br />[https://github.com/raspberrypi/firmware/issues/1529 kernel/initramfs cannot be loaded from subdirectory with same name as volume label] }}<br />
<br />
== Preparation ==<br />
<br />
# [http://alpinelinux.org/downloads/ Download] the Alpine for Raspberry Pi tarball. You should be safe using the '''armhf''' build on all versions of Raspberry Pi (including Pi Zero and Compute Modules); but it may perform less optimally on recent versions of Raspberry Pi. The '''armv7''' build is compatible with Raspberry Pi 2 Model B. The '''aarch64''' build should be compatible with Raspberry Pi 2 Model v1.2, Raspberry Pi 3 and Compute Module 3, and Raspberry Pi 4 model B.<br />
# [[Create a Bootable USB#Format USB stick|Create a bootable FAT32 partition on your SD card.]] The partition type should be <code>W95 FAT32 (LBA)</code>. (The current type can be found in the "Type" column in the output of <code>fdisk -l</code>.) You can use a partitioning tool such as [https://en.wikipedia.org/wiki/GNOME_Disks gnome-disks] or [http://linux.die.net/man/8/fdisk fdisk].<br />
# Create a filesystem on the partition with <code>mkdosfs -F 32 /dev/sdX1</code> (Replace sdX1 with the correct reference to the partition you just created.)<br />
# Mount the partition and extract the tarball contents unto it.<br />
<br />
Optionally create a '''usercfg.txt''' file on the partition to configure low-level system settings. Specifications can be found [https://www.raspberrypi.org/documentation/configuration/config-txt here]. Note, however, that some settings can only be set directly in '''config.txt'''. In particular, <code>gpu_mem</code> will have no effect when specified in '''usercfg.txt''' [https://github.com/raspberrypi/firmware/issues/1332 source]. Some interesting values include:<br />
* To enable audio: <code>dtparam=audio=on</code><br />
* If you see black edges around your screen after booting the Pi, you can add <code>disable_overscan=1</code><br />
<br />
Recent versions include Broadcom firmware files. If you're using an older Alpine version, see [[#Wireless_support_with_older_Alpine_images|section below]].<br />
<br />
== Installation ==<br />
<br />
Alpine Linux will be installed as [[Installation#Installation_Handbook|diskless mode]], hence you need to use [[Alpine local backup|Alpine Local Backup (lbu)]] to save your modifications between reboots.<br />
<br />
For users who will be using their Raspberry Pi in scenarios where there is not expected to be significant changes to disk after setup (like running a static HTTP server), this is likely preferable, as running the entire system from memory will help improve performance (by avoiding the slow SD card) and improve the SD card life (by reducing the writes to the card, as all logging will happen in memory). Diskless installations still allow you to install packages, save local files, and tune the system to your needs. <br />
<br />
However, if you:<br />
* Expect there will be constant changes to the disk after initial setup (for example, if you expect people to login and save files in their home directories)<br />
* Need logs to reliably persist after reboot<br />
* Plan to install packages which consume more space than can be loaded into RAM<br />
* Want to install kernel modules (such as ZFS or Wireguard)<br />
<br />
Then may be better served by a [[Classic install or sys mode on Raspberry Pi|sys-mode installation]]. <br />
<br />
Follow these steps to install Alpine Linux in Diskless Mode:<br />
<br />
# Insert the SD card into the Raspberry Pi and turn it on<br />
# Login into the Alpine system as root. Leave the password empty.<br />
# Type <code>setup-alpine</code><br />
# Once the installation is complete, commit the changes by typing <code>lbu commit -d</code><br />
<br />
Type <code>reboot</code> to verify that the installation was indeed successful.<br />
<br />
== Post Installation ==<br />
<br />
=== Update the System ===<br />
<br />
Upon installation, make sure that your system is up-to-date:<br />
<br />
{{cmd|apk update<br />
apk upgrade}}<br />
<br />
Don't forget to save the changes:<br />
<br />
{{cmd|lbu commit -d}}<br />
<br />
Note that this does not upgrade the kernel. In order to upgrade the kernel, a full upgrade of the Alpine Linux version must be performed as described in [[Upgrading Alpine#Upgrading Alpine Linux on other removable media (such as CF/USB)|upgrading Alpine Linux for removable media]].<br />
<br />
=== Clock-related error messages ===<br />
<br />
During the booting time, you might notice errors related to the hardware clock. The Raspberry Pi does not have<br />
a hardware clock and therefore you need to disable the hwclock daemon and enable swclock:<br />
<br />
{{cmd|rc-update add swclock boot # enable the software clock<br />
rc-update del hwclock boot # disable the hardware clock}}<br />
<br />
Since Raspberry Pi does not have a clock, the Alpine Linux needs to know what the time is by using a<br />
[https://en.wikipedia.org/wiki/Network_Time_Protocol Network Time Protocol (NTP)] daemon. Make sure that you a<br />
NTP daemon installed and running. If you are not sure, then you can install NTP client by running the following<br />
command:<br />
<br />
{{cmd|setup-ntp}}<br />
<br />
The Busybox NTP client might be the most lightweight solution. Save the changes and reboot, once the NTP software is<br />
installed and running:<br />
<br />
{{cmd|lbu commit -d<br />
reboot}}<br />
<br />
After reboot, make sure that the <code>date</code> command outputs the correct date and time.<br />
<br />
=== WiFi on boot ===<br />
If you have already [[Connecting_to_a_wireless_access_point|configured WiFi]] during the setup, the connection will not return on reboot.<br />
You will need to start up a service to automatically connect to the wireless access point.<br />
# Run <code>rc-update add wpa_supplicant boot</code> to connect to the wireless access point on boot.<br />
# Run it manually with <code>/etc/init.d/wpa_supplicant start</code>.<br />
<br />
=== Enable OpenGL (Raspberry Pi 3) ===<br />
<br />
Remount the boot partition writeable (ie. /media/mmcblk0p1):<br />
<br />
{{cmd|mount -o remount,rw /media/mmcblk0p1}}<br />
<br />
Add the following lines to /media/mmcblk0p1/config.txt <br />
<br />
dtoverlay=vc4-kms-v3d<br />
gpu_mem=128<br />
<br />
256MB gpu_mem is also possible<br />
<br />
Install mesa-dri-vc4:<br />
{{cmd|apk add mesa-dri-vc4}}<br />
<br />
Reboot:<br />
<br />
{{cmd|lbu_commit -d; reboot}}<br />
<br />
== Persistent storage ==<br />
<br />
=== Loopback image with overlayfs ===<br />
<br />
When you install Alpine in diskless mode, the entire system is loaded into memory at boot. If you want additional storage (for example, if you need more space than offered by your RAM) we need to create loop-back storage onto the SD mounted with overlayfs.<br />
<br />
First make the SD card writable again and change fstab to always do so:<br />
{{cmd|mount /media/mmcblk0p1 -o rw,remount<br />
sed -i 's/vfat\ ro,/vfat\ rw,/' /etc/fstab}}<br />
<br />
Create the loop-back file, this example is 1 GB:<br />
<br />
{{cmd|dd if&#61;/dev/zero of&#61;/media/mmcblk0p1/persist.img bs&#61;1024 count&#61;0 seek&#61;1048576}}<br />
<br />
Install the ext utilities:<br />
<br />
{{cmd|apk add e2fsprogs}}<br />
<br />
Format the loop-back file:<br />
<br />
{{cmd|mkfs.ext4 /media/mmcblk0p1/persist.img}}<br />
<br />
Mount the storage: <br />
<br />
{{cmd|echo "/media/mmcblk0p1/persist.img /media/persist ext4 rw,relatime,errors&#61;remount-ro 0 0" >> /etc/fstab<br />
mkdir /media/persist <br />
mount -a}}<br />
<br />
Make the overlay folders, we are doing /usr here, but you can do /home or anything else:<br />
<br />
{{cmd|mkdir /media/persist/usr <br />
mkdir /media/persist/.work <br />
echo "overlay /usr overlay lowerdir&#61;/usr,upperdir&#61;/media/persist/usr,workdir&#61;/media/persist/.work 0 0" >> /etc/fstab <br />
mount -a}}<br />
<br />
Your /etc/fstab should look something like this:<br />
{{Cmd|/dev/cdrom /media/cdrom iso9660 noauto,ro 0 0<br />
/dev/usbdisk /media/usb vfat noauto,ro 0 0<br />
/dev/mmcblk0p1 /media/mmcblk0p1 vfat rw,relatime,fmask&#61;0022,dmask&#61;0022,errors&#61;remount-ro 0 0<br />
/media/mmcblk0p1/persist.img /media/persist ext4 rw,relatime,errors&#61;remount-ro 0 0<br />
overlay /usr overlay lowerdir&#61;/usr,upperdir&#61;/media/persist/usr,workdir&#61;/media/persist/.work 0 0}}<br />
<br />
Now commit the changes: (optionally remove the e2fsprogs, but it does contain repair tools)<br />
{{cmd|lbu_commit -d}}<br />
<br />
Remember with this setup, if you install things and you have done this overlay for /usr, you must not commit the 'apk add', otherwise while it boots it will try and install it to memory and not to the persist storage.<br />
<br />
If you do want to install something small at boot you can use `apk add` and `lbu commit -d`.<br />
<br />
If it is something a bit bigger then you can use `apk add` but then not commit it, it will be persistent (in /user), but do check everything you need is in that directory and not in folders you have not made persistent.<br />
<br />
=== Traditional disk-based (sys) installation ===<br />
<br />
{{Warning|This isn't yet supported by the Alpine setup scripts for Raspberry Pi. It requires manual intervention, and might break.}}<br />
<br />
It is also possible to switch to a fully disk-based installation: this is not yet formally supported, but can be done somewhat manually. This frees all the memory otherwise needed for the root filesystem, allowing more installed packages.<br />
<br />
Split your SD card into two partitions: the FAT32 boot partition described above (in this example it'll be <code>mmcblk0p1</code>) , and a second partition to hold the root filesystem (here it'll be <code>mmcblk0p2</code>). Boot and configure your diskless system as above, then create a root filesystem:<br />
<br />
{{cmd|apk add e2fsprogs<br />
mkfs.ext4 /dev/mmcblk0p2}}<br />
<br />
Now do a disk install via a mountpoint. The <code>setup-disk</code> script will give some errors about syslinux/extlinux, but you can ignore these: the Raspberry Pi doesn't need this to boot anyway.<br />
<br />
{{cmd|<nowiki>mkdir /stage<br />
mount /dev/mmcblk0p2 /stage<br />
setup-disk -o /media/mmcblk0p1/MYHOSTNAME.apkovl.tar.gz /stage<br />
# (ignore errors about syslinux/extlinux)</nowiki>}}<br />
<br />
Add a line to <code>/stage/etc/fstab</code> to mount the Pi's boot partition again:<br />
<br />
{{cmd|/dev/mmcblk0p1 /media/mmcblk0p1 vfat defaults 0 0}}<br />
<br />
Now add a <code>root=/dev/mmcblk0p2</code> parameter to the Pi's boot command line, either <code>cmdline-rpi2.txt</code> or <code>cmdline-rpi.txt</code> depending on model:<br />
<br />
{{cmd|<nowiki>mount -o remount,rw /media/mmcblk0p1<br />
sed -i '$ s/$/ root=\/dev\/mmcblk0p2/' /media/mmcblk0p1/cmdline-rpi2.txt</nowiki>}}<br />
<br />
You might also consider <code>overlaytmpfs=yes</code> here, which will cause the underlying SD card root filesystem to be mounted read-only, with an overlayed tmpfs for modifications which will be discarded on shutdown.<br />
<br />
Beware, though, that <b>the contents of /boot will be ignored when the Pi boots</b>: it will use the kernel, initramfs, and modloop images from the FAT32 boot partition. To update the kernel, initfs or modules, you will need to manually (generate and) copy these to the boot partition or you could use bind mount so that manually copy the files to boot partition is not needed.<br />
<br />
{{cmd|<nowiki>echo /media/mmcblk0p1/boot /boot none defaults,bind 0 0 >> /etc/fstab</nowiki>}}<br />
<br />
=== Persistent Installation on Raspberry Pi 3 ===<br />
<br />
See this page : https://wiki.alpinelinux.org/wiki/Classic_install_or_sys_mode_on_Raspberry_Pi<br />
<br />
See https://web.archive.org/web/20171125115835/https://forum.alpinelinux.org/comment/1084#comment-1084<br />
<br />
== Troubleshooting ==<br />
<br />
=== Long boot time when running headless ===<br />
<br />
If no peripherals are connected the system might hang for an exceptionally long period of time while it attempts to accumulate entropy.<br />
<br />
If this is the case simply plugging in any USB device should work around this issue.<br />
<br />
'''Alternatively''', installing haveged, the random numbers generator, would speed up the process : <br />
<br />
apk update <br />
apk add haveged<br />
rc-update add haveged boot<br />
lbu commit -d<br />
service haveged start<br />
<br />
(Tested on a raspberry pi zero W headless mode, no USB connected, Alpine 3.10.3)<br />
<br />
=== apk indicating 'No space left on device' ===<br />
<br />
Note some models of the Raspberry Pi such as the 3A+ only have 512M of RAM, which on fresh Alpine deployment will only leave around 200M for tmpfs root. It's important to keep this limitation in mind when using these boards.<br />
<br />
=== Wireless support with older Alpine images ===<br />
<br />
If you need WiFi to work, you have to [https://github.com/RPi-Distro/firmware-nonfree/tree/master/brcm download] the latest Broadcom drivers to your SD card. (Replace /mnt/sdcard with the correct mount point.)<br />
<br />
git clone --depth 1 https://github.com/RPi-Distro/firmware-nonfree.git<br />
cp firmware-nonfree/brcm/* /mnt/sdcard/firmware/brcm<br />
<br />
== See Also ==<br />
<br />
* [[Classic install or sys mode on Raspberry Pi]] - a variant.<br />
* [[Raspberry Pi 3 - Setting Up Bluetooth]]<br />
* [[Raspberry Pi 3 - Configuring it as wireless access point -AP Mode]]<br />
* [[Raspberry Pi 3 - Browser Client]]<br />
* [[Linux Router with VPN on a Raspberry Pi]]<br />
* [[Create a bootable SDHC from a Mac]]<br />
* Build custom Raspberry Pi images based on Alpine via [https://github.com/tolstoyevsky/pieman Pieman]<br />
<br />
* [[Tutorials_and_Howtos#Raspberry_Pi]]<br />
<br />
<br />
[[Category:Installation]]<br />
[[Category: Raspberry]]</div>Etothepiihttps://wiki.alpinelinux.org/w/index.php?title=Classic_install_or_sys_mode_on_Raspberry_Pi&diff=19663Classic install or sys mode on Raspberry Pi2021-06-23T03:44:31Z<p>Etothepii: Update instructions with work around for issue 12353</p>
<hr />
<div>{{TOC right}}<br />
<br />
A howto for classic installation, or "sys mode".<br />
<br />
This method works with a desktop PC under Ubuntu and other Linuxes.<br />
<br />
= Preparation =<br />
<br />
Download the archive from the '''Rasperry Pi armhf''' link [https://alpinelinux.org/downloads/ here].<br />
'''Sha256''' and '''GPG''' links appear next to the link to check the download.<br />
<br />
On a class 10 sd-card with a size of 8Go or more, create two partitions:-<br />
* First in '''fat16''' with size of 256Mo. You may have to check <code>boot</code> and <code>lba</code> flags<br />
* Second in '''ext4''' with the remaining place<br />
<br />
Eject and insert your SD card in order to recognize all the partitions.<br />
<br />
Now go into the first partition ('''fat16''').<br />
<br />
Untar the archive with {{pkg|tar}}:<br />
tar zxvf ~/Download/alpine-rpi-*-armhf.tar.gz<br />
<br />
Due to a bug, it is recommended to add a file named <code>usercfg.txt</code> into the partition. The file should contain the following single line:<br />
<br />
enable_uart=1<br />
<br />
You could also add for headless use to maximize memory (32 megs is required for the rpi bootloader):<br />
<br />
gpu_mem=32<br />
<br />
And to enable audio support:<br />
<br />
dtparam=audio=on<br />
<br />
Eject the SD card properly, insert it into the Raspberry Pi, plug a usb keyboard in plus the HDMI and network cables, and power on.<br />
<br />
When a prompt displays, connect as root without a password.<br />
<br />
== OSX Preparation: creating a FAT16 partition on microSD ==<br />
<br />
To create a FAT16 partition with OSX, use the diskutil program and a USB microSD card reader (I used an older version of this: https://www.bestbuy.com/site/insignia-usb-3-0-memory-card-reader/5787406.p?skuId=5787406).<br />
<br />
Put the microSD card in reader, the reader in a USB port, and type <code>ls -1 /Volumes</code> in a terminal. Note the name of the microSD volume; for example, VOL1 in the output below:<br />
$ ls -1 /Volumes<br />
Macintosh HD<br />
Preboot<br />
VOL1<br />
$<br />
<br />
Unmount the reader, unplug it and re-run <code>ls -1 /Volumes</code>. Verify the microSD volume name is no longer listed and then re-insert the USB reader.<br />
<br />
Find the mount point of your microSD volume; for example, disk3 in the output below:<br />
$ diskutil list VOL1<br />
/dev/disk3 (external, physical):<br />
#: TYPE NAME SIZE IDENTIFIER<br />
0: FDisk_partition_scheme *31.4 GB disk3<br />
1: DOS_FAT_16 VOL1 256.0 MB disk3s1<br />
2: Linux 30.0 GB disk3s2<br />
3: Linux_Swap 1.2 GB disk3s3<br />
$<br />
<br />
(For help on diskutil command, type <code>diskutil</code> to list all command verbs. For help on a specific verb, add the verb; for example, <code>diskutil partitionDisk</code>)<br />
<br />
Destroy all the existing partitions on the microSD card and create two new ones: <br />
# a 256MB, FAT16, DOS-compatible partition and <br />
# a free space gap for the rest of the card<br />
<br />
$ diskutil partitionDisk disk3 MBR "MS-DOS FAT16" VOL1 256MB "Free Space" VOL2 R<br />
Started partitioning on disk3<br />
Unmounting disk<br />
Creating the partition map<br />
Waiting for partitions to activate<br />
Formatting disk3s1 as MS-DOS (FAT16) with name VOL1<br />
512 bytes per physical sector<br />
/dev/rdisk3s1: 499472 sectors in 62434 FAT16 clusters (4096 bytes/cluster)<br />
bps=512 spc=8 res=1 nft=2 rde=512 mid=0xf8 spf=244 spt=32 hds=32 hid=2 drv=0x80 bsec=500000<br />
Mounting disk<br />
Finished partitioning on disk3<br />
/dev/disk3 (external, physical):<br />
#: TYPE NAME SIZE IDENTIFIER<br />
0: FDisk_partition_scheme *31.4 GB disk3<br />
1: DOS_FAT_16 VOL1 256.0 MB disk3s1<br />
$ <br />
<br />
Change your current working directory to the new FAT16 partition and then pickup with the untar instruction in the parent prep section.<br />
<br />
$ cd /Volumes/VOL1/<br />
<br />
= Installation =<br />
<br />
Execute the following commands. Make sure there is an internet connection available otherwise setting up the apk mirrors will fail.<br />
<br />
setup-alpine <br />
<br />
Set the mapping keyboard, the timezone, how to connect to the network ('''dhcp''' is the best method), say '''none''' at <code>save config</code> and <code>save cache</code>.<br />
<br />
apk update<br />
<br />
If the extra space in the sd card was left empty, a partition must be created now:<br />
<br />
apk add cfdisk # or the tool of your choice<br />
cfdisk /dev/mmcblk0 # create the new partition with the free space<br />
mkfs.ext4 /dev/mmcblk0p2 # create the ext4 filesystem in the new partition<br />
<br />
Raspberry Pi has no battery for his hardware clock, so synchronize with an ntp server:<br />
<br />
apk add chrony <br />
service chronyd restart<br />
apk add e2fsprogs<br />
<br />
{{warning | 22 June 2021 - There is currently a bug that causes setup-disk to fail on ext4 mounts on Raspberry Pi. The work around is marked in the instructions below. <br />[https://gitlab.alpinelinux.org/alpine/aports/-/issues/12353] }}<br />
<br />
mount /dev/mmcblk0p2 /mnt # The second partition, in ext4 format, where Alpine Linux is installing in sys mode<br />
export FORCE_BOOTFS=1 # work around for issue 12353<br />
setup-disk -m sys /mnt<br />
mount -o remount,rw /media/mmcblk0p1 # An update in the first partition is required for the next reboot.<br />
<br />
You may get some warning about syslinux when you run setup-disk. You can safely ignore this.<br />
<br />
Clean up the boot folder in the first partition to drop unused files:<br />
<br />
rm -f /media/mmcblk0p1/boot/* <br />
cd /mnt # We are in the second partition <br />
rm boot/boot # Drop the unused symbolink link<br />
<br />
Move the image and <code>init ram</code> for Alpine Linux into the right place:<br />
<br />
mv boot/* /media/mmcblk0p1/boot/ <br />
rm -Rf boot<br />
mkdir media/mmcblk0p1 # It's the mount point for the first partition on the next reboot<br />
<br />
Don't worry about the error with the following:<br />
<br />
ln -s media/mmcblk0p1/boot boot<br />
<br />
Update <code>/etc/fstab</code>:<br />
<br />
echo "/dev/mmcblk0p1 /media/mmcblk0p1 vfat defaults 0 0" >> etc/fstab<br />
sed -i '/cdrom/d' etc/fstab # Of course, you don't have any cdrom or floppy on the Raspberry Pi<br />
sed -i '/floppy/d' etc/fstab<br />
cd /media/mmcblk0p1<br />
<br />
If you want to active edge repository<br />
sed -i '/edge/s/^#//' etc/apk/repositories # But enable the repository for community if you want vim, mc, php, apache, nginx, etc.<br />
<br />
For the next boot, indicate that the root filesystem is on the second partition. If the cmdline.txt file<br />
contains a line that starts with <code>/root</code>, then use sed:<br />
<br />
sed -i 's/$/root=\/dev\/mmcblk0p2 /' /media/mmcblk0p1/cmdline.txt <br />
reboot<br />
<br />
That works on '''Raspberry Pi 3B''' and '''1B''', but if you have the '''1B''' version, let's be very, very patient (several tens of minutes).<br />
<br />
If a hard disk is connected via '''usb''', you can replace the <code>/dev/mmcblk0p2</code> above with <code>/dev/sda1</code>, for example.<br />
<br />
If you don't like the '''sed''' above and its expressions, you can use a nano editor instead after executing the following command:<br />
<br />
apk add nano<br />
<br />
= Post-installation =<br />
<br />
The '''Raspberry Pi (RPI)''' has no battery to keep the time updated. Therefore, we need to enable the right service to synchronize with an ntp server:<br />
<br />
rc-update del hwclock boot<br />
rc-update add swclock boot<br />
service hwclock stop<br />
service swclock start<br />
<br />
Update and upgrade the system:<br />
<br />
apk update<br />
apk upgrade<br />
<br />
If you want a cool editor ({{Pkg|vim}}), a file manager ({{Pkg|mc}}), and to determine which tasks are running and which services are starting on boot ({{Pkg|htop}}), add the right packages:<br />
<br />
apk add vim mc htop<br />
htop<br />
rc-update<br />
<br />
The '''RPI 3B''' has wifi on board for networking, so start the service for the encrypted key on wpa2 protocol:<br />
<br />
apk add wpa_supplicant<br />
rc-update add wpa_supplicant boot<br />
service wpa_supplicant start<br />
setup-interfaces <br />
Replace the IP address by dhcp for all the interfaces if necessary; select the SSID network for wifi; and add password.<br />
ip addr # to know the IP address for all interfaces<br />
<br />
If you want to connect on your remote RPI via <code>ssh</code>, an additional user (''foo'') and the {{Pkg|sudo}} package are required because it's forbidden to connect as root:<br />
<br />
apk add sudo<br />
adduser foo<br />
adduser foo wheel<br />
visudo <br />
<br />
Uncomment line #82 with <code>wheel ALL=(ALL) ALL</code>. If {{Pkg|vim}} is installed, save the changes by typing '''Esc :x'''<br />
<br />
= Troubleshooting =<br />
<br />
Following the prepare instructions for setting up the boot partition as outlined, using the armv7 image (3.10.3), my rpi2 would not even boot, and I was trapped in the dreaded rainbow screen, with the green led blinking a few times in a row, repeatedly.<br />
<br />
The rpi2 I had appears to require '''fat32''' for the boot partition, NOT '''fat16''' as suggested in prepare. Use linux fdisk to set the boot partition type as "c" (for fat32/lba) amd set the '''lba''' and '''boot''' flags for the partition as suggested. Created the boot partition filesystem as fat32 with:<br />
<br />
mkdosfs -F 32 /dev/sdX1 <br />
<br />
Mount and unpacked the tarball to that, and everything should then work as documented after prepare.<br />
<br />
After booting you may also find less system memory available than you expect. Currently the Pi requires a minimum of 32 megs gpu to boot, unless you have the cutdown boot loader installed, in which case you can use 16. However, you may find more gpu memory is still being used, even if you configure for less, if you enable audio or camera support. To find out how your system is actually split, you can do:<br />
<br />
apk add raspberrypi<br />
/opt/vc/bin/vcgencmd get_mem gpu<br />
/opt/vc/bin/vcgencmd get_mem arm<br />
<br />
= See also =<br />
<br />
* [[Raspberry Pi]]<br />
* [[Raspberry Pi 3 - Setting Up Bluetooth]]<br />
* [[Raspberry Pi 3 - Configuring it as wireless access point -AP Mode]]<br />
* [[Linux Router with VPN on a Raspberry Pi]]<br />
<br />
[[Category:Installation]]<br />
[[category: Raspberry]]</div>Etothepii