# Laptop dies on shutdown

## avitase

Hey guys,

I once again have a peculiar problem: my laptop dies on shutdown, that is: I type 'shutdown -h now' and after roughly one second the power is off, no LEDs are blinking, no friendly shutdown logs. I tried to figure out whether there are some correlation between my usage of programs or attached hardware (e.g. docking station) and this dying on shutdown but I wasn't able to find any configuration which leads to a proper shutdown; however, I am sure that some time ago I didn't have this problem, I assume this could be related to recent updates?

Besides this premature power off another indicator that something went wrong (albeit potentially biased) is my Google Chrome that always complains about not exiting properly...

I find this issues pretty hard to tackle, do you have any suggestions which log files I could consider? Do you have any other ideas how I could fix or at least understand this behavior?

Thanks a lot!

----------

## khayyam

avitase ...

not a lot of information to go on, can you provide the output of the following:

```
# ps -p 1 -o comm=

# egrep -v '(^#|^$)' /etc/inittab

# for i in $(awk -F: '!/^(#|$)/{gsub(/ .*/,""); print $4}' /etc/inittab | sort -u) ; do ls -l $i ; done

# rc-status shutdown

# emerge -pvq sys-apps/openrc
```

If you get poweroff (without init having run the shutdown process) you probably don't have anything written to log files, however the above should give some idea of what 'shutdown' would be doing.

best ... khay

----------

## avitase

Thank you very much for your help. Here are the dumps:

```
# ps -p 1 -o comm= 

init

```

```
# egrep -v '(^#|^$)' /etc/inittab 

id:3:initdefault:

si::sysinit:/sbin/openrc sysinit

rc::bootwait:/sbin/openrc boot

l0:0:wait:/sbin/openrc shutdown 

l0s:0:wait:/sbin/halt -dhnp

l1:1:wait:/sbin/openrc single

l2:2:wait:/sbin/openrc nonetwork

l3:3:wait:/sbin/openrc default

l4:4:wait:/sbin/openrc default

l5:5:wait:/sbin/openrc default

l6:6:wait:/sbin/openrc reboot

l6r:6:wait:/sbin/reboot -dkn

su0:S:wait:/sbin/openrc single

su1:S:wait:/sbin/sulogin

c1:12345:respawn:/sbin/agetty 38400 tty1 linux

c2:2345:respawn:/sbin/agetty 38400 tty2 linux

c3:2345:respawn:/sbin/agetty 38400 tty3 linux

c4:2345:respawn:/sbin/agetty 38400 tty4 linux

c5:2345:respawn:/sbin/agetty 38400 tty5 linux

c6:2345:respawn:/sbin/agetty 38400 tty6 linux

ca:12345:ctrlaltdel:/sbin/shutdown -r now

x:a:once:/etc/X11/startDM.sh

```

```
# for i in $(awk -F: '!/^(#|$)/{gsub(/ .*/,""); print $4}' /etc/inittab | sort -u) ; do ls -l $i ; done

-rwxr-xr-x 1 root root 818 May  7 14:25 /etc/X11/startDM.sh

-rwxr-xr-x 1 root root 57472 May  7 12:23 /sbin/agetty

-rwxr-xr-x 1 root root 18752 May  7 11:36 /sbin/halt

-rwxr-xr-x 1 root root 44128 May  7 15:06 /sbin/openrc

lrwxrwxrwx 1 root root 4 May  7 11:36 /sbin/reboot -> halt

-rwxr-xr-x 1 root root 23152 May  7 11:36 /sbin/shutdown

-rwxr-xr-x 1 root root 43952 May  7 12:23 /sbin/sulogin

```

```
rc-status shutdown 

Runlevel: shutdown

 killprocs                [  stopped  ]

 savecache                [  stopped  ]

 mount-ro                 [  stopped  ]

```

```
# emerge -pvq sys-apps/openrc

[ebuild   R   ] sys-apps/openrc-0.34.11  USE="ncurses netifrc pam unicode -audit -debug -newnet (-prefix) (-selinux) -static-libs"

```

----------

## khayyam

avitase ...

nothing obviously wrong there, can you also post the following:

```
# emerge --info

# mount
```

It might also be good to see your kernel config, so can you pastebin that (app-text/wgetpaste).

best ... khay

----------

## avitase

```
 # emerge --info

Portage 2.3.40 (python 3.5.5-final-0, default/linux/amd64/17.0/desktop/plasma, gcc-6.4.0, glibc-2.26-r7, 4.9.95-gentoo x86_64)

=================================================================

System uname: Linux-4.9.95-gentoo-x86_64-Intel-R-_Core-TM-_i7-4910MQ_CPU_@_2.90GHz-with-gentoo-2.4.1

KiB Mem:    16370872 total,  14078520 free

KiB Swap:    1048572 total,   1048572 free

Timestamp of repository gentoo: Sun, 10 Jun 2018 16:30:01 +0000

Head commit of repository gentoo: 32ed40b4a4f8c903e6930d08de3fe929e9e330c9

sh bash 4.4_p12

ld GNU ld (Gentoo 2.30 p2) 2.30.0

app-shells/bash:          4.4_p12::gentoo

dev-lang/perl:            5.24.3-r1::gentoo

dev-lang/python:          2.7.14-r1::gentoo, 3.5.5::gentoo

dev-util/cmake:           3.9.6::gentoo

dev-util/pkgconfig:       0.29.2::gentoo

sys-apps/baselayout:      2.4.1-r2::gentoo

sys-apps/openrc:          0.34.11::gentoo

sys-apps/sandbox:         2.13::gentoo

sys-devel/autoconf:       2.13::gentoo, 2.69-r4::gentoo

sys-devel/automake:       1.11.6-r3::gentoo, 1.15.1-r2::gentoo

sys-devel/binutils:       2.30-r2::gentoo

sys-devel/gcc:            6.4.0-r1::gentoo

sys-devel/gcc-config:     1.8-r1::gentoo

sys-devel/libtool:        2.4.6-r3::gentoo

sys-devel/make:           4.2.1::gentoo

sys-kernel/linux-headers: 4.13::gentoo (virtual/os-headers)

sys-libs/glibc:           2.26-r7::gentoo

Repositories:

gentoo

    location: /usr/portage

    sync-type: rsync

    sync-uri: rsync://rsync.gentoo.org/gentoo-portage

    priority: -1000

    sync-rsync-extra-opts: 

    sync-rsync-verify-metamanifest: yes

    sync-rsync-verify-jobs: 1

    sync-rsync-verify-max-age: 24

ACCEPT_KEYWORDS="amd64"

ACCEPT_LICENSE="*"

CBUILD="x86_64-pc-linux-gnu"

CFLAGS="-march=haswell -O2 -pipe"

CHOST="x86_64-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /usr/share/themes/oxygen-gtk/gtk-2.0"

CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"

CXXFLAGS="-march=haswell -O2 -pipe"

DISTDIR="/usr/portage/distfiles"

EMERGE_DEFAULT_OPTS="--ask"

ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"

FCFLAGS="-O2 -pipe"

FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync multilib-strict news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"

FFLAGS="-O2 -pipe"

GENTOO_MIRRORS="http://ftp.halifax.rwth-aachen.de/gentoo/"

LANG="en_US.utf8"

LDFLAGS="-Wl,-O1 -Wl,--as-needed"

MAKEOPTS="-j9"

PKGDIR="/usr/portage/packages"

PORTAGE_CONFIGROOT="/"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"

PORTAGE_TMPDIR="/var/tmp"

USE="X a52 aac acl acpi activities alsa amd64 berkdb branding bzip2 cairo cdda cdr cli consolekit crypt cups cxx dbus declarative dri dts dvdr emboss encode exif fam flac fortran gdbm gif glamor gpm gtk iconv ipv6 jpeg kde kipi kwallet lcms ldap libnotify libtirpc mad mng modules mp3 mp4 mpeg multilib ncurses nls nptl ogg opengl openmp pam pango pcre pdf phonon plasma png policykit ppds qml qt3support qt5 readline sdl seccomp semantic-desktop spell ssl startup-notification svg tcpd tiff truetype udev udisks unicode upower usb vorbis widgets wxwidgets x264 xattr xcb xcomposite xml xv xvid zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon plan sheets stage words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx avx2 fma3 mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="evdev synaptics" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6 php7-0" POSTGRES_TARGETS="postgres9_5" PYTHON_SINGLE_TARGET="python3_5" PYTHON_TARGETS="python2_7 python3_5" RUBY_TARGETS="ruby23" USERLAND="GNU" VIDEO_CARDS="nvidia" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"

Unset:  CC, CPPFLAGS, CTARGET, CXX, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

```

```
# mount

/dev/sda3 on / type ext4 (rw,noatime,discard,data=ordered)

devtmpfs on /dev type devtmpfs (rw,nosuid,relatime,size=10240k,nr_inodes=2045994,mode=755)

proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)

tmpfs on /run type tmpfs (rw,nodev,relatime,size=1637088k,mode=755)

mqueue on /dev/mqueue type mqueue (rw,nosuid,nodev,noexec,relatime)

devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)

shm on /dev/shm type tmpfs (rw,nosuid,nodev,noexec,relatime)

sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)

debugfs on /sys/kernel/debug type debugfs (rw,nosuid,nodev,noexec,relatime)

fusectl on /sys/fs/fuse/connections type fusectl (rw,nosuid,nodev,noexec,relatime)

selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime)

cgroup_root on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,relatime,size=10240k,mode=755)

openrc on /sys/fs/cgroup/openrc type cgroup (rw,nosuid,nodev,noexec,relatime,release_agent=/lib64/rc/sh/cgroup-release-agent.sh,name=openrc)

none on /sys/fs/cgroup/unified type cgroup2 (rw,nosuid,nodev,noexec,relatime)

cpuset on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)

cpu on /sys/fs/cgroup/cpu type cgroup (rw,nosuid,nodev,noexec,relatime,cpu)

cpuacct on /sys/fs/cgroup/cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct)

blkio on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)

memory on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)

devices on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)

freezer on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)

net_cls on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls)

perf_event on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)

net_prio on /sys/fs/cgroup/net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_prio)

hugetlb on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)

pids on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)

/dev/sda2 on /boot type ext2 (rw,noatime,block_validity,barrier,user_xattr,acl,stripe=4)

/dev/sda4 on /home type btrfs (rw,noatime,ssd,discard,space_cache,subvolid=5,subvol=/)

/dev/sdb1 on /data type btrfs (rw,noatime,ssd,discard,space_cache,subvolid=5,subvol=/)

binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,nosuid,nodev,noexec,relatime)

none on /run/user/1000 type tmpfs (rw,relatime,mode=700,uid=1000)

```

and this is my kernel config: https://pastebin.com/zwBp93Fa

thanking you again ...

----------

## khayyam

avitase ...

again, nothing that suggests a cause, though there is an awful lot of features in 4.9.x I'm unfamiliar with (like retpoline). You mentioned you did an update, can you provide a list of those packages ('qlop -Cl' should show what was updated). Also, have you looked through /var/log/messages for segfaults and/or any entries that come immediately prior to the shutdown?

you're welcome & best ... khay

----------

## Goverp

My laptop, running kernel 4.17, shows similar behaviour.  Look at openrc's log (/var/log/rc.log by default, if you enable logging).  Mine has entries for shutdown that look OK.

Speaking from profound ignorance, I wonder if the issue lies in consolekit not switching to tty0 or something.  I consider any code with "kit" in the name to be witchcraft.

----------

## joanandk

 *avitase wrote:*   

> I find this issues pretty hard to tackle, do you have any suggestions which log files I could consider? Do you have any other ideas how I could fix or at least understand this behavior?

 

Could you check if the directory /run is existant and has files and folders in it? If this folder is missing or its content, it is likely that the shutdown process does not shut down the init-scripts properly.

BR

----------

## bobbymcgee

 *Goverp wrote:*   

> My laptop, running kernel 4.17, shows similar behaviour.  Look at openrc's log (/var/log/rc.log by default, if you enable logging).  Mine has entries for shutdown that look OK.
> 
> Speaking from profound ignorance, I wonder if the issue lies in consolekit not switching to tty0 or something.  I consider any code with "kit" in the name to be witchcraft.

 

I'm no inherent poettering hater, but you are probably right. consolekit and openrc-shutdown stopped working reliably a while back. use elogind or none of it.  :Smile: 

https://wiki.gentoo.org/wiki/Elogind

----------

## khayyam

 *Goverp wrote:*   

> My laptop, running kernel 4.17, shows similar behaviour.  Look at openrc's log (/var/log/rc.log by default, if you enable logging).  Mine has entries for shutdown that look OK.

 

Goverp ... it's not clear if it's the kernel or not, if I were to guess I would roll back openrc as the most likely candidate, but lets wait and see what packages were updated prior to the issue (you should probably compare that list with your own ... particularly where openrc is concerned).

 *Goverp wrote:*   

> Speaking from profound ignorance, I wonder if the issue lies in consolekit not switching to tty0 or something.  I consider any code with "kit" in the name to be witchcraft.

 

Not sure what you mean, but init is the parent of consolekit, so it's very unlikely the later can effect the former.

 *joanandk wrote:*   

> Could you check if the directory /run is existant and has files and folders in it? If this folder is missing or its content, it is likely that the shutdown process does not shut down the init-scripts properly.

 

If you look above you'll see the output of 'mount', and "tmpfs on /run" exists.

 *bobbymcgee wrote:*   

> [...] consolekit and openrc-shutdown stopped working reliably a while back.

 

Let's not confuse things, 'openrc-shutdown', I assume, is a replacement for sysvinit's 'shutdown' and  works in conjunction with 'openrc-init', the OP is still using sys-apps/sysvinit (see the above 'ps'). That's not to say that openrc doesn't play some part in this only that 'shutdown' and 'openrc-shutdown' are different things.

best ... khay

----------

## bobbymcgee

khayyam,

openrc+consolekit+shutdown issues started cropping up last year sometime, I don't know the cause or even all the ways the kits intertwine with shutdown, but most distros have swapped consolekit for elogind in the past year, so it was more of a blanket statement that users will generally receive better support with elogind these days.

----------

## avitase

thanks for your comments

I checked my /var/log/messages but nothing suspicious here, except for this kworker dying (but this was 5min prior to the shutdown)

```
Jun 12 11:05:12 jimbob kernel: [  882.041531] kworker/dying (1125) used greatest stack depth: 11896 bytes left

Jun 12 11:10:07 jimbob shutdown[6066]: shutting down for system halt

Jun 12 11:10:08 jimbob kernel: Kernel logging (proc) stopped.

Jun 12 11:10:08 jimbob kernel: Kernel log daemon terminating.

Jun 12 11:10:09 jimbob exiting on signal 15

```

Unfortunately, I am used to update almost daily, so I can not give you the list of packages that were updated at the time this issue occurred for the first time:/

The /run directory does exist and inhabit files:

```
ls -1 /run/

acpid.pid

acpid.socket

agetty.reload

console

ConsoleKit

crond.pid

cron.reboot

cups

cupsd.pid

dbus

dbus.pid

dhcpcd

dhcpcd-eno1.pid

ifplugd.eno1.pid

klogd.pid

lock

lvm

mount

mysqld

ntpd.pid

openrc

saslauthd

sddm

sddm.pid

syslogd.pid

tmpfiles.d

udev

user

utmp

```

----------

## avitase

 *bobbymcgee wrote:*   

> khayyam,
> 
> openrc+consolekit+shutdown issues started cropping up last year sometime, I don't know the cause or even all the ways the kits intertwine with shutdown, but most distros have swapped consolekit for elogind in the past year, so it was more of a blanket statement that users will generally receive better support with elogind these days.

 

So you are suggesting moving to elogind and exile consolekit?

----------

## bobbymcgee

I would, not promising it'll fix your issue, but it does in general work better than consolekit and it's maintained by a gentoo user.  :Smile: 

----------

