Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved] Rename enp0s29u1 to enp0s20u1
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
grant123
l33t
l33t


Joined: 23 Mar 2005
Posts: 994

PostPosted: Fri Aug 22, 2014 6:18 pm    Post subject: [solved] Rename enp0s29u1 to enp0s20u1 Reply with quote

How can I have network interface enp0s29u1u1 renamed to enp0s20u1 at boot?

Last edited by grant123 on Sun Aug 24, 2014 4:47 pm; edited 1 time in total
Back to top
View user's profile Send private message
VoidMage
Watchman
Watchman


Joined: 14 Oct 2006
Posts: 6194

PostPosted: Fri Aug 22, 2014 6:58 pm    Post subject: Re: Rename enp0s29u1 to enp0s20u1 Reply with quote

grant123 wrote:
How can I have network interface enp0s29u1u1 renamed to enp0s20u1 at boot?

...and the point of doing that would be ?
Back to top
View user's profile Send private message
grant123
l33t
l33t


Joined: 23 Mar 2005
Posts: 994

PostPosted: Fri Aug 22, 2014 6:59 pm    Post subject: Reply with quote

It's so I can use a script I've written with all of my laptops instead of with most of them.
Back to top
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10383
Location: Somewhere over Atlanta, Georgia

PostPosted: Fri Aug 22, 2014 7:24 pm    Post subject: Reply with quote

Ah, the benefits of "predictable network naming". Why not rename them both to something more sensible, like "net0" or even disable the new mechanisms and let them go back to the traditional "eth0"? Search "predictable network names" and you will find the solution stated many times over.

- John
_________________
I can confirm that I have received between 0 and 499 National Security Letters.
Back to top
View user's profile Send private message
VoidMage
Watchman
Watchman


Joined: 14 Oct 2006
Posts: 6194

PostPosted: Fri Aug 22, 2014 8:05 pm    Post subject: Reply with quote

Why not make use of the same command noted in udev's pkg_postinst notes ?
Back to top
View user's profile Send private message
grant123
l33t
l33t


Joined: 23 Mar 2005
Posts: 994

PostPosted: Sat Aug 23, 2014 12:39 am    Post subject: Reply with quote

John R. Graham wrote:
Ah, the benefits of "predictable network naming". Why not rename them both to something more sensible, like "net0" or even disable the new mechanisms and let them go back to the traditional "eth0"? Search "predictable network names" and you will find the solution stated many times over.

I like the new functionality because I can plug various network interfaces into the same USB port and always end up with the same device name. Are you referring to the /etc/udev/rules.d/ files? I'm working on that now.


VoidMage wrote:
Why not make use of the same command noted in udev's pkg_postinst notes ?

I just read through it but I don't see a command like that.
Back to top
View user's profile Send private message
grant123
l33t
l33t


Joined: 23 Mar 2005
Posts: 994

PostPosted: Sat Aug 23, 2014 12:57 am    Post subject: Reply with quote

The solutions I can find online require me to specify the network adapter's MAC address in the udev rule, but I'm looking for something that will rename based on where it is plugged in (or based on the default name). Can this be done?
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 14360

PostPosted: Sat Aug 23, 2014 1:02 am    Post subject: Re: Rename enp0s29u1 to enp0s20u1 Reply with quote

grant123 wrote:
How can I have network interface enp0s29u1u1 renamed to enp0s20u1 at boot?
Move the network card from PCI slot 29 to PCI slot 20. Unfortunately, this may be difficult or warranty-voiding on laptop hardware. Your problem is that you are allowing udev to name it based on where it is plugged in.
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 6013

PostPosted: Sat Aug 23, 2014 1:24 am    Post subject: Re: Rename enp0s29u1 to enp0s20u1 Reply with quote

Hu wrote:
grant123 wrote:
How can I have network interface enp0s29u1u1 renamed to enp0s20u1 at boot?
Move the network card from PCI slot 29 to PCI slot 20. Unfortunately, this may be difficult or warranty-voiding on laptop hardware. Your problem is that you are allowing udev to name it based on where it is plugged in.

...and reprogram its firmware so the card appears as a flat topology instead of a sub-device. I'm assuming that's the reason for the double "u1u1" on the end.
Back to top
View user's profile Send private message
grant123
l33t
l33t


Joined: 23 Mar 2005
Posts: 994

PostPosted: Sat Aug 23, 2014 1:30 am    Post subject: Re: Rename enp0s29u1 to enp0s20u1 Reply with quote

Hu wrote:
Move the network card from PCI slot 29 to PCI slot 20. Unfortunately, this may be difficult or warranty-voiding on laptop hardware. Your problem is that you are allowing udev to name it based on where it is plugged in.


I'm trying to rename USB device enp3s0u1 to enp0s20u1 so it works with my script. I like having my interfaces named based on their location, but I want to be able to override that in certain situations like this one. Can I do that?
Back to top
View user's profile Send private message
VoidMage
Watchman
Watchman


Joined: 14 Oct 2006
Posts: 6194

PostPosted: Sat Aug 23, 2014 2:16 am    Post subject: Re: Rename enp0s29u1 to enp0s20u1 Reply with quote

grant123 wrote:
Hu wrote:
Move the network card from PCI slot 29 to PCI slot 20. Unfortunately, this may be difficult or warranty-voiding on laptop hardware. Your problem is that you are allowing udev to name it based on where it is plugged in.


I'm trying to rename USB device enp3s0u1 to enp0s20u1 so it works with my script. I like having my interfaces named based on their location, but I want to be able to override that in certain situations like this one. Can I do that?


:roll: Of course you can - it's just not a good idea to do so or rather a wrong approach to getting a good solution.
You do know where those names come from, right ?
Before, I was referring to the line
Code:
udevadm test-builtin net_id /sys/class/net/<ifname> 2> /dev/null


Of course, by the time udev rules had ran, it won't be much help, but as you're scripting something anyway, you could - for example - check the content of /sys/class/net/ and based on the output 'udevadm test-builtin net_id' identify the one you're interested in.
Back to top
View user's profile Send private message
grant123
l33t
l33t


Joined: 23 Mar 2005
Posts: 994

PostPosted: Sat Aug 23, 2014 2:43 am    Post subject: Re: Rename enp0s29u1 to enp0s20u1 Reply with quote

It's probably obvious but I'm not getting it. It's been a long day. Can udevadm rename a network interface? If not, what should I use it for?
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3806
Location: Austro Bavaria

PostPosted: Sat Aug 23, 2014 12:26 pm    Post subject: Reply with quote

It seems the posters above try to tell you that you should determine your network interface name on these commands and than use the output of that for your scripts.

Sidenote, I dislike those new naming scheme and when you use a script anyway a proper approach is to search for a defined pattern for your device and than use that device in your script. some things wont change like MAC and therfore you should be able to write your script.

I also agree with the posters above that a human readable format like net0 is something preferable as some numbers and letters name which is hard to remember. ...
Back to top
View user's profile Send private message
grant123
l33t
l33t


Joined: 23 Mar 2005
Posts: 994

PostPosted: Sat Aug 23, 2014 4:18 pm    Post subject: Reply with quote

tw04l124 wrote:
It seems the posters above try to tell you that you should determine your network interface name on these commands and than use the output of that for your scripts.

The udevadm command above takes the interface name as input, but maybe there's another udevadm command that lists all interface names? But this strategy breaks down if there are multiple connected interfaces since I wouldn't know which is which.


tw04l124 wrote:
Sidenote, I dislike those new naming scheme and when you use a script anyway a proper approach is to search for a defined pattern for your device and than use that device in your script. some things wont change like MAC and therfore you should be able to write your script.

I want my USB network interfaces to be interchangeable so I don't have to keep track of which interface goes with which laptop. What I really want to be able to do is define names for interfaces keyed on the interface location instead of the interface MAC address.


I was able to get this udev rule to execute:

Code:
SUBSYSTEM=="net", KERNEL=="enp3s0u1", NAME="net0"

But it doesn't happen automatically at boot, I have to execute this command:

Code:
udevadm trigger --action=add

How can I execute that command before the /etc/init.d/net.* scripts run?
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3806
Location: Austro Bavaria

PostPosted: Sun Aug 24, 2014 7:52 am    Post subject: Reply with quote

I think you should search for a way to add it as a separate service or make a rule that it is loaded at the proper way before you start your network.
Back to top
View user's profile Send private message
grant123
l33t
l33t


Joined: 23 Mar 2005
Posts: 994

PostPosted: Sun Aug 24, 2014 1:01 pm    Post subject: Reply with quote

I'd rather not write an initscript for it. How would that rule be set up?
Back to top
View user's profile Send private message
grant123
l33t
l33t


Joined: 23 Mar 2005
Posts: 994

PostPosted: Sun Aug 24, 2014 4:47 pm    Post subject: Reply with quote

Here's the solution:

Code:
SUBSYSTEM=="net", ACTION=="add", ENV{ID_NET_NAME_PATH}=="enp3s0u1", NAME="net0"


https://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=4&chap=2#doc_chap4
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3806
Location: Austro Bavaria

PostPosted: Tue Aug 26, 2014 3:14 pm    Post subject: Reply with quote

Code:
menuentry ' title ' --class gento --class gnu-linux --class gnu --class os {
 linux /kernel-name init=linuxrc ramdisk=8192 crypt_root=dev/mapper/abc realroot=/dev/mapper/cde dolvm net.ifnames=0
 initrd /initramfs-genkernel-x86_64-3.5.3-gentoo_Sept_2012
}


I do not know if it was already mentioned but if you want the old behaviour you just need to add net.ifnames=0, as you can see on the example above which I personally use atm in my grub.cfg
Back to top
View user's profile Send private message
grant123
l33t
l33t


Joined: 23 Mar 2005
Posts: 994

PostPosted: Tue Aug 26, 2014 8:59 pm    Post subject: Reply with quote

I can't go with the old behavior because I want to define network device names based on location instead of MAC address.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware 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