HOWTO: Full Disk encryption on Ubuntu 12.04

How to set up an entirely encrypted disk using Ubuntu 12.04 (LTS):

Use the Alternative installer (text based) ISO image so that you have access to the LVM and Encrypted Disk options.

Assuming you want to keep a windows partition or some other pre-existing partitions intact, you will have to manually partition things instead of using the guided partitioner, so select “manual”.

Set up two partitions. One will be your /boot partition and should be around 250MB. This is the only data that will be unencrypted on the disk. The other will be your encrypted volume, that will hold an LVM physical volume that will contain all of your other partitions such as your swap partition, / (root) partition and any /home /var etc partitions that you want to set up. You should select “Use as:” “physical volume for encryption” when setting it up.

Then go back up to the top of the menu to the “Configure encrypted volumes” option (You may have to write changes to the partition table before you can do this.) Use the “Create encrypted volumes” option, and “check” / select the large LVM partition you just created. Then select “Finished” and it will prompt you for a pass-phrase.

Now, go back up to the top of the menu to the “Configure the Logical Volume Manager” option. This will prompt you to write changes to disk, and create an encrypted volume (defaults to using ext4).

Now, go back up to the top of the menu to the “Configure the Logical Volume Manager” option. Create a volume group (vg0 is as good of a name as any) on the /dev/mapper encrypted volume you created above.

Create a logical volume (I named mine “swap”) that will hold your swap partition. It should be at least as large as the maximum amount of RAM you ever intend on installing in your computer if you want to use suspend to disk (hibernate).

Depending upon how many other partitions you want (one big root, or /home and /var, etc”¦) create other partitions using the rest of the space inside of your LVM volume group, and select Finished.

Once you leave the LVM configuration area, you will see all of the LVM logical partitions that you have created. Select each of them and configure their mount point and file system type. (or use as Swap in the case of your swap partition.)

Write everything to disk (which will also format partitions) and you are ready to continue with the rest of your installation!

Thinkpad X31 – PAE cpu options with newer Linux Kernels

The Pentium M CPU that comes on IBM Thinkpad X31 laptops (circa 2003…) claims to not support PAE (Physical Address Extension ). Luckily however it DOES support PAE if your kernel forces it, which you can do by following the instructions here:

https://help.ubuntu.com/community/PAE

They explain: “A number of older Pentium M processors produced around 2003-4 (the Banias family) do not display the PAE flag, and hence a normal installation fails. However, these processors are in fact able to run the latest (and PAE-demanding) kernels if only the installation process is modified a little. The problem is not missing PAE, it’s about the processor not displaying its full capabilities.”

I can just imagine an IBM or Intel engineering thinking…it’ll be 10 years before operating systems require a PAE extension…none of these chips will still be running then…lets call it a night and not bother displaying the PAE flag…

Editing cellphone videos in Ubuntu Linux

If you have a slightly older android cell phone, chances are it records videos using the “3gp” format. When editing 3gp videos in OpenShot on Ubuntu, the audio and video can become unsynced. I have found that using the WinFF application you can convert the 3gp video into “DV – Raw DV for NTSC full screen” format, which will allow OpenShot to edit it correctly without having audio sync problems.

As a side note, sometimes when shooting videos with a cell phone, you may forget to rotate the phone to “landscape” orientation and be left with a vertical video that is rotated 90 degrees when shown on a computer. OpenShot can be used to rotate videos as follows:

  1. right click on the clip
  2. click Properties
  3. Choose the Effect tab (far right)
  4. Hit the “+” sign and then scroll down to “R” for Rotate.
  5. In the effects settings:
    • set the Rotate X, Y and Z to 0.00
    • set the Fixed Rotate X variable to 90.0.
  6. Hit apply

Electric Pickup Truck: Cost of Ownership

ev_operating_costs
We have owned an electric S-10 pickup truck for the last 1008 days (2.75 years) and used it as a daily driver. It was driven most frequently to the MARTA station, a 4 mile round trip commute, but also made trips to hardware stores, the Georgia Tech Campus, and to the homes of various people who were selling furniture or other larger items on craigslist. It uses twenty (six volt lead acid) golf cart batteries for its traction pack, and they have gradually lost capacity. When brand new, I would take the truck on 20 to 25 mile trips without stressing the battery pack. Recently however, the absolute maximum range of the truck had dropped to 12-14 miles and if you actually drove it 14 miles you could watch individual batteries hitting their absolute end of their state of charge. Although it could have functioned as a “Get to the MARTA station” vehicle for another year (or two?) I decided it was time to replace the pack to be able to comfortably go to the hardware store or make an extra emergency trip without worry. I have placed 685 charge cycles on the pack, which is in line with the lifespan for lead acid golf cart batteries.

The replacement pack cost $2,171 (I gave back all but one of the used batteries for the core charge), which gives me the final piece of information needed to calculate the total cost of ownership over the last 1008 days. We spent $464 on electricity (estimated at $0.11 a KWH), $610 on maintenance, and the previously mentioned $2,171 on batteries. Obviously, the battery pack is the large cost here. In fact, the electricity cost is very small on a monthly basis, and was never more than 10-15% of our total KWH usage.

We drove a total of 4,861 miles in that timeframe, giving a cost of $0.66 a mile or $3.22 a day. This does not take into account licensing and insurance, but those costs would be exactly the same for an internal combustion engine (ICE) vehicle. If the S-10 were an ICE model, it would probably get around 20 mpg, so the fuel cost (estimating $3.50 for a gallon of gas) would be $0.175 per mile. So for 4,861 miles it would take 242.55 gallons of gas or a fuel cost of $849. This would imply that an ICE vehcile would have to have a maintenance cost of $2400 to get the same per mile cost of ownership as my EV.

Although ICE vehicles are more expensive to maintain, unless something major on the engine exploded, it looks like my hypotheical ICE S10 pickup wins the straight up cost comparison. Of course, I never had to drive out of my way to stop at a gas station, and there is the matter of 242.5 gallons of gas I didn’t use. (the lead and plastic in my batteries goes back to the factory to make new batteries)

In the interest of full disclosure, my first pack of batteries was purchased at a Sam’s Club for $1,800, so my true cost per mile is closer to $0.59. (But I used the pack replacement cost as an estimate for the cost of ownership for my next pack.)

I am hopefull that my 2nd pack (from Interstate batteries) will last longer, either because Interstate sells better batteries, or because I have learned how to care for them better. (Although I don’t think I did anything horrible to murder the first pack…)

Small Phone Review: Sony Ericsson Xperia Mini cell phone

I recently purchased a Sony Ericsson Xperia Mini ST15a Cellphone to see if I would like it enough to replace my HTC Aria / Liberty A6366. (I did a review of the aria here.)

Form Factor:
I specifically picked the Xperia Mini because it is a small phone. Small enough to fit in my backpack’s older style cell-phone pocket. Small enough to (easily) fit in my front pocket if I want to carry it around without my backpack. From an outline standpoint, it is actually smaller than the HTC Aria, (and weights a half oz less) but it is almost 50% thicker (only 16mm or 0.63 inches). I was slightly worried that it might be a bit too thick, but after using it for a few days I have decided that it’s fine. The extra thickness is nice to keep it from disappearing in my hand…it’s a VERY small form factor for a modern android smart-phone.

Buttons & Ports
The audio jack comes out the bottom of the phone, which means I have to put it in my backpack’s cell-phone pocket upside down when listening to music with headphones. The micro-USB port is also on the bottom, and covered by a small removable plastic tab that is “hinged” to the phone with a small piece of plastic that goes into a hole. I doubt that the plastic tab will last for more than a few months, as I plug in the phone to charge at least twice a day. The USB port has a “square” appearance, and does not look like a micro-USB on first glance. You have to look inside of it to determine which way is “up” (it’s “upside down”…), but a standard micro-USB cable does work with it. Not major issues, but I don’t see the point of having a removable cover for a port you are going to be using multiple times a day.

A volume up/down rocker is on the top right side, and the bottom right side has a dedicated camera button. You have to long-press the button to auto-start the camera application, I have never started it by accident, and it’s nice having a dedicated button to pull it up. The power button is on the top left.

The battery cover/back of the phone snaps on and off from the side and wraps around the back of the phone. You have to pull the battrey to change the SIM card, and the back cover has a small plastic tab that holds the MicroSD card in when the cover is on. (You need fingernails or tweezers to remove the microSD card, it does not have any push-spring-return mechanism.)

The phone’s speaker, LED flash, and camera lens are on the back.

Screen:
The screen is just slightly (0.2in) smaller than that of the Aria, and has the same resolution (320×480). Even at the full brightness setting it doesn’t appear to be as bright as the Aria’s screen, but I haven’t noticed it being too dim either. According to the Internet, the glass is “scratch resistant” but not “Corning Gorilla Glass”. I typically use a plastic screen protector on all of my phones (at least for the first year or so) and keep them out of pockets with keys, so the exact type of glass probably doesn’t matter. Percentage wise, a much larger portion of the front of the Xperia is screen.

Software/UI:
I purchased a phone that was not carrier branded, so the only pre-loaded apps it had came from Sony Ericsson. I was able to remove, disable, or hide all of the annoying pre-loaded offers and things I didn’t want, and almost immediately downloaded the Sony Phone Companion software for my PC to upgrade the phone to Android 4.0.4, so I can’t comment on the original Android 2.x OS that the phone originally shipped with.

Android 4.0 on the phone is as good as my CyanogenMod ROM on the Aria. My phone has full support for setting itself up as a wifi-hotspot for wireless tethering. (Perhaps carrier branded versions of the phone have that part of android disabled?) It also supports various VPN’s out of the box (noticeably lacking is OpenVPN, I had to set up a PPTP server at home, which was actually a lot easier than getting an OpenVPN server working). In short, the stock OS/ROM did everything I want from a phone, so I don’t anticipate having to root the phone and install CyanogenMod on it anytime soon.

Freedom/ROM Support
However, I am happy to report that CyanogenMod did support this phone (I use the CyanogenMod supported phone list as a pre-filter for any phone shopping, just in case I don’t like the default software the comes with the phone.). I am even happier to report that Sony Ericsson fully supports you voiding your warantee by providing an online service that allows you to unlock your bootloader so that you can replace it with anything you want. This feature is what made me specifically decide to give the Xperia a shot.

Camera/Flash:
I like having an LED light on the back of the phone. I installed an application that lets me switch it on and off from the home screen. Even if it didn’t act as a flash for the camera, a flashlight seems like such a useful thing to have built into your phone I don’t know why all phones don’t have them. I haven’t actually evaluated the phone’s camera yet….

The biggest negative of the phone is the limited memory footprint, and with modern applications (I’m looking at you Google!) starting to take up more and more space, I find myself having to choose what to un-install just to be able to install updates on other more critical applications.

Using a Raspberry Pi as a RepRap print host with webcam

I set up a Raspberry Pi as a print host for my RepRap (using the Pi Camera Board as a webcam to view the print status). Here are my summary steps:

  1. Install Rasberrian and update it.
  2. Configure your system to enable wifi (if used) and camera board (if used) and enable the SSH server if you want to remotely administer the pi board using the “sudo raspi-config” command (you may also want to tweak your overclocking settings here, I’m using “Moderate”)
  3. Install OctoPrint following directions here: https://github.com/foosel/OctoPrint/wiki/Setup-on-a-Raspberry-Pi-running-Raspbian
  4. If you have a camera board, you may need to update your pi firmware (sudo apt-get install rpi-update; sudo rpi-update)
  5. To get the camera board set up as a streaming webcam, install mjpg-streamer experimental version from here:
    “git clone https://github.com/jacksonliam/mjpg-streamer”
  6. You can compile it on the Pi using these instructions:
    http://www.instructables.com/id/Create-an-internet-controlled-robot-using-Livebots/step5/Get-the-webcam-streamer-for-Raspberry-Pi/ (ignoring the step to download from sourceforge.net)
  7. Install the plugins to /usr/local/lib with “sudo make install”. Copy the www directory to the same location.
  8. Start the webcam streamer: mjpg_streamer -o “/usr/local/lib/output_http.so -w /usr/local/lib/www” -i “/usr/local/lib/input_raspicam.so -x 640 -y 480”
  9. Start OctoPrint (“OctoPrint/run”)
  10. Test it by pointing your browser to your raspberry pi’s IP address, port 8080 for the mjpg-stream and port 5000 for OctoPrint
  11. When all that works, put some commands in your /etc/rc.local file to start them both up whenever your Pi boot sup. I used: su pi -c ‘/home/pi/OctoPrint/run’ & AND su pi -c ‘/usr/local/bin/mjpg_streamer -o “/usr/local/lib/output_http.so -w /usr/local/lib/www” -i “/usr/local/lib/input_raspicam.so -x 640 -y 480” ‘ &

My Thoughts: Everything works great on a wired (ethernet) connection, but my wifi adapter is performing extremely poorly for streaming video of the printer. Also, why can’t the camera board just have V4L support out of the box?

Fixing the problem where gparted (parted) won’t see a partition due to a mac partition table

I purchased an external HD that was “mac compatable” but I used it with a linux system and used fdisk to put two partitions on it.

Later on, I wanted to use gparted to easily resize one of the partitions, but it refused to see any partitions at all on the disk.

fdisk could still see them just fine, but reported “Partition type: mac”

It turns out that the problem was that the disk originally came with a mac partition table in addition to (right after) the regular MBR Master Boot Record.

I noticed that the first partition didn’t actually start until 63 sectors into the disk (at the beginning of the 2nd cylinder).

Device Boot Start End Blocks Id System
/dev/sdb1 63 1171893554 585946746 83 Linux

So I used DD to copy the first cylinder to a file:

sudo dd bs=512 count=62 if=/dev/sdb of=firstCyl.bin
62+0 records in
62+0 records out
31744 bytes (32 kB) copied, 0.000715733 s, 44.4 MB/s

Looking at that bin file in an editor, I saw the string “Apple_partition_map” which is a dead givaway of what the problem was.

So, I wrote out all zeros to the first cylinder:

sudo dd bs=512 count=62 if=/dev/zero of=/dev/sdb
62+0 records in
62+0 records out
31744 bytes (32 kB) copied, 0.00165608 s, 19.2 MB/s

And then I copied the first sector (512 bytes) back from the firstCyl.bin file I had made:

summetj@constantine:~$ sudo dd bs=512 count=1 if=firstCyl.bin of=/dev/sdb
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0.00183878 s, 278 kB/s

And it worked! Now gparted is no longer confused by the apple (mac) partition table that I zeroed out, and sees my partition.

dyndns.org (dyn) ddclient configuration fix

I have been using ddclient to update my dynamic dns records for various servers and laptops for many years now. Around a month ago they all stopped updating the DNS server. I eventually tracked the error down to a line in the configuration file:

server=members.dyndns.org

It’s not like I had made up a random server name…this server had been working successfully for several years. And it is the server recommended by the ddclient automatic configuration script generator on the dyndns.org website even now. [https://account.dyn.com/tools/clientconfig.html] However, at least for me on Ubuntu 10.04 and ddclient 3.8.0 it had stopped working.

I changed it over to:

server=members.dyndns.com

And this fixed the problem.

Serial Shift Register MOSFET driver (version 1.1)

My BubbleDisplay project needed to control sixty DC motors or solenoids to control air injection into individual columns of liquid. Due to the large number of outputs needed, I am using a chain of (74HC595) serial shift registers so that three I/O pins can control all sixty outputs. As each serial shift register has 8 outputs, this requires eight chips (for a total of 64 outputs, four are unused). The 74HC595 can not source/sync enough current to drive the motors/solenoids directly, so I am using a TO-220 N-Channel MOSFET rated at 60 volts and 32 amps (digikey: FQP30N06L-ND) to drive the load, with an 1N4001 rectifier diode to handle current spikes. Because I had to make 8 (9 for a hot spare) copies of this circuit, I decided that fabricating a printed circuit board was the only way to go.

Circuit board with 8 LED's and 8 MOSFETS connected to a 74HC595 shift register

It only took me two tries (Moving from Version 1.0 to 1.1) before I was happy with the design, which you can see (populated for testing) above. Looks a lot nicer than the prototype, right?
protoboard with MOSFETS and LED's
Continue reading

Opening winmail.dat files in Thunderbird

Outlook will attach items and forwarded email embedded in a “winmail.dat” file. The winmail.dat file is a TNEF file and Mozilla Thunderbird does not process them natively. The LookOut plugin for Thunderbird will allow you to see the attachments embedded within the winmail.dat file and treat them like normal attachments.