Ubuntu for Windows Users: How Do I Reuse My Home Directory? (Updated)
[Updated 4 August 2013]
Perhaps the hardest part of setting up Ubuntu on a system that has Windows on it is setting it up to share your documents, music and other files easily, not only locally but across the network. Yes, you can simply mount the drive and navigate around if it’s on a local partition, but doesn’t it make more sense that Pictures should point to the same Pictures folder no matter the operating system?
Ubuntu has changed how it has done things, and so the instructions for doing this in 13.04 are about as clear as mud. In addition, if you want to share out an NTFS mount coming or going, you’ll need not only Samba but cifs. Even more frustrating is the fact that this too has changed and is an even darker color of mud.
I recommend you get these things working before installing apps and such.
First, assuming that you will want to mount a Samba share, I finally found some instructions that worked on Help Ubuntu in the article “Samba/SambaClientGuide“. I recommend going through the manual steps to ensure it all works correctly before adding it to fstab.
You will need a working cifs setup, which can be checked via the commandline “mount.cifs -V”. It was not initially installed on my machine (cannot figure that one out), so that caused a great deal of grief sorting out. Add the cifs package, and things should smooth out afterwards:
sudo apt-get install cifs-utils
Permissions are always a tricky issue, but even more so when mounting an NTFS drive in another operating system. The fstab command that finally seemed to work was:
//<MyOtherPC>/<ShareName> /mnt/<MountName> cifs credentials=/etc/samba/.smbcredentials,iocharset=utf8,defaults,uid=1000 0 0
where <MyOtherPC> is the remote computer name, <ShareName> is the NTFS share name, and <MountName> is the local directory you created to mount it into (via “sudo mkdir /mnt/<MountName>”).
Note that this is not a secure setup! It assumes that only you will have access to the machine in question.
The Samba package will allow Samba shares in and out. You might run into a problem with Windows 7 that a mount error (12) on the Ubuntu machine occurs complaining it cannot allocate memory. It actually is a Windows 7 problem that can be fixed in the registry. Open a command prompt using Run as Administrator, and do:
reg add “HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management” /v “LargeSystemCache” /t REG_DWORD /d 1 /f
reg add “SYSTEM\CurrentControlSet\services\LanmanServer\Parameters” /v “Size” /t REG_DWORD /d 3 /f
Next, mount the NTFS partition you want to use for mapping your documents. Ask Ubuntu has an article “How do I correctly mount a NTFS partition in /etc/fstab?” on mounting an NTFS partition in fstab.
Again, it took me quite a bit of experimentation, but here is what I finally seemingly got to work after creating the /mnt/windows directory (again, “sudo mkdir /mnt/windows”):
/dev/sda3 /mnt/windows ntfs-3g exec,permissions,auto 0 0
Notice that I mounted the entire partition, which will allow me to access not only my own documents but those in the Public folder as well.
Before performing the next portion, you should create an alternate admin user to login and perform these steps. This will ensure there are no problems during it as well as ensuring you have a way to login in case of catastrophe! Go to your System Settings and double-click on User Accounts, click on the lock in the upper right-hand corner to unlock then click on the ‘+’ at the bottom to add the user. Be sure to set Account Type to Administrator!
Now, you could map to your entire NTFS home directory (using the above example, it would be /mnt/windows/Users/<Windows username>), but I advise against that. Your permissions will be severely messed up. Instead, and it can still cause issues in Windows, make symbolic links to Documents, Music, etc. You’ll have to delete (be sure you know nothing of consequence is there!) the current directories and create symbolic links, so make sure nothing of consequence is in these directories before removing them. Make sure you are already in your home directory (your real one, not the one you created for this task) in a terminal session and type:
sudo rm -rf Documents
sudo ln -s /mnt/windows/Users/<Windows username>/Documents
You can do the same for Downloads, Music, Pictures and Videos. I even did it with the Desktop, VirtualBox VMs and Dropbox directories.
Afterwards, you might have to go up to the home directory and be sure the permissions are correct:
sudo chown -hR <username>:<group> <Ubuntu username>
NOTE: In Ubuntu, your username and group are usually the same. If you run “touch test.txt” in your home directory, then run “ls -l test.txt” to see the user and default group.
In theory, that should suffice. However, when you return to Windows, you will probably have to play with permissions still. The worst headache seems to be iTunes, for whatever reason. I finally just moved my iTunes library onto another computer, as it got tiring.