My desktop's PCI wireless card is always scanning for available wireless networks, but I only rarely use it. Can I keep the radio turned off until I need it?
Ubuntu – How to keep a wireless card’s radio powered off by default
There are at least two Upstart jobs that affect the default wireless state:
/etc/init/rfkill-restore.confrestores the soft block state for all radios to what they were at last shutdown, as recorded in
/etc/init/network-manager.confstarts Network Manager which in turn restores its idea of wireless state from
If you look at those two job configurations you will find that they have no temporal relationship, which seems like a design flaw to me. I'm guessing this race condition is rarely a problem because
/etc/init/rfkill-restore.confis much simpler and has fewer start conditions.
All the solutions to enforcing a wireless-off default that I've seen try to use
/etc/rc.local, including the "modern" solution that @Lekensteyn and @rubo77 came up with. Unfortunately, that solution does not work for me on either of two laptops I have tried. This is not particularly surprising because
/etc/rc.localalso has no temporal relationship that I can find to either of
/etc/init/network-manager.conf. Throwing in a lengthy sleep in
/etc/rc.localprior to issuing an
rfkill block wifiis an ugly workaround for this race condition mess, but it works if the delay is long enough.
A better solution would be for us to impose our desired states in
/var/lib/NetworkManager/NetworkManager.statebefore those two Upstart jobs are even permitted to run. We can achieve this by creating our own Upstart job. In actual fact, we'll need two job configuration files to achieve the timing we need.
Our first job configuration does the actual file modifications we need. It will run as early as possible and will only run once. Create
/etc/init/radio-silence.confwith this content:
As I prefer total radio silence when my laptop starts, I soft block all radios, not just wireless, but you can modify the first
sedin the above to limit this job's impact to whichever wireless devices you wish to soft block.
Our second job configuration is responsible for ensuring that neither of the
network-managerjobs will start before
radio-silencehas completed the file modifications. Create
With this solution I am no longer seeing race condition problems, although I have not addressed the theoretical race between
For more detail on how these jobs work together to achieve our temporal goal, refer to my question and answer, "How do I create a single-execution Upstart job guaranteed to complete before two other jobs begin?"