RPi Ethernet and Wifi at the same time

May 25, 2014 at 9:34 pm (computers, internet, maker) (, , , )

This should have been a lot easier than it ended up being!  I wanted to turn one RPi into a router between its Ethernet and Wifi networks, so that a single wifi dongle could be shared across a few Ethernet devices (via a simple dumb Ethernet hub I had lying around).

Well there are lots of posts around the Internet showing how to configure the Pi as an Access Point or an Ethernet Bridge, but in all discussions of the /etc/network/interfaces file I’ve found, no-one has really (that I’ve found so far) mentioned quite how the wpa_supplicant, ifconfig and ifplugd systems all interact and fit together.

Whilst a number of people have speculated that there might be power supply issues that will knock out your Wifi if you plug in an Ethernet cable, I didn’t see any evidence of that.  What I was actually seeing is ifplugd detecting the plugging in of the cable and then running its action scripts in /etc/ifplugd/action.d.  On my version of Raspbian, one of these scripts is a symlink over to /etc/wpa_supplicant/action_wpa.sh which basically disconnects any wpa-roam managed interfaces if the Ethernet is plugged in.

This is the designed-in behaviour, as the basic idea is that if you are using Ethernet and Wifi, then typically it will be to the same network (and ultimately connected to the Internet) so it will only need Wifi when the Ethernet is not connected.  If you have a wired connection, it will disable the wireless connection to use the wired for preference, which is the desired behaviour in the vast majority of cases.

There are a number of “fixes” around the Internet, from killing ifplugd to removing or adding auto or hotplug related options in /etc/network/interfaces.  I’m sure there must be some magic combination of options that means that the hotplugging of cables and dongles can still work, but will not automatically turn the wifi on and off – but I haven’t found it yet.

Instead, I went for the very simple, but almost definitely “quick hack” version of including an “exit 0” command near the top of /etc/wpa_supplicant/action_wpa.sh before it actually did anything.  This way, I get to keep the automatic configuration on plugging cables and dongles in, but the arrival of a new interface does not automatically shutdown the wpa-roam managed ones.

This seems to work really well for keeping Wifi connections open when plugging in an Ethernet cable.  When plugging in a Wifi dongle, that also seems to work, in that both Ethernet and Wifi end up active – although I did get a break in continuity over the Ethernet when this happened – but it reconnected again fine.

Of course, this may well completely shaft true wifi roaming across networks – I don’t know – I don’t take this RPi out and about to test it and I haven’t read enough how the wpa-roam system is meant to work to see.

I expect there is a more elegant way to achieve this, but the Internet wasn’t providing it; the Debian networking configuration manual seemed to be suggesting that I should probably use the GUI and that everything else is legacy; and I’d had enough of reading man pages. If you know of a good reference for how these scripts all interact and how this can be achieved in a nicer way, I’d very much like to hear from you!

But, this will do for now for my relatively static setup of single Wifi network, routed across to the Ethernet network.



Permalink 1 Comment

Error 13: Invalid or Unsupported Executable Format

October 27, 2009 at 8:25 pm (computers) (, , , )

Just a quick techy post.

I was setting up Windows 7 on my laptop, which trashed access to the existing Linux Ubuntu installation on the machine (as any Windows install will do).  By the way – if you want to install Windows 7 on a free partition to dual boot, its possible, but I had to make the free partition ‘active’ to make Windows recognise it as a ‘system’ partition … but I digress.

Anyway, I followed the instructions in this post – http://ubuntuforums.org/showthread.php?t=224351 – to restore the boot loader (Grub) and get Linux booting again, but then had to add an entry to allow me to select the new Windows installation.

Well, again I was able to use the usual way you get another non-Linux OS running within Grub, and there are loads of resources on the Internet to tell you how to do this.

For me it was an entry like this in menu.lst:

title          Windows 7
rootnoverify   (hd0,1)
chainloader    +1

But I was getting the error “Invalid or Unsupported Executable Format”.  After quite a bit of searching around, with lots of varied responses to this particular error, I just couldn’t see what was wrong.

Then, after staring at the grub configuration for quite a long time, eventually I realised that the rootnoverify command had no space between the rootnoverify and the brackets – i.e. “rootnoverify(hd0,1)” … after adding a space, as shown above, all was well.

This post is just in case someone else has the same problem, and to remind them that before they start trying all the variants of grub commands and partition numbers that the Internet serves up in response to that error, do check the exact syntax of the menu.lst file first!


(Now thats enough geek for today)

Permalink 2 Comments

Dual boot Vista, Windows 98 using Grub and Knoppix

April 7, 2008 at 8:52 pm (computers) (, , , , )

I’m in the process of setting up a new PC that has Windows Vista on it. I’ll put Linux on it at some point, but for now, I wish to dual boot it with Windows 98 (don’t worry, it won’t be connected to the Internet) so that we can play some old games.

Well, this is the sort of thing that is possible with the GRUB boot-loader – even if I don’t actually have Linux installed yet.

Setup – I have 2 hard disks as follows:

  • Disk 1 – NTFS partition with main Vista install
  • Disk 2 – NTFS partition with data on it

Procedure (warning, this worked for me, but requires an understanding of disks and operating systems. Proceed at your own risk – this could trash everything on your PC if it doesn’t apply directly to your setup!):

  1. Use the Vista management console disk management snap-in to resize the NTFS partitions to give me some space. I created 160 Mb on disk 1 and 40 Gb on disk 2 (I had more space on disk 2 for the W98 installation).
  2. Boot into Knoppix (I used an old Knoppix 3.7 CD) and get up a root console
  3. Create a Windows FAT partition in the spare space on disk 2

    # fdisk /dev/hdb
    -> n (new partition – used default sizes)
    -> t (set type – used c – Win FAT (lba))
    -> w (write parition table)

  4. Create a Linux partition in the spare space on disk 1

    # fdisk /dev/hda
    -> n (new partition – used default sizes)
    -> t (set type – used 83 – Linux)
    -> w (write partition table)

  5. Format the Linux partition (# mkfs /dev/hda2)
  6. Mount the Linux partition so that Knoppix can read/write to it (# mount /mnt/hda2)
  7. Run grub-install to install grub into the mounted Linux partition and in the MBR of the main disk

    # grub-install –root-directory=/mnt/hda2 /dev/hda

  8. Create a grub menu for the two entries now (for me, this was in /mnt/hda2/boot/grub/menu.lst). I used the following:

    default 0
    timeout 30

    title Windows Vista
    root (hd0,0)
    chainloader +1

    title Windows 98
    map (hd0) (hd1)
    map (hd1) (hd0)
    root (hd1,1)
    chainloader +1

  9. I needed the two map entries above as I was installed W98 on a second disk, and needed to tell GRUB to swap them over (as you can’t boot W98 off a second disk apparently). Recall, Vista is on disk 1 partition 1 (hd0,0), W98 on disk 2, partition 2 (hd1,1).
  10. Then I booted from a Windows 98 startup disk, used FDISK to verify that my C: drive was the unallocated 40 Gb on the second disk (and not any of my other partitions) and formatted C: as a system disk – (format /s c:)
  11. There was a problem though – on rebooting, I got a “GRUB error 17” indicating that it couldn’t mount the linux partition. On rebooting into Knoppix, I re-ran grub-install but then got a “stage1 not read correctly” error. On examining the partitions in fdisk, it appeared that the Linux partition had been changed to type 93 – Ameoba! No idea why. Changing the type back to Linux (83) solved the problem.
  12. The system now boots either into Windows Vista or Windows 98 (well, DOS – I now need to install Windows 98 – but I’ll actually be copying stuff off an old PC to do that).

Remember – mucking about with Linux boot disks, partitions and formatting is highly likely to screw up your PC. I’ve only put this here as I couldn’t find any mention of how to do this sort of thing on the Internet and it may be useful to someone attempting something similar. This is not a recipe, its just what worked for me. I can’t help you if you try anything here and it breaks something. Sorry.


Permalink Leave a Comment