Sep 01

Ubuntu 14.04: ‘no talloc stackframe’ Error

I have been getting this error whenever I set up an Ubuntu 14.04 machine with Samba, also when I upgraded a 12.04 LTS with Samba. This apparently is a bug problem between Samba and PAM authentication. Hopefully soon a fix will come out and get this resolved, because even the work around is not good.

Basically, the work around is to run “sudo pam-auth-update” and uncheck “SMB password synchronization”. This prevents Samba from getting updated passwords from PAM and vice-versa. This also prevents Samba from getting new passwords. If you have an existing Samba server, don’t upgrade until this problem has been resolved. Here in my private network, I have my file server set up for the ultimate in insecurity, no authentication. If yours is set up the same, the fix won’t be an issue.

Sep 01

XenServer 6: Adding a New Ubuntu 14.04 Template

Currently XenServer does not have a template for the new Ubuntu 14.04. This will most likely be fixed in a future update, but for now it’s a really easy to add a new template. Thanks to http://virantha.com/2014/05/21/ubuntu-14-04-trusty-on-xenserver-62/ for the quick instructions.

In XenCenter, head over to the console of the server and log in.

Run the following 3 commands (I chose to name it the full name Trusty Tahir instead of just Trusty):

These three commands basically just copy the template from Lucid Lunx 10.04 and renames it. Simples!

Sep 01

XenServer 6: Problems Starting a New Ubuntu 14.04 VM

Currently XenServer has a problem starting a new Ubuntu 14.04 image. There is a problem with one of the Python scripts it uses to start machines. This should be fixed by an update soon, but for now it’s a really easy fix to perform real quick. Thanks to http://virantha.com/2014/05/21/ubuntu-14-04-trusty-on-xenserver-62/ for the quick instructions.

In XenCenter, head over to the console of the server and log in.

Edit the file in question to fix the line:

In vi, head down to line 428. You can do this quickly by typing “:428″ and pressing enter. Then press “i” or the insert key to start editing.

Change this line:

to say:

Save and quit (Press ESC and type “:wq”), and you’re done. The Ubuntu 14.04 machine should now start.

Sep 01

Ubuntu: Auto Login Securely From Windows

I log into my various home Linux servers a lot (I know, geek, right?), so being able to auto log in to the servers helps a lot. Having a weak password or trying to disable password logins entirely is dangerous and insecure. After just a little setup, you can easily do it safely.

This assumes you are using SSH. If you are using Telnet to remotely manage your server, stop now and uninstall Telnet. Telnet sends all of your data, including password in plain text.

Most of these instructions were taken from: http://www.howtoforge.com/ssh_key_based_logins_putty, however I do deviate a little bit as I keep the key bits at 2048. I also don’t have all of the pretty screenshots.

At a certain point you will be asked to make a passphrase (password) for your private key. You can choose not to, however that means anyone can use the keys if they get a hold of them. If you do use a passphrase which is way more secure, when you log in, you will still have to enter a password. There is another program that can be used to store and use the password automatically however on the Windows side called Pageant. Since I’m in a private network with not a lot of outside access, I do it without. I like to live dangerously.

Set up:

  1. Download PuTTY and PuTTYGen (Pageant too if you want to use a passphrase with your key).
  2. Create a profile with the server IP Address, make sure to choose SSH as the protocol. Also in Connection -> Data, specify the user to auto log in as.
  3. Be sure to save the profile after changes are made, it doesn’t do it automatically!
  4. Connect to the server. If it is the first time, it will ask to accept the server’s host key. Press Yes.

Key generation:
Windows Side:

  1. Open PuTTYGen
  2. Click “Generate” to generate a key. Move the mouse around the blank area to make it really random.
  3. After generation, it provides a few more fields. You can change the comment if you would like. Since I’m the only one who uses my personal network, I kept everything default.
  4. Create the passphrase if you have chosen to go that route.
  5. Click on “Save private key” and “Save public key”, and save them both somewhere safe and where PuTTY can get to them. The public key must end in .txt and the private key must end in .ppk.

For example, I created a folder called “Keys” in my c:\users\username directory and save them both there.
Highlight and copy the entire key (remember to scroll down/drag down if needed). You can also open the text file and copy from there.

Linux side:
In your home directory (~), create a .ssh directory and change permissions to secure the directory:

Now create a new file to paste your public key in, then change permissions to secure the key:

Quick vi how-to:

Press i (or insert key) to start insert mode.
Right click in the PuTTY window to paste.
Press ESC key to exit insert mode.
Press : (colon) to enter command mode.
Type wg to both write and quit.

Back to Windows:

  1. Close out your putty session (running “exit” in Ubuntu will close your session on the server and exit PuTTY).
  2. Re-launch PuTTY and load the profile made earlier, but don’t connect.
  3. Go over to Connection -> SSH -> Auth and browse for your private key.
  4. Remember to go back to “Session” and click Save!
  5. Now click Open and you should log in automatically!

If you decided to use a pass phrase, you can use Pageant (part of the PuTTY suite) to provide the passphrase automatically. Pageant runs in the tray and waits to enter the passphrase when requested. For setup, just open Pageant and click “Add Key”. Browse to the same private key and enter the passphrase.

Sep 01

XenServer 6: An Easy Way to Apply Patches Manually

If you are setting up XenServer for the first time, or you have had an installation for a while but need to update it and aren’t paying for a license, you can’t apply updates via a pretty GUI in XenCenter. You can however do it manually in the command line.

1. Put the server into Maintenance Mode. This will require Pausing/Shutting down all of the VM’s. This way nothing gets corrupted or messed up by any chance.

2. Take a look at the system alerts that’s telling you what updates are missing. Thankfully for each patch you click on you can click on the “Go to Web Page…” button to go directly to the download. These patches are pretty big so it might take some time to get them all downloaded.

Note: As of this writing I am doing a brand new installation of XenServer, and I ended up needing 16 updates. That sounds like a lot, but one of them is Service Pack 1, which is a roll-up and takes care of a good chunk of those. Look for a service pack update first, something like “XS62ESP1″. Download that one first and apply it before downloading the rest. After that service pack, I only needed to download 7 more (which really ended up only being 5, see note below).

Note 2: In my case, even after XS62ESP1, It said I had 2 pre-SP1 updates to install, 14 and 15. I tried to install these afterwards but they would not work. After applying the rest of the post-SP1 updates however, the need for the pre-SP1 14 and 15 patches went away.

3. Download the update in question, and unzip it. You will need to upload the file ending in .xsupdate. The other files in the zip can be ignored.

4. Use a program like Filezilla to create an sftp connection to your server. You will log in as root and your password. Upload the file, it will upload to your home directory.

5. Switch over to the console tab on the XenServer itself in XenCenter. You should be logged in as root and at your home directory (~).

6. Run this command to add the update to the pool:
xe patch-upload file-name=nameofupdate.xsupdate
For example: xe patch-upload file-name=XS62ESP1.xsupdate

7. Hightlight and copy (right-click) the resulting UUID. You will need this next.
Example: 0850b186-4d47-11e3-a720-001b2151a503

8. (Optional) You can run the following to see if the patch actually uploaded:
xe patch-list

9. Run the patch to actually apply:
xe patch-pool-apply uuid=(previous ssid)
Example: xe patch-pool-apply uuid=0850b186-4d47-11e3-a720-001b2151a503

10. After it applies successfully, it just drops back down to a command line. Use XenCenter to reboot the server for the patch to take effect.

Done! Soon you will be an expert and these steps will fly by! You can remove the .xsupdate files afterwards to free up space.

Jan 01

Bored? Stats!

Every year that you are signed up with Jetpack (with WordPress), you get a report at the end of the year with several interesting (to me) statistics about your site. Because of the various server hackings that went on in the year 2012, the last report didn’t go so well, this one however worked great! Anyway, if you are really bored and looking for something to do, check it out below! It’s all pretty and everything.

Jetpack Annual Report – 2013

Anyway, happy new year!

Dec 21

Electronics Projects: VFD Informatron 2000

After looking at various very cool and vary old display technologies on eBay, I ran across a 4 line dot matrix VFD display. It was one of 4 left, so I decided to order it and build a project similar to this one that an IRC friend linked me to: http://www.pyrofersprojects.com/blog/vfd-clock-with-snmp-and-ntp/. I originally was going to go down the similar route of a Arduino or Arduino clone and an Ethernet shield, but after looking at what the cost would be, the Raspberry Pi made a lot more sense. The Raspberry Pi itself is only $25 or $35 for the B model, and wifi module for $10. Since I didn’t have any of this equipment, I ended up getting a really nice kit from Adafruit (Click here to see it) to get started. I also purchased some discreet electronics and other parts from Newark (Element 14) to build a RasPi UART to TTL converter (You can also do this with a MAX232 chip, which I haven’t tried yet) as I thought I would need it, which turned out not to be the case with the particular VFD module I got. Keep in mind however that the RasPi is 3.3v UART, not +5 TTL. That circuit will convert the two with 4 1k resistors and 2 2N222 transistors.

Here is most of the kit after I took everything out of the box and set some of it up:

raspi

After plugging it in, it was simple enough to download the NOOBS software kit from Raspberri’s site and unzip the contents onto the microSD card through the microSD card reader that both came in the kit (tiny USB connector as seen in the picture). Sliding the card into the adapter and into the pi and turning it on brought it right up to a really nice and simple installation interface where you got to choose your OS to install. Since it seems to be the most popular and most supported, I went with the default, Raspbian.

raspi2

The install took a while, but completed without any issues (sorry about the flash glare and quality of picture).

Unfortunately I totally didn’t take ANY pictures during the build. Not much was missed though. First I went straight to building the TTL conversion circuit, which promptly didn’t work. I took the “big risk” and plugged the display directly into the pi and it came to life! It was actually pretty simple. The 3 pin connector on the VFD module has +5 volt, Serial Data, and GND. All 3 pins went straight to the pi. The Serial Data pin is connected to pin 8 of the pi header which is the UART transmit, 5v got connected to pin 2, and GND to pin 6. You can probably picture it in your head, there’s no components inbetween.

After that initial success, it was just down to software; so I decided to build a case. Since I had never done this before, I was hoping to make just a simple, easy to put together case with a couple pieces of Lexan (plexiglass, etc). Thankfully my local hardware store had smaller pieces but thick enough for just under $4 each, so I got 3. Two extras just in case (and I needed them). I spent hours trying to cut and drill holes correctly. Wasted many a piece of Lexan. I ended up with this!

vfdcase_1st_attempt_front vfdcase_1st_attempt_back

As you can see I used 3 molex connectors and a piece of old ribbon cable to go between the pi and the VFD module. There was barely enough room for it all. It’s actually a little more tight than I really would want it to be. That is the “B” version of the PI, and will eventually be replaced with the cheaper and less powerful “A” version, since it’s not doing much. Then I can use the “B” for other projects.

I’m still developing the script, but here is what I have as of at the time of this writing. Before you look at it, remember that this project was the first time I had ever touched Python, so the writing is going to be laughable to you experts.

This script has a few bugs and problems. If there is no working internet connection, it hangs when updating the weather, so you have to kill it and restart the script when an internet connection is available again. This particular display module is a little strange in that it is set up as 19200 8E1, instead of the normal 9600 7N1. The script sets up the serial connection to the display, initializes a couple variables, then goes into an infinite loop. Every minute it cycles through the loop, first clearing the display, then repositioning the cursor to the top left. It then calls the function to display the time and date, and the weather. The weather function is programmed to only actually grab the current weather every hour, as to not needlessly load up the site and get the IP address banned from it requesting every minute. The script will be a continual work in progress while I continue to learn Python and add features.
This is the end result of the script in action:

raspi-vfd-info

The display is very blue and looks a lot better in this picture than in real life. This display is very tired as the “pixels” in real life are mostly dim, and very uneven in brightness. I believe it’s the camera flash that makes it look blue, but in reality, it’s green. See my other posts about the other parts of programming for this project for more info.

 

UPDATE:

Several weeks later the project failed, and it was an important lesson type of failure. The raspberry pi ran pretty warm the whole time, but not knowing what was “normal” I didn’t think much of it, other than thinking that I should get some heatsinks on it. Well, by then it was too late. One day the display was blank. Both the pi and the display were toast. Looking at it then revealed that I was probably pulling too much amperage through the poor little pi. The lesson? Watch the power draw! In the future anything eternal outside of an LED in my projects will have it’s own power supply. Unfortunately I couldn’t breathe any life into the pi or the display. Lots to the beginners lessons of time forever.

Dec 21

Raspbian: Run a Program at Startup

There are many directions out there that don’t work on Raspbian. Specifically the “upstart” scripts, as Raspbian doesn’t come with upstart, and will mess things up greatly if you install it. Raspbian uses init.d. It’s fairly simple to get things going since a nice script was provided at the link below, mirrored here.

Create script in /etc/init.d

The following is an example based on starting up the no-ip service [/usr/local/bin/noip], but change the name of the script and the command to start and stop it and it would work for any command.

Warning – Its important you test your script first and make sure it doesn’t need a user to provide a response, press “y” or similar, because you may find it hangs the raspberry pi on boot waiting for a user (who’s not there) to do something!

Make script executable

Test starting the program

Test stopping the program

Register script to be run at start-up
To register your script to be run at start-up and shutdown, run the following command:

Note – The header at the start is to make the script LSB compliant and provides details about the start up script and you should only need to change the name. If you want to know more about creating LSB scripts for managing services, see http://wiki.debian.org/LSBInitScripts

If you ever want to remove the script from start-up, run the following command:

Credit: Big huge thanks to: http://www.stuffaboutcode.com/2012/06/raspberry-pi-run-program-at-start-up.html. The words above are his.

Big note from me:
In my case I needed my script to wait for the network to become available, so I modified the script to say:

For more variables you could use, see: https://wiki.debian.org/LSBInitScripts

Dec 21

Raspbian: Wifi Going to Sleep

It seemed like I couldn’t contact my Pi after a while (and my SSH session would end seemingly for no reason). I would start a ping and it would time out for the first few times before it would start responding. At first I thought the Pi itself was, or the USB ports were going to sleep, but the Pi has no power saving functions. I finally came across the answer. In my case it was the USB wifi adapter itself that was going to “sleep” or low power mode. This works with Realtek 8192cu chipset (very common).

First, see if this is the cause:

If it can’t find the file, you aren’t using the module, and your wifi probably uses a different chip.
If it’s 0, power management is disabled.
If it’s 1, power management is enabled.

To disable power management, create a new file:

Put the following in:

Save, exit, and then reboot. All done.
Credit: http://raspberrypi.stackexchange.com/questions/1384/how-do-i-disable-suspend-mode

Dec 21

Python: Parsing Online XML The Easy Way

On my Raspberry Pi VFD project, I needed a way to download the XML feed from weather.gov to display the weather. After hours of searching Google and trying different things, I finally came across a way that actually works, using lxml and urllib2. I am still very new at Python, so I don’t completely understand it yet. Here is the code I used that works for me, hopefully will work for you too:

Of course, this just returns the temperature in Fahrenheit. If you look at the xml itself you can see that the section I was interested in was “temp_f” under “current_observation”. Another interesting Python trick is “temp[:-2]“. This removes the right 2 characters from the string, changing 37.6 to 37. I also later made a variable for weather which returns things like “overcast”. That line looks like weather = doc.xpath("//current_observation/weather")[0].text. Hopefully this much simpler example than what I could find on Google will make things a little clearer for everyone.

To use this, make sure you install lxml:

Note: I lost the URL to the code I ended up using, so I can’t give proper credit, sorry!

Older posts «