Last active
May 28, 2021 00:57
-
-
Save akamas/af4c4d37507897156ebbda2061b93715 to your computer and use it in GitHub Desktop.
Home directories outside of ‘/home’
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://forum.snapcraft.io/t/home-directories-outside-of-home/19224 | |
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. | |
:information_source: 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: 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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment