Question

Error upgrading to Ubuntu 22.04.5 LTS, droplet-agent install fails with "File has unexpected size"

I’m attempting to upgrade my droplet from Ubuntu 20.04.6 to 22.04.5. Running do-release-upgrade told me that I needed to install all available updates, so I ran sudo apt upgrade. Unfortunately it fails with the following:

Err:4 https://repos-droplet.digitalocean.com/apt/droplet-agent main/main amd64 droplet-agent amd64 1.2.4
  File has unexpected size (2287354 != 2287284). Mirror sync in progress? [IP: 2606:4700::6813:ae44 443]
  Hashes of expected file:
   - SHA512:555cafa182619a2165febc85c4345577c444fd8fcc5bcc76376eed398e5c2878abe804878f775e685c48fb225871a63450ec2168813ffb1eddc41e06db56ab2f
   - SHA256:08bfd62e3ac59d46dd9a2bbb75a62ec8161cc819bc3a322f09bc753148f24ea2
   - SHA1:652827bb411bab6435fb7530dcab54a9ec7a1c53 [weak]
   - MD5Sum:668f6fd7160aa8511bdde67633d2c442 [weak]
   - Filesize:2287284 [weak]
Get:5 http://mirrors.digitalocean.com/ubuntu focal-updates/main amd64 libnss-systemd amd64 245.4-4ubuntu3.24 [95.8 kB]
Get:6 http://mirrors.digitalocean.com/ubuntu focal-updates/main amd64 udev amd64 245.4-4ubuntu3.24 [1366 kB]
Get:7 https://repos-droplet.digitalocean.com/apt/droplet-agent main/main amd64 droplet-agent-keyring amd64 2.0.0 [2326 B]
Err:7 https://repos-droplet.digitalocean.com/apt/droplet-agent main/main amd64 droplet-agent-keyring amd64 2.0.0
  File has unexpected size (3390 != 2326). Mirror sync in progress? [IP: 2606:4700::6813:ae44 443]
  Hashes of expected file:
   - SHA512:594709a0de03e0623447741b35ad81448738089adcc3624367a87b8d03558b3dd1b883a528db1ad1d71ef3bba857fbd47ac7974e436238af9200590e9ba634bf
   - SHA256:c7657c63cd2486c9c1861ee343cdcfa8b578fe305980af207cf2420e3f4278de
   - SHA1:2970942fbba624c260f8ae7c0a19a0b24ddffe5e [weak]
   - MD5Sum:ace3ee12f96b42fb874eeb79bd504082 [weak]
   - Filesize:2326 [weak]

Running sudo apt-get update failed as well, with a different error for the same package:

W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://repos-droplet.digitalocean.com/apt/droplet-agent main InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 35696F43FC7DB4C2
W: Failed to fetch https://repos-droplet.digitalocean.com/apt/droplet-agent/dists/main/InRelease  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 35696F43FC7DB4C2

I attempted to get the public key with both sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 35696F43FC7DB4C2 and sudo gpg --homedir /tmp --keyserver keyserver.ubuntu.com --recv-keys 35696F43FC7DB4C2. They each appear to work, but I’m still getting the same errors from above.

Any help would be appreciated, thanks!


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

alexdo
Site Moderator
Site Moderator badge
February 4, 2025

Heya, @joelhobsn

Before attempting a major upgrade on any system, you should make sure you won’t lose data if the upgrade goes awry. The best way to accomplish this is to make a backup of your entire filesystem. Failing that, ensure that you have copies of user home directories, any custom configuration files, and data stored by services such as relational databases.

On a DigitalOcean Droplet, one approach is to power down the system and take a snapshot (powering down ensures that the filesystem will be more consistent). See How to Create Snapshots of Droplets for more details on the snapshot process. After you have verified that the Ubuntu update was successful, you can delete the snapshot so that you will no longer be charged for its storage.

For backup methods which will work on most Ubuntu systems, see How To Choose an Effective Backup Strategy for your VPS.

Ubuntu no longer supports apt-key adv, so you need to manually import the key.

sudo mkdir -p /etc/apt/keyrings 
sudo curl -fsSL https://repos-droplet.digitalocean.com/apt/droplet-agent.asc |  sudo tee /etc/apt/keyrings/droplet-agent.asc

Then update the DigitalOcean repository configuration:

echo "deb [signed-by=/etc/apt/keyrings/droplet-agent.asc] https://repos-droplet.digitalocean.com/apt/droplet-agent main main" | sudo tee /etc/apt/sources.list.d/droplet-agent.list

Finally, update the package lists:

sudo apt update

After fixing the repository errors:

sudo apt clean 
sudo apt autoclean 
sudo apt update 
sudo apt upgrade

Then, retry your Ubuntu upgrade:

sudo do-release-upgrade

Hope that this helps!

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.