10

How can i move a enrypted home directory to another partition? Are there differences between moving an unencrypted home directory to another partition and an encrypted home directory?

Perhaps does Ubuntu installer offer an option to place your home directory on an other partition?

NES
  • 33,935

5 Answers5

8

I am assuming you want to keep your data encrypted on the new partition.

First close all running applications, we don't want files being updated during the copy. Copy the encrypted data to the new partition:

ecryptfs-umount-private
chown $USER /new_mount_point/$USER
rsync -avP $HOME/.Private $HOME/.ecryptfs /new_mount_point/$USER
editor /etc/passwd # Change the user's home dir to point to the new location

Log-off Log-in

If you want to move/copy an encrypted home you only need to copy/move ~/.Private and the encryption keys (~/.ecryptfs). If you want to copy/move to an unencrypted location just copy everything except .Private and .ecryptfs.

João Pinto
  • 17,323
2

There's another way to do this still:

Using the Ubuntu Help page found at https://help.ubuntu.com/community/Partitioning/Home/Moving

That tutorial will show you how to move an unencrypted partition, but the tweak I used for moving an encrypted partition was to follow that tutorial with the following difference in commands. My explanation for why I did it this way may need some corrections from someone who knows more than me, so please edit or comment if you have time.

  1. Create your partition in Gparted, and give it a label that you will easily recognize. Some of us have too many disks and partitions to remember by numbers.

  2. Before using rsync to copy the files over, unmount your encrypted home using ecryptfs-umount-private. The reason I did this was because rsync seemed to copy the mounted/unencrypted stuff AND the .Private ecryptfs thingies. You only need the .Private and .ecryptfs folders mentioned in the earlier posts.

  3. To copy the files, enter the command "sudo rsync -aVP /home/ /media/home/" instead of using " sudo rsync -aXS --exclude='/*/.gvfs' /home/. /media/home/. " as the tutorial says.


a note on the output from the command "sudo diff -r /home /media/home"

The diff command did report a long list of differences in my case, but I think that was because I was still using Firefox and opening a bunch of documents which changed bookmarks,history etc. I checked my files after completing all of the steps in the tutorial and didn't notice anything missing. After restarting, Firefox reopened a session with a bunch of tabs that I had closed long before copying the files over, hence my assumption about the output of the diff command.

2

After half a day of getting confused trying to move an encrypted home to a new drive with ubuntu 10.04 I eventually found this thread.

mount your new drive
make a new folder on it with your user name
make sure your the owner of it

chown $USER /new_mount_point/$USER

if your file structure under home looks like this

  • home/user/.Private
  • home/user/.ecryptfs
  • home/.ecryptfs

use this replacing $HOME and $USER otherwise try How can i move an encrypted home directory to another partition?

ecryptfs-umount-private
rsync -avP $HOME/$USER/.Private $HOME/$USER/.ecryptfs /new_mount_point/$USER
rsync -avP $HOME/.ecryptfs /new_mount_point

rename your home folder to something else "homeold"
make a new folder called home

Edit your fstab
mount the new drive to /home

Restart

0

A Simple approach to moving an encrypted /home/user directory. Should also work for non encrypted content as well. Just successfuly achieved this after a few trials.

Boot to live DVD or USB session Do not use sudo copy, as you will encounter issues with permissions, attributes ext.

IMPORTANT ! Use the rsync command at the terminal within your live session. This can be modified based on your exact requirements. This command essentially duplicates the /home from a hard drive back to the root file system.

sudo rsync -aXS /media/ubuntu/"source UUID"/. /media/ubuntu/"root file system UUID"/home/.

This command essentially duplicates the /home from your root file systema to a stand alone drive.

sudo rsync -aXS /media/ubuntu/"root file system UUID"/home/. /media/ubuntu/"hard drive destination UUID"/.

Edit fstab entry at /etc/fstab within your root file system to reflect the new location.

sudo nano /etc/fstab

No fstab entry is required if /home is in your root filesysem, otherwise correctly point to the drive UUID and mount point /home/ PS - You can copy the fstab entry for the root filesystem as a reference, just change the UUID and mount point to form a /home/ fstab entry.

Rebooted the machine in normal mode. you should be able to log in with your encryption password without issues.

IMPORTANT ! No need to mess with ecryptfs. Main point = ecryptfs does not need any configuring at all. As long as the new home is identical to the old home and the fstab entry points to your new home correctly, that's all that is required.

Using sudo copy does not work for encrypted files. You have to use rsync. Copy the encrypted version of the user home folder with rsync and simply edit fstab to avoid complications.

0

Copy your home directory to other partition and then use System->Administration->Users & Groups to open user settings dialog. Click on the keys icon to authenticate your self

alt text

After that select the user that you want to change and click properties, go to advanced tab

alt text

change the home directory to new directory i.e the directory that you copied to other partition.

binW
  • 13,194