Ubuntu 22.04 – Migrating from Firefox snap to Firefox apt

Using snaps might have its advantages, but the amount of RAM and CPU cycles that Firefox seems to take made me want to switch. The browser certainly feels more responsive.

Remove the Firefox snap.

# snap remove firefox

If you don't have an APT keyring create one, import the Mozilla APT repository signing key and add it to your sources.
# install -d -m 0755 /etc/apt/keyrings

$ wget -q https://packages.mozilla.org/apt/repo-signing-key.gpg -O- | sudo tee /etc/apt/keyrings/packages.mozilla.org.asc > /dev/null

$ echo "deb [signed-by=/etc/apt/keyrings/packages.mozilla.org.asc] https://packages.mozilla.org/apt mozilla main" | sudo tee -a /etc/apt/sources.list.d/mozilla.list > /dev/null

You need to change the Firefox apt priority to avoid the snap version being re-installed.

$ echo '
Package: *
Pin: origin packages.mozilla.org
Pin-Priority: 1000
' | sudo tee /etc/apt/preferences.d/mozilla

And install the Firefox apt.

# apt update && sudo apt install firefox

[Install a localised version if you need it or want it]

# apt install firefox-l10n-gb

When you launch Firefox it will now be the apt version. Remember to move/copy your profiles from the snap to the new version.

$ cp -a ~/snap/firefox/common/.mozilla/firefox/* ~/.mozilla/firefox/

Finally, launch Firefox and point to the right profile (and delete any you don’t want to keep).

This is best done using the Profile Manager (about:profiles):

https://support.mozilla.org/en-US/kb/profile-manager-create-remove-switch-firefox-profiles




Ubuntu: apt upgrades failing with “Cannot initiate the connection to ports.ubuntu.com”

While doing a distro upgrade with

# do-release-upgrade

I kept getting failures half-way stating

Cannot initiate the connection to ports.ubuntu.com:80

The errors showed several IPv6 addresses that couldn’t be reached. My router supports IPv6, but not my ISP. Somehow I was expecting that the router would be doing the translation or DNS resolution between the two but this wasn’t the case.

Disabling IPv6 on the router didn’t to much. I have a recollection that some of the services I am running on my Ubuntu server require IPv6 enabled or else the OS breaks. So it can’t be disabled for the whole OS.

Luckily you can configure apt to only use IPv4:

# apt-get -o Acquire::ForceIPv4=true update

This will automatically refresh the sources and next time you run apt it will complete the upgrade. If not, your problem lies somewhere else.




Ubuntu/Debian: Not enough free space on disk ‘/boot’ when updating the OS

My /boot partition is only 512MB and I get this error message every now and then when updating:

Not enough free space

The upgrade needs a total of xx.x M free space on disk ‘/boot’. Please free at least an additional xx.x M of disk space on ‘/boot’. You can remove old kernels using ‘sudo apt autoremove’, and you could set COMPRESS=xz in /etc/initramfs-tools/initramfs.conf to reduce the size of your initramfs.

The obvious process is to expand /boot to be at least 1GB and be more careful in the future when partitioning during the OS installation.

Luckily there are a couple of things to try before repartitioning.

Try cleaning old kernels automatically:

# apt autoremove

Compress your initramfs by editing /etc/initramfs-tools/initramfs.conf

# vim /etc/initramfs-tools/initramfs.conf

and change the COMPRESS entry to:

COMPRESS=xz

You might need to rebuild your initramfs for the compression to start applying.

If after doing the above you still don’t have enough free space you can manually delete old kernels.

First check which Linux kernel you are on:

# uname -r

4.15.0-76-generic

In the example above the current kernel is 4.15.0-76. It is really important that the current used kernel is left untouched on the system. Under no circumstances should it be removed.

Check which kernels are on your system:

# dpkg -l | grep linux-image

rc  linux-image-4.15.0-55-generic              4.15.0-55.60                                     amd64        Signed kernel image generic
rc  linux-image-4.15.0-58-generic              4.15.0-58.64                                     amd64        Signed kernel image generic
rc  linux-image-4.15.0-60-generic              4.15.0-60.67                                     amd64        Signed kernel image generic
rc  linux-image-4.15.0-62-generic              4.15.0-62.69                                     amd64        Signed kernel image generic
rc  linux-image-4.15.0-64-generic              4.15.0-64.73                                     amd64        Signed kernel image generic
rc  linux-image-4.15.0-65-generic              4.15.0-65.74                                     amd64        Signed kernel image generic
rc  linux-image-4.15.0-66-generic              4.15.0-66.75                                     amd64        Signed kernel image generic
rc  linux-image-4.15.0-69-generic              4.15.0-69.78                                     amd64        Signed kernel image generic
rc  linux-image-4.15.0-70-generic              4.15.0-70.79                                     amd64        Signed kernel image generic
ii  linux-image-4.15.0-72-generic              4.15.0-72.81                                     amd64        Signed kernel image generic
ii  linux-image-4.15.0-74-generic              4.15.0-74.84                                     amd64        Signed kernel image generic
ii  linux-image-4.15.0-76-generic              4.15.0-76.86                                     amd64        Signed kernel image generic
ii  linux-image-generic                        4.15.0.76.78                                     amd64        Generic Linux kernel image

The first column of the output provides a 2-3 letter code with useful information on the status of each package.

For reference this is their meaning:

First letter. Desired package state:

u ... unknown
i ... install
r ... remove/deinstall
p ... purge (remove including config files)
h ... hold

Second letter. Current package state:

n ... not-installed
i ... installed
c ... config-files (only config files are installed)
U ... unpacked
F ... half-configured (configuration failed for some reason)
h ... half-installed (installation failed for some reason)
W ... triggers-awaited (package is waiting for a trigger from another package)
t ... triggers-pending (package has been triggered)

Third letter. Error state:

R ... reinstallation-required (package broken, reinstallation required)

From the previous output we know that there are some config files left around (rc header), and that several kernel images are still installed (ii header).

The ii ones are the ones consuming the space we need to free up. We need to remove some of those.

We have to keep the current kernel version and at least one or two previous versions as good practice.

So based on all of the above and in this example:

To remove
linux-image-4.15.0-55-generic
linux-image-4.15.0-58-generic
linux-image-4.15.0-60-generic
linux-image-4.15.0-62-generic
linux-image-4.15.0-64-generic
linux-image-4.15.0-65-generic
linux-image-4.15.0-66-generic
linux-image-4.15.0-69-generic
linux-image-4.15.0-70-generic
linux-image-4.15.0-72-generic

To keep
linux-image-4.15.0-74-generic (previous)
linux-image-4.15.0-76-generic (current)

You can remove them one by one:

# apt purge linux-image-4.15.0-55-generic
# apt purge linux-image-4.15.0-58-generic
# apt purge linux-image-4.15.0-60-generic
.
.
.

Or all of them in one go with:

# apt purge linux-image-4.15.0-{55,58,60,62,64,65,66,69,60,72}-generic

This will free up enough space of /boot until you repartition.