[Trilug-ontopic] Anyone have info on Ubuntu local disk persistent usbkey home dir?

Mike Shaw mdshaw89 at gmail.com
Mon Feb 16 15:15:49 EST 2009

On Sat, Feb 14, 2009 at 6:09 PM, Mike Shaw <mdshaw89 at gmail.com> wrote:
> Anyone have a persistent home setup on a Ubuntu harddrive installed
> system that they feel sharing config details, i.e. the system is
> installed on the local disk but I want my home on a usbkey?

Okay - I figured it out.  Took some hints from the following pages:


If you want a persistenty USB key home(no encryption) you need to use
pam_mount.  On Ubuntu/Debian use the following to install:

% sudo apt-get install libpam-mount

Add your mount options to /etc/security/pam_mount.conf.xml.  I chose
to use a separate loopback filesystem since most of the setup info I
found was for encrypted filesystems and they all used loopback devices
instead of the real device.  I also had to tell pam_mount to do a lazy
unmount otherwise it would not unmount the filesystems upon logout:

% sudo vi /etc/security/pam_mount.conf.xml
. . .
<umount>umount -l %(MNTPT)</umount>
. . .
<volume user="myuser" path="/dev/sdb1" mountpoint="/mnt/disk"
options="rw,noatime" />
<volume user="myuser" path="/mnt/disk/myuser.img"
mountpoint="/home/myuser" options="loop,rw,noatime"/>

Configure PAM by adding the following to /etc/pam.d/common-auth:

% sudo vi /etc/pam.d/common-auth
. . .
auth    optional        pam_mount.so use_first_pass

And to /etc/pam.d/common-session:

%sudo vi /etc/pam.d/common-session
. . .
session optional        pam_mount.so

Logout and log back in and you are set!

Keep in mind, in my example above you will need to created an image
file for your home directory, format it and copy your current $HOME to

Let me know if you have any suggestions or questions on getting it to
work.  It was a bit of a pain.


BosWars(http://www.boswars.org/) - a futuristic real time strategy game (RTS).

More information about the Trilug-ontopic mailing list