Tuesday, December 16, 2014

Taking two steps back

Since my last post, I have lost progress unfortunatly, although not much. 

I was going to setup my git repository, and I wanted to set ownership of the relevant files to a new user. But the flashdrive that I was planning on using was mounted in fat32, which doesn't support owners. so I reformated the drive, and had to change the ID in my fstab. When I tried to reboot, to check that the changes worked, It put me into emergency mode, asking for root credentials, which I had forgot. So I realized I had to reinstall the OS. Luckily, this is really simple with NOOBS on the raspberry pi. This time while installing, I decided I wouldn't need the graphical interface, and tried to use the headless mode. After logging on the first time, I remembered that I had used the graphical interface to setup wireless, but thought I was up for the challenge of configuring it without. 

After much searching on google, finding results for different distros, and different versions of distros, I was eventually able to find a set of commands that at least made me feel like I was making progress. I started by running iwconfig, which told me that wlan0 was my wireless adapter, I then ran 
sudo iwlist wlan0 scanning | grep ESSID to find all availible ESSID's. I already knew mine, but I figuredthis was something that may be important to know later on. At this point, the guide I was using explaned how to connect with WEP, but I use WPA, so I had to look for a couple different options. Everything I found required installing wpa_supplement, but I was pretty convinced that there had to be a way to do it without needing another library, but I couldn't find anything else, so I went ahead and tried to install it, only to realize that it was already there.

After I had decided to use wpa_supplement, I ran sudo  bash -c 'wpa_passphrase SSID password > /etc/wpa_supplicant/SSID.config' to store the configuration in a file to be used by wpa_supplicant, then sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/SSID.config, which ran fine. The guide said that all that was left to do was to get an ip through dhcp, so I ran dhclient wlan0, and that succedded, so I figured I should be good to go. After trying to ping my main laptop, I realized that was not the case.

So I started going through the troubleshooting steps again, and realized that when I ran iwconfig, wlan0 still had a status of DOWN, which i figured was a problem. When trying to figure out how to remedy this, all the sources I found said I needed to run ifconfig wlan0 up. Unfortunately, ifconfig didn't exist. A couple people mentioned that I may just need the full path to it (i.e. /sbin/ifconfig) however, it didn't exist there either. eventually I realized that what I needed was ifup wlan0, which gave me the error configuration for wlan0 not found. I recalled while I was looking around some that I had seen some files in /etc/sysconfig/network-scripts/ that had one for lo and eth0, but not wlan0. So I copied ifcfg-eth0 to ifcfg-wlan0, and changed the first line from DEVICE=eth0 to DEVICE=wlan0, an ran ifup wlan0 again. This time the command seemed to run to completion, but iwconfig still reported that wlan0 was DOWN. At this point I decided it would be easier to boot to a graphical, and use the GUI. I looked in the inittab file (I remembered how to do that part from a class in college), which told me that the system uses targets instead of runlevels, so I needed to run
ln -sf /lib/systemd/system/<target name (for me it was graphical)>.target /etc/systemd/system/default.target. Then after running a shutdown -r now, I was able to log in and connect with just a couple mouse clicks, making me feel like I had wasted the past couple hours. 

Once the pi was online, I wanted to verify that I could still connect via ssh. First I tried to ping it, to verify my laptop could resolve the host name. For the most part its fine, but occassionally it appears to resolve to the ip that was given to the pi  before I reinstalled. Since I gave it the same hostname it had before, I'm assuming that my laptop has cached the ip, and that it will get better with a little time. Putty prompted me to verify the rsa key again, so I had to run ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key.pub, but there weren't any other problems with connecting via ssh.

Still need to add my flashdrive to my fstab, and reinstall git, then set that all up, but I was frustrated enough with the wifi setup, that I think it will be a while before I get back to this.

No comments:

Post a Comment