Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does "biosdevname" really work?

Tags:

linux

ubuntu

I know the purpose of "biosdevname" feature in Linux, but I'm not sure how exactly it works.

I tested it with Ubuntu 14.04 and Ubuntu 14.10 (both 64-bit server editions) and it looks like they enable it by default - right after system startup my network interface has a name such as p4p1 instead of eth0, no customization is needed. As I understood it, in order for biosdevname to be enabled, BOTH of these two conditions must be met:

  • a boot option biosdevname=1 must be passed to a kernel
  • biosdevname package must be installed

As I already mentioned, both Ubuntu 14.04 and 14.10 seem to offer biosdevname as a default feature: they come with biosdevname package already installed, I didn't need to modify grub.cfg either - GRUB_CMDLINE_LINUX_DEFAULT has no parameters and my network interface still has a BIOS name (p*p*) instead of a kernel name (eth*.)

Later I wanted to restore the old style device naming and that's where the interesting part begins. I decided to experiment a bit while trying to disable the biosdevname feature. Since it requires biosdevname package to work (or so I read here and there), I assumed removing it would be enough to disable the feature, so I typed:

sudo apt-get purge biosdevname

To my surprise, after reboot my network interface was still p4p1, so biosdevname clearly still worked even though biosdevname package had been wiped out.

As a next step, I applied appropriate changes to /etc/network/interfaces in order to restore the old name of my network interface (removed entry for p4p1 and added entry for eth0). As a result, after another reboot, ifconfig reported neither eth0 nor p4p1 which was another proof that OS still understood BIOS names instead of kernel names.

It turned out that I also had to explicitly change GRUB entry to GRUB_CMDLINE_LINUX_DEFAULT=biosdevname=0 and update GRUB to get the expected result (biosdevname disabled and old name of network interface restored).

My question is: how could biosdevname work without biosdevname package? Is it not required after all? If so, what exactly provides the biosdevname functionality and how does it work?

like image 838
Peter Avatar asked Nov 24 '14 19:11

Peter


People also ask

What is Biosdevname?

Description. biosdevname takes a kernel device name as an argument, and returns the BIOS-given name it "should" be.

What does net ifnames 0 do?

The simple way of disabling the whole current interface naming scheme (which you might want to try for one-off testing) is just to boot with the kernel parameter net. ifnames=0, which can be set in an interactive grub session at boot or made persistent by editing /etc/default/grub and running update-grub.


1 Answers

The reason biosdevname keeps annoying you even after you uninstall the package, is that it installed itself in the initrd 'initial ramdisk' file as well.

When uninstalling, the /usr/share/initramfs-tools/hooks/biosdevname is removed, but there is no postrm script in the package so update-initramfs is not executed and biosdevname is still present in the /boot/initrd... file used in the first stage of system startup.

You can fully get rid of it like this:

$ sudo update-initramfs -u
like image 52
pvdputte Avatar answered Nov 16 '22 01:11

pvdputte