4

I have kubuntu 20.10 that was moved from a bad hard disk to a new one. After I managed to get the system running, I have the following problem: any reference to snap (eg. snap refresh) results in the following error:

error: cannot communicate with server: Post http://localhost/v2/snaps: dial unix /run/snapd.socket: connect: connection refused

As suggested in various other places, I tried to restart snap: systemctl restart snapd

Which did not work:

Job for snapd.service failed because the control process exited with error code. See "systemctl status snapd.service" and "journalctl -xe" for details.

systemctl status snapd

systemd[1]: snapd.service: Scheduled restart job, restart counter is at 5. systemd[1]: Stopped Snap Daemon. systemd[1]: snapd.service: Start request repeated too quickly. systemd[1]: snapd.service: Failed with result 'exit-code'. systemd[1]: Failed to start Snap Daemon. systemd[1]: snapd.service: Triggering OnFailure= dependencies.

journalctl -xe

Journal file /var/log/journal/01b4740d96764e08a9d72db26b6152ca/system@0005b814dc04bedd-c0e64a0174849be3.journal~ is truncated, ignoring file. A start job for unit snapd.service has finished with a failure.

The job identifier is 10214 and the job result is failed. snapd.socket: Failed with result 'service-start-limit-hit'. Subject: Unit failed Defined-By: systemd Support: http://www.ubuntu.com/support

The unit snapd.socket has entered the 'failed' state with result 'service-start-limit-hit'. snapd.service: Triggering OnFailure= dependencies.
systemd[1]: Starting Failure handling of the snapd snap... Subject: A start job for unit snapd.failure.service has begun execution Defined-By: systemd Support: http://www.ubuntu.com/support A start job for unit snapd.failure.service has begun execution. The job identifier is 10359. snapd.failure.service: Succeeded. Subject: Unit succeeded Defined-By: systemd Support: http://www.ubuntu.com/support The unit snapd.failure.service has successfully entered the 'dead' state. Finished Failure handling of the snapd snap. Subject: A start job for unit snapd.failure.service has finished successfully Defined-By: systemd Support: http://www.ubuntu.com/support A start job for unit snapd.failure.service has finished successfully. The job identifier is 10359.

Any ideas how to get it fixed?

Additional info:

The /var partition was recovered from a faulty drive with ddrescue, had errors fixed by e2fsck after recovery.

1
  • @bardia rajabi, no VPN here, the problem was caused by snap internal data corruption caused by hard disk damage. I was asking is there a way to repair a snap without full reinstall.
    – TimSparrow
    Mar 9, 2021 at 11:20

3 Answers 3

5

A brute force fix:

sudo apt purge snapd
sudo apt install snapd

Followed by manual re-installation of all snaps.

If anyone can suggest a better fix, you are welcome.

1
  • 2
    It works fine but it removes the span and the packages installed via snap. Apr 7, 2021 at 8:28
1

You can try to run /usr/lib/snapd/snapd by hand and see what happens. In my case I mounted snaps directory to /var/snapd instead of /var/lib/snapd and got error "cannot run daemon: fatal: directory "/var/lib/snapd" must be present"

0

A workaround script can be found in: https://github.com/DamionGans/ubuntu-wsl2-systemd-script

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.