Page 1 of 3 123 LastLast
Results 1 to 10 of 27

Thread: Script cannot access external HDD (ntfs)

  1. #1
    Join Date
    Oct 2009
    Beans
    49

    Question Script cannot access external HDD (ntfs)

    Hi all,

    I have been trying to setup up a script that copies files/folders to an external hdd when a torrent is finished in Transmission. I did not succeed and I therefore made this dummy/debug script.

    Code:
    #!/bin/bash
    echo test > /home/xbmc/Complete/test.txt
    This works perfect. The script is correctly triggered, and the test.txt file is created in the specified folder on the internal hdd.

    When I modify the script such that the target folder is on the external hdd, the test.txt file is NOT created.

    Code:
    #!/bin/bash
    echo test > /media/xbmc/MedieHD/Complete/test.txt
    If the user "xbmc" executes the script, the test.txt file is created as expected. Based on this, I thought it was the folder permissions that were set incorrect. But the output of
    Code:
    ls -l
    for the two folders are almost the same, at least the permission and owner part:

    /home/xbmc/
    Code:
    drwxrwxr-x  6 xbmc debian-transmission     4096 Dec 31 12:15 Complete
    /media/xbmc/MedieHD/
    Code:
    drwxrwxr-x 1 xbmc debian-transmission  4096 Dec 31 06:44 Complete
    The external hdd mount command in /etc/fstab is:
    Code:
    UUID=8030C79D30C79914   /media/xbmc/MedieHD     ntfs-3g defaults,uid=1000,gid=117,umask=002 0 0
    Where the uid and gid are determined from
    Code:
    id xbmc
    uid=1000(xbmc)
    and
    Code:
    id debian-transmission
    gid=117(debian-transmission)
    Based on all the above, my conclusion is that I have set the correct ownership and permission. But why is it STILL not working? Is it really because the target is an external hdd and has some "inbuilt" limitations?! Or is the user of the script (when executed upon torrent finish) not "debian-transmission" when accessing the external hdd. But all this is just speculations and way beyond my Ubuntu knowledge, unfortunately.

    It has been driving me insane for the last 2 days... And it is the only thing I am missing from having the perfect HTPC setup. Hope you can help me out!

    Bonus info:
    OS: XBMCbuntu 12.00RC2
    HW: Asrock ION 330
    Transmission 2.74

    Thanks in advance,
    Kjeldgaard

  2. #2
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: Script cannot access external HDD (ntfs)

    I think that it is a problem with permissions. Maybe you are running the script as another user. Try to insert the following line into the script
    Code:
    whoami>/tmp/user
    and check afterwards with the following command
    Code:
    cat /tmp/user
    and you will find out.

    Maybe you can change how you mount the external drive so that everybody gets write access, now only user and group have write access but not others.

  3. #3
    Join Date
    Oct 2009
    Beans
    49

    Re: Script cannot access external HDD (ntfs)

    Hi sudodus.

    Thank you very much for your suggestions!

    I inserted
    Code:
    whoami > /tmp/user
    in the script and the output for both versions (internal and external hdd target) was:
    Code:
    debian-transmission
    At least that make sense. And again running the
    Code:
    ls -l
    for folder /media/xbmc/MedieHD/Complete gives:
    Code:
    drwxrwxr-x 1 xbmc debian-transmission  4096 Dec 31 06:44 Complete
    which as I understand is correct, so that does still not make sense to me.

    I have just given everybody writing right, rebooting now, and I'll be back with the result in 5 minutes.

    One more thing, what is the difference of 'ntfs' and 'ntfs-3g' in the /etc/fstab?

    Thanks,
    Kjeldgaard

  4. #4
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: Script cannot access external HDD (ntfs)

    Quote Originally Posted by Kjeldgaard View Post
    ...
    One more thing, what is the difference of 'ntfs' and 'ntfs-3g' in the /etc/fstab?
    I guess in the beginning it meant using different drivers for the NTFS file system. The 3g version allowed writing too. But I think that in some systems today ntfs is an alias for ntfs-3d if that driver is installed, and you will be able to write by default.

    Anyway it is should be OK to have ntfs-3g in /etc/fstab.

    Good luck

  5. #5
    Join Date
    Oct 2009
    Beans
    49

    Re: Script cannot access external HDD (ntfs)

    Ok, I just changed the /etc/fstab such that everybody has writing permissions in /etc/fstab.

    Code:
    UUID=8030C79D30C79914   /media/xbmc/MedieHD     ntfs-3g defaults,uid=1000,gid=117,umask=000 0 0
    And confirming the change with
    Code:
    drwxrwxrwx 1 xbmc debian-transmission  4096 Dec 31 13:35 Complete
    But the script is still not able to create the test.txt file!

    Again, to check that I didn't make a typo, I executed the script from a terminal, and the test.txt file was created. And in the /tmp/user was written xbmc, just as expected.

    So I am still VERY confused!

    Cheers,
    Kjeldgaard

  6. #6
    Join Date
    May 2006
    Location
    Boston
    Beans
    1,918
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Script cannot access external HDD (ntfs)

    can you pleas post the output of the command
    Code:
    touch /media/xbmc/MedieHD/test
    ls -al /media/xbmc/MedieHD/test

    blog
    Donations BTC : 12FwoB7uAM5FnweykpR1AEEDVFaTLTYFkS
    DOUBLEPLUSGOOD!!

  7. #7
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: Script cannot access external HDD (ntfs)

    try to cd to the directory on the external drive

    Code:
    cd /media/xbmc/MedieHD/Complete
    and
    Code:
    echo test>test.txt
    This would eliminate some risk typing errors.

    Or try copying some file with the cp command or the file browser! Will it work?
    Last edited by sudodus; December 31st, 2012 at 02:05 PM. Reason: I mean copy interactively, not from any script

  8. #8
    Join Date
    Oct 2009
    Beans
    49

    Re: Script cannot access external HDD (ntfs)

    Quote Originally Posted by fdrake View Post
    can you pleas post the output of the command
    Code:
    touch /media/xbmc/MedieHD/test
    ls -al /media/xbmc/MedieHD/test
    Code:
    touch /media/xbmc/MedieHD/test
    does not give any output.

    Code:
    ls -al /media/xbmc/MedieHD/test
    outputs
    Code:
    -rwxrwxrwx 1 xbmc debian-transmission 0 Dec 31 14:03 /media/xbmc/MedieHD/test

  9. #9
    Join Date
    Oct 2009
    Beans
    49

    Re: Script cannot access external HDD (ntfs)

    Quote Originally Posted by sudodus View Post
    try to cd to the directory on the external drive

    Code:
    cd /media/xbmc/MedieHD/Complete
    and
    Code:
    echo test>test.txt
    This would eliminate some risk typing errors.

    Or try copying some file with the cp command or the file browser! Will it work?
    This works fine, a test.txt is created. Basically, I can copy files back and forth (internal and external) in file managers and in the terminal. It is only when the dummy script is triggered by transmission daemon that the access to the external hdd is "lost".

    I starting to think if it is a Transmission problem...

  10. #10
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: Script cannot access external HDD (ntfs)

    Quote Originally Posted by Kjeldgaard View Post
    This works fine, a test.txt is created. Basically, I can copy files back and forth (internal and external) in file managers and in the terminal. It is only when the dummy script is triggered by transmission daemon that the access to the external hdd is "lost".

    I starting to think if it is a Transmission problem...
    When you run the script triggered by transmission daemon, what is the user (as shown by whoami>/tmp/user)?

Page 1 of 3 123 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
  •