[Solved] postgresql with systemd

Hello Guys,
I'm having problems starting the postgres with systemd.
Following errors:
Running systemctl start postgresql
k@archK ~ % sudo systemctl start postgresql
Job for postgresql.service failed. See 'systemctl status postgresql.service' and 'journalctl -xn' for details.
1 k@archK ~ %
Running systemctl status postgresql.service got the message below:
k@archK ~ % systemctl status postgresql.service
postgresql.service - PostgreSQL database server
Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled)
Active: failed (Result: exit-code) since Sáb, 2012-12-29 19:09:19 BRT; 1min 19s ago
Process: 1746 ExecStart=/usr/bin/pg_ctl -s -D ${PGROOT}/data start -w -t 120 (code=exited, status=1/FAILURE)
Process: 1741 ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGROOT}/data (code=exited, status=0/SUCCESS)
CGroup: name=systemd:/system/postgresql.service
3 k@archK ~ %
and journalctl -xn this:
k@archK ~ % sudo journalctl -xn
[sudo] password for k:
-- Logs begin at Sáb, 2012-12-29 03:47:42 BRT, end at Sáb, 2012-12-29 19:11:49 BRT. --
Dez 29 19:09:19 archK systemd[1]: postgresql.service: control process exited, code=exited status=1
Dez 29 19:09:19 archK systemd[1]: Failed to start PostgreSQL database server.
-- Subject: Unit postgresql.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- Documentation: http://www.freedesktop.org/wiki/Software/systemd/catalog/be02cf6855d2428ba40df7e9d022f03d
-- Unit postgresql.service has failed.
-- The result is failed.
Dez 29 19:09:19 archK systemd[1]: Unit postgresql.service entered failed state
Dez 29 19:09:19 archK sudo[1738]: pam_unix(sudo:session): session closed for user root
Dez 29 19:11:27 archK udisks-daemon[430]: **** Refreshing ATA SMART data for /sys/devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda
Dez 29 19:11:27 archK udisks-daemon[430]: helper(pid 1781): launched job udisks-helper-ata-smart-collect on /dev/sda
Dez 29 19:11:28 archK udisks-daemon[430]: helper(pid 1781): completed with exit code 0
Dez 29 19:11:28 archK udisks-daemon[430]: **** EMITTING CHANGED for /sys/devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda
Dez 29 19:11:49 archK sudo[1786]: k : TTY=pts/0 ; PWD=/home/k ; USER=root ; COMMAND=/usr/bin/journalctl -xn
Dez 29 19:11:49 archK sudo[1786]: pam_unix(sudo:session): session opened for user root by k(uid=0)
Here is the postgresql.service
[Unit]
Description=PostgreSQL database server
After=network.target
[Service]
Type=forking
TimeoutSec=120
User=postgres
Group=postgres
Environment=PGROOT=/var/lib/postgres
SyslogIdentifier=postgres
PIDFile=/var/lib/postgres/data/postmaster.pid
ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGROOT}/data
ExecStart= /usr/bin/pg_ctl -s -D ${PGROOT}/data start -w -t 120
ExecReload=/usr/bin/pg_ctl -s -D ${PGROOT}/data reload
ExecStop= /usr/bin/pg_ctl -s -D ${PGROOT}/data stop -m fast
# Due to PostgreSQL's use of shared memory, OOM killer is often overzealous in
# killing Postgres, so adjust it downward
OOMScoreAdjust=-200
[Install]
WantedBy=multi-user.target
and /etc/conf.d/postgresql
## Parameters to be passed to postgresql
## Default data directory location
PGROOT="/var/lib/postgres"
## Passed to initdb if necessary
INITOPTS="--locale en_US.UTF-8"
## Default log file location
#PGLOG="/var/log/postgresql.log"
## Additional options to pass via pg_ctl's '-o' option
#PGOPTS=""
Does anyone have any idea how to fix this?
Thanks.
Last edited by kleitonkk (2013-01-03 23:51:41)

Sorry for the delay, was traveling and just returned yesterday.
lothar_m was followed as described in the post, since removed the packages twice and did the install again but the same error.
[root@archK conf.d]# systemctl start postgresql
Job for postgresql.service failed. See 'systemctl status postgresql.service' and 'journalctl -xn' for details.
[root@archK conf.d]#
systemctl status postgresql.service
➜ ~ systemctl status postgresql.service
postgresql.service - PostgreSQL database server
Loaded: loaded (/usr/lib/systemd/system/postgresql.service; disabled)
Active: failed (Result: exit-code) since Thu, 2013-01-03 18:14:43 BRT; 9min ago
Process: 10897 ExecStart=/usr/bin/pg_ctl -s -D ${PGROOT}/data start -w -t 120 (code=exited, status=1/FAILURE)
Process: 10892 ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGROOT}/data (code=exited, status=0/SUCCESS)
CGroup: name=systemd:/system/postgresql.service
➜ ~
[root@archK conf.d]# journalctl -xn
-- Logs begin at Wed, 2013-01-02 16:50:57 BRT, end at Thu, 2013-01-03 18:34:41 BRT. --
Jan 03 18:25:28 archK su[11082]: pam_unix(su:session): session opened for user root by k(uid=1000)
Jan 03 18:34:36 archK systemd[1]: Starting PostgreSQL database server...
-- Subject: Unit postgresql.service has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- Documentation: http://www.freedesktop.org/wiki/Software/systemd/catalog/7d4958e842da4a758f6c1cdc7b36dcc5
-- Unit postgresql.service has begun starting up.
Jan 03 18:34:36 archK postgres[11127]: LOG: could not translate host name "localhost", service "5432" to address: Name or service not known
Jan 03 18:34:36 archK postgres[11127]: WARNING: could not create listen socket for "localhost"
Jan 03 18:34:36 archK postgres[11127]: FATAL: could not create any TCP/IP sockets
Jan 03 18:34:41 archK postgres[11127]: pg_ctl: could not start server
Jan 03 18:34:41 archK postgres[11127]: Examine the log output.
Jan 03 18:34:41 archK systemd[1]: postgresql.service: control process exited, code=exited status=1
Jan 03 18:34:41 archK systemd[1]: Failed to start PostgreSQL database server.
-- Subject: Unit postgresql.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- Documentation: http://www.freedesktop.org/wiki/Software/systemd/catalog/be02cf6855d2428ba40df7e9d022f03d
-- Unit postgresql.service has failed.
-- The result is failed.
Jan 03 18:34:41 archK systemd[1]: Unit postgresql.service entered failed state
/usr/lib/systemd/system/postgresql.service
[Unit]
Description=PostgreSQL database server
After=network.target
[Service]
Type=forking
TimeoutSec=120
User=postgres
Group=postgres
Environment=PGROOT=/var/lib/postgres
SyslogIdentifier=postgres
PIDFile=/var/lib/postgres/data/postmaster.pid
ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGROOT}/data
ExecStart= /usr/bin/pg_ctl -s -D ${PGROOT}/data start -w -t 120
ExecReload=/usr/bin/pg_ctl -s -D ${PGROOT}/data reload
ExecStop= /usr/bin/pg_ctl -s -D ${PGROOT}/data stop -m fast
# Due to PostgreSQL's use of shared memory, OOM killer is often overzealous in
# killing Postgres, so adjust it downward
OOMScoreAdjust=-200
[Install]
WantedBy=multi-user.target
➜ ~ pacman -Q |grep postgres
postgresql 9.2.2-2
postgresql-libs 9.2.2-2
➜ ~
/etc/conf.d
## Parameters to be passed to postgresql
## Default data directory location
PGROOT="/var/lib/postgres"
## Passed to initdb if necessary
INITOPTS="--locale en_US.UTF-8"
## Default log file location
#PGLOG="/var/log/postgresql.log"
## Additional options to pass via pg_ctl's '-o' option
#PGOPTS=""
/usr/lib/systemd/system/postgresql.service
[Unit]
Description=PostgreSQL database server
After=network.target
[Service]
Type=forking
TimeoutSec=120
User=postgres
Group=postgres
Environment=PGROOT=/var/lib/postgres
SyslogIdentifier=postgres
PIDFile=/var/lib/postgres/data/postmaster.pid
ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGROOT}/data
ExecStart= /usr/bin/pg_ctl -s -D ${PGROOT}/data start -w -t 120
ExecReload=/usr/bin/pg_ctl -s -D ${PGROOT}/data reload
ExecStop= /usr/bin/pg_ctl -s -D ${PGROOT}/data stop -m fast
# Due to PostgreSQL's use of shared memory, OOM killer is often overzealous in
# killing Postgres, so adjust it downward
OOMScoreAdjust=-200
[Install]
WantedBy=multi-user.target
I'm still looking for how to solve.
Thank you.

Similar Messages

  • [SOLVED] Problems with systemd's journal when using syslog() in C

    Hi,
    I have a problem with journalctl and syslog output within a C program:
    When I use journalctl in follow mode:
      $ journalctl -f
    and I run the folowing program in another terminal
    #include <stdio.h>
    #include <syslog.h>
    int main()
    FILE *pf;
    int i;
    /* logging made in file /var/log/syslog */
    openlog("martins",LOG_CONS,LOG_USER);
    pf = fopen("not_here","r");
    if (!pf)
    syslog(LOG_ERR | LOG_USER,"oops -- %m\n");
    return 0;
    no syslog error message appears in the journal.
    But, when I modify the programm by adding a 'sleep(1);' right before 'return 0;'
    there is a correct error message shown in the journal.
    Is this a bug in systemd? Or do I understand something wrong with systemd's journal?
    I'm actually running
    linux-3.10-12-1-lts
    systemd 207
    with a 32Bit installation
    Thanks for any hints,
    Martin
    Last edited by thesofty (2013-10-01 19:10:13)

    Now, I understand what's going on:
    1) There is an known issue about a race condition in journald when the logging process exits. In this case the message isn't assigned to the user whose process generated the message.
    2) Apparently the group of the journal files have been changed from 'adm' to 'systemd-journal' in Arch Linux around April 2013.
    But still I only have been member of 'adm' as described in the journal tutorial on http://0pointer.de/blog/projects/journalctl.html. So I  can only see syslog messages, which are correctly assigned to my own user account. The messages with the race condition, as mentioned above, have been invisible to me.
    After joining to the new right group again:
      $ sudo usermod -d G  martin systemd-journal
    I also see the syslog messaes just before exiting the process again :-).

  • [SOLVED]Problem with systemd and awesome wm

    Hello,
    I recently have installed systemd and I have enabled slim.service, but after logging in throught slim I cannot run any programs in my awesome wm. Well, actually I can, but only a few seconds after login. If I run xterm and then try to run a program throught it I get messages "no protocol specified" and "cannot open display :0.0". If I quit awesome/X and login again(without reboot) all works just fine. Could you please help me to solve this problem? Thank you in advance.
    Edit: found this in the Xorg.0.log:
    [ 164.412] (==) Log file: "/var/log/Xorg.0.log", Time: Fri Jun 15 11:47:28 2012
    [ 164.412] (==) Using config directory: "/etc/X11/xorg.conf.d"
    [ 164.413] (==) No Layout section. Using the first Screen section.
    [ 164.413] (==) No screen section available. Using defaults.
    [ 164.413] (**) |-->Screen "Default Screen Section" (0)
    [ 164.413] (**) | |-->Monitor "<default monitor>"
    [ 164.413] (==) No monitor specified for screen "Default Screen Section".
    Using a default monitor configuration.
    Last edited by ArtemGuzhva (2012-06-18 07:46:12)

    Okay, it is working fine now I have uninstalled initscripts and installed sysvcompat.
    NOTE: before uninstalling initscripts and sysvinit, reboot your computer with init=/bin/systemd in your kernel cmdline, because you will not be able to shutdown properly due to the lack of inittab.
    Last edited by ArtemGuzhva (2012-06-18 07:49:12)

  • [SOLVED] Postgresql and systemd - Unable to start or enable service

    I'm trying to run postgresql in a pure systemd machine.
    i've done a fresh install of postgresql using pacman as instructed in the wiki. However when i try to start the service i get the following:
    user@frodo:~$ sudo systemctl start postgresql.service
    Failed to issue method call: Unit postgresql.service failed to load: No such file or directory. See system logs and 'systemctl status postgresql.service' for details.
    user@frodo:~$ sudo systemctl status postgresql.service
    postgresql.service
    Loaded: error (Reason: No such file or directory)
    Active: inactive (dead)
    So it seems the package has no systemd service files included. Did anyone got around to make one of these?
    Last edited by lothar_m (2012-09-26 22:01:21)

    well, i've managed to fix the problem.
    it seems that the wiki is missing a couple of steps. so i manually done the following:
    i) create the data directory (acordingly  with the PGROOT variable set before in the config file)
    user@frodo:~$ sudo mkdir /var/lib/postgres/data
    ii) set /var/lib/postgres/data ownership to user 'postgres'
    iii) As user 'postgres' start the database.
    user@frodo:~$ sudo -i -u postgres
    [postgres@frodo ~]$ initdb -D '/var/lib/postgres/data'
    iv) start the service as root
    user@frodo:~$ sudo systemctl start postgresql.service
    that should be it.
    Issuing a systemctl status should return
    user@frodo:~$ sudo sudo systemctl status postgresql.service
    postgresql.service - PostgreSQL database server
    Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled)
    Active: active (running) since Wed, 26 Sep 2012 22:50:09 +0100; 6s ago
    Process: 11187 ExecStart=/usr/bin/pg_ctl -s -D ${PGROOT}/data start -w -t 120 (code=exited, status=0/SUCCESS)
    Process: 11183 ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGROOT}/data (code=exited, status=0/SUCCESS)
    Main PID: 11193 (postgres)
    CGroup: name=systemd:/system/postgresql.service
    ├ 11193 /usr/bin/postgres -D /var/lib/postgres/data
    ├ 11198 postgres: checkpointer process
    ├ 11199 postgres: writer process
    ├ 11200 postgres: wal writer process
    ├ 11201 postgres: autovacuum launcher process
    └ 11202 postgres: stats collector process
    Sep 26 22:50:08 frodo postgres[11187]: LOG: database system was shut down at 2012-09-26 22:49:13 WEST
    Sep 26 22:50:08 frodo postgres[11187]: LOG: database system is ready to accept connections
    Sep 26 22:50:08 frodo postgres[11187]: LOG: autovacuum launcher starte
    Last edited by lothar_m (2012-12-30 09:52:52)

  • [SOLVED] Problems with systemd-update-utmp after systemd update

    Hi all,
    I noticed that systemd-update-utmp-runlevel.service has been failing since the last systemd update. My systemd is:
    Repository : core
    Name : systemd
    Version : 184-2
    $ systemctl status systemd-update-utmp-runlevel.service
    systemd-update-utmp-runlevel.service - Update UTMP about System Runlevel Changes
    Loaded: loaded (/usr/lib/systemd/system/systemd-update-utmp-runlevel.service; static)
    Active: failed (Result: exit-code) since Sat, 02 Jun 2012 13:55:40 +0200; 56min ago
    Docs: man:utmp(5)
    Main PID: 395 (code=exited, status=1/FAILURE)
    CGroup: name=systemd:/system/systemd-update-utmp-runlevel.service
    The exact cause of error is:
    Jun 02 13:55:40 arch systemd-update-utmp[395]: Failed to write utmp record: No such file or directory
    Jun 02 13:55:40 arch systemd[1]: systemd-update-utmp-runlevel.service: main process exited, code=exited, status=1
    What's more, after this update I am not able to mount vmware hgfs shares. I've got following entry in my /etc/fstab (from arch's wiki)
    #enable shared folders
    .host:/ /mnt/hgfs vmhgfs defaults,ttl=5 0 0
    It worked just fine. After the update system boots into maintenance mode with the following message found in sysemd-journal:
    arch mount[143]: Directory in share name must not be empty
    arch mount[143]: Error: share name is invalid, aborting mount
    After commenting hgfs mount entry out the system boots normally.
    Thanks in advance.
    EDIT:
    Mounting hgfs shares manually works as expected
    $: sudo mount /mnt/hgfs
    Could not add entry to mtab, continuing
    mtab:
    .host:/ /mnt/hgfs vmhgfs rw,relatime 0 0
    so this issue must be systemd related
    Last edited by mrzeznicki (2012-06-07 15:18:05)

    falconindy wrote:Still can't reproduce this. libmount's parser does just fine with ".host" as a dummy entry in my /etc/hosts file mapped for an NFS share.
    Yep, libmount is probably not a problem, I guess this error comes from vmware's hgfsmounter
    static Bool
    ParseShareName(const char *shareName, // IN: Share name to validate
    const char **shareNameHost, // OUT: Share name, host component
    const char **shareNameDir) // OUT: Share name, dir component
    const char *colon, *dir;
    /* 1) Must be colon separated into host and dir. */
    colon = strchr(shareName, ':');
    if (colon == NULL) {
    printf("Share name must be in host:dir format\n");
    return FALSE;
    /* 2) Dir must not be empty. */
    dir = colon + 1;
    if (*dir == '\0') {
    printf("Directory in share name must not be empty\n");
    return FALSE;
    /* 3) Dir must start with forward slash. */
    if (*dir != '/') {
    printf("Directory in share name must be an absolute path\n");
    return FALSE;
    /* 4) Host must be ".host". */
    if (strncmp(shareName, ".host:", 6) != 0) {
    printf("Host in share name must be \".host\"\n");
    return FALSE;
    *shareNameHost = ".host";
    LOG("Host component of share name is \"%s\"\n", *shareNameHost);
    *shareNameDir = dir;
    LOG("Directory component of share name is \"%s\"\n", *shareNameDir);
    return TRUE;
    I am just wondering why it worked before (and why manual mount works). Is there anything in systemd mount layer that consumes '/'?

  • [SOLVED] Help with systemd .service script

    Hello,
    I have been using ArchLinux (ARM version) on some “plug computers” for over a year and love it.  Recently I forced myself to move to systemd by upgrading all my computers from scratch.  I migrated all my applications and learned new ways of doing things but am having trouble with one last migration.  I run a c++ communication program that monitors a TCP port for traffic.  In the past I started this program (daemon) from an entry in rc.conf.  I have read all I can about systemd’s new approach to starting daemons (https://wiki.archlinux.org/index.php/Systemd and https://wiki.archlinux.org/index.php/Systemd/Services)
    So far I created what I thought is the correct systemd .service file listed below.
    [Unit]
    Description=EQBCS
    After=network.target
    [Service]
    Type=simple
    ExecStart=/home/public/EQBCS/eqbcs -p 12947 -d &> /dev/null
    [Install]
    WantedBy=multi-user.target
    I put this file in /usr/lib/systemd/system/eqbcs.service.  I then ran the following commands in the following order:
    systemctl daemon-reload
    systemctl enable eqbcs.service (created a link in /etc/systemd/system/multi-user.target.wants)
    systemctl start eqbcs.service
    Here is output from systemctl (status)
    eqbcs.service                                 loaded failed failed    EQBCS
    I thought this would start the service but no luck.  I also thought maybe a reboot would work but no luck.  I verified I can start the daemon manually if I run /home/public/EQBCS/eqbcs -p 12947 -d &> /dev/null from the command line.
    I think I am close, but after several hours of looking at examples of .service files and other posts, I am at a loss.  I am not one of those types who posts a question without taking the time to read the wealth of information on these boards, but I am truly out of ideas and can’t figure out what to do next.  I sincerely could use some help/advice.
    Last edited by calzon65 (2013-06-01 21:18:20)

    Thank you for the suggestions, I believe I am getting closer to success. When I run systemctl start eqbcs.servcie it starts the service but the only way I can get out of systemctl is to ^c out.
    Here is my current .service file:
    [Unit]
    Description=EQBCS
    After=network.target
    [Service]
    ExecStart=/home/public/EQBCS/eqbcs -p 12947
    Type=forking
    [Install]
    WantedBy=multi-user.target
    Output from systemctl status eqbcs:
    eqbcs.service - EQBCS
       Loaded: loaded (/etc/systemd/system/eqbcs.service; enabled)
       Active: failed (Result: timeout) since Sat 2013-06-01 12:48:43 PDT; 2min 11s ago
      Process: 427 ExecStart=/home/public/EQBCS/eqbcs -p 12947 (code=killed, signal=TERM)
    Main PID: 396 (code=killed, signal=KILL)
       CGroup: name=systemd:/system/eqbcs.service
    Jun 01 12:47:13 alarm systemd[1]: Starting EQBCS...
    Jun 01 12:47:13 alarm eqbcs[427]: WARNING: Running as root NOT recommended.
    Jun 01 12:47:13 alarm eqbcs[427]: EQ Box Chat Server 10.12.18
    Jun 01 12:47:13 alarm eqbcs[427]: Waiting for connections on port: 12947...
    Jun 01 12:48:43 alarm systemd[1]: eqbcs.service operation timed out. Terminating.
    Jun 01 12:48:43 alarm systemd[1]: Failed to start EQBCS.
    Jun 01 12:48:43 alarm systemd[1]: Unit eqbcs.service entered failed state.
    Are there any other suggestions for settings in my .service file?

  • [Solved] Running mpd as user mpd with systemd without using mpd.conf

    Maybe this is tivial, but I searched about an hour without any results. I want to run mpd as user mpd. I cant use the mpd config file since mpd set the UID and GID explicitely resulting in mpd not having the necessary supplementary groups to access the locally shared music on my pc. Well I tried to run mpd with systemd by
    # systemctl start mpd
    and  the systemd contains the user mpd
    $ cat /etc/systemd/system/default.target.wants/mpd.service
    [Unit]
    Description=Music Player Daemon
    After=network.target sound.target
    [Service]
    User=mpd
    ExecStart=/usr/bin/mpd --no-daemon
    # allow MPD to use real-time priority 50
    LimitRTPRIO=50
    LimitRTTIME=-1
    # move MPD to a top-level cgroup, as real-time budget assignment fails
    # in cgroup /system/mpd.service, because /system has a zero real-time
    # budget; see
    # http://www.freedesktop.org/wiki/Software/systemd/MyServiceCantGetRealtime/
    ControlGroup=cpu:/mpd
    # assign a real-time budget
    ControlGroupAttribute=cpu.rt_runtime_us 500000
    [Install]
    WantedBy=default.target
    but it did not run as mpd.
    Well how can I run mpd as mpd? Is there a way to do it like with dropbox: dropbox@<user>.service
    Last edited by manuelschneid3r (2015-03-25 12:52:52)

    Glad you solved it. Was just typing a response and I'll still add two remarks:
    The ps|grep output showed that you run grep as root, not mpd itself (which won't have a space in the command -- the second time it only worked because the mpd group is preceded by a space).
    It sounds like it took you a while to find the drop-in configuration snippet in the mpd.service.d directory. These drop-in are shown in `systemctl status`, which is something you'd normally check in situations like these, and that might help to discover them more quickly.
    Last edited by Raynman (2015-03-25 12:58:36)

  • [SOLVED] samba does not start properly again -this time with systemd

    Definitely no luck with this one...
    So, today I've switched to a pure systemd init system, and noticed that I have this old issue again.
    (Link to my old thread: https://bbs.archlinux.org/viewtopic.php?id=142704)
    Samba doesn't start properly again, more precisely smbd is launched but not nmbd, so samba is not working as it should (for example smbtreee lists nothing).
    Last time I've solved it by putting samba long before networkmanager in the daemons array, but with systemd I'm a bit confused...
    Anyone has this issue?
    Last edited by scar (2012-11-03 07:05:42)

    I think that nmbd isn't waiting for networkmanager to start on my system, because I'm getting journal entries like
    Oct 31 00:47:21 spacebar winbindd[431]: [2012/10/31 00:47:21.556005, 0] param/loadparm.c:7969(lp_do_parameter)
    Oct 31 00:47:21 spacebar systemd[1]: nmbd.service: main process exited, code=exited, status=1
    Oct 31 00:47:21 spacebar systemd[1]: Unit nmbd.service entered failed state.
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> (eth0): carrier now ON (device state 20)
    Oct 31 00:47:22 spacebar kernel: r8169 0000:03:00.0: eth0: link up
    Oct 31 00:47:22 spacebar kernel: IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> (eth0): device state change: unavailable -> disconnected (reason 'carrier-changed') [20 30 40]
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> Auto-activating connection 'Static'.
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> Activation (eth0) starting connection 'Static'
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> (eth0): device state change: disconnected -> prepare (reason 'none') [30 40 0]
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> Activation (eth0) Stage 1 of 5 (Device Prepare) scheduled...
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> Activation (eth0) Stage 1 of 5 (Device Prepare) started...
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> Activation (eth0) Stage 2 of 5 (Device Configure) scheduled...
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> Activation (eth0) Stage 1 of 5 (Device Prepare) complete.
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> Activation (eth0) Stage 2 of 5 (Device Configure) starting...
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> (eth0): device state change: prepare -> config (reason 'none') [40 50 0]
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> Activation (eth0) Stage 2 of 5 (Device Configure) successful.
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> Activation (eth0) Stage 3 of 5 (IP Configure Start) scheduled.
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> Activation (eth0) Stage 2 of 5 (Device Configure) complete.
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> Activation (eth0) Stage 3 of 5 (IP Configure Start) started...
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> (eth0): device state change: config -> ip-config (reason 'none') [50 70 0]
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> Activation (eth0) Stage 5 of 5 (IPv4 Configure Commit) scheduled...
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> Activation (eth0) Stage 3 of 5 (IP Configure Start) complete.
    Oct 31 00:47:22 spacebar NetworkManager[391]: <info> Activation (eth0) Stage 5 of 5 (IPv4 Commit) started...
    Oct 31 00:47:22 spacebar rpc.mountd[462]: Version 1.2.6 starting
    Oct 31 00:47:22 spacebar systemd[1]: Startup finished in 3s 850ms 155us (kernel) + 21s 279ms 972us (userspace) = 25s 130ms 127us.
    Oct 31 00:47:23 spacebar NetworkManager[391]: <info> (eth0): device state change: ip-config -> activated (reason 'none') [70 100 0]
    Oct 31 00:47:23 spacebar ntpd_intres[441]: DNS 0.au.pool.ntp.org -> 116.66.160.39
    Oct 31 00:47:23 spacebar NetworkManager[391]: <info> Policy set 'Static' (eth0) as default for IPv4 routing and DNS.
    Oct 31 00:47:23 spacebar NetworkManager[391]: <info> Activation (eth0) successful, device activated.
    Oct 31 00:47:23 spacebar NetworkManager[391]: <info> Activation (eth0) Stage 5 of 5 (IPv4 Commit) complete.
    Oct 31 00:47:23 spacebar dbus[401]: [system] Activating service name='org.freedesktop.nm_dispatcher' (using servicehelper)
    Oct 31 00:47:20 spacebar smbd[428]: [2012/10/31 00:47:20.771872, 0] param/loadparm.c:7969(lp_do_parameter)
    Oct 31 00:47:20 spacebar smbd[428]: Ignoring unknown parameter "user client driver"
    Oct 31 00:47:20 spacebar smbd[428]: [2012/10/31 00:47:20.794252, 0] lib/interface.c:543(load_interfaces)
    Oct 31 00:47:20 spacebar smbd[428]: WARNING: no network interfaces found
    Oct 31 00:47:20 spacebar smbd[428]: [2012/10/31 00:47:20.805126, 0] smbd/server.c:1109(main)
    Oct 31 00:47:20 spacebar smbd[428]: standard input is not a socket, assuming -D option
    Oh, this started happening after putting a MUCH faster cpu and motherboard in the system, so maybe there's a race-condition there?
    Last edited by MisterAnderson (2012-10-30 04:59:46)

  • [Solved] Numlock on boot (with systemd)

    I recently upgraded to systemd. Everything is working extremely well. Except that I am given to understand that systemd no doesn't use /etc/inittab, where I had added the command from the wiki that turns on numlock on each of the virtual terminals. Unfortunately the wiki doesn't have any method to do it with systemd, only the /etc/inittab method.
    This means that for a brief while, I had to live with the onerous task of hitting numlock manually. It was one of the worst weeks of my life. My index finger is still raw.
    I have come up with a somewhat-solution. I just edited /etc/bash.bashrc and added
    if [[ $( tty ) == /dev/tty? ]]; then
        setleds +num
    fi
    to it, which works quite well. It turns on num lock once you're logged in as long as you are on a virtual terminal and not on one of the /dev/pts/* ones.
    My question is, is there a better place to do this? Maybe some way to get it to turn on before you're even logged in? It doesn't really matter all that much, I'm just trying to make things "correct."
    Last edited by scott_fakename (2012-09-06 20:29:46)

    DSpider wrote:
    https://wiki.archlinux.org/index.php/Ac … _on_Bootup
    Set it in Xorg for whatever DE/WM you use and it will be active when you switch to a tty.
    Don't forget to mark it as solved.
    Yes, I tried that. I use lxdm and xfce, and setting the numlock=1 option in /etc/lxdm/lxdm.conf turns on numlock in xfce and the light in the consoles, but not the actual numlock itself in consoles.
    And Kejpi thanks, I was doing that but when I upgraded to systemd it said those would be taken out "at some point" so I was trying to find out if a permanent solution existed yet. Apparently it does not exist yet, which is fine, I was just curious. So I guess I'll stick with the bashrc method for now.
    Thanks for the replies.
    --Scott

  • [solved] How to restart all services with systemd?

    I had the habit of restarting all daemons after an upgrade so to make sure the newest libraries, configuration files etc were loaded. I did that with a shell script that restarted the daemons in order which they were listed in rc.conf. With systemd I could do something similar by first getting a list of running services and ordering a 'systemcrl restart  <servicename>' for each. But since systemd keeps track of dependencies I wonder if that would be the way to do it. Also I would need to filter out 'one shot' type services that are only needed on bootup.
    <edit>restart instead of reload</edit>
    <edit>solved it with a little script</edit>
    Last edited by rwd (2012-11-27 21:02:02)

    I think that's what systemctl snapshot does.
    snapshot [NAME]
               Create a snapshot. If a snapshot name is specified, the new snapshot will be named after it. If none is specified an automatic snapshot name is generated. In either case, the snapshot name used is printed to STDOUT, unless --quiet is specified.
               A snapshot refers to a saved state of the systemd manager. It is implemented itself as a unit that is generated dynamically with this command and has dependencies on all units active at the time. At a later time the user may return to this state by using the isolate command on the snapshot unit.
               Snapshots are only useful for saving and restoring which units are running or are stopped, they do not save/restore any other state. Snapshots are dynamic and lost on reboot.
    Then, isolate emergency.target or rescue target and switch to the snapshot.

  • Howto suspend with systemd [SOLVED]

    Hi All,
    I have converted my machines to full systemd including some laptops. ... and am on the whole, very happy with systemd ..
    I notice my daughter's laptop (a Samsung N70)  sleeps and resumes just fine without any extra work from me ..
    However, my Sony vaio laptop just reboots when I use the Gnome3 suspend menu item. Is there something else I can try to get it to suspend?
    I presume the Gnome3 suspend is suspend and not hibernate to disk ..
    NB: The samsung was installed from a fresh installation, where the Sony has been recently upgraded and converted to systemd.
    Thanks,
    B
    Last edited by bmentink (2012-09-17 04:18:14)

    First of all, don't presume things - establish the facts. I have no experience with Gnome, so my advice would be to see if 'systemctl suspend' works in a terminal. If it does, then you need to make sure that's what Gnome uses. If it doesn't you have a more fundamental issue, and the information provided by the systemd journal will help you solve it.

  • Getting sasc-ng to work properly with systemd service files [SOLVED]

    This thread is intended for getting the following AUR packages to work with each other with systemd service scripts:
    https://aur.archlinux.org/packages/open-sasc-ng-dkms/
    https://aur.archlinux.org/packages/open-sasc-ng/
    https://aur.archlinux.org/packages/oscam-svn/   (this is a related package as it must properly execute prior to sasc-ng)
    So my server is now on a fresh Arch install with systemd. All is well (& very fast) except I cannot get sasc-ng to function with systemd service init files. Prior to systemd the system worked fine with the rc initscripts & was very stable with the following setup:
    rc.local
    /etc/rc.d/oscam start
    sleep 15
    /etc/rc.d/sasc-ng start
    sleep 4
    /etc/rc.d/mythbackend start
    /etc/conf.d/sasc-ng.conf
    SASCNG_ARGS="-j 0:3 -j 1:4 -j 2:5" -b 16M --sid-allpid --sid-nocache --cam-budget"
    DVBLOOPBACK_ARGS="num_adapters=3"
    LOGDIR="/home/mythtv/logs/"
    CAMDIR="/etc/camdir"
    /etc/camdir/cardclient.conf
    camd35:localhost:15050:1/0000/0000:mythtv:mythtv
    I'll leave out the oscam stuff as that loads fine and doesn't appear to be a part of the problem
    I've tried this with the systemd service file that comes with the open-sasc-ng-dkms package and when it was not sucessful I tried a bunch of variants including using "Type=simple" ect. "Type=Forked" seems to be only option that actually tries to start the processes. I also "hardcoded" the service files for the 2 sasc-ng components to find a few issues with the EnvironmentFile variables. The log variable has been removed for now as this seems to cause a fatal error but the rest of the variables load fine now. I also tested spliting up the DVB loopback module from the sasc-ng binary but this also gives similar results as the following script stands now. Running them manually with systemctl start commands doesn't make a difference but that is not surprising. The service file I'm fiddling with now which I feel has the best potential become working is:
    sasc-ng.service
    [Unit]
    Description=Sasc-ng
    After=oscam.service
    [Service]
    Type=forking
    EnvironmentFile=/etc/conf.d/sasc-ng
    ExecStartPre=/sbin/modprobe dvbloopback $DVBLOOPBACK_ARGS
    TimeoutSec=2
    ExecStart=/usr/sbin/sasc-ng -D $SASCNG_ARGS --cam-dir=$CAMDIR
    TimeoutSec=4
    [Install]
    WantedBy=multi-user.target
    Mythbackend always runs fine (even without DTV via sasc-ng) with the following mythbackend.service:
    [Unit]
    Description=MythTV_backend
    After=sasc-ng.service
    [Service]
    Type=simple
    Environment=MYTHCONFDIR=/etc/conf.d/mythbackend
    Environment=HOME=/usr/share/mythtv
    User=mythtv
    ExecStart=/usr/bin/mythbackend --logpath /var/log/mythtv
    [Install]
    WantedBy=multi-user.target
    oscam.service taken mostly from AUR package also seems fine. I added the TimeoutSec=15 to give time for oscam to load the SC and client protocol before moving on or else sasc-ng fails
    Unit]
    Description=An Open Source Conditional Access Module software
    After=network.target
    [Service]
    Type=forking
    EnvironmentFile=/etc/conf.d/oscam
    ExecStart=/usr/bin/oscam $OSCAM_ARGS
    TimeoutSec=15
    [Install]
    WantedBy=multi-user.target
    Below is the output of the systemctl status commands. Despite the noise in the sasc-ng binary status, it is the loopback module that is " inactive (dead)" and there are no virtual DVB devices being created:
    [mythtv@server ~]$ sudo systemctl status oscam.service
    oscam.service - An Open Source Conditional Access Module software
    Loaded: loaded (/usr/lib/systemd/system/oscam.service; enabled)
    Active: active (running) since Tue, 2012-11-27 21:10:17 CET; 1min 7s ago
    Process: 338 ExecStart=/usr/bin/oscam $OSCAM_ARGS (code=exited, status=0/SUCCESS)
    Main PID: 377 (oscam)
    CGroup: name=systemd:/system/oscam.service
    ├ 377 /usr/bin/oscam -b -c /etc/oscam
    └ 378 /usr/bin/oscam -b -c /etc/oscam
    Nov 27 21:10:17 server systemd[1]: Started An Open Source Conditional Acces...e.
    [mythtv@server ~]$ sudo systemctl status loopback.service
    loopback.service - Sasc-ng DVB Loopback Module
    Loaded: loaded (/etc/systemd/system/loopback.service; enabled)
    Active: inactive (dead) since Tue, 2012-11-27 21:10:28 CET; 1min 27s ago
    Process: 907 ExecStart=/sbin/modprobe dvbloopback num_adapters=3 (code=exited, status=0/SUCCESS)
    CGroup: name=systemd:/system/loopback.service
    Nov 27 21:10:28 server systemd[1]: Started Sasc-ng DVB Loopback Module.
    [mythtv@server ~]$ sudo systemctl status sasc-ng.service
    sasc-ng.service - Sasc-ng
    Loaded: loaded (/etc/systemd/system/sasc-ng.service; enabled)
    Active: failed (Result: exit-code) since Tue, 2012-11-27 21:10:47 CET; 1min 45s ago
    Process: 913 ExecStart=/usr/sbin/sasc-ng -D -j 0:3 -j 1:4 -j 2:5" -b 16M --sid-allpid --sid-nocache --cam-budget --cam-dir=/etc/camdir -l /home/mythtv/logs/sasc-ng.log (code=exited, status=0/SUCCESS)
    Main PID: 921 (code=exited, status=255)
    CGroup: name=systemd:/system/sasc-ng.service
    Nov 27 21:10:39 server sasc-ng[921]: [921] [general.error] failed open /etc...ry
    Nov 27 21:10:40 server sasc-ng[921]: [921] [general.error] failed open /etc...ry
    Nov 27 21:10:40 server sasc-ng[921]: [921] [general.error] failed open /etc...ry
    Nov 27 21:10:40 server sasc-ng[921]: [921] [general.info] loading cardclien...nf
    Nov 27 21:10:42 server sasc-ng[921]: [1062] Netwatcher thread started (pid=...6)
    Nov 27 21:10:42 server sasc-ng[921]: [921] [general.error] no keys loaded f...m!
    Nov 27 21:10:46 server sasc-ng[921]: [1098] SC housekeeper thread started (...2)
    Nov 27 21:10:47 server sasc-ng[921]: [1062] Netwatcher thread ended (pid=92...6)
    Nov 27 21:10:47 server systemd[1]: sasc-ng.service: main process exited, co.../a
    Nov 27 21:10:47 server systemd[1]: Unit sasc-ng.service entered failed state
    [mythtv@server ~]$ sudo systemctl status sasc-ng.service
    sasc-ng.service - Sasc-ng
    Loaded: loaded (/etc/systemd/system/sasc-ng.service; enabled)
    Active: failed (Result: exit-code) since Tue, 2012-11-27 21:10:47 CET; 2min 9s ago
    Process: 913 ExecStart=/usr/sbin/sasc-ng -D -j 0:3 -j 1:4 -j 2:5" -b 16M --sid-allpid --sid-nocache --cam-budget --cam-dir=/etc/camdir -l /home/mythtv/logs/sasc-ng.log (code=exited, status=0/SUCCESS)
    Main PID: 921 (code=exited, status=255)
    CGroup: name=systemd:/system/sasc-ng.service
    Nov 27 21:10:39 server sasc-ng[921]: [921] [general.error] failed open /etc/camdir/smartcard.conf: No such file or directory
    Nov 27 21:10:40 server sasc-ng[921]: [921] [general.error] failed open /etc/camdir/cardslot.conf: No such file or directory
    Nov 27 21:10:40 server sasc-ng[921]: [921] [general.error] failed open /etc/camdir/SoftCam.Key: No such file or directory
    Nov 27 21:10:40 server sasc-ng[921]: [921] [general.info] loading cardclient config from /etc/camdir/cardclient.conf
    Nov 27 21:10:42 server sasc-ng[921]: [1062] Netwatcher thread started (pid=921, tid=140074379712256)
    Nov 27 21:10:42 server sasc-ng[921]: [921] [general.error] no keys loaded for softcam!
    Nov 27 21:10:46 server sasc-ng[921]: [1098] SC housekeeper thread started (pid=921, tid=140074371319552)
    Nov 27 21:10:47 server sasc-ng[921]: [1062] Netwatcher thread ended (pid=921, tid=140074379712256)
    Nov 27 21:10:47 server systemd[1]: sasc-ng.service: main process exited, code=exited, status=255/n/a
    Nov 27 21:10:47 server systemd[1]: Unit sasc-ng.service entered failed state
    [mythtv@server ~]$
    Any ideas?
    Last edited by wdirksen (2012-12-10 19:54:43)

    After some head scratching it seems to be all good now. Considering there have been no replies to this I've come to wonder if I might be the only one with this issue. I could get it working somewhat using service files but never ideal, ex. sasc-ng only using a few of the entitlements from oscam because it started too quick etc. Anyway this might help a few and I'm hoping the linux savvy who find what I'm writing here painfully newbie like or flawed will reply and educate me a bit if what's provided here needs some sharpening up:
    1) Systemd was confusing the sasc-ng binary shorthand arguments with Linux init arguments and a few were misinterpreted if they were not nested into the environment specifiers. So the -l (log) was causing problems and -b (buffer) wasn't loading. To be safe I'm using only the sasc-ng longhand specifiers from now on (two "--" and more verbose) so that they can never be confused even if safely nested in an environment parameter. That means that /etc/conf.d/sasc-ng will also need to be changed to reflect this. I also decided to simplify the LOGFILE parameter to include the whole argument syntax.
    2) Oscam.service needs to be initiated with oneshot and RemainAfterExit=yes to make sure the delay (15 seconds in my config) gets counted out before sasc-ng initiates.
    [EDIT 12/12/2012: Initially I had a second TimeoutSec=2 after ExecStart in sasc-ng.service but this had no function. Turns out that it almost always does work without this delay but not always with my setup. Adding TimeoutSec=2 to mythbackend.service prior to ExecStart command does function and makes things init more consistant]
    sasc-ng.service
    [Unit]
    Description=Sasc-ng
    After=oscam.service
    [Service]
    Type=simple
    EnvironmentFile=/etc/conf.d/sasc-ng
    ExecStartPre=/sbin/modprobe dvbloopback $DVBLOOPBACK_ARGS
    TimeoutSec=2
    ExecStart=/usr/sbin/sasc-ng $SASCNG_ARGS --cam-dir $CAMDIR --log $LOGFILE
    [Install]
    WantedBy=multi-user.target
    /etc/conf.d/sasc-ng
    SASCNG_ARGS="--join 0:3 --join 1:4 --join 2:5 --buffer 16M --sid-allpid --sid-nocache --cam-budget"
    DVBLOOPBACK_ARGS="num_adapters=3"
    LOGFILE="/home/mythtv/logs/sasc-ng.log"
    CAMDIR="/etc/camdir"
    oscam.service
    [Unit]
    Description=An Open Source Conditional Access Module software
    After=network.target
    [Service]
    Type=oneshot
    EnvironmentFile=/etc/conf.d/oscam
    ExecStart=/usr/bin/oscam $OSCAM_ARGS
    TimeoutSec=15
    RemainAfterExit=yes
    [Install]
    WantedBy=multi-user.target
    mythbackend.service
    [Unit]
    Description=MythTV_backend
    After=sasc-ng.service
    [Service]
    Type=simple
    TimeoutSec=2
    Environment=MYTHCONFDIR=/etc/conf.d/mythbackend
    Environment=HOME=/usr/share/mythtv
    User=mythtv
    ExecStart=/usr/bin/mythbackend --logpath /var/log/mythtv
    [Install]
    WantedBy=multi-user.target
    I will make the related changes to the open-sasc-ng AUR package which I currently maintain
    Last edited by wdirksen (2012-12-23 14:40:43)

  • [Solved] Automating btrfs scrub with systemd

    I have a single disk laptop (no RAID) and would like to have btrfs scrub run automatically on some interval and to be automatically emailed if any errors are found.  (My data is backed up online and I can attempt a manual fix.)  I'm trying to set this up with systemd and the btrfs tools.  Here's what I figure I need:
    A systemd service to run btrfs scrub on my entire filesystem.
    A systemd timer to schedule this job weekly.
    systemd services to pause and resume a running btrfs scrub when the machine suspends and wakes up.
    A script to run btrfs status when the previous service has finished, parse the output for the number of errors, and email me if the number is greater than 0.
    A systemd service to run that script when the scrub service has completed.
    What I have so far is below.  I'm sure there are problems with it all, and I'm especially uncertain about #5, since I don't know if the After attribute of one service waits until another has completed or just started.  If anyone could take a look and give me some pointers I'd appreciate it very much.  (The python script is a hack but I'm more concerned with the systemd at the moment, unless you see obvious problems or improvements you'd like to suggest.)
    Attempt at 1 and 2:
    /etc/systemd/system/btrfs_scrub.service
    [Unit]
    Description=Run btrfs scrub on filesystem
    [Service]
    Type=forking
    ExecStart=btrfs scrub start /home
    /etc/systemd/system/btrfs_scrub.timer
    [Unit]
    Description=Weekly btrfs scrub
    [Timer]
    OnCalendar=weekly
    Persistent=true
    [Install]
    WantedBy=timers.target
    Attempt at 3:
    /etc/systemd/system/btrfs_cancel.service
    [Unit]
    Description=Pause a running btrfs scrub on suspend
    Before=suspend.target
    [Service]
    Type=oneshot
    ExecStart=btrfs scrub cancel /home
    [Install]
    WantedBy=suspend.target
    /etc/systemd/system/btrfs_resume.service
    [Unit]
    Description=Resume a paused btrfs scrub after suspend
    After=suspend.target
    [Service]
    Type=oneshot
    ExecStart=btrfs scrub resume /home
    [Install]
    WantedBy=suspend.target
    Attempt at 4:
    /home/username/Code/Scripts/btrfs_results.py
    #Runs btrfs scrub and looks for an indication of errors found, upon
    #which an email is sent.
    import subprocess
    import smtplib
    from email.mime.text import MIMEText
    def email_alert():
    text = "btrfs scrub found errors"
    addr = 'myemail@address'
    username = 'myusername'
    password = 'mypassword'
    msg = MIMEText(text)
    msg['Subject'] = 'btrfs errors'
    msg['From'] = addr
    msg['To'] = addr
    server = smtplib.SMTP('smtp.gmail.com', '587')
    server.starttls()
    server.login(username,password)
    server.sendmail(addr, addr, msg.as_string())
    server.quit()
    print('email sent')
    def main():
    cmd = ['btrfs', 'scrub', 'status', '/home']
    output = subprocess.check_output(cmd)
    output_str = output.decode("utf-8")
    output_words = output_str.split(' ')
    for w in range(0, len(output_words)):
    if output_words[w].find('error') > -1:
    if int(output_words[w - 1]) > 0:
    email_alert()
    main()
    Attempt at 5:
    /etc/systemd/system/btrfs_results.service
    [Unit]
    Description=Parse output from btrfs scrub
    Requires=btrfs_scrub.service
    After=btrfs_scrub.service
    [Service]
    Type=oneshot
    ExecStart=/usr/bin/python /home/username/Code/Scripts/btrfs_results.py
    [Install]
    WantedBy=multi-user.target
    Last edited by 0112358 (2014-09-16 01:26:21)

    0112358 wrote:I have a single disk laptop (no RAID) and would like to have btrfs scrub run automatically on some interval and to be automatically emailed if any errors are found.  (My data is backed up online and I can attempt a manual fix.)  I'm trying to set this up with systemd and the btrfs tools.  Here's what I figure I need:
    0112358 wrote:
    A systemd service to run btrfs scrub on my entire filesystem.
    A systemd timer to schedule this job weekly.
    Should not be hard.
    0112358 wrote:systemd services to pause and resume a running btrfs scrub when the machine suspends and wakes up.
    This happens automatically with s2disk. Am I missing something?
    0112358 wrote:A script to run btrfs status when the previous service has finished, parse the output for the number of errors, and email me if the number is greater than 0.
    You might want to integrate that in the main btrfs scrub script, just after scrub is completed you will run this. Right?
    0112358 wrote:A systemd service to run that script when the scrub service has completed.
    0112358 wrote: What I have so far is below.  I'm sure there are problems with it all, and I'm especially uncertain about #5, since I don't know if the After attribute of one service waits until another has completed or just started.  If anyone could take a look and give me some pointers I'd appreciate it very much.  (The python script is a hack but I'm more concerned with the systemd at the moment, unless you see obvious problems or improvements you'd like to suggest.)
    0112358 wrote:
    Attempt at 1 and 2:
    /etc/systemd/system/btrfs_scrub.service
    [Unit]
    Description=Run btrfs scrub on filesystem
    [Service]
    Type=forking
    ExecStart=btrfs scrub start /home
    /etc/systemd/system/btrfs_scrub.timer
    [Unit]
    Description=Weekly btrfs scrub
    [Timer]
    OnCalendar=weekly
    Persistent=true
    [Install]
    WantedBy=timers.target
    Yes, why not wrap this in some sort of main bash (or python) script.
    0112358 wrote:
    Attempt at 3:
    /etc/systemd/system/btrfs_cancel.service
    [Unit]
    Description=Pause a running btrfs scrub on suspend
    Before=suspend.target
    [Service]
    Type=oneshot
    ExecStart=btrfs scrub cancel /home
    [Install]
    WantedBy=suspend.target
    /etc/systemd/system/btrfs_resume.service
    [Unit]
    Description=Resume a paused btrfs scrub after suspend
    After=suspend.target
    [Service]
    Type=oneshot
    ExecStart=btrfs scrub resume /home
    [Install]
    WantedBy=suspend.target
    Why not do nothing at all? Just let the fs continue after resume. Or is s2disk cancelling this process?
    0112358 wrote:
    Attempt at 4:
    /home/username/Code/Scripts/btrfs_results.py
    #Runs btrfs scrub and looks for an indication of errors found, upon
    #which an email is sent.
    import subprocess
    import smtplib
    from email.mime.text import MIMEText
    def email_alert():
    text = "btrfs scrub found errors"
    addr = 'myemail@address'
    username = 'myusername'
    password = 'mypassword'
    msg = MIMEText(text)
    msg['Subject'] = 'btrfs errors'
    msg['From'] = addr
    msg['To'] = addr
    server = smtplib.SMTP('smtp.gmail.com', '587')
    server.starttls()
    server.login(username,password)
    server.sendmail(addr, addr, msg.as_string())
    server.quit()
    print('email sent')
    def main():
    cmd = ['btrfs', 'scrub', 'status', '/home']
    output = subprocess.check_output(cmd)
    output_str = output.decode("utf-8")
    output_words = output_str.split(' ')
    for w in range(0, len(output_words)):
    if output_words[w].find('error') > -1:
    if int(output_words[w - 1]) > 0:
    email_alert()
    main()
    Ok
    0112358 wrote:
    Attempt at 5:
    /etc/systemd/system/btrfs_results.service
    [Unit]
    Description=Parse output from btrfs scrub
    Requires=btrfs_scrub.service
    After=btrfs_scrub.service
    [Service]
    Type=oneshot
    ExecStart=/usr/bin/python /home/username/Code/Scripts/btrfs_results.py
    [Install]
    WantedBy=multi-user.target
    Yeah, why not wrap 1,2,4 and 5 into one script/service. Why the fine granularity?

  • Mythtv with systemd problems [SOLVED]

    Anyone using mythtv with systemd?  I am using the following to get systemd to start mythbackend but it attempts to start before mysqld is fully ready and thus fails:
    $ cat /etc/systemd/system/mythbackend.service
    [Unit]
    Description=MythTV backend service
    After=network.target mysqld.service
    [Service]
    Type=simple
    Environment=MYTHCONFDIR=/etc/conf.d/mythbackend
    Environment=HOME=/usr/share/mythtv
    User=mythtv
    ExecStart=/usr/bin/mythbackend --logpath /var/log/mythtv
    [Install]
    WantedBy=multi-user.target
    Here is the status output... any advice?
    # systemctl status mythbackend.service
    mythbackend.service - MythTV backend service
    Loaded: loaded (/etc/systemd/system/mythbackend.service; enabled)
    Active: failed (Result: exit-code) since Thu, 10 May 2012 11:59:57 -0400; 2min 40s ago
    Process: 415 ExecStart=/usr/bin/mythbackend --logpath /var/log/mythtv/mythbackend.log (code=exited, status=130)
    CGroup: name=systemd:/system/mythbackend.service
    May 10 11:59:54 mars mythbackend[415]: 2012-05-10 11:59:54.273466 E Driver error was [1/2002]:
    May 10 11:59:54 mars mythbackend[415]: QMYSQL: Unable to connect
    May 10 11:59:54 mars mythbackend[415]: Database error was:
    May 10 11:59:54 mars mythbackend[415]: Can't connect to local MySQL server through socket '/var/ru... (2)
    May 10 11:59:56 mars mythbackend[415]: No UPnP backends found
    May 10 11:59:56 mars mythbackend[415]: Would you like to configure the database connection now? [no]
    May 10 11:59:56 mars mythbackend[415]: [console is not interactive, using default 'no']
    May 10 11:59:56 mars mythbackend[415]: 2012-05-10 11:59:56.526065 I UPnPautoconf() - No UPnP back...ound
    May 10 11:59:56 mars mythbackend[415]: 2012-05-10 11:59:56.526080 A No UPnP backends found
    May 10 11:59:56 mars mythbackend[415]: 2012-05-10 11:59:56.526190 C Failed to init MythContext.
    Last edited by graysky (2012-05-11 20:17:34)

    Cool, 65kid.  Back on topic: http://rpm.pbone.net/index.php3/stat/4/ … 4.rpm.html
    $ cat ./usr/libexec/mysqld-wait-ready
    #!/bin/sh
    # This script waits for mysqld to be ready to accept connections
    # (which can be many seconds or even minutes after launch, if there's
    # a lot of crash-recovery work to do).
    # Running this as ExecStartPost is useful so that services declared as
    # "After mysqld" won't be started until the database is really ready.
    # Service file passes us the daemon's PID
    daemon_pid="$1"
    # extract value of a MySQL option from config files
    # Usage: get_mysql_option SECTION VARNAME DEFAULT
    # result is returned in $result
    # We use my_print_defaults which prints all options from multiple files,
    # with the more specific ones later; hence take the last match.
    get_mysql_option(){
    result=`/usr/bin/my_print_defaults "$1" | sed -n "s/^--$2=//p" | tail -n 1`
    if [ -z "$result" ]; then
    # not found, use default
    result="$3"
    fi
    # Defaults here had better match what mysqld_safe will default to
    get_mysql_option mysqld datadir "/var/lib/mysql"
    datadir="$result"
    get_mysql_option mysqld socket "$datadir/mysql.sock"
    socketfile="$result"
    # Wait for the server to come up or for the mysqld process to disappear
    ret=0
    while /bin/true; do
    RESPONSE=`/usr/bin/mysqladmin --socket="$socketfile" --user=UNKNOWN_MYSQL_USER ping 2>&1`
    mret=$?
    if [ $mret -eq 0 ]; then
    break
    fi
    # exit codes 1, 11 (EXIT_CANNOT_CONNECT_TO_SERVICE) are expected,
    # anything else suggests a configuration error
    if [ $mret -ne 1 -a $mret -ne 11 ]; then
    ret=1
    break
    fi
    # "Access denied" also means the server is alive
    echo "$RESPONSE" | grep -q "Access denied for user" && break
    # Check process still exists
    if ! /bin/kill -0 $daemon_pid 2>/dev/null; then
    ret=1
    break
    fi
    sleep 1
    done
    WTF: /usr/bin/my_print_defaults
    Here is the Arch rc.d script... how to adapt this for systemd?
    stat_busy "Starting MySQL Server"
    [ ! -d /var/run/mysqld ] && install -d -g mysql -o mysql /var/run/mysqld &>/dev/null
    if [ -z "$(getPID)" ]; then
    /usr/bin/mysqld_safe --user=mysql &>/dev/null &
    if [ $? -gt 0 ]; then
    stat_fail
    exit 1
    else
    timeo=30
    while [ $timeo -gt 0 ]; do
    response=`/usr/bin/mysqladmin -uUNKNOWN_USER ping 2>&1` && break
    echo "$response" | grep -q "mysqld is alive" && break
    sleep 1
    let timeo=${timeo}-1
    done
    if [ $timeo -eq 0 ]; then
    stat_fail
    exit 1
    else
    echo $(getPID) > /var/run/mysqld/mysqld.pid
    add_daemon mysqld
    stat_done
    fi
    fi
    else
    stat_fail
    exit 1
    fi
    Last edited by graysky (2012-05-10 19:06:04)

  • How to start dhclient with systemd at startup? [SOLVED]

    I have eth0 connected to DHCP server and want to use dhclient instead of dhcpcd. How can I start dhclient with systemd? Is there something similar to
    systemctl enable dhcpcd@eth0
    Last edited by mpelikan (2012-12-18 13:43:28)

    dhcpcd comes in package with completed systemd unit (/usr/lib/systemd/system/dhcpcd.service and /usr/lib/systemd/system/[email protected]) by package developer, but dhclient doesn't.
    mpelikan, you should write your own systemd unit for dhclient for yourself using
    1) dhcpcd units as example
    2) wiki page https://wiki.archlinux.org/index.php/Sy … vice_files
    3) man page for dhclient to get the right options
    Also I'm sure I saw somewhere an example of dhclient unit but I can't find it now. Anyway, it was not working out-of-box in Arch.
    I've done this previously but then I've realized disadvantages of dhclient (so I've removed it).
    Firstly, I didn't like how it's working in daemon-mode after some testing.
    Secondly, it depends on deprecated net-tools.
    You should try dhcpcd. If it doesn't work, you can make it work by editing configuration files / kernel options (like switching off IPv6 if you think you have an issues with it) or adding some parameters.

Maybe you are looking for

  • How does obj permitted in Determination (Org. Unit) work?

    Hi , How does Object permitted in Detetmnation chck box in the Org Unit works.... Please explain.... Many Thanks, Neeraj

  • Cannot post SD documents after upgrade to Oracle 11g

    Dear Gurus, Lately I have tried to upgrade database for SAP R/3 Enterprise 4.7 from Oracle 9i (9.2.0.7) to Oracle 11g (11.2.0.2). I have tried some of its features including table and index compression. Right now my team is testing my server and find

  • Portal KM and Domino Doc Integration

    Hi Is there anyway I can Integrate Portal Knowledge Management with domino doc. Regards Senthil

  • COBRA issue

    Cobra event was collected(HRBENUSCOB01) for an employee (period=current year). However, at the letter generation(HRBENUSCOB02)  the selection period (current year) was missed and the letter generation screen showed for 01/01/1800 to 12/31/9999 and ha

  • License Error 2004

    Hello When we try to connect to a company, we get the following message: License Error -2147023174 Server RPC not available. Somebody have any idea about how to solve this? Regards,