Ubuntu – Ubuntu upgrade failing from 16.04 to 16.10: ‘Failed to lock /var/cache/apt/archives/lock’

16.10aptupgrade

I am unable to upgrade Ubuntu from 16.04 to 16.10.

Error message:

Failed to lock /var/cache/apt/archives/lock

There are numerous answers on how to fix it. I tried all. But no success. Can anybody help?

Existing posts on the same topic:

Error Message:

Calculating the changes    
Calculating the changes
Do you want to start the upgrade?     
10 installed packages are no longer supported by Canonical. You can 
still get support from the community. 
16 packages are going to be removed. 293 new packages are going to be 
installed. 1842 packages are going to be upgraded. 
Installing the upgrade can take several hours. Once the download has 
finished, the process cannot be canceled. 
 Continue [yN]  Details [d]y
Fetching Fetched 0 B in 0s (0 B/s)                                   
Upgrading
Could not download the upgrades 
The upgrade has aborted. Please check your Internet connection or 
installation media and try again. 

Failed to lock /var/cache/apt/archives/lock 

Traceback (most recent call last):   File
"/tmp/ubuntu-release-upgrader-kfjtjdko/yakkety", line 8, in <module>  
File
"/tmp/ubuntu-release-upgrader-kfjtjdko/DistUpgrade/DistUpgradeMain.py",
line 242, in main   File
"/tmp/ubuntu-release-upgrader-kfjtjdko/DistUpgrade/DistUpgradeController.py",
line 1880, in run   File
"/tmp/ubuntu-release-upgrader-kfjtjdko/DistUpgrade/DistUpgradeController.py",
line 1845, in fullUpgrade   File
"/tmp/ubuntu-release-upgrader-kfjtjdko/DistUpgrade/DistUpgradeController.py",
line 1263, in doDistUpgrade   File
"/tmp/ubuntu-release-upgrader-kfjtjdko/DistUpgrade/DistUpgradeController.py",
line 1385, in abort   File
"/tmp/ubuntu-release-upgrader-kfjtjdko/DistUpgrade/sourceslist.py",
line 366, in restore_backup   File "/usr/lib/python3.5/shutil.py",
line 236, in copy
    copymode(src, dst, follow_symlinks=follow_symlinks)   File "/usr/lib/python3.5/shutil.py", line 138, in copymode
    chmod_func(dst, stat.S_IMODE(st.st_mode)) PermissionError: [Errno 1] Operation not permitted: '/etc/apt/sources.list' Error in
sys.excepthook: Traceback (most recent call last):   File
"/usr/lib/python3/dist-packages/apport_python_hook.py", line 109, in
apport_excepthook
    pr.add_proc_info(extraenv=['PYTHONPATH', 'PYTHONHOME'])   File "/usr/lib/python3/dist-packages/apport/report.py", line 544, in
add_proc_info
    self['ExecutableTimestamp'] = str(int(os.stat(self['ExecutablePath']).st_mtime)) PermissionError:
[Errno 13] Permission denied:
'/tmp/ubuntu-release-upgrader-kfjtjdko/yakkety'

Original exception was: Traceback (most recent call last):   File
"/tmp/ubuntu-release-upgrader-kfjtjdko/yakkety", line 8, in <module>  
File
"/tmp/ubuntu-release-upgrader-kfjtjdko/DistUpgrade/DistUpgradeMain.py",
line 242, in main   File
"/tmp/ubuntu-release-upgrader-kfjtjdko/DistUpgrade/DistUpgradeController.py",
line 1880, in run   File
"/tmp/ubuntu-release-upgrader-kfjtjdko/DistUpgrade/DistUpgradeController.py",
line 1845, in fullUpgrade   File
"/tmp/ubuntu-release-upgrader-kfjtjdko/DistUpgrade/DistUpgradeController.py",
line 1263, in doDistUpgrade   File
"/tmp/ubuntu-release-upgrader-kfjtjdko/DistUpgrade/DistUpgradeController.py",
line 1385, in abort   File
"/tmp/ubuntu-release-upgrader-kfjtjdko/DistUpgrade/sourceslist.py",
line 366, in restore_backup   File "/usr/lib/python3.5/shutil.py",
line 236, in copy
    copymode(src, dst, follow_symlinks=follow_symlinks)   File "/usr/lib/python3.5/shutil.py", line 138, in copymode
    chmod_func(dst, stat.S_IMODE(st.st_mode)) PermissionError: 
[Errno 1] Operation not permitted: '/etc/apt/sources.list'

Best Answer

I had the same issue where I got Failed to lock /var/cache/apt/archives/lock every single time I tried the upgrade.

I did everything as described here, except to start update-manager with sudo.

So:

  1. sudo apt-get update

  2. sudo apt-get upgrade

  3. sudo apt-get dist-upgrade

  4. sudo update-manager -d

... and finally, on the 27th try, it worked out.