The snap daemon (snapd) requires a user’s home directory ($HOME) to be located under /home
on the local filesystem. This requirement cannot currently be changed.
However, it is possible to bind mount an alternative $HOME location to /home
to allow other locations to be found by snapd. This process is outlined below.
A bind mount allows a mounted filesystem to be accessible from more than one location at the filesystem level. This is unlike a hard or symbolic link, for instance, which operate as special additional files that point to a destination.
There are two steps to bind mount a home directory to a different location:
$ sudo mkdir -p /home/$USER
$ sudo mount --bind <original-home-location> /home/$USER
/etc/passwd
: backup passwd
and edit the home location for your user:$ cp /etc/passwd passwd.backup
$ # sudo edit /etc/passwd with your favourite editor
$ cat /etc/passwd | grep $USER
ubuntu:x:1000:1000:ubuntu,,,:/home/ubuntu:/bin/bash
The following awk
command can be used to edit /etc/passwd
(change OLD_HOME to your old home directory):$ awk -vold=$"OLD_HOME" -vnew=$"/home" -F: ' BEGIN {OFS = ":"} \
{sub(old,new,$6);print}' /etc/passwd > passwd.new
$ sudo cp passwd.new /etc/passwd
Log out and back in again, and snap will work from the freshly mounted home location. If you run into difficulties, copy the backup passwd file to /etc/passwd
.
Last updated 6 months ago. Help improve this document in the forum.