Bobcares

DigitalOcean – A foolproof way to update packages

by | Dec 28, 2018

The immediate reaction when you see that your DigitalOcean packages need updates could be:

“I’m busy now, will do it later.” OR “Update can break my working apps, I will update, but not now!”

Unfortunately, these excuses can make your server a perfect target for hackers.

At Bobcares, we help cloud server owners to update the server packages as part of our Manged Cloud Services.

Today, we’ll see how our Cloud Engineers update DigitalOcean Droplets without breaking the server. Additionally, we’ll see common errors seen while updating and how we fix them.

 

Steps to update DigitalOcean packages

Just like any other server, updating DigitalOcean packages keep your Droplet safe from known security holes. When updates are available in the Droplets, it shows the following message.

186 packages can be updated.
119 updates are security updates.

Now, let’s see how our Cloud Engineers do this update.

 

1. Backup the Droplet

First and foremost, we take a backup of the Droplet. It is rather easy to restore a Droplet from backups than fix a broken Droplet. So, its really critical to have a valid backup.

 

2.Package update commands

To perform the package update, our Cloud Engineers login to the server as root user. We verify the working of repositories from where the files are fetched.

We then begin by updating the package list. For this, we execute:

apt-get update

Next step is to upgrade installed packages to their latest available versions. This is done by

apt-get upgrade

Upon executing this, we’ll see a list of upgrades, and we can choose how to continue.

Once it finishes, we use the dist-upgrade command. This will perform upgrades involving changing dependencies, adding or removing new packages, etc. Additionally, it will handle a set of upgrades which was not done by the upgrade command earlier.

apt-get dist-upgrade

After executing these commands, server will have all packages updated.

 

Common errors while package updates and their fixes

From our experience in managing cloud servers, we often get requests from customers to fix broken Droplets.

There can be many reasons for DigitalOcean package update failure. And, the error message varies in each case.

Now, let’s have a look at the top errors that we see and their fixes.

 

1. Conflict with package lists

Often, when doing package update, there can be conflict with package lists.

For instance, recently we found the following error in a Ubuntu Droplet.

Reading package lists... Error!
E: Encountered a section with no Package: header
E: Problem with MergeList /var/lib/apt/lists/mirrors.digitalocean.com_ubuntu_dists_trusty_universe_i18n_Translation-en%5fUS
E: The package lists or status file could not be parsed or opened.

This happened due to the problems with the package cache file in the Droplet. To fix this, our Support Engineers removed the cached package list files at /var/lib/apt/lists folder and downloaded them again. After that update worked correctly.

 

2. Memory shortage

Similarly, DigitalOcean package update can fail due to memory issues as well. When the server do not have enough memory, the package update process cannot function properly.

To fix this, first we find out the process consuming more memory on the server. Then, depending on the server requirement, we either stop the process or add more memory to the Droplet.

 

3. 404 errors when fetching packages

During package update, the files are fetched from remote location. And, sometimes we see “file not found” or 404 errors when the source files do not exist.

The error shown while package update was:

Err http://mirrors.digitalocean.com utopic-updates/restricted Sources 
404 Not Found
Err http://mirrors.digitalocean.com utopic-updates/universe Sources 
404 Not Found

Here, the requested file was not available and it was moved to a different location. To make the server update the files, we had to edit the /etc/apt/sources.list with working repository location.

 

4. Bad resolver configuration

Again, bad resolver configuration of Droplet can affect the package update process. Here, the error looks like:

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/trusty-security/Release.gpg Could not resolve 'security.ubuntu.com'
W: Failed to fetch http://mirrors.digitalocean.com/ubuntu/dists/trusty/Release.gpg Could not resolve 'mirrors.digitalocean.com'
W: Failed to fetch http://mirrors.digitalocean.com/ubuntu/dists/trusty-updates/Release.gpg Could not resolve 'mirrors.digitalocean.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.

In this Ubuntu Droplet, the connection to hosts like security.ubuntu.com, mirrors.digitalocean.com, etc. were failing. As a result, package download was not happening.

To fix the error, our Cloud Specialists corrected the resolver configuration by editing the file /etc/resolv.conf. And, after this, update worked perfectly.

 

5. Firewall blocks

Similarly, firewall blocks also can prevent the updates from happening.

Recently, a customer reported problem with updating his Droplet. When we checked, we found that server firewall was blocking all ports except 22 and 80. This blocked the package updates too.

To make the update working, our Cloud Support Engineers disabled server firewall temporarily with the command

sudo ufw disable

After that, update worked correctly. Then, we enabled the firewall on the server again.

Conclusion

For security reasons, package updates should be done on DigitalOcean Droplets promptly. Today, we’ve seen how our Cloud Engineers execute the updates without breaking the server. We also discussed the common errors that happens during update and how we fix them.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

SEE SERVER ADMIN PLANS

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF