Home directories outside of '/home'
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.
Bind mount home directories
There are two steps to bind mount a home directory to a different location:
-
the bind mount: create the mount point and run the mount command:
$ sudo mkdir -p /home/$USER $ sudo mount --bind <original-home-location> /home/$USER
-
edit
/etc/passwd
: backuppasswd
and edit the home location for your user:
The following$ 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
awk
command can be used to edit/etc/passwd
(change OLD_HOME to your old home directory):$ awk -vold=$"OLD_HOME" -vnew=$"/home/$USER" -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 a month ago.