Short Version:
From the command line run:
1.
$ udhcpc -i <interface> (Interface = eth0, wlan0 etc).
- Then and ONLY then run:
$ opkg upgrade #after running opkg update of course
- IMPORTANT: Either set this to run in a startup script (below) or do this manually on each boot as /etc/resolv.conf gets reset on each boot. This fix only seems important for opkg upgrade; opkg update seems to run fine either way.
TL;DR version:
So I think I have a fix that seems to take care of the failing to boot after an initial “opkg upgrade” with the stock BBB Angstrom distribution (2013-09-04) for me. This problem, seems to stem from the dns server not being correctly set in /etc/resolv.conf. If you look at it with your favorite text editor (e.g. “nano /etc/resolv.conf”), it will likely say something like:
`
Generated by Connection Manager
nameserver 127.0.0.1
`
Running the opkg upgrade command with only this in resolv.conf caused the BBB to hang on reboot every time for me. However, if you automatically set your dns server in /etc/resolv.conf with udhcpc -i or manually set the dns server, opkg upgrade runs no problem. FYI The first time you run it, opkg upgrade does take quite a while.
For example, here are my working /etc/resolv.conf files:
`
#/etc/resolv.conf after running “udhcpc -i eth0”:
domain eau.wi.charter.com
nameserver 192.168.0.1
`
`
##/etc/resolv.conf after manually setting dns:
Generated by Connection Manager <–Delete or comment out old DNS settings
nameserver 127.0.0.1 <–Delete or comment out old DNS settings
I used a Google Public DNS Server (e.g. 8.8.8.8 or 8.8.4.4)
nameserver 8.8.8.8
`
Important:
This fix has worked great for me and I have not had a problem since I started doing this. One important thing to keep in mind is that /etc/resolv.conf defaults back to:
`
Generated by Connection Manager
nameserver 127.0.0.1
`
So you must set it on every boot BEFORE running opkg upgrade. A startup script is really helpful here. Something like this seems to work for me:
$ nano /lib/systemd/system/myStartUpService.service
/lib/systemd/system/myStartUpService.service:
`
[Unit]
Description=My BBB startup service
Wants=network-online.target #wait for network up. Can slow down script. This is important if setting dns with “udhcpc -i .” Can be omitted if manually setting /etc/resolv.conf
[Service]
Environment=HOME=/home/root
WorkingDirectory=/home/root
ExecStart=/home/root/bin/myStartUpScript.sh #script you want executed
SyslogIdentifier=my-start
RemainAfterExit=yes #allows you to check status even after script finishes
Restart=on-fail #restart if script fails. e.g. dependancies haven’t started yet
RestartSec=10 #but wait 10 seconds before trying again
[Install]
WantedBy=multi-user.target
`
`
$ cd
$ mkdir bin
$ cd bin
$ nano myStartUpScript.sh
$ cd
`
/home/root/bin/myStartUpScript.sh:
`
#!/bin/bash
udhcpc -i eth0 #or whatever interface you are using to connect to the internet (wlan0 etc)
/---------------------------------OR-------------------------------------/
#could also use something like this and remove “Wants=network-online.target” from service file
#echo “nameserver 8.8.8.8” > resolv.conf #8.8.8.8 is a public google dns server
/-------------Whatever else you feel like starting on boot below-------------/
`
From the command line:
`
$ chmod +x /home/root/bin/myStartUpScript.sh
$ systemctl enable myStartUpService.service #enable run on boot
$ cat /etc/resolv.conf #nameserver should be 127.0.0.1 if you haven’t set it since last reboot
$ systemctl start myStartUpService.service #attempt to start script for this session
$ cat /etc/resolv.conf #nameserver should now be set (e.g. 8.8.8.8, 192.168.0.1 etc)
$ sudo reboot
`
`
#Check to make sure script ran ok after reboot
$ systemctl status my myStartUpService.service #if failed, wait 10-20 seconds and try again
$ cat /etc/resolv.conf #nameserver should now be set (e.g. 8.8.8.8, 192.168.0.1 etc)
`
If everything works, you should now be able to run “opkg upgrade” to your heart’s content! You can also run ntpdate in the startup script if you want, but after the initial opkg upgrade, the time should automatically set itself on boot with a network connection.
P.S. The systemd website always takes me a minute to figure out again every time I look at it when making a .service file. Here are some links I found helpful for each section of the service file:
Quick general index: http://www.freedesktop.org/software/systemd/man/systemd.directives.html
`
#Useful links for .service files
[Unit] # http://www.freedesktop.org/software/systemd/man/systemd.unit.html
Wants= # http://www.freedesktop.org/software/systemd/man/systemd.special.html and http://www.freedesktop.org/software/systemd/man/systemd.target.html
[Service]
http://www.freedesktop.org/software/systemd/man/systemd.service.html
[Install]
WantedBy= #http://www.freedesktop.org/software/systemd/man/systemd.target.html
`