With Linux we can easily clone an installation, or move hard drive between different systems. The hardware changes normally don't make much of a difference. BUT, with modern Ubuntu systems - and other distro's I'm sure - the network card can cause a problem. This comes up with virtual machines (with VMWare, Xen, KVM, etc.) when a copy of an existing guest install is used to create a new virtual machine.
The results of these changes normally show up as an error something like this:
SIOCSIFADDR: No such device eth0 eth0: ERROR while getting interface flags: No such device
Fixing this problem might be as simple as restarting the network services. Often it isn't though.
The problem stems from the way Ubuntu (and some other distros) map a MAC address to a network device. The problem is actually in the "udev" subsystem. Which is deep enough into the inner workings of Linux to be confusing to even experienced Linux folks.
Here's how to fix the problem:
- First, open a command prompt.
- Now see if your installation actually knows about your network card, and if so, make note of the MAC address. You enter "ifconfig -a" command and get an output something like this:
sgrover@peon:~$ ifconfig -a eth1 Link encap:Ethernet HWaddr 01:21:81:c1:f1:61 inet addr: Bcast: Mask: inet6 addr: fe81::221:8cf1:fec1:ff61/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:6696 errors:0 dropped:0 overruns:0 frame:0 TX packets:6974 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:3767357 (3.7 MB) TX bytes:1059897 (1.0 MB) Interrupt:251 Base address:0xe000 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:1549 errors:0 dropped:0 overruns:0 frame:0 TX packets:1549 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:806212 (806.2 KB) TX bytes:806212 (806.2 KB)Notice line # 2 - it is telling us "eth1" - this should be "eth0". But it also tells is the HWaddr value - this is the MAC address - the unique identifier for the network card. We'll need this in the next step.
If you ONLY see the "lo" device, you have other problems. You may need to "modprobe" some modules to get the drivers for your network card loaded.
- Now we need to edit the "udev" rules that do the device mappings. Enter the command
sudo nano /etc/udev/rules.d/70-persistent-net.rules
This will open the file that does the mappings. You may have many entries here. Take a look for the line that has the ATTR{address} that matches the MAC address for your network card. For instance, mine looks like this:
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="01:21:81:c1:f1:61", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"Notice that the end of the line says "eth1". Change this to "eth0".
Now, find the OTHER entry in the file that has "eth0" at the end of the line. Comment out this line by putting a # character at the start of it. Or if you know you don't need that entry, delete that line (and the comment immediately above it). Save the file.
- Restart your computer. Simply restarting the network services will not do the trick. You need "udev" to re-assess your hardware. Once the restart is done, you should be back to normal. If not, a Google Search may help you find what you need.
This issue caused me some grief setting up my new server. It's been quite a while since I worked with virtual machines so I had forgotten about this. Now it's refreshed AND blogged, so I shouldn't forget again.