Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: hard-linking /data folders to /home with fstab

  1. #1
    Join Date
    May 2009
    Location
    Canada
    Beans
    868
    Distro
    Ubuntu Development Release

    hard-linking /data folders to /home with fstab

    So initially I had / on my SSD and /home on my HDD. I just did a clean install of Oneiric but put my entire filesystem including /home on my SSD and instead had my old /home folder mounted at /media/data. I'm now trying to hard-link the two so that whenever I refer to any of my folders in /home it automatically looks in my /media/data folders seamlessly as if they were the same folder. What I did was put the folders into the correct place and then changed the entire /media/data folder owner to my user. Then I added this to the end of /etc/fstab via gksu gedit /etc/fstab:

    Code:
    LABEL=Data  /media/data  ext4  defaults  0  0
    /media/data/Documents  /home/andrew/Documents  none  bind  0  0
    /media/data/Downloads  /home/andrew/Downloads  none  bind  0  0
    /media/data/Music  /home/andrew/Music  none  bind  0  0
    /media/data/Pictures  /home/andrew/Pictures  none  bind  0  0
    /media/data/Videos  /home/andrew/Videos  none  bind  0  0
    /media/data/Public  /home/andrew/Public  none  bind  0  0
    After I restart it fails to mount the partition so I press "S" to skip and when I log in and try to mount it manually it basically says I can't because it belongs to root. I then remove what I had added to the end of fstab and restart and it boots again and mounts fine (though not hardlinked). Anyone have any clue what may be the problem?
    Intel Core i7 970 6/12 (Cores/Threads) 3.2GHz 12MB Cache
    6GB DDR3
    1866MHz RAM | ATI Radeon HD 5770 1GB GDDR5
    60GB SSD
    (/) | 1TB 64MB Cache HDD (/home)
    Ubuntu Oneiric
    Ocelot 11.10 x64

  2. #2
    Join Date
    May 2009
    Location
    Canada
    Beans
    868
    Distro
    Ubuntu Development Release

    Re: hard-linking /data folders to /home with fstab

    From a bit of reading, apparently you can't create hard-links between different file systems (and often not even with directories). Though, what I'm trying to do isn't actually a hard-link. I'm actually trying to mount each folder in a different location. Which should be possible even from different hard drives, but I'm not sure. Anyways, in the mean time I've created symbolic links to all the folders.
    Intel Core i7 970 6/12 (Cores/Threads) 3.2GHz 12MB Cache
    6GB DDR3
    1866MHz RAM | ATI Radeon HD 5770 1GB GDDR5
    60GB SSD
    (/) | 1TB 64MB Cache HDD (/home)
    Ubuntu Oneiric
    Ocelot 11.10 x64

  3. #3
    Join Date
    Jan 2008
    Location
    Manchester UK
    Beans
    13,573
    Distro
    Ubuntu

    Re: hard-linking /data folders to /home with fstab

    Basic checks first.

    1. The drive is labled Data and is formatted ext4

    2. The directory /media/data exists. The automount feature will create the directory /media/DATA when you plug it in. If you mount it with fstab the directory has to exist already.

    3. You own the drive.

    4. The directories in your /home/$USER exist and are empty.

    I have no idea if ssds effect any of this because I have never used one.

  4. #4
    Join Date
    May 2009
    Location
    Canada
    Beans
    868
    Distro
    Ubuntu Development Release

    Re: hard-linking /data folders to /home with fstab

    Quote Originally Posted by nothingspecial View Post
    Basic checks first.

    1. The drive is labled Data and is formatted ext4
    I just copied what you had in your fstab and changes the folders to mine. I didn't distinctly label a drive Data or made any changes.


    Quote Originally Posted by nothingspecial View Post
    2. The directory /media/data exists. The automount feature will create the directory /media/DATA when you plug it in. If you mount it with fstab the directory has to exist already.
    The folder already exists with all the sub folders I wanted mounted within /home

    Quote Originally Posted by nothingspecial View Post
    3. You own the drive.
    I right clicked /media and changed it's owner to my user along with all enclosed files and folders. If I right click /media/data it says my user owns it. Is that what you mean?

    Quote Originally Posted by nothingspecial View Post
    4. The directories in your /home/$USER exist and are empty.

    I have no idea if ssds effect any of this because I have never used one.
    They do exist and are empty, though currently they are actually just folders with a symbolic link to the folders in /media/data but that can easily be reverted.
    Intel Core i7 970 6/12 (Cores/Threads) 3.2GHz 12MB Cache
    6GB DDR3
    1866MHz RAM | ATI Radeon HD 5770 1GB GDDR5
    60GB SSD
    (/) | 1TB 64MB Cache HDD (/home)
    Ubuntu Oneiric
    Ocelot 11.10 x64

  5. #5
    Join Date
    Jun 2009
    Location
    SW Forida
    Beans
    Hidden!
    Distro
    Kubuntu

    Re: hard-linking /data folders to /home with fstab

    I just use soft links and only mount the data partition in /mnt/data.

    But bind is supposedly a better way. Your SSD may mount too fast for HDD to mount with the bind. Then you may want an upstart script.

    Another way to share:
    HowTo: Create shared directory for local users (with bindfs).
    http://ubuntuforums.org/showthread.php?t=1460472
    With upstart script
    http://ubuntuforums.org/showthread.php?t=1771773&page=5
    kansasnoob's sharing and Morbius1 use of bindfs
    http://ubuntuforums.org/showthread.php?t=1495798
    UEFI boot install & repair info - Regularly Updated :
    https://ubuntuforums.org/showthread.php?t=2147295
    Please use Thread Tools above first post to change to [Solved] when/if answered completely.

  6. #6
    Join Date
    Dec 2009
    Beans
    6,776

    Re: hard-linking /data folders to /home with fstab

    @oldfred, thanks for the plug but I think bindfs is going to have the same problem as a normal bind in fstab. I thinks it's a timing issue. I would go with the upstart idea:

    [1] Create an upstart script named "home-mounts.conf"
    Code:
      gksu gedit /etc/init/home-mounts.conf
    [2] The content of that file would look something like this:
    Code:
    # Remount partitions with bind
    #
    description "Bind Data Subdirectories to Andres' Home Directory"
    
    start on stopped mountall
    
    script
    mount --bind /media/data/Documents  /home/andrew/Documents
    mount --bind /media/data/Downloads  /home/andrew/Downloads
    mount --bind /media/data/Music  /home/andrew/Music
    mount --bind /media/data/Pictures  /home/andrew/Pictures
    mount --bind /media/data/Videos  /home/andrew/Videos
    mount --bind /media/data/Public  /home/andrew/Public
    end script
    It's the "start on stopped mountall" that does the trick since it won't run the script until everything in fstab ( i.e., /media/data ) is mounted first.

  7. #7
    Join Date
    Jan 2008
    Location
    Manchester UK
    Beans
    13,573
    Distro
    Ubuntu

    Re: hard-linking /data folders to /home with fstab

    Quote Originally Posted by akand074 View Post
    I didn't distinctly label a drive Data or made any changes.
    While I bow to the vastly superior knowledge of oldfred and Morbius1.....

    if your drive is not labeled Data the whole thing will fail.

  8. #8
    Join Date
    May 2009
    Location
    Canada
    Beans
    868
    Distro
    Ubuntu Development Release

    Re: hard-linking /data folders to /home with fstab

    Quote Originally Posted by nothingspecial View Post
    While I bow to the vastly superior knowledge of oldfred and Morbius1.....

    if your drive is not labeled Data the whole thing will fail.
    I see. I'm going to give Morbius1's route a go a little later perhaps. Thanks for the help!

    Yeah when I first got my SSD I had a lot of problems where the OS was loading faster than the config files in /home and would thus load with an odd look. It also used to hang a bit on boot. With oneiric now having /home on the SSD I've had no problems and my boot time dropped significantly. Under 15 seconds now it seems.

    Anyways, I'll give that script a go. Worst case, the soft links do the job fine, I would though preferably like to not have the HDD show up in devices and be able unmount it (might eject it by accident) but it's not the end of the world.
    Intel Core i7 970 6/12 (Cores/Threads) 3.2GHz 12MB Cache
    6GB DDR3
    1866MHz RAM | ATI Radeon HD 5770 1GB GDDR5
    60GB SSD
    (/) | 1TB 64MB Cache HDD (/home)
    Ubuntu Oneiric
    Ocelot 11.10 x64

  9. #9
    Join Date
    Feb 2005
    Location
    Melbourne, Australia
    Beans
    13,510
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: hard-linking /data folders to /home with fstab

    Quote Originally Posted by oldfred View Post
    I just use soft links and only mount the data partition in /mnt/data.

    But bind is supposedly a better way.
    .......
    A matter of opinion, apparently:

    http://www.fedoraforum.org/forum/sho...d.php?t=150277

    And this is worth a peruse:

    http://aplawrence.com/Linux/mount_bind.html
    Last edited by dcstar; October 25th, 2011 at 11:40 AM.
    Regards, David.
    Please use the Forum search and Wiki search for immediate help
    Please mark your thread as Solved when appropriate
    New to technical forums?: How To Ask Questions The Smart Way

  10. #10
    Join Date
    Dec 2009
    Beans
    6,776

    Re: hard-linking /data folders to /home with fstab

    Quote Originally Posted by nothingspecial View Post
    While I bow to the vastly superior knowledge of oldfred and Morbius1.....

    if your drive is not labeled Data the whole thing will fail.
    I missed that in this thread. So much for "vastly superior knowledge"

    You can get around this problem by not using LABEL in fstab but do it by UUID. So instead of this:
    LABEL=Data /media/data ext4 defaults 0 0
    It becomes this:
    UUID=e92eaf02-ff61-4db0-9397-35f1aadb98e8 /media/data ext4 defaults 0 0
    TO find the correct UUID for you partition run the following command:
    Code:
    sudo blkid -c /dev/null

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •