166b0
![]() |
|
|
|
|
|||||||
| General General questions about the FreeBSD operating system. Ask here if your question does not fit elsewhere. |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
I was following this thread to mount ntfs-3g at boot time. The solution involves creating a symlink from ntfs-3g to mount_ntfs which I'm not familiar with.
I'm on FreeBSD 7.1-RELEASE. I'll describe what i did to my system. I tried creating a symlink by putting Code:
ln -s /sbin/mount_ntfs /usr/local/bin/ntfs-3g Code:
ln: /usr/local/bin/ntfs-3g: File exists I read the ln man page some more and tried: Code:
ln -sf /sbin/mount_ntfs /usr/local/bin/ntfs-3g Code:
ln -sf /usr/local/bin/ntfs-3g /sbin/mount_ntfs I issued the following to check the symlink. I got: Code:
file /sbin/mount_ntfs /sbin/mount_ntfs: broken symbolic link to `/usr/local/bin/ntfs-3g' Code:
file /usr/local/bin/ntfs-3g /usr/local/bin/ntfs-3g: broken symbolic link to `/sbin/mount_ntfs' Code:
unlink /sbin/mount_ntfs ![]() Figuring that until I find a way to replace the deleted /sbin/mount_ntfs, I should just remove the broken symlink of /usr/local/bin/ntfs-3g from /sbin/mount_ntfs at this time. I made a backup this time with: Code:
cp -RP /usr/local/bin/ntfs-3g /usr/local/bin/ntfs-3g_bak After issuing: Code:
rm /usr/local/bin/ntfs-3g That was what happened. Please teach me how to safely remove symlinks between 2 binary files without removing the file itself and how to replace /sbin/mount_ntfs that I've deleted. Last edited by tekkon; August 22nd, 2009 at 23:54. Reason: [code] |
|
#2
|
||||
|
||||
|
1. Do not use `-f` flag unless you need to FORCE action. That why you overwrited ur real binary..
2. If you do `ln -s /usr/local/bin/ntfs-3g /sbin/mount_ntfs` one time, this will create symlink "/sbin/mount_ntfs" pointing to your binary. It is *no need* to do it every boot. (If your /sbin/ is not a ramdisk lol)) 3. Do not put any stuff to /etc/rc.local or /etc/rc.d or /etc anyway =) Its not linux, user startup scripts must live in /usr/local/etc/rc.d/ 4. If you do `rm /sbin/mount_ntfs` it will remove object "/sbin/mount_ntfs" - no matter symlink or file. Real file not affected. (Caution if you symlink a directory and then `rm -rf` it can destroy real files) |
| The Following User Says Thank You to Alt For This Useful Post: | ||
tekkon (August 21st, 2009) | ||
|
#3
|
|||
|
|||
|
Thank you for your advices.
I used -f with ln because using -s only returned the error: 'ln: /usr/local/bin/ntfs-3g: File exists' As symlinks are created one time, how do I get a list of the symlinks created besides having to check the individual linked files? Since I had symlinked one binary to another, removing the symlink will remove the symlink will remove the linking binary too. Is there a way to remove the symlink only without touching the binary? |
|
#4
|
||||
|
||||
|
Quote:
Quote:
Read part 4 above =) |
|
#5
|
|||
|
|||
|
I've put a working example of symlink creation in /etc/motd (along
with other commands) so that I can grep the proper usage instantly... (Sorry to not answer the question(s)...) (ignoring the post immediately above, it was posted as I wrote) |
|
#6
|
|||
|
|||
|
Alt:
Okay, I think I learn something new about symlinks. A symlinks is an object and cannot exist together with another object of the same name along the same path. Since I had already issued 'ln -sf' on both '/sbin/mount_ntfs' and '/usr/local/bin/ntfs-3g' as targets, that means both mount_ntfs and ntfs-3g now is a symlink instead of the original binary. I think reinstalling ntfs-3g can get the ntfs-3g binary back but how do I restore mount_ntfs ? From what I had seen, the correct way to symlink the source 'ntfs-3g' to target 'mount_ntfs' is to issue: Code:
mv /sbin/mount_ntfs /sbin/mount_ntfs.bak Code:
ln -s /usr/local/bin/ntfs-3g /sbin/mount_ntfs I thought the system had a list somewhere keeping track of all the symlinks that exist throughout the system. jb_fvwm2: Thanks for the good tip. Last edited by tekkon; August 22nd, 2009 at 23:59. Reason: [code] |
|
#7
|
||||
|
||||
|
The argument order for ln is the same as for cp or for mv. In other words, you link from an existing file to the name of the link.
The correct ln command is # ln -s /usr/local/bin/ntfs-3g /usr/bin/mount_ntfs.To remove a symlink is as simple as removing a file, just rm it: # rm /usr/bin/mount_ntfs After all, a symlink is just a file.What happened, in your case, is that you wrote the arguments backwards. And it gave an error. Which you then ignored, and forced the link from a non-existent file overtop of an existing file (which wiped out the contents of ntfs-3g). Then you deleted the non-existent symlink, leaving an empty file behind. ![]() You'll need to re-install the ntfs-3g port to get things working again. And then re-do the symlink, with the arguments in the right order.
|
|
#8
|
||||
|
||||
|
Quote:
Quote:
Look this: Code:
> ls -la s.tgz lrwxr-xr-x 1 alt wheel 14 22 авг 09:20 s.tgz -> sitemap.xml.gz |
|
#9
|
|||
|
|||
|
Alt, phoenix:
Thanks for further explaining. I now have a better understanding of how to work with symlinks. One last thing though, how do I replace the '/sbin/mount_ntfs' binary that I had destroyed? Since 'mount_ntfs' is part of the base system, do I need to rebuild my FreeBSD 7.1-RELEASE to get mount_ntfs back? |
|
#10
|
|||
|
|||
|
If you still have the ISO/CD, why don't you just get it back from there? It's in the /7.x-RELEASE/base directory. You'll have to merge the chunks and untar the merged file. Check install.sh for more information. You'll find mount_ntfs in /sbin obviously.
EDIT: if you don't have the ISO anymore, you can also get the base from the ftp: ftp://ftp.freebsd.org/pub/FreeBSD/re...-RELEASE/base/ (change the x to your release minor version)
__________________
May the source be with you! Last edited by Beastie; August 22nd, 2009 at 17:30. |
| The Following User Says Thank You to Beastie For This Useful Post: | ||
tekkon (August 22nd, 2009) | ||
|
#11
|
||||
|
||||
|
If you have the source tree installed, you should be able to go into /usr/src/sbin/mount_ntfs and run
# make; make install to re-install it.
|
| The Following User Says Thank You to phoenix For This Useful Post: | ||
tekkon (August 22nd, 2009) | ||
![]() |
| Tags |
| ntfs-3g, symlink, unlink |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Learning C programming, C99 or not | marius | Userland Programming & Scripting | 15 | December 14th, 2012 15:47 |
| Learning FreeBSD | lha | General | 12 | January 26th, 2009 09:40 |
| How to undo unlink operation | mukembo | General | 4 | January 4th, 2009 06:35 |
| simple question, just learning | pk7 | Firewalls | 7 | December 31st, 2008 00:31 |
| Simple? PF question. Just learning | neurosis | Firewalls | 11 | November 20th, 2008 12:38 |