Difference between revisions of "Upgrading Alpine"

From Alpine Linux
Jump to: navigation, search
(WIP)
(Upgrading system: we need --available when upgrading from v2.7 to v3.0)
(4 intermediate revisions by 2 users not shown)
Line 2: Line 2:
  
 
== Upgrading an Alpine Linux Hard-disk installation ==
 
== Upgrading an Alpine Linux Hard-disk installation ==
 +
 +
=== Upgrading Alpine v2.x to v3.x ===
 +
 +
{{Warning|Alpine Linux 3.x is using a different libc implementation compared to previous versions. Musl libc is not ABI compatible with uClibc. Additional steps are required for an upgrade.}}
 +
 +
==== Installing statically linked tools ====
 +
 +
Statically linked version of apk-tools is needed, otherwise it will stop working after libc upgrade (possibly in the middle of upgrade). Static version of busybox can be handy in case of the recovery from a failure.
 +
 +
{{Cmd|apk add busybox-static apk-tools-static}}
 +
 +
==== Changing repositories to v3.x ====
 +
 +
To begin, you need to update your {{Path|/etc/apk/repositories}} file. Here are some shortcuts for doing so:
 +
:* Launch {{Cmd|setup-apkrepos}} Enter {{Key|e}} to edit {{Path|/etc/apk/repositories}}. Change the version number by hand.
 +
:* 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}}
 +
 +
==== Upgrading system ====
 +
 +
Use statically linked version of apk to update content of repository:
 +
 +
{{Cmd|apk.static update}}
 +
 +
Simulating upgrade is recommended in order to detect issues beforehand:
 +
 +
{{Cmd|apk.static upgrade --no-self-upgrade --available --simulate}}
 +
 +
With no problems encountered or after resolving them, start proper upgrade:
 +
 +
{{Cmd|apk.static upgrade --no-self-upgrade --available}}
  
 
=== Upgrading to latest release ===
 
=== Upgrading to latest release ===
Line 12: Line 42:
  
 
See [[Upgrading from older versions]].
 
See [[Upgrading from older versions]].
 
  
 
== Upgrading Alpine Linux on CD ==
 
== Upgrading Alpine Linux on CD ==
Line 20: Line 49:
 
=== Update remaining packages from Web repository ===
 
=== Update remaining packages from Web repository ===
  
If you are using [[How_to_enable_APK_caching|APK caching]] you should also perform the following steps:
+
If you are using [[How_to_enable_APK_caching|APK caching]] you should also perform the following steps.
 +
{{:Include:Using_Internet_Repositories_for_apk-tools}}
  
{{:Include:Using_Internet_Repositories_for_apk-tools}}
+
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:
 +
{{Cmd|apk add --upgrade apk-tools}}
  
Ensure you have the latest available version of the Alpine Linux Package Manager first before upgrading anything else:
+
Next, upgrade all your packages:
{{Cmd|apk add -u apk-tools}}
 
  
{{Cmd|apk upgrade
+
{{Cmd|apk upgrade --available
 
sync}}
 
sync}}
  
== Upgrading Alpine Linux on Flash Memory (such as CF/USB) ==
+
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.
  
Your installation may consist of Alpine Linux running on Compact Flash or USB media. In most cases, it should be sufficient to upgrade most packages using the '''Alpine Linux Hard-disk Installation''' upgrade procedures described above. However, for new packages to survive after a reboot, you should enable [[How_to_enable_APK_caching|APK caching]].
+
After upgrading packages, save any configuration changes (you should have backed up your earlier configuration prior to upgrading).
 +
{{Cmd|lbu ci}}
 +
 
 +
 
 +
== Upgrading Alpine Linux on other removable media (such as CF/USB) ==
 +
 
 +
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:
 +
{{Cmd|apk upgrade --update-cache --available}}
 +
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]].)
  
{{Warning|As the newer version of alpine may include kernel upgrades, simply pointing the Alpine Linux Package Manager to an Internet-based repository and running ''apk upgrade'' will not be enough, as kernel components are not upgraded when Alpine Linux is run from memory.}}
+
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.
  
 
{{:Include:Upgrading_Alpine_environmentvars}}
 
{{:Include:Upgrading_Alpine_environmentvars}}
Line 40: Line 78:
 
=== Upgrade Operating System ===
 
=== Upgrade Operating System ===
  
Start by checking that you have enough space on your media.<BR>
+
Start by checking that you have enough space on your media. For a '''standard''' Alpine image, you need at least 400MB available space.
You need at least 400MB available space.
+
{{Cmd|df -h {{!}} grep "Filesystem\{{!}}$LBU_MEDIA"}}
{{Cmd|df -h | grep "Filesystem\|$LBU_MEDIA"}}
 
  
 
==== Download and verify new release ====
 
==== Download and verify new release ====
  
Make sure the media is mounted readwrite.
+
Make sure the media that holds your Alpine system is mounted readwrite.
{{Cmd|mount --remount rw /media/$LBU_MEDIA}}
+
{{Cmd|mount -oremount,rw /media/$LBU_MEDIA}}
  
{{Tip|If using Alpine Linux 2.2.3 or newer, use the following command to download, mount and copy files as needed for you: {{Cmd|setup-bootable -u {{#latestalp:alpine|url}} /media/$LBU_MEDIA}}Once the command completes, proceed to the [[#Load new kernel|Load new kernel]] section. }}
+
'''If using Alpine Linux 2.2.3 or newer''': use the following command to download, mount and copy files as needed for you: {{Cmd|setup-bootable -u {{#latestalp:alpine|url}} /media/$LBU_MEDIA}} Once the command completes, proceed to the [[#Save changes|Save changes]] section.
  
 +
==== For older versions of Alpine ====
 
Start downloading a new '.iso' and a '.sha1' file  
 
Start downloading a new '.iso' and a '.sha1' file  
 
{{Cmd|cd /media/$LBU_MEDIA
 
{{Cmd|cd /media/$LBU_MEDIA
Line 56: Line 94:
 
wget {{#latestalp:alpine|url}}.sha1}}
 
wget {{#latestalp:alpine|url}}.sha1}}
  
Check integrity of the downloaded files ''(it might take some time)''
+
Check integrity of the downloaded files ''(it might take some time)'':
 
{{Cmd|sha1sum -c {{#latestalp:alpine|file}}.sha1}}
 
{{Cmd|sha1sum -c {{#latestalp:alpine|file}}.sha1}}
 
''The output of the above command should say 'OK'.<BR>''
 
''The output of the above command should say 'OK'.<BR>''
 
''If says 'FAILED', delete the iso file and download it again.''
 
''If says 'FAILED', delete the iso file and download it again.''
  
==== Copy the new release  ====
+
'''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}}
{{Note|There is a tool, ''setup-bootable'', in alpine-1.10.4 and newer, that does the mounting and copying for you. With this tool simply do: {{Cmd|setup-bootable -u {{#latestalp:alpine|file}} /media/$LBU_MEDIA}}Once the command completes, proceed to the [[#Load new kernel|Load new kernel]] section.
 
}}
 
 
 
Mount the ISO.
 
 
{{Cmd|mount -t iso9660 {{#latestalp:alpine|file}} /mnt}}
 
 
Back up files that you have modified. For example, you might have modified ''syslinux.cfg'' to show console output on a serial port.<BR>
 
 
 
{{Cmd|cp /media/$LBU_MEDIA/syslinux.cfg /media/$LBU_MEDIA/syslinux.cfg.my}}
 
 
 
Install the '''rsync''' package if necessary, and copy the files:
 
 
 
{{Cmd|cd /mnt
 
apk add rsync
 
rsync --delete -rltv .alpine-release * /media/$LBU_MEDIA/}}
 
 
 
Restore your backed up files ''(in case you had any)''
 
 
 
{{Cmd|mv -f /media/$LBU_MEDIA/syslinux.cfg.my /media/$LBU_MEDIA/syslinux.cfg}}
 
 
 
Make sure that all files are permanently saved in right place
 
 
 
{{Cmd|sync}}
 
  
==== Clean up ====
+
[[Upgrading from older versions#Upgrading_a_removable_medium_from_Alpine_before_1.10.4|Instructions for older versions of Alpine]] are located elsewhere.
Clean up the downloaded/unpacked files
 
{{Cmd|cd ..
 
umount /mnt
 
rm /media/$LBU_MEDIA/{{#latestalp:alpine|file}}
 
rm /media/$LBU_MEDIA/{{#latestalp:alpine|file}}.sha1}}
 
  
 
=== Save changes ===
 
=== Save changes ===
Line 100: Line 109:
 
=== Load new kernel ===
 
=== Load new kernel ===
 
In most cases you will need to reboot Alpine Linux (especially if there are changes in the kernel):
 
In most cases you will need to reboot Alpine Linux (especially if there are changes in the kernel):
{{Cmd|reboot}}
+
{{Cmd|sync
 +
reboot}}
 +
 
 
{{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.}}
 
{{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.}}
  
 
=== Update remaining packages from Web repository ===
 
=== Update remaining packages from Web repository ===
If you are using [[How_to_enable_APK_caching|APK caching]] you should perform the following steps:
+
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.
 
 
{{:Include:Using_Internet_Repositories_for_apk-tools}}
 
  
Ensure you have the latest available version of the Alpine Linux Package Manager first before upgrading anything else:
 
{{Cmd|apk add -u apk-tools}}
 
{{Cmd|apk upgrade
 
sync}}
 
  
 
[[Category:Installation]]
 
[[Category:Installation]]
 
[[Category:Package Manager]]
 
[[Category:Package Manager]]

Revision as of 13:38, 5 September 2014

Tango-dialog-warning.png
Warning: Make sure that you have a backup of your important data before continuing to update your system.


Upgrading an Alpine Linux Hard-disk installation

Upgrading Alpine v2.x to v3.x

Tango-dialog-warning.png
Warning: Alpine Linux 3.x is using a different libc implementation compared to previous versions. Musl libc is not ABI compatible with uClibc. Additional steps are required for an upgrade.


Installing statically linked tools

Statically linked version of apk-tools is needed, otherwise it will stop working after libc upgrade (possibly in the middle of upgrade). Static version of busybox can be handy in case of the recovery from a failure.

apk add busybox-static apk-tools-static

Changing repositories to v3.x

To begin, you need to update your /etc/apk/repositories file. Here are some shortcuts for doing so:

  • Launch

    setup-apkrepos

    Enter e to edit /etc/apk/repositories. Change the version number by hand.
  • Or, edit the file in place. This is how you'd change v2.7 to v3.0:

    sed -i -e 's/v2\.7/v3.0/g' /etc/apk/repositories

Upgrading system

Use statically linked version of apk to update content of repository:

apk.static update

Simulating upgrade is recommended in order to detect issues beforehand:

apk.static upgrade --no-self-upgrade --available --simulate

With no problems encountered or after resolving them, start proper upgrade:

apk.static upgrade --no-self-upgrade --available

Upgrading to latest release

When Alpine Linux is installed to hard drive, upgrading to a newer stable version is straightforward.

To begin, you need to update your /etc/apk/repositories file. Here are some shortcuts for doing so:


Or you could do this manually: Edit the /etc/apk/repositories file using an editor (nano for instance) and if necessary, add references to the Alpine package repositories. In the example below, the reference to the Alpine CD is maintained, so that if the requested package is available on the local media, it will be obtained from there instead of being downloaded from the remote repository:

Contents of /etc/apk/repositories

/media/cdrom/apks http://dl-3.alpinelinux.org/alpine/v3.3/main

Another example: upgrading from version 3.3 to 3.4 simply change:

http://dl-3.alpinelinux.org/alpine/v3.3/main

to

 http://dl-3.alpinelinux.org/alpine/v3.4/main

Thus, the file will now look like this:

Contents of /etc/apk/repositories

/media/cdrom/apks http://dl-3.alpinelinux.org/alpine/v3.4/main
Note: Starting with version 3.3, there is a new repository called community. Many packages have been moved from the main repository to community to indicate that they are not guaranteed to be supported beyond six months. If you are using any of these packages, be sure to add the community repository. For example: http://dl-3.alpinelinux.org/alpine/v3.3/community

Only one repository is shown above; however, you may also replace http://dl-3.alpinelinux.org/alpine/ with any of the mirrors from: http://rsync.alpinelinux.org/alpine/MIRRORS.txt

After updating the repositories file, obtain the latest index of available packages:

apk update

Tip: Adding the -U/--update-cache to another apk command, as in apk add -U ... or apk upgrade -U, has the same effect as running apk update before the other apk command.

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:

apk add --upgrade apk-tools

Next, upgrade all your packages:

apk upgrade --available

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

Note: You will need to restart any services that have been upgraded to begin using the upgraded versions. If the kernel is upgraded, you will need to reboot to begin using the upgraded version:

sync reboot

Upgrading to Edge

An upgrade of Alpine Linux from a stable version to the rolling development version, edge can be done in a few simple steps. (These instructions assume that Alpine Linux is installed to a hard drive, rather than run-from-RAM.)

To begin, you need to update your /etc/apk/repositories file. Here are some shortcuts for doing so:

  • Launch

    setup-apkrepos

    Enter e to edit /etc/apk/repositories. Change the version number (such as v3.2) to edge.
  • Or, edit the file in place:

    sed -i -e 's/v[[:digit:]]\..*\//edge\//g' /etc/apk/repositories

The result should look like this:

Contents of /etc/apk/repositories

... http://dl-3.alpinelinux.org/alpine/edge/main


Next, upgrade all your packages in one shot:

apk upgrade --update-cache --available

The --available switch is used to force all packages to be upgraded, even if they have the same version numbers. Sometimes changes in musl-libc have required doing this.

Note: You will need to restart any services that have been upgraded to begin using the upgraded versions. If the kernel is upgraded, you will need to reboot to begin using the upgraded version:

sync reboot

To check your current release:

cat /etc/alpine-release

You will see the build date attached to the release.

Upgrading from older versions

See Upgrading from older versions.

Upgrading Alpine Linux on CD

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.

Update remaining packages from Web repository

If you are using APK caching you should also perform the following steps. Edit the /etc/apk/repositories file using an editor (nano for instance) and if necessary, add references to the Alpine package repositories. In the example below, the reference to the Alpine CD is maintained, so that if the requested package is available on the local media, it will be obtained from there instead of being downloaded from the remote repository:

Contents of /etc/apk/repositories

/media/cdrom/apks http://dl-3.alpinelinux.org/alpine/v3.3/main

Another example: upgrading from version 3.3 to 3.4 simply change:

http://dl-3.alpinelinux.org/alpine/v3.3/main

to

 http://dl-3.alpinelinux.org/alpine/v3.4/main

Thus, the file will now look like this:

Contents of /etc/apk/repositories

/media/cdrom/apks http://dl-3.alpinelinux.org/alpine/v3.4/main
Note: Starting with version 3.3, there is a new repository called community. Many packages have been moved from the main repository to community to indicate that they are not guaranteed to be supported beyond six months. If you are using any of these packages, be sure to add the community repository. For example: http://dl-3.alpinelinux.org/alpine/v3.3/community

Only one repository is shown above; however, you may also replace http://dl-3.alpinelinux.org/alpine/ with any of the mirrors from: http://rsync.alpinelinux.org/alpine/MIRRORS.txt

After updating the repositories file, obtain the latest index of available packages:

apk update

Tip: Adding the -U/--update-cache to another apk command, as in apk add -U ... or apk upgrade -U, has the same effect as running apk update before the other apk command.

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:

apk add --upgrade apk-tools

Next, upgrade all your packages:

apk upgrade --available sync

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

After upgrading packages, save any configuration changes (you should have backed up your earlier configuration prior to upgrading).

lbu ci


Upgrading Alpine Linux on other removable media (such as CF/USB)

The following instructions are for run-from-RAM Alpine installations running on Compact Flash or USB media. Updating your repositories using the procedures detailed above, then running:

apk upgrade --update-cache --available

will suffice for some purposes. (If you want the new packages to be used after a reboot, you should enable APK caching.)

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.

Setup environment variables

To make the documentation a bit more "generic" we start by setting some environment variables.

vi /etc/lbu/lbu.conf

Make sure that the variable LBU_MEDIA is not commented (by removing the leading '#').

You also need to set a appropriate value for your LBU_MEDIA. The media you choose will be the media where you store your settings/configuration.

Note: Even if you have you alpine installed on CF, HD or USB you can still choose to save your config on some other media that suits your needs. But remember that both the media where you have your Alpine system AND the media where you have your config need to be in your box when booting it.

Examples:

LBU_MEDIA=usb

or:

LBU_MEDIA=sda1

Now that you have your /etc/lbu/lbu.conf configured for your needs, we will set the environment variables (note the leading .).

. /etc/lbu/lbu.conf

You can test if your environment variable was set:

echo $LBU_MEDIA

It should output something like usb, sda1, or whatever you just configured.

Back up your config

Before starting to upgrade, it's wise to save your configuration.

lbu ci

Upgrade Operating System

Start by checking that you have enough space on your media. For a standard Alpine image, you need at least 400MB available space.

df -h | grep "Filesystem\|$LBU_MEDIA"

Download and verify new release

Make sure the media that holds your Alpine system is mounted readwrite.

mount -oremount,rw /media/$LBU_MEDIA

If using Alpine Linux 2.2.3 or newer: use the following command to download, mount and copy files as needed for you:

setup-bootable -u {{#latestalp:alpine|url}} /media/$LBU_MEDIA

Once the command completes, proceed to the Save changes section.

For older versions of Alpine

Start downloading a new '.iso' and a '.sha1' file

cd /media/$LBU_MEDIA wget -c {{#latestalp:alpine|url}} wget {{#latestalp:alpine|url}}.sha1

Check integrity of the downloaded files (it might take some time):

sha1sum -c {{#latestalp:alpine|file}}.sha1

The output of the above command should say 'OK'.
If says 'FAILED', delete the iso file and download it again.

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:

setup-bootable -u {{#latestalp:alpine|file}} /media/$LBU_MEDIA

Instructions for older versions of Alpine are located elsewhere.

Save changes

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

lbu ci

Load new kernel

In most cases you will need to reboot Alpine Linux (especially if there are changes in the kernel):

sync reboot

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.

Update remaining packages from Web repository

If you are using APK caching you should follow the instructions to Update remaining packages from Web repository, above.