Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

is dpkg install atomic?

55 views
Skip to first unread message

Han

unread,
Oct 26, 2021, 2:00:04 PM10/26/21
to
Hi, 

This might be a dumb question:  is dpkg installing (or updating) a package using a .deb file atomic in the event of power outage? 

By atomic, I meant either the new version of the application is fully installed, or not at all.  Is this always guaranteed? 

I read the `man dpkg` doc, but couldn't find a clear answer. I might have missed it though.

Thanks,
Han

Roberto C. Sánchez

unread,
Oct 26, 2021, 2:00:04 PM10/26/21
to
It's not a dumb question. The installation of a package might seem,
from the user perspective, like it could be atomic, but it is really
made up of a variety of steps.

Broadly, the package is downloaded, then unpacked, then any included
pre-installation script is executed, the unpacked contents are placed in
their location on the system, and then any included post-installation
script is executed. A power outage at any point in the process could
leave the package in a state where is it is not fully installed.
Though, generally speaking, a situation like that can almost always be
recovered from by a command like 'apt-get install --reinstall <pkg>'.
However, there might circumstances where more advanced techniques might
be required.

Regards,

-Roberto
--
Roberto C. Sánchez

Greg Wooledge

unread,
Oct 26, 2021, 2:00:04 PM10/26/21
to
On Tue, Oct 26, 2021 at 10:31:54AM -0700, Han wrote:
> Hi,
>
> This might be a dumb question: is dpkg installing (or updating) a package
> using a .deb file atomic in the event of power outage?
>
> By atomic, I meant either the new version of the application is fully
> installed, or not at all. Is this always guaranteed?

No. A package can be in a "half-installed" state.

unicorn:~$ dpkg -l | head -n3
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)

See where it says "Half-inst" in the middle? If an "H" is shown in
that column, the package is half-installed.

Also, the post-install scripts that most packages use are shell scripts,
so you already know a priori that the script could be interrupted
partway through.

Brian

unread,
Oct 26, 2021, 2:20:05 PM10/26/21
to
On Tue 26 Oct 2021 at 13:57:13 -0400, Roberto C. Sánchez wrote:

> On Tue, Oct 26, 2021 at 10:31:54AM -0700, Han wrote:
> > Hi, 
> > This might be a dumb question:  is dpkg installing (or updating) a package
> > using a .deb file atomic in the event of power outage? 
> > By atomic, I meant either the new version of the application is fully
> > installed, or not at all.  Is this always guaranteed? 
> > I read the `man dpkg` doc, but couldn't find a clear answer. I might have
> > missed it though.
> > Thanks,
> > Han
>
> It's not a dumb question. The installation of a package might seem,
> from the user perspective, like it could be atomic, but it is really
> made up of a variety of steps.

Indeed.

> Broadly, the package is downloaded, then unpacked, then any included
> pre-installation script is executed, the unpacked contents are placed in
> their location on the system, and then any included post-installation
> script is executed. A power outage at any point in the process could
> leave the package in a state where is it is not fully installed.
> Though, generally speaking, a situation like that can almost always be
> recovered from by a command like 'apt-get install --reinstall <pkg>'.
> However, there might circumstances where more advanced techniques might
> be required.

Assuming that Ctrl-C while dpkg or apt is running is equivalent to a
power outage, I have found that running the specific command afterwards
is generally successful.

--
Brian.

David Wright

unread,
Oct 26, 2021, 4:10:04 PM10/26/21
to
On Tue 26 Oct 2021 at 19:11:50 (+0100), Brian wrote:

> Assuming that Ctrl-C while dpkg or apt is running is equivalent to a
> power outage, I have found that running the specific command afterwards
> is generally successful.

And it might be worth adding that if apt is downloading a large
package when interrupted, it will continue the download from
wherever it got to, without wasting bandwidth.

Cheers,
David.
0 new messages