LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-02-2014, 07:10 AM   #1
robsbots
LQ Newbie
 
Registered: Oct 2008
Posts: 26

Rep: Reputation: 1
Ubuntu 12.04: Updating via ssh. Dropped connection. Updating locked. How to continue


Hi all.

I have a Ubuntu 12.04.5 LTS server that I was in the middle of updating via ssh.
I had completed the 'sudo apt-get update' command, and was part way though 'sudo apt-get upgrade' when the connection dropped due to a time out. When I now log in to the machine via ssh and try 'sudo apt-get update' I get the error
E: Could not get lock /var/lib.dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it ?

Is there a way to switch back to the original update process and continue ? The server has not been rebooted so I assume the process is still running, I just don't know how to retrive it.

Thanks.
 
Old 10-02-2014, 07:31 AM   #2
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Current: Debian and OpenSUSE. Past: Arch, RedHat (pre-RHEL). FreeBSD & OpenBSD novice, Hackintosh
Posts: 1,191
Blog Entries: 7

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
At which stage did it get disconnected? Download? Installation?

Download, would be rather easy to recover: remove the lock file specified, and try again.

During actual package installation, it gets tricky because there may now be files in an unknown state. Half written, whatever. If it was installation and you're sure of which package, reinstall that package, then do the above.

This would be a good time to start using screen. This is how I always did it. GNU screen (http://www.gnu.org/software/screen/) will allow you to detach the terminal. So you log in via ssh, start screen detached, and if this happens again the upgrade should continue if it does not require any interaction, and either way, you can reattach.
 
1 members found this post helpful.
Old 10-02-2014, 07:48 AM   #3
robsbots
LQ Newbie
 
Registered: Oct 2008
Posts: 26

Original Poster
Rep: Reputation: 1
Hi goumba.

Thanks for the reply. Unfortunaltey is was during installation and I'm not sure which package. It was asking wheather I should replace a file, then someone popped in and I got side tracked with another task. Now of course I'm not sure what was being updated and how far it had got. I have checked, and screen is not currently installed. This is something I will look at when I get up and running again.

Is there a way to look though the update list and see how far it has got and maybe the package it was currently processing ?
The update database is currently locked, so I assume the files used to update are still available somewhere, but I don't know enough about apt-get and dpkg to know what to check for.

Thanks for your help.
 
Old 10-02-2014, 08:01 AM   #4
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Current: Debian and OpenSUSE. Past: Arch, RedHat (pre-RHEL). FreeBSD & OpenBSD novice, Hackintosh
Posts: 1,191
Blog Entries: 7

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
There is a log file, /var/log/dpkg.log.

Try this:
Code:
grep upgrade /var/log/dpkg.log
Edit: note, if dpkg.log is empty, try dpkg.log.1. The logs get rotated (although I would think an unsuccessful run will leave the last log as dpkg.log).

Do the same for install, see which has the later timestamp, and that may be your package.

For safety's sake, run
Code:
dpkg --configure -a
to make sure no packages are partially configured, as this may block you from continuing.

Reinstall the package. Again, to be safe.

Then run the upgrade process again. Any packages that had not been installed will be installed at this time. Hopefully you'll be ok. Please realize this isn't foolproof as you can't be sure of which package aborted installation. Fortunately as long as it wasn't a critical package (which you'd probably know by now anyway if it were something like libc, etc), the worst case is you'll get an error somewhere which will point you to another botched install to fix.

Last edited by goumba; 10-02-2014 at 09:29 AM.
 
1 members found this post helpful.
Old 10-02-2014, 08:58 AM   #5
robsbots
LQ Newbie
 
Registered: Oct 2008
Posts: 26

Original Poster
Rep: Reputation: 1
Currently I'm getting a list of errors from
Code:
dpkg --configure -a
All errors follow the same format.
Code:
Setting up php5-gd (5.5.17+dfsg-2+beb.sury.org~prcise+1) ...
debconf: DbDriver "config": /var/cache/debconf/config.dat is locked by another process: Resource temporarily unavailable
dpkg: error processing php5-gd (--configure):
 subprocess installed post-installation script returned error exit status 1

Last edited by robsbots; 10-02-2014 at 09:00 AM.
 
Old 10-02-2014, 09:13 AM   #6
robsbots
LQ Newbie
 
Registered: Oct 2008
Posts: 26

Original Poster
Rep: Reputation: 1
I have found the pid of the process locking this file. Should I kill this process and try again ? I'm not sure of the implicatios of doing this though. Is it safe ?
 
Old 10-02-2014, 09:30 AM   #7
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Current: Debian and OpenSUSE. Past: Arch, RedHat (pre-RHEL). FreeBSD & OpenBSD novice, Hackintosh
Posts: 1,191
Blog Entries: 7

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Depends on the process that's locking it, but I'd venture you're better off trying. Now you also possibly have the name of the package that was being installed at the time, especially if it's not listed in the log.

Last edited by goumba; 10-02-2014 at 09:31 AM.
 
1 members found this post helpful.
Old 10-02-2014, 09:53 AM   #8
robsbots
LQ Newbie
 
Registered: Oct 2008
Posts: 26

Original Poster
Rep: Reputation: 1
I currently have a list of 14 packages that where being updated. Top of the list is php5-gd.

Using the command
Code:
sudo fuser -v /var/cache/debconf/config.dat
I get :-
Code:
USER    PID    ACCESS    COMMAND
root  23358    F....     frontend
If I kill this process, then update all the packages listed by the 'dpkg --configure -a' command will this get me to a safe point or should I kill it and re-run the dpkg command ?
 
Old 10-02-2014, 09:57 AM   #9
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Current: Debian and OpenSUSE. Past: Arch, RedHat (pre-RHEL). FreeBSD & OpenBSD novice, Hackintosh
Posts: 1,191
Blog Entries: 7

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Kill it, and run dpkg-configure. That will finish configuring any packages that had their configuration aborted. If you don't do this, dpkg will block you no matter what you try, with an error about package configuration errors (and likely suggest itself for you to run dpkg --configure -a). Then run the upgrade procedure again. If you run into any problems with any php scripts that use gd, I would reinstall php5-gd.

Before removing any files, make backups, might as well of the dpkg database, too.

Code:
cp -arf /var/lib/dpkg /var/lib/dpkg.backup
Don't forget to remove the lock files.

/var/lib/dpkg/lock

If problems persist, there may be others you need to remove. Try the above first, and only move on if it doesn't help.

/var/lib/apt/lists/lock
/var/cache/apt/archives/lock

Last edited by goumba; 10-02-2014 at 10:04 AM.
 
1 members found this post helpful.
Old 10-02-2014, 10:09 AM   #10
robsbots
LQ Newbie
 
Registered: Oct 2008
Posts: 26

Original Poster
Rep: Reputation: 1
That seems to have cracked it. php5-gd seems to be working fine and I have also run apt-get update and apt-get upgrade with no problems. I have rebooted the server and all systems/services seem to be firing.

Thankyou very much for your help.

Last edited by robsbots; 10-02-2014 at 10:13 AM.
 
Old 10-02-2014, 07:51 PM   #11
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Current: Debian and OpenSUSE. Past: Arch, RedHat (pre-RHEL). FreeBSD & OpenBSD novice, Hackintosh
Posts: 1,191
Blog Entries: 7

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
You're welcome, glad it worked out.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Internet connection gone after updating Ubuntu Precise to 3.13.032-generic kernel judoka Linux - Newbie 3 02-23-2016 12:12 AM
rpm changes are not updating immediately and updating after some time. shri_22ram Linux - Newbie 1 05-13-2013 12:50 PM
Can't get my ssh to work after updating ubuntu pixartist Linux - Newbie 2 02-20-2011 07:39 PM
SVN working copy locked error updating e17 sources. The_Seraphim Linux - Software 0 04-28-2009 03:53 AM
updating SSH whaase Linux - Software 6 09-18-2002 01:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration