It is getting closer and closer to the official release of Ubuntu 22.04 on April 21. In order to upgrade various Ubuntu devices at home with peace of mind, I decided to experience the nearly completed beta version in advance.
The upgrade methods mentioned in this article apply to both Desktop and Server versions.
Preparation before upgrade
Whether it is the Desktop desktop version or the Server server version of Ubuntu, before upgrading, we need to do a few things:
- User data backup in the system.
- Upgrade the software packages in the system to the latest, and restart the system according to the actual needs to make the upgraded software packages take effect.
- Unlocks software locked by
apt-mark
, allowing the software to be upgraded to a version compatible with the new system during system release upgrades. - Clean up the system kernel, leave enough space, and install the new kernel.
- Of course, because the new version of the system has not yet been officially released, we also need to unlock the system upgrade restrictions.
Next, let's talk about how to complete these pre-preparations.
Data Backup: Packaged and Fast Copy
There are many ways to back up data. Without considering commercial software and installing non-system software, I recommend you to use rsync
and tar
to complete a quick backup.
Compared with using various compression parameters, directly using tar cf
can keep the directory structure and convert it into a single file, which is convenient for us to carry out subsequent file backup and transfer, without having to worry about the file format and permissions of the target partition issues of attribution. Moreover, when there are many small files in our directory, doing so can greatly improve the speed of backing up data.
For example, with the following command, we will package the files in the directory into a file with the suffix tar
, usually we call this process "a tarball".
tar cf demo.soulteary.com.tar demo.soulteary.com
In the actual production process, we will have a lot of directories with a structure similar to the following.
board.black.com
board.data.black.com
cache.black.com
carbon.black.com
certs.black.com
If we want to package the above directories as tarballs, it is obviously troublesome to execute one command one by one. Is there a way to be lazy? Apparently there is.
find . -maxdepth 1 -type d -name '*.*' | xargs -I {} tar cf {}.tar {}
Compared with the use of ls
, we may pack some content by mistake, and directly use find
to limit the type of content we want to pack to a directory, and the naming method of the target name must satisfy *.*
.
If your data volume is very small, of course, you can also consider giving up packaging and directly copying the data.
Compared with direct use of commands such as scp
, I prefer to use rsync
to express our complete file from "departure" to "destination", rsync
In addition to supporting data backup between different partition directories, full content replication across devices is also supported:
# 本地跨分区/目录进行备份
rsync -rv --copy-links /data-need-backup /disk2/data-backup
# 将本地数据备份至其他设备
rsync -rv --copy-links /data-need-backup soulteary@10.11.12.13:/data-backup
If you use Docker, you can choose to refer to the Docker image batch saving scheme in the system mentioned in the article "Improve Docker Desktop For macOS Disk Utilization" :
docker images | sed '1d' | grep -v '<none>' | awk '{print "docker save " $1 ":" $2 " -o " $3 ".tar"}' | bash
Alternatively, if you want to save the Docker image with a more readable filename, you can choose to use the following script:
#!/bin/bash
IMAGES_LIST=($(docker images | sed '1d' | awk '{print $1}'))
IMAGES_NM_LIST=($(docker images | sed '1d' | awk '{print $1"-"$2}'| awk -F/ '{print $NF}'))
IMAGES_NUM=${#IMAGES_LIST[*]}
for((i=0;i<$IMAGES_NUM;i++))
do
docker save "${IMAGES_LIST[$i]}" -o "${IMAGES_NM_LIST[$i]}".tar.gz
done
Alright, that's it for data backup.
Upgrading the software in the system
In order to upgrade to a newer system version, we need to use the following command to upgrade the packages in the system to the latest version of the current system:
apt update && apt upgrade -y
If we have upgraded the software to a newer version, we will see logs similar to the following:
Hit:1 http://cache.black.com/cn.archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://cache.black.com/cn.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:3 http://cache.black.com/cn.archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:4 http://cache.black.com/cn.archive.ubuntu.com/ubuntu focal-security InRelease
Hit:5 http://cache.black.com/mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu focal InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
eatmydata libeatmydata1 libfwupdplugin1 python3-importlib-metadata python3-jinja2
python3-json-pointer python3-jsonpatch python3-jsonschema python3-markupsafe
python3-more-itertools python3-pyrsistent python3-zipp
Use 'apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
If you want, you can use apt autoremove
to uninstall software that is no longer used on the system. If you are too lazy to operate now, it is not a big problem, because after the system is upgraded, we need to clean it up again, so we can deal with it later.
(During the system upgrade process, we will also be asked if we want to clean up, so there is no need for additional operations.)
Unlock locked software
Sometimes, in order to run the software stably for a long time, we have to lock some software packages, such as docker
and so on. However, in the process of system upgrade, it is generally recommended to "unlock" these software packages to avoid incompatibility problems after upgrading to the new system.
apt-mark showhold
Unlocking our locked software in bulk is as simple as one command:
apt-mark showhold | xargs -I {} apt-mark unhold {}
After the command is executed, you will be able to see a log similar to the following:
Canceled hold on docker-ce.
Canceled hold on software-name.
Canceled hold on software-name-2.
...
Clean up kernels that are no longer needed
If you have a separate partition /boot
partition, it is recommended that you clean up the boot partition before upgrading to free up some space so that the new kernel can be installed smoothly. The following content was mentioned in the article "Installing Ubuntu 20.04 on AMD 4750u and 5800u Laptops" .
To clean up the kernel, we first need to know which kernels we have installed:
dpkg --get-selections | grep linux-image
After the command is executed, we will be able to see a result similar to the following:
linux-image-5.13.0-37-generic install
linux-image-5.13.0-39-generic install
linux-image-5.15.0-25-generic install
linux-image-generic install
linux-image-generic-hwe-22.04 install
linux-image-unsigned-5.11.10-051110-generic install
linux-image-5.13.0-35-generic deinstall
Here we can mark the system as deinstall
and delete all the old kernels we no longer need, leaving only two or three kernels that we think will be used.
apt-get purge linux-image-5.13.0-37 linux-image-5.13.0-35
After completing the kernel cleanup, remember to use update-grub
to regenerate the Grub system boot kernel list:
update-grub
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-xxx-generic
Found initrd image: /boot/initrd.img-xxx-generic
...
done
Unlock system upgrade restrictions
Because the current official version of Ubuntu 22.04 has not been Released, we can only upgrade the version lock by changing /etc/update-manager/release-upgrades
and install Ubuntu 22.04 which is still in the development channel.
You can use the following command to complete the "upgrade unlock" of the LTS system with one click.
sed -i -e "s/Prompt=lts/Prompt=normal/" /etc/update-manager/release-upgrades
When the above operations are completed, we start the system upgrade.
Upgrade Ubuntu 20.04
What I use here is a step-by-step upgrade, first upgrade the system to Ubuntu 21.10, which is close to Ubuntu 22.04, and then upgrade the Ubuntu 22.04 version.
Upgrade Ubuntu 20.04 system to Ubuntu 21.10
Compared with the above series, which seems to be a cumbersome operation, the operation of upgrading the system is actually very simple. Just execute do-release-upgrade
to start the upgrade road to the new version.
During the process, if a prompt appears, you can always use the following methods to solve it:
- Enter
y
,yes
in the command line or press Enter to confirm - Press Enter directly in the pop-up command line GUI dialog box to keep the default options
When everything is ready, the command line will prompt us that the upgrade is complete, do you want to restart:
System upgrade is complete.
Restart required
To finish the upgrade, a restart is required.
If you select 'y' the system will be restarted.
Continue [yN] y
At this time, continue to enter y
to restart the system, and the first stage of the system upgrade is complete.
Upgrade Ubuntu 21.10 to Ubuntu 22.04
After logging in to the system again, you will see that the system prompt has changed from Ubuntu 20.04 to Ubuntu 21.10:
Welcome to Ubuntu 21.10 (GNU/Linux 5.13.0-39-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
Next, let's continue to talk about how to upgrade Ubuntu 22.04.
Here is a little trick. For networks that have not fully opened IPv6, it is strongly recommended to disable the IPv6 function of the kernel before upgrading, in case the Ubuntu 22.04 version software package cannot be obtained during the upgrade process, resulting in an infinite loop of the upgrade process:
Failed to fetch
http://cn.archive.ubuntu.com/ubuntu/pool/universe/f/fuse/libfuse2_2.9.9-5ubuntu3_amd64.deb
Connection failed [IP: 91.189.91.38 80]
Restoring original system state
Aborting
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
=== Command detached from window (Sun Apr 10 05:41:24 2022) ===
=== Command terminated with exit status 1 (Sun Apr 10 05:41:34 2022) ===
If your network does not support IPv6, and you happen to enter the system upgrade process, don't be afraid, press x
before the upgrade starts, and exit the upgrade.
Disabling the IPv6 function is actually very simple, just need to modify the /etc/default/grub
file and add ipv6.disable=1
GRUB_CMDLINE_LINUX_DEFAULT
---0fa22e209de21669c7f535f2c04e861b---.
For example, the original file content in the system looks like the following:
GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="maybe-ubiquity"
GRUB_CMDLINE_LINUX=""
We just need to add ipv6.disable=1
to the original configuration:
GRUB_CMDLINE_LINUX_DEFAULT="maybe-ubiquity ipv6.disable=1"
After completing the modification of the file content, execute update-grub && reboot
to regenerate the configuration, and restart the system for the configuration to take effect. In addition, because the overseas server is not particularly stable, if the upgrade is not performed on the cloud server, you can consider using Tsinghua source to replace the default cn.archive.ubuntu.com
and other software sources.
Because Ubuntu 22.04 has not been officially released at the current time, we need to add -d
after the upgrade command to install the system that is still in the development channel.
do-release-upgrade -d
Like the above upgrade system, choose y
and ok
, and the system upgrade will be completed after a while, log in to the system again, you can see that we are already in the Ubuntu 22.04 environment:
Welcome to Ubuntu Jammy Jellyfish (development branch) (GNU/Linux 5.15.0-25-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
At last
In Ubuntu 22.04, because the kernel is upgraded to 5.15 by default, the support for AMD processors (including amdgpu
) is much better. It is recommended to use AMD Ryzen R5/R7 for the upgrade experience.
I was busy a while ago, and since February, I have accumulated a lot of articles and drafts. I hope that this month, I can publish the accumulated content one by one.
--EOF
This article uses the "Signature 4.0 International (CC BY 4.0)" license agreement, welcome to reprint, or re-modify for use, but you need to indicate the source. Attribution 4.0 International (CC BY 4.0)
Author of this article: Su Yang
Creation time: April 10, 2022 Word count: 2587 words Reading time: 6 minutes Link to read this article: https://soulteary.com/2022/04/10/early-access-to-ubuntu-22-04-jammy -jellyfish.html
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。