HowTo: Fix a missing eth0 adapter after moving Ubuntu Server from one box to another.
Scenario: You have a box running Ubuntu Server. Something happens to the box and you decide to move the hard-drive to another physical machine to get the server back up and running. The hardware is identical on the other machine, so there shouldn’t be any issues at all, right?
The machine starts up fine, but when you try and hit the network, you can’t. Closer inspection using the ifconfig command reveals that there is no “eth0″ adapter configured. Why?
Here’s how to fix it.
Ubuntu Server keeps tabs on the MAC address of the configured ethernet adapter. Unlike Ubuntu Desktop, you can’t simply change network cards willy nilly – while Ubuntu Server does detect and automatically setup new cards, it won’t automatically replace any adapter already configured as eth0 with another one, so you need to tell Ubuntu Server that you no longer need the old adapter.
This problem can also appear if you have a virtual machine such as one from Virtualbox, and you move or copy it from one host to another without ensuring that the MAC address configured for that VM’s ethernet adapter is 100% identical to the previous one.
These instructions were done with Ubuntu Server 9.04 Jaunty Jackalope in mind, but should apply to just about any release.
- Since you can’t SSH in, you will need to login directly on the Ubuntu Server console as an appropriate user with sudo rights.
- Once logged in, type in the following and hit Enter:
$ sudo nano /etc/udev/rules.d/70-persistent-net.rules
- You are now presented with the Nano text editor and some info that looks similar to the following:
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# PCI device 0x8086:0x1004 (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="0a:03:27:c2:b4:eb", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0" - Delete the last two lines or simply comment out the SUBSYSTEM line on the end. This is a rule defining what MAC address should be explicitly assigned to “eth0″. Since you no longer have an ethernet card with the specified MAC address in this machine (it’s on the old PC, remember), Ubuntu Server effectively ignores your new ethernet adapter because its MAC address does not match the defined rule for “eth0″.
- Once you’ve made your changes, press CTRL + X and then Y and then Enter to save your changes.
- Now reboot your box with:
$ sudo reboot
- Upon reboot, Ubuntu Server will detect the “new” ethernet adapter in your PC and will automatically write a new rule into the /etc/udev/rules.d/70-persistent-net.rules file, thus enabling networking over eth0 for your server.
- To verify that the new adapter is working, type in:
$ ifconfig
…and you should see eth0 now listed with your defined IP address. - Test remote connectivity to the server and if all is well, then pat yourself on the back. You’re done.
Leave a Reply