Results 1 to 7 of 7

Thread: creating symbolic links to files on usb drives

  1. #1
    Join Date
    Apr 2012
    Beans
    23

    creating symbolic links to files on usb drives

    Hey
    I got an ubuntu server set up, which automounts a couple of external usb harddrives.

    Now I wanna make a folder which links every file from certain folders on the usb drives to that special folder, is that possible?

    I tryed doing a "sudo ln -s /media/usb0/photos/*" and I typed that when I was in the folder where I wanted the links, but it told could not create symbolic link, the file exists? (translated error msg from danish to english)

    Thanks

  2. #2
    Join Date
    Apr 2011
    Location
    Maryland
    Beans
    1,461
    Distro
    Kubuntu 12.04 Precise Pangolin

    Re: creating symbolic links to files on usb drives

    The correct syntax for 'ln' is ln -s TARGET LINK_NAME where TARGET is the location you want the link to point to, and the LINK_NAME is the name of the link you want. I don't believe that you can glob that (i.e. use *). But, if you want to create a symbolic link to that photos directory from (let's say) your home directory:

    Code:
    ln -s /media/usb0/photos/ /home/<username>/PhotosOnUSB0
    That will create a link in your home folder (substitute <username> with your actual username!) that's called "PhotosOnUSB0" that points to the photos folder on usb0.

    Hope that helps!

  3. #3
    Join Date
    Apr 2012
    Beans
    23

    Re: creating symbolic links to files on usb drives

    It helps a little

    What I want to do is that i have these usb drives connected with a photos folder on both of them, I want them somehow merged into one folder, without moving the files into the same harddrives or anything, so I can browse trough them all without changing folders, like a fake folder or something with all the photos from both harddrives in it. Is that even possible?

    Thanks

  4. #4
    Join Date
    Apr 2011
    Location
    Maryland
    Beans
    1,461
    Distro
    Kubuntu 12.04 Precise Pangolin

    Re: creating symbolic links to files on usb drives

    Hmmmm...I'm not sure how you can point to two locations with one link. I don't think it's possible.

  5. #5
    Join Date
    Apr 2012
    Beans
    23

    Re: creating symbolic links to files on usb drives

    Crap... thanks for your time though, and ill be happy to listen if you or anyone else can figure out how it can be done

  6. #6
    Join Date
    Oct 2012
    Location
    Catalunya
    Beans
    Hidden!
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: creating symbolic links to files on usb drives

    You could create a symbolic link for each file on both drivers you want to link, but it's so... tedious. You can't create a symbolic link pointing to two different places, that'd be like if you made a shortcut on your desktop pointing to ~/Images and ~/Documents!
    So I recommend you creating a folder and then just two subfolders:
    Code:
    $ mkdir ~/usbhub
    $ ln -s /media/usb0/photos/ ~/usbhub/usb1
    $ ln -s /media/usb1/photos/ ~/usbhub/usb2
    Just in example.

  7. #7
    Join Date
    Oct 2008
    Location
    Ottawa, Canada
    Beans
    809
    Distro
    Xubuntu 16.04 Xenial Xerus

    Re: creating symbolic links to files on usb drives

    You can create a merged view of folders with UnionFS or Aufs. Both can be awfully complicated to setup and I have no experience with them, but in theory it should work.

    Aufs needs package aufs-tools

    Syntax:
    Code:
    sudo mount -t aufs -o br:/dir1:/dir2 none /mergedir
    Two useful links:
    Forum thread
    Aufs man page

    Cheers!
    husband@wife$ make sandwich
    Permission denied
    husband@wife$ sudo make sandwich

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
  •