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

Thread: mounting and binding via fstab

  1. #1
    Join Date
    Aug 2007
    Beans
    18

    mounting and binding via fstab

    I have a dual boot setup with Ubuntu 10.10 and Windows 7 on an Asus UL80jt (64-bit).

    I am trying to keep various data directories on a separate partition which can be accessed by both Ubuntu and Windows. This is sda3, labelled as "shared":

    Code:
    % sudo blkid 
    ...
    /dev/sda3: LABEL="shared" UUID="fab4ccb2-3642-4f17-b82f-337201d19d3c" TYPE="ext3"
    ...
    I modified my fstab file to mount this partition, and then to bind (for example) a Music directory on this partition to ~/Music:

    Code:
    % more /etc/fstab 
    ...
    # Mount sda3
    UUID=fab4ccb2-3642-4f17-b82f-337201d19d3c /media/shared ext3 defaults 0 0
    ...
    #Linking /media/shared/Music to ~/Music
    /media/shared/Music /home/fmhoyt/Music none bind 0 0
    This successfully mounts "shared" as /media/shared, but fails to bind /media/shared/Music to ~/Music.

    I get no errors from:

    Code:
    % sudo mount -a
    .

    The following works in a shell:

    Code:
    % sudo mount --bind /media/shared/Music ~/Music
    I would rather have the binding take place as startup (or login). However, a shell script containing this does not work at startup (perhaps because of sudo?).

    I have tried both adding a script containing the command above to Startup Applications, and adding it to /usr/local/bin (without the sudo commands) and calling it in /etc/rc.local. As far as I can tell, neither of these approaches has any effect.

    As such, the only way I can mount /media/shared/Music as ~/Music is by executing a shell command after startup/login.

    One of my goals with this setup is to be able to use UbuntuOne synchronization, which does not work with symlinks.

    Can anyone tell what I am doing wrong?

    Thank you
    Last edited by fmhoyt; December 11th, 2010 at 05:20 AM. Reason: Mentioning use of UbuntuOne

  2. #2
    Join Date
    Nov 2009
    Location
    Madrid, Spain
    Beans
    1,403
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: mounting and binding via fstab

    I recommend to use a symbolic link.

    Simply type these commands:

    Code:
    cd
    mv Music Music.old
    ln -s /media/shared/Music Music
    I have moved the Music dir to a different directory named Music.old. Remove Music.old it if you want.

  3. #3
    Join Date
    Aug 2007
    Beans
    18

    Re: mounting and binding via fstab

    Thank you for the reply!

    I should have mentioned in my initial post that I am trying to use UbuntuOne synchronization with my setup. In other words, I want to be able to synchronize the directories that I'm mounting with my Ubuntuone account.

    UbuntuOne sync apparently does not work with symlinks. So, the solution that Imarmisa suggests will allow me to link my ~/Music with /media/shared/Music, but it won't allow me to use UbuntuOne synce.

    The setup I am trying for has apparently worked for others, such as poster Krippa (see reply #4):

    http://ubuntuforums.org/showthread.p...unt+bind+Music

    So I'm puzzled as to why it isn't working for me.

  4. #4
    Join Date
    Nov 2009
    Location
    Madrid, Spain
    Beans
    1,403
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: mounting and binding via fstab

    Edit the file /etc/rc.local ( sudo gedit /etc/rc.local ) and add this line:

    Code:
    #!/bin/sh -e
    #
    # rc.local
    #
    # This script is executed at the end of each multiuser runlevel.
    # Make sure that the script will "exit 0" on success or any other
    # value on error.
    #
    # In order to enable or disable this script just change the execution
    # bits.
    #
    # By default this script does nothing.
    
    mount --bind /media/shared/Music /home/fmhoyt/Music
    
    exit 0
    Save, exit and reboot your system.

    I hope this solution will work fine (at least it runs ok on my computer).

  5. #5
    Join Date
    Aug 2007
    Beans
    18

    Re: mounting and binding via fstab

    Unfortunately your solution does not work.

    Adding the following to /etc/rc.local has no (apparent) effect:

    Code:
    $ sudo nano /etc/rc.local 
    #!/bin/sh -e
    #
    # rc.local
    #
    # This script is executed at the end of each multiuser runlevel.
    # Make sure that the script will "exit 0" on success or any other
    # value on error.
    #
    # In order to enable or disable this script just change the execution
    # bits.
    #
    # By default this script does nothing.
    
    mount --bind /media/shared/Music /home/fmhoyt/Music
    
    exit 0
    Interestingly, after start up "mount -a" has the following results:

    Code:
    $ sudo mount -av
    ...
    mount: /media/shared/Music already mounted on /home/fmhoyt/Music
    nothing was mounted
    However, none of the contents of /media/shared/Music appear in ~/Music:

    Code:
    $ ls ~/Music
    $
    Once I run:

    Code:
    $ sudo mount --bind /media/shared/Music ~/Music
    Then the contents appear.

    For what it's worth, I have also made sure that ownership of /media/shared is assigned to my username.

    Code:
    $ sudo chown fmhoyt:fmhoyt /media/shared
    Also, I notice that if I place a simple shell command in /etc/rc.local, or place the command in /usr/local/bin and call in in /etc/rc.local (with the appropriate permissions), nothing happens:

    Code:
    $ sudo nano /etc/rc.local 
    #!/bin/sh -e
    #
    # rc.local
    #
    # This script is executed at the end of each multiuser runlevel.
    # Make sure that the script will "exit 0" on success or any other
    # value on error.
    #
    # In order to enable or disable this script just change the execution
    # bits.
    #
    # By default this script does nothing.
    
    echo "My name is Fred" > /home/fmhoyt/Desktop/Fred.txt"
    
    exit 0
    The same command works if I create in my home directory and add it to Startup Applications.

    Still mystified.

  6. #6
    Join Date
    Feb 2009
    Location
    Georgia
    Beans
    87
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: mounting and binding via fstab

    Hope this doesn't make me look dumb *L* but could you now write a script to run at start up to do this for you? Maybe it could run after fstab has run like right after you log on.
    Currently A Command Line Flunkie an a GUI Junkie
    I believe in Jesus Christ

  7. #7
    Join Date
    Aug 2007
    Beans
    18

    Re: mounting and binding via fstab

    Quote Originally Posted by argedion View Post
    Hope this doesn't make me look dumb *L* but could you now write a script to run at start up to do this for you? Maybe it could run after fstab has run like right after you log on.
    Thank you for the reply.

    Like I said above, I wrote the following script:

    Code:
    #!/bin/sh
    mount --bind /media/shared/Music /home/fmhoyt/Music
    I have tried both putting this in my Startup Applications (so that it runs at log-in, after fstab applies), as well as including it in or calling it from /etc/rc.local (which, I believe, runs before fstab?).

    Neither approaches had any effect. The script does, however, work when I run it after login.

  8. #8
    Join Date
    Nov 2009
    Location
    Madrid, Spain
    Beans
    1,403
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: mounting and binding via fstab

    I would like to check if the problem is limited to the directories of your account.

    Please, delete the mount command of the file /etc/rc.local.

    Then type this command

    Code:
    sudo mkdir /media/Music
    and change the line of the file /etc/fstab corresponding to /media/shared/Music:


    Code:
    ...
    #Linking /media/shared/Music to /media/Music
    /media/shared/Music /media/Music none bind 0 0
    Restart your system and type these commands:

    Code:
    cat /etc/ftab
    cat /etc/mtab
    mount
    ls -l /media
    ls -l /media/shared
    ls -l /media/shared/Music
    ls -l /media/Music
    Please, post the outputs of the commands.

    Best regards,

    Luis

  9. #9
    Join Date
    Dec 2009
    Beans
    6,424

    Re: mounting and binding via fstab

    I don't want to contradict anything that lmarmisa has posted because as far I can tell everything posted was textbook correct. But I think the problem is Ubuntu's use of mountall and Upstart. I think that the bind operation is happening before the /media/shared partition is actually mounted.

    One possible way around this was suggested by sisco311 in another post. Create an Upstart job that will bind the subdirectory after mountall has completed its job:

    Create an upstart file:
    Code:
    gksu gedit /etc/init/mount-bind.conf
    With this content:
    Code:
    #
    # bind mounts
    #
    
    description "bind"
    
    start on stopped mountall 
    
    script 
    
       mount --bind /media/shared/Music /home/fmhoyt/Music 
    
    end script
    Last edited by Morbius1; December 12th, 2010 at 03:32 PM.

  10. #10
    Join Date
    May 2010
    Location
    uk
    Beans
    9,299
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: mounting and binding via fstab

    Hi

    This is, i expect, a silly, silly question but you rc.local file is executable?

    sudo chmod 755 /etc/rc.local

    Kind regards
    If you believe everything you read, you better not read. ~ Japanese Proverb

    If you don't read the newspaper, you're uninformed. If you read the newspaper, you're mis-informed. - Mark Twain

    Thinking about becoming an Ubuntu Member?

Page 1 of 2 12 LastLast

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
  •