Ubuntu – How to auto-mount a copied encrypted home

automountecryptfs

How can I auto-mount and use my encrypted home that I copied to another partition on the same hard disk?

I'm running Ubuntu 11.10. My encrypted home is on sda1. There I've 2 users: userA and userB. Another partition is sda3 on which I have some other Data. BTW, sda1 is formatted as EXT4, sda3 is formatted as EXT3.

I did the following:

I logged out from GUI (Gnome) and changed (using Ctrl+Alt+F1) to the shell. From there I logged in, changed to sudo (using sudo -s) . After then I

created a new mountpoint (tmp) under /mnt (mkdir /mnt/tmp)
mounted /dev/sda3 on that mountpoint /mnt/tmp (mount /dev/sda3 /mnt/tmp)
copied my encrypted /home to /mnt/tmp using rsync
(rsync --acvxASXH --progress --stats /home/ /mnt/tmp/).

After the “copy-procedure” I looked to my “new home” in /mnt/tmp and there I found the following 3 folders:

userA, 
userB,  
.ecryptfs

My structure for /dev/sda3 mounted on /mnt/tmp looks like the following (userB in ecryptfs I've not listed):

┬userA
│
├userB
│   
├.ecryptfs
    │
    ├userA
    │      ├ auto-mount
    │      ├ auto-umount            
    │      ├ Private.mnt
        │      ├ Private.sig
    │      ├  wrapped-passphrase
    │      ├ .wrapped-passphrase.recorded
    │   
    ├ .Private  
             ├ (encrypted file_1)
             ├ (encrypted file_2)
             ├ (encrypted file_n)

Now I would like that this copy of the original home-directory should act with the same behavior as the original home-directory means, that it should be auto-mounted at reboot and give me access to my unencrypted files and after logout all my files should be encrypted again. Any suggestions?

Best Answer

Looking at what you want to do, I would say use symlinks.

The auto mount I would do with fstab.

this is how I'd do it:-

run sudo blkid to get the UUID of the partition

sudo cp /etc/fstab /etc/fstab.backup Then, edit fstab (with for example sudo nano or gksu gedit) and add this line:

UUID= /media/Media ntfs defaults 0 0 Make sure that the mount location, /media/Media, exists before doing this, then reboot.

Remove all existing symlinks(having backed up all files prior)

rm -rf ~/Videos && ln -s /media/Media/your-folder/Videos ~/Videos Repeat for all the folders you want to appear in your Home directory.

If this is a pain, you could use Ubuntu tweak as this give you a GUI to manage the folder locations. I would make sure the auto mount si setup first though.

Hope this helps.

Related Question