You are not logged in.
Hey,
(forgive me if this is not the right place to post this. It was a tricky one to place.)
I have a really big music collection and some of it I don't even really care about. So I've decided to downsize, however I still want to keep all the music and artists I've amassed.
So my solution was to:
$ mv library .complete
then
$ sudo ln library/artist -t .complete/
That way I'd have the same directory structure under library as in .complete. Expect of course I'd only cherry pick handful of files from .complete to include in library. From there I could easily drop the library directory to an mp3 player or wherever.
But of course, I got the error:
ln: ‘link’: hard link not allowed for directory
Is it possible to do something like this? I know of "mount -bind" and use it quite a bit for sticking stuff in my home directory but I don't want to drop a 50-100 mount commands in my fstab.
If you have any ideas or solutions for what I am trying to accomplish please share. It would be really nice for me to have
Peace!
Offline
We may move this thread. Let's see how it goes.
Is there some reason that a symbolic link will not work? Hard links will work between individual files, not directories. If you have two files that are hard linked, you can delete one or the other without impacting the other files that are linked. Only when the last link is removed is the file actually removed. This does not work for directories (on Linux)
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
A symbolic link should work; just make sure when you're dumping to your mp3 player or whatever that you dereference the symlinks (--dereference with cp or --copy-links with rsync for example)
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
The only reason that a symlink might not work is if the symlink leads to an area that is outside of a chroot'ed service (like sftp for example). But in that case a bind mount would work just fine. I also don't think that this case is actually one of those instances either.
If you are worried about the extra overhead of a billion bind mounts in the fstab, you can give it the 'noauto,x-systemd.automount' mount options so that it isn't actually mounted until first access.
Offline
If soft links don't work for you, just try copying the directory with cp --link so the directories get recreated, but the files not.
I think that I would probably just move the whole folder, and then change ".complete" to ".other", for simplicity.
Offline
Hey,
Sorry I disappeared for awhile. Thanks for your replies. So I guess using hard links on directories isn't feasible unless I hack the linux kernel or something Thats a bit annoying cause the way I originally envisioned makes more logical sense than using symbolic links imo.
I'm still not quite sure how I will do this. One annoying thing about symbolic link is that if I add a link to a artist folder in my library folder when you follow that link you, obviously, change where you are in the filesystem. So "cd .." won't take you back to the library folder but the complete folder. Ahh! Damn you man page for luring me in with the prospect of hard links but then refusing to allow it for directories!
One quick question I want to ask you guys. A trivial problem but driving me insane.
If I type
$ ln -s foo/bar bar
I get a working bar symlink to foo/bar. If I put in a path.
$ ln -s foo/bar new/bar
I still get a file generated called bar in new however it doesn't seem to work. Anybody know what the trick is?
Offline
So "cd .." won't take you back to the library folder but the complete folder.
I am not sure I understand what you meant. But if you are in /home/user and follow the link /home/user/link and do 'cd ..', you will be back in /home/user.
If I put in a path.
$ ln -s foo/bar new/bar
I still get a file generated called bar in new however it doesn't seem to work. Anybody know what the trick is?
I get an error when I try this command. You should first create the 'new' directory, then create the symlink. Or did you try to achieve another result?
Last edited by jpgg (2014-01-29 23:00:10)
Offline
If I type
$ ln -s foo/bar bar
I get a working bar symlink to foo/bar. If I put in a path.
$ ln -s foo/bar new/bar
I still get a file generated called bar in new however it doesn't seem to work. Anybody know what the trick is?
ln -s does not resolve relative locations for you.
Think of it more of an 'echo foo/bar > new/bar'. If you cd new and cat bar it will still say 'foo/bar'. Thus the bar symlink will link to foo/bar which is new/foo/bar.
If you want new/bar to go to ../foo/bar, you have to write it this way.
ln -s ../foo/bar new/bar
One of my favorite symlinks is one that points to the same dir, i.e. .
ln -s . /boot/boot
regardless which directory you are in, /boot/boot links to /boot.
That way you don't get trouble in your grub.cfg when you add a superfluous /boot/ to a file path on the boot partition. A boot partition does not usually have a /boot dir but with the symlink it's there.
Last edited by frostschutz (2014-01-30 09:22:36)
Offline
ln -s does not resolve relative locations for you.
Think of it more of an 'echo foo/bar > new/bar'. If you cd new and cat bar it will still say 'foo/bar'. Thus the bar symlink will link to foo/bar which is new/foo/bar.
If you want new/bar to go to ../foo/bar, you have to write it this way.
Ahh thats makes sense. Good explanation The ln command isn't the most intuitive thing ever devised imo.
I am not sure I understand what you meant. But if you are in /home/user and follow the link /home/user/link and do 'cd ..', you will be back in /home/user.
I mean if I make something like
$ ln -s ~/linux/aur ~/aur
then
$ cd ~
$ cd aur
$ cd ..
that will take me to ~/linux not ~/
Whereas if hard linking was possible on directories I could create two separate paths in the filesystem. eg:
--- linux --- aur
--- home --- user --- {
--- aur
I don't think what I want is possible without learning C then learning how to hack the kernel....
Offline
You might consider dantalian. The developer created it specifically for this purpose--using hard links to organize a large music collection---although you can organize any collection of files. You'd have to be selective about how you used your tags to achieve your specific goal, but I think the idea's the same.
Offline
which shell are you using? I have a ~/www/ symlink that points to /var/www/...
yet cd ~; cd www; cd ..; puts me back in ~, and not ever in /var/www.
Offline
Thanks for the link ANOKNUSA. I'll check it out.
frostschutz, I was using the fish shell. Bash worked fine
Offline