Problem solved. I didn't want to mess about with my OSX login, since this is the active login at the moment until I migrate to Ubuntu. So all changes had to be on the Ubuntu side. This is how I solved my problem, but first my situation. Change values for your own situation.
My Ubuntu account is newly created and contains no personal data. My account is james and my home directory is /home/james
. My OSX account, Users/james contains all my data, music, movies, what have you. It is contained on a separate USB disk under a partition called Spare with four top directories, of which one is Users, and contains my home directory, Users/james.
In Ubuntu:
- Create a new account, in my case, hacker. Don't forget to give hacker a password
Log out and log in again as hacker. When logged in, type:
sudo su -
You will now be logged in as root. To save having to do this again you can now type:
passwd
and give root a password. In future you can get to the root account with a simple
su -
and provide the root password.
As root unmount the mount containing your OSX Users directory. You should find this under /media/hacker/(userdisk) where (userdisk) is the location containing Users. I suggest remounting it as, say, /media/Users with this command, so that it will always be in the same place (it moves around depending on the account you logged in with):
mount -t hfsplus -o rw,uid=99,gid=99 /dev/(userdisk) /media/(userdisk)
The uid and gid values are chosen because these are the values an OSX home directory shows when mounted in Ubuntu. I'll try and make these values permanent further down this article.
You now have a number of choices: you can replace your /home/james directory with your OSX Users/james directory; you can mount some or all of your Users/james subdirectories under your Ubuntu /home/james directory; you can leave everything as is and go hunting for the Users/james directory under /media when you need something from there. I'm going to opt for the first choice. As root do the following:
cd /home
mv james james.org
ln -s /media/(userdisk)/Users/james
If you do a directory listing you will now see two entries under /home: /home/james.org and /home/james, of which the latter is a symlink.
Now exit from the root account, logout from hacker and log in again as james. Bingo! Your home directory contains all your OSX files and directories. Type
touch test
to see whether you can write files, then
rm test
to get rid of it again.
Now let's make this permanent so you won't have to begin each session by remounting the disk with the Users directory.
Under Ubuntu open a terminal window and type
blkid /dev/(userdisk)
You will get a reply which begins with a UUID for the disk, something like this:
UUID="a3063a2b-331d-3389-9f0a-49093af68ea9" and then some other stuff
Copy the line from UUID to ...ea9" (or whatever appears in your case) to a text document and remove the two speech marks, ", so that it looks like this:
UUID=a3063a2b-331d-3389-9f0a-49093af68ea9
then add the following parameters and copy this whole line into /etc/fstab:
UUID=a3063a2b-331d-3389-9f0a-49093af68ea9 /media/<diskname> hfsplus rw,uid=99,gid=99 0 1
This is basically the same as the command you entered manually earlier, but has the advantage that the UUID is fixed to the disk. I have seen signs that disks may change their /dev/xxx
notation between boots. Mine showed up as /dev/sdc2
after one boot, and /dev/sdb2
after another.
Okay, I've apparently made it work as I want in my instance. Now I'm going to test it a bit before signing off on it. I have had a little trouble locating files I have created in one OS when I have booted into the other. I'll get back after a little testing.
root
only! You are not meant to replaceroot
with your own account. And UIDs smaller than 1000 are invisible users by default, as those UIDs are mainly used by system or application daemon users. Unless you change the configuration of your login screen etc, those will not appear as human accounts. Why would you want the UIDs like that anyway? Please rethink your plans. – Byte Commander Aug 12 '16 at 19:50