1

I've installed Ubuntu 16 on a SSD and want to get my Homefolder be written to an other Disk ( /media/USER/DISK/folder/NEWHOMEFODLER).

My question is how to archieve it :). I can't use bind (?), because this doesn't works with folders, only partitions, and as I tried ln Linux created a link NEXT to my home folder, so I'm a bit out of ideas :)

hope for help, thanks :)

KuSpa
  • 125
  • Not sure if you've seen this: http://askubuntu.com/questions/5484/how-can-i-move-my-home-directory-to-another-partition-if-its-already-part-of-t – Erik Feb 24 '17 at 22:33
  • I don't think that this is similar to my problem, because it's about mounting and I can't use mount since NEWHOMEFOLDER is not a block device – KuSpa Feb 24 '17 at 22:44

1 Answers1

2

If you have freshly installed system, maybe the easiest way is to install it again and on partitioning you can choose to create /home partition on other disk and that is basically all you need.

It is not too much to modify working system too. In Linux definition of usage of disks is in config file /etc/fstab. Every non-comment line there defines how to mount particular filesystem. On your case I suppose you have there something like:

# / was on /dev/sda1 during installation
UUID=ae6abc58-956d-4a4f-9a07-6aa5ab02eb56 /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda2 during installation
UUID=6fc82ee1-de18-447b-ac59-443a12c0eabd none            swap    sw              0       0

Now you need know what is UUID of the partition you want to use as home-part. For that you may use this command:

$ lsblk -f

This command lists all available filesystems and their UUID-s, also filesystem types. All following assumes your new home-partition uses ext4 filesytem and it is umounted.

Now you could add entry to /etc/fstab (to edit this file you need root-permissions, use your preferred editor, for example sudo nano /etc/fstab):

UUID=[uuid-you-found-in-previous-step] /home2           ext4    defaults        0       2

After creating mounting point with

$ sudo mkdir /home2

you can mount with

$ sudo mount -a

Next problem: you already have directories inside /home-directory. You can't use /home directory as mounting point, if this directory contains anything. That's why you can't move your home-directories with one step. For next steps is strongly suggested to log out from grahpical session and to use text console in. You need:

  1. move all files from /home to /home2 (mv /home/* /home2/)
  2. change mounting point in /etc/fstab: home2 -> home
  3. reboot

EDIT. Using NTFS-filesystem as /home will not work. But you can link symbollically from NTFS-tree into your home directory. You may make just one robust link like :

$ ln -s /media/USER/DISK/folder /home/myuser/winfolder

But you may refine it like:

$ ln -s "/media/USER/DISK/folder/My music" /home/myuser/Music
$ ln -s "/media/USER/DISK/folder/My documents" /home/myuser/Documents
$ ln -s /media/USER/DISK/folder/Downloads /home/myuser/Downloads

etc

Last examples assume you remove those directories (Music etc) before linking.

wk.
  • 600
  • is there a possibility to use ntfs on the other disk? My visionn is to have the same Userdata for Linux and Windows (Dualboot) – KuSpa Feb 24 '17 at 22:59
  • I update my answer accordingly. – wk. Feb 24 '17 at 23:05
  • I just found out about mount --bind shouldn't this do the same? As far as I understood, it does the same. – KuSpa Feb 24 '17 at 23:20
  • mount is system-space tool and you could use mount many ways to solve your problem. If this disk is not removable, you could mount it directly into suitable place in home-dir (using directive in /etc/fstab ). I would prefer fstab and link, because linking works fine in user-space. You would not need any sudo-s. – wk. Feb 25 '17 at 00:02
  • I have a very similar config. I have a mounted partition at /myfiles (using fstab), and have replaced the directories in /home/me with simlinks to the actual directories in /myfiles. To me the small advantage is that I don't have to worry about old config files if I upgrade or install a new distro. Everything gets removed and that's fine for me. – Samuel Feb 25 '17 at 06:27