SOLVED: Ubuntu & Debian, repo installation: Sync loads new user profile after system reboots from kernel update


jdrch

Recommended Posts

On Ubuntu and Debian systems, if you run a kernel update, autoremove the old kernel, and then reboot the machine, Sync will load a new user profile from scratch (asking to set up, etc.) The only way to avoid this is to shut down the system completely and then boot it up again. This is inconvenient and can be wildly confusing for new users who might not know why Sync doesn't appear to be starting.

I wanna say this problem started around Ubuntu 19.x and I've just experienced it on Debian 10 (Buster) for the 1st time today. The new kernel I'm running in Debian is 4.19.0-13-amd64. I suspect the problem may be to a kernel-side change, but it would be nice if Sync could adapt accordingly. I filed an issue on Zendesk: #133488

Link to comment
Share on other sites

  • 2 months later...

CAVEAT: The solution below assumes you don't want to run Resilio Sync under the rslsync user profile. I suppose it can be modified for those who do want that, but I don't currently have any instructions to that effect. Since running under rslsync is Resilio Sync's default behavior, I believe simply following the official setup documentation will get you there.

This fix worked on a fully patched and updated Debian Buster system on the calendar week of this post's writing.

If Sync is loading with no profile:

1) Shut down (not restart) the computer

2) Start the computer.

3) On boot, check that the Sync instance with the existing profile has loaded. Load the web interface and note which port it's running on (the "nnnn" after the ":" in the browser address bar. The value is usually 8888) If it has, proceed:

4) Run the following:

$ ps aux | grep rslsync | grep -v grep

This should give you a list of rslync (Resilio Sync) processes currently running:

$ ps aux | grep rslsync | grep -v grep
YourUsername     1213  2.4  1.8 1554204 305756 ?      Ssl  09:13   0:24 /usr/bin/rslsync --config /home/YourUsername/.config/resilio-sync/config.json
rslsync  17678  0.0  0.1 972796 29900 ?        Ssl  09:30   0:00 /usr/bin/rslsync --config /etc/resilio-sync/config.json

Now you know there are 2 rslsync processes running: one under YourUsername, and the other under rslsync. But which one has the existing profile (read: is driving the web interface)? The next step answers that.

5) Run the following command to list all processes using the port 8888 (the port the correct Sync profile from Step 3 is using):

# lsof -i :8888

This should give you an output with a single entry:

COMMAND  PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
rslsync 1213 YourUsername 50u  IPv4  36915      0t0  TCP localhost:8888 (LISTEN)

The instructions from here on assume the output of the above under the USER column is YourUsername. If it's something else, a modified approach not covered here may be necessary.

Now that we know the correct profile is running on YourUsername, it's time to figure out which profile or user the Resilio Sync service is using:

6) Stop the Resilio Sync service:

# systemctl stop resilio-sync

This will kill 1 of the rslsync processes from Step 4

7) Repeat Step 4:

$ ps aux | grep rslsync | grep -v grep
YourUsername     1213  1.8  1.8 1636556 309544 ?      Ssl  09:13   0:47 /usr/bin/rslsync --config /home/YourUsername/.config/resilio-sync/config.json

As you can see, the Resilio Sync process under the rslsync user was killed in Step 6. This means it's the Resilio Sync service is running under rslsync, which is undesirable for our purposes.

8 ) To confirm the previous step's finding, start the Resilio Sync service:

# systemctl start resilio-sync

9) Repeat Step 4:

$ ps aux | grep rslsync | grep -v grep
YourUsername     1213  1.8  1.8 1636556 309544 ?      Ssl  09:13   0:47 /usr/bin/rslsync --config /home/YourUsername/.config/resilio-sync/config.json
rslsync  14130  7.0  0.1 890604 20108 ?        Ssl  09:57   0:00 /usr/bin/rslsync --config /etc/resilio-sync/config.json

The rslsync Resilio Sync process has reappeared upon starting the Resilio Sync service, which means the service is currently running under rslsync. We want to both switch the service to run under YourUsername AND ensure Resilio Sync processes don't automatically launch under rslsync.

10) Repeat Step 6

11) Disable the Resilio Sync service:

# systemctl disable resilio-sync
Synchronizing state of resilio-sync.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install disable resilio-sync
Removed /etc/systemd/system/multi-user.target.wants/resilio-sync.service.

Of note is the "multi-user.target.wants" in the above. It confirms that Resilio Sync is current configured to run under multiple users, which is not what we want.

12) Repeat Step 4:

$ ps aux | grep rslsync | grep -v grep
YourUsername     1213  1.8  1.8 1636556 309544 ?      Ssl  09:13   0:47 /usr/bin/rslsync --config /home/YourUsername/.config/resilio-sync/config.json

As you can see, stopping and disabling the service did not kill the Resilio Sync process running under YourUsername (anyone want to explain why? I'm not sure myself. If the process under YourUsername isn't controlled by the Resilio Sync service, how is it starting automatically at boot?)

13) Follow the official setup documentation on editing the corresponding systemd file so that the Resilio Sync service uses YourUsername only:

Quote

 

If you want to run Sync under your current user - edit file /usr/lib/systemd/user/resilio-sync.service and change "WantedBy=multi-user.target" to "WantedBy=default.target". Save this file and then enable the service with --user parameter:



$ systemctl --user enable resilio-sync

Do not run the last command as root or using sudo, as it is intended for your account, not root, and so will throw an error message, such as:

Failed to connect to bus: No such file or directory

On some distros, such as openSUSE, you will also need to run the following command to explicitly start Resilio Sync under your username:

$ systemctl --user start resilio-sync

14) Repeat Step 4:

$ ps aux | grep rslsync | grep -v grep
YourUsername     1213  1.8  1.8 1636556 309544 ?      Ssl  09:13   0:47 /usr/bin/rslsync --config /home/YourUsername/.config/resilio-sync/config.json

Resilio Sync is now running as intended under YourUsername only.

I believe this should persist across reboots, shutdowns, and kernel updates. Thanks Alex Witz from Support for the commands and ideas.

Link to comment
Share on other sites

  • jdrch changed the title to SOLVED: Ubuntu & Debian, repo installation: Sync loads new user profile after system reboots from kernel update
  • 1 month later...
  • 3 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.