Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Multiple NICs init-scripts: link, don't copy!
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
ElCondor
Guru
Guru


Joined: 10 Apr 2002
Posts: 520
Location: Vienna, Austria, Europe

PostPosted: Fri Sep 17, 2004 9:10 am    Post subject: Multiple NICs init-scripts: link, don't copy! Reply with quote

I'm not sure whether to post this here or in "Documentation,Tips an Tricks", but anyway:
The gentoo install guide told me (2 1/2 years ago) that I should simply copy my /etc/init.d/net.eth0 to /etc/init.d/net.eth1 for my second NIC. Well, a certain time after installation and (multiple) upgrades of the system, this won't work anymore, simply because init scripts are subject to change, bringing new features - and I'm rather sure, many admins out there forget to update their copies of the init scripts. IMHO the much better way to do this is linking:
Code:
ln -s /etc/init.d/net.eth0 /etc/init.d/net.eth1


* ElCondor pasa *
_________________
Here I am the victim of my own choices and I'm just starting!
Back to top
View user's profile Send private message
hardcore
l33t
l33t


Joined: 01 Nov 2003
Posts: 626
Location: MSU, MI

PostPosted: Fri Sep 17, 2004 10:52 am    Post subject: Re: Multiple NICs init-scripts: link, don't copy! Reply with quote

ElCondor wrote:
I'm not sure whether to post this here or in "Documentation,Tips an Tricks", but anyway:
The gentoo install guide told me (2 1/2 years ago) that I should simply copy my /etc/init.d/net.eth0 to /etc/init.d/net.eth1 for my second NIC. Well, a certain time after installation and (multiple) upgrades of the system, this won't work anymore, simply because init scripts are subject to change, bringing new features - and I'm rather sure, many admins out there forget to update their copies of the init scripts. IMHO the much better way to do this is linking:
Code:
ln -s /etc/init.d/net.eth0 /etc/init.d/net.eth1


* ElCondor pasa *


True that, it's in the newest gentoo handbook, and I believe in the router howto as well.
_________________
Nothing can stop me now, cuz I just don't care.
Back to top
View user's profile Send private message
nielchiano
Veteran
Veteran


Joined: 11 Nov 2003
Posts: 1287
Location: 50N 3E

PostPosted: Fri Sep 17, 2004 12:39 pm    Post subject: Reply with quote

I would rather Hardlink those files, instead of using symlinks. Won't matter mutch, but it's a bit "cleaner" (no symlinks in the init.d dir)

just omit the -s in the code:
Code:

ln /etc/init.d/net.eth0 /etc/init.d/net.eth1
Back to top
View user's profile Send private message
fleed
l33t
l33t


Joined: 28 Aug 2002
Posts: 756
Location: London

PostPosted: Fri Sep 17, 2004 12:43 pm    Post subject: Reply with quote

If you hard link you'll end up with the same situation as if you had copied, I think.
Back to top
View user's profile Send private message
nielchiano
Veteran
Veteran


Joined: 11 Nov 2003
Posts: 1287
Location: 50N 3E

PostPosted: Fri Sep 17, 2004 5:23 pm    Post subject: Reply with quote

fleed wrote:
If you hard link you'll end up with the same situation as if you had copied, I think.

hmm... I don't know if emerge will unlink first, but you might be right...
Back to top
View user's profile Send private message
ElCondor
Guru
Guru


Joined: 10 Apr 2002
Posts: 520
Location: Vienna, Austria, Europe

PostPosted: Fri Sep 17, 2004 6:59 pm    Post subject: Reply with quote

nielchiano wrote:
fleed wrote:
If you hard link you'll end up with the same situation as if you had copied, I think.

hmm... I don't know if emerge will unlink first, but you might be right...

nope. a hard link is just a second name for a file, exept the difference, that the file will not be deleted until the last hard link / name for it is deleted.

* ElCondor pasa *
_________________
Here I am the victim of my own choices and I'm just starting!
Back to top
View user's profile Send private message
nielchiano
Veteran
Veteran


Joined: 11 Nov 2003
Posts: 1287
Location: 50N 3E

PostPosted: Fri Sep 17, 2004 9:14 pm    Post subject: Reply with quote

ElCondor wrote:
nope. a hard link is just a second name for a file, exept the difference, that the file will not be deleted until the last hard link / name for it is deleted.

I know what a hardlink is. The point is: if you change one "filename" you also change the other.
The question is: does emerge CHANGE the files, or does he deletes them and creates new ones?
The first case will leave you 2 updated files, while the second one will give you 1 updated file, and a broken link (since they aren't hardlinked anymore)
Back to top
View user's profile Send private message
Tsonn
Guru
Guru


Joined: 03 Jun 2004
Posts: 550

PostPosted: Fri Sep 17, 2004 11:32 pm    Post subject: Reply with quote

You don't get broken links with hard links... when a file which is hard linked is removed, the number of remaining references is checked, and the file is only removed if there are none left.

So, in fact, what you might get if the second file is hard linked to the first is the second file being the outdated version, and you're back where you started :-)

Code:

# echo test > file1
# ln file1 file2
# rm file1
# ls
file2
# cat file2
test

_________________
If your question was answered, please edit the first post and add [SOLVED] to the title. Thanks!
Back to top
View user's profile Send private message
nielchiano
Veteran
Veteran


Joined: 11 Nov 2003
Posts: 1287
Location: 50N 3E

PostPosted: Sat Sep 18, 2004 8:37 am    Post subject: Reply with quote

26199 wrote:
You don't get broken links with hard links... when a file which is hard linked is removed, the number of remaining references is checked, and the file is only removed if there are none left.

You don't get my point: from the file-system view there is nothing wrong (as you say). From the user point of view, the hardlink might be broken:
In the case emerge will delete, and copy the new file (instead of changing the one in place) this happens:
  • emerge deletes file 1
  • file 2 isn't toughed and still exists (now without extra names)
  • emerge copy's the new file 1
  • from the user point of view, his link between 1 and 2 is broken, since 1 is updated and 2 isn't
  • Symlinks will not show this problem
Back to top
View user's profile Send private message
ElCondor
Guru
Guru


Joined: 10 Apr 2002
Posts: 520
Location: Vienna, Austria, Europe

PostPosted: Sat Sep 18, 2004 9:11 am    Post subject: Reply with quote

you're right. even if you move the ._newfile to oldfile, it actually performs a rm on oldfile first so that the hardlink/second name keeps the original file, so hardlinks just work like copies here.
Maybe symlinks are not "clean", but they work for sure :)

* ElCondor symlinked pasa * ;)
_________________
Here I am the victim of my own choices and I'm just starting!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum