Friday, January 23, 2015

Nano Drivers

Today's Arduino lesson is that not all Arduino Nano v3 boards are the same (and this is probably true for other Arduino models when purchased from different sources). Let's skip over how long it took me to discover that, m'kay? I discovered this by looking in System Information, going to System Report, and looking at what was connected to USB. Get drivers for that, whatever it is.

My first Nano required PL2303 serial drivers. My second Nano needs the more standard FTDI libraries instead. Sparkfun has FTDI installation directions, and those drivers can also be downloaded directly from FTDI.

And just like that, sprinkling a little driver magic over it, this Arduino is now happy to talk to its IDE.

Thursday, January 22, 2015


We all know how fun brain dumps are to read, so move along, nothing to see here.

Today was my second day arguing with learning virsh. Here's what I've learned so far (with some bruises).

Basic virsh


You'll need to install various tools, but that should be readily search-able. I had the tools and some existing VMs as my starting point, but I had a lot to learn.

Create (build) a new VM

  • define (export) NEWVM, OLDVM, HOST, DOMAIN, and ME (assuming your VG, LV, and VM naming scheme matches mine; otherwise, watch out!)
  • sudo lvcreate -n vm_${NEWVM} -L 8192M /dev/vg_${HOST} # from
  • The rest of this is mostly
  • virt-builder --list
  • virt-builder --notes ubuntu-14.04
  • From that, I learned that I want to add --firstboot-command "dpkg-reconfigure openssh-server" to virt-builder.
  • Create a file with your desired initial root password. Mine was /tmp/password.
  • virt-builder ubuntu-14.04 -o /dev/vg_${HOST}/lv_${NEWVM} --firstboot-command "dpkg-reconfigure openssh-server" --root-password file:/tmp/passwd --hostname ${NEWVM}.${DOMAIN}
  • Now I leverage that I already had some working VMs of the same OS type and version:
  • virsh dumpxml ${OLDVM} | sed 's/${OLDVM}/${NEWVM}/g' | grep -v "mac address\|uuid" > ${NEWVM}.xml
  • virsh define ${NEWVM}.xml # persistent VM
  • virsh start ${NEWVM}
  • Alternatively, 'virsh create ${NEWVM}.xml' is a transient VM that goes away when shutdown
  • Very awesomely, console access was available by default! If it weren't, you'll want to configure it.
  • virsh console ${NEWVM} # log in as root with the password set in the file
  • useradd -G sudo -s /bin/bash -d /home/${ME} -m -c "Your Name" ${ME}
  • passwd ${ME} # set your password
  • If console doesn't work, you'll need to use some brute force.
    • virsh domiflist ${NEWVM}
    • ipv6calc --action prefixmac2ipv6 --in prefix+mac --out ipv6addr fe80:: [that MAC]
    • ssh -l root [that IP]
  • Add DNS records for the new VM.
  • When you're done, virsh shutdown ${NEWVM}

Clone a VM

  • Read This was a CentOS 7 clone.
  • virsh list --all
  • virsh shutdown ${OLDVM}
  • virsh list --all # verify that shutdown completed
  • sudo virt-clone --original ${OLDVM} --name ${NEWVM} --prompt # first time, or
  • sudo virt-clone --original ${OLDVM} --name ${NEWVM} -m [previous MAC] --prompt # subsequently, if you're learning by breaking as I did
    • answer /dev/vg_${HOST}/vm_${NEWVM} to prompt if you named yours like mine
  • virsh list --all
  • virsh start ${OLDVM}
  • sudo virt-sysprep --hostname ${NEWVM}.${DOMAIN} --enable cron-spool,dhcp-client-state,dhcp-server-state,logfiles,mail-spool,random-seed,ssh-hostkeys,yum-uuid -d ${NEWVM}
  • virsh start ${NEWVM}
  • The clone has my user account and other niceties, but I don't know its address. Luckily I can use available information and link-local IPv6.
  • virsh domiflist ${NEWVM}
  • ipv6calc --action prefixmac2ipv6 --in prefix+mac --out ipv6addr fe80:: [that MAC]
  • ssh [replace with that IPv6 address]%br0 # replace with your local network interface after '%'
    • grep "${OLDVM}\|${NEWVM}" /etc/hostname # always verify!!!
    • sudo sed -i 's/${OLDVM}/${NEWVM}/g' /etc/hostname
    • grep "${OLDVM}\|${NEWVM}" /etc/hostname # and check my work!
    • sudo vgrename centos_${OLDVM} centos_${NEWVM} # or use lvm, see below
    • grep "${OLDVM}\|${NEWVM}" /etc/fstab
    • sudo sed -i 's/${OLDVM}/${NEWVM}/g' /etc/fstab # only needed if vgrename used
    • grep "${OLDVM}\|${NEWVM}" /etc/fstab
    • grep "${OLDVM}\|${NEWVM}" /etc/default/grub
    • sudo sed -i 's/${OLDVM}/${NEWVM}/g' /etc/default/grub # only needed if vgrename used
    • Now is a good time to add the RHEL7 console tips below!
    • grep "${OLDVM}\|${NEWVM}" /etc/default/grub
    • sudo grub2-mkconfig -o /boot/grub2/grub.cfg
    • grep "${OLDVM}\|${NEWVM}" /boot/grub2/grub.cfg
    • exit # log out of ${NEWVM} now
  • virsh reboot ${NEWVM}
  • Add DNS records for the new VM.
  • virsh shutdown ${NEWVM} # when you're done

Enable Console Access

Typically, you don't care about console access until it's the only way to get out of trouble. So enable it right away if it isn't working yet. Check with 'virsh console ${NEWVM}' and press return at least once to see if you get a login prompt.

The directions for RHEL6 are Edit the /boot/grub/grub.conf file to append this to the kernel line: console=tty0 console=ttyS0,115200

The directions for RHEL7 are, to add the following lines to /etc/default/grub:

GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"
Since mine already had GRUB_CMDLINE_LINUX (to apply it to all the menu entries), I just appended " console=tty0 console=ttyS0,115200n8" to that line inside the quotes, then added the next two lines. Next you need to rebuild the grub.cfg file:
sudo grub2-mkconfig -o /boot/grub2/grub.cfg


[${ME}@${NEWVM} ~]$ sudo lvm
lvm> pvdisplay
lvm> vgrename centos_${OLDVM} centos_${NEWVM}
  Volume group "centos_${OLDVM}" successfully renamed to "centos_${NEWVM}"
lvm> pvdisplay
lvm> lvdisplay
lvm> exit

Loose Ends

sudo virt-inspector -d ${NEWVM}
sudo virt-filesystems -d ${NEWVM}
sudo virt-df -d ${NEWVM}
sudo virt-df
sudo virt-edit -d ${BrokenGuest} /boot/grub2/grub.cfg
sudo virt-rescue -d ${BrokenGuest}

Saturday, January 10, 2015

Canon MX870 Print Head "Repair"

I'm usually cranky when the directions I want are only available on YouTube because I can read much faster than the video plays, and I find the extra time to be excruciating. Seriously, please just tell me in words!

A few months ago, my Canon PIXMA MX870 printer decided that it would mostly print yellow: no cyan printing, and only sometimes the faintest magenta printing. I suppose the other colors weren't cheerful enough? Some searching indicated that the problem was the print head. I tried all of the printer's built-in cleaning routines to no avail. I looked at replacement printers (I mostly print kid pictures), but I decided to see if I could fix it. It wasn't useful the way it was, replacing it seemed likely, so I had nothing to lose for trying. After a while, all remaining hints pointed YouTube. I decided that removing a print head might be best described in a video, so (prepare yourself for the shock!) I watched YouTube videos about printers.

The video that worked for me was "How to remove and clean a Canon printhead" and it delivered on the promise of its title! I thought I might need to watch "The secret on how to remove the Canon print head" but the first video with some gentle but persistent jiggling was sufficient.

What I had to do was to remove the ink carts, then remove the print head. I rinsed the print head in warm water from my kitchen faucet at a low pressure for several days (in between bouts of going about my regularly scheduled life), until I no longer saw any ink bleeding out when I did so. Yes, I spent days rinsing the print head, but it was essentially a free experiment. La, la, la, several days of rinsing and a day of drying later, I re-installed the print head and the ink carts. And my printer worked again! I couldn't believe something so cheap and easy actually resurrected my printer, but it did! I'm so glad I didn't replace it hastily!

Thursday, January 8, 2015

Recycled and Reusable Produce Bag

I thought this was too simple to post, until two weeks ago. I was at the grocery store, and I handed my reusable shopping bags to the checkout clerk. He said, "I'm glad you remembered; sometimes I forget." I replied that's why the bags live in the back of my car, so I can remember them. Then he asked, "Where did you get these produce bags?" I explained that I ran some yarn through the top of plastic mesh bags, and the one he was holding right then was from the turkey I had cooked for Thanksgiving. After a moment of stunned silence on his part, he said, "That's awesome! High five!"

produce bag

So in case it's not completely obvious, start with a plastic mesh bag. For me, the larger ones are more useful, and the most plastic-y ones hold up better. I typically re-use these from bags of onions, but this turkey bag is bigger. Weave a long length of yarn over and under at the top until you've woven all the way around; I used a crochet hook for the weaving. Make sure the yarn is larger than you ever expect to open the expandable mesh bag! I have tried plarn and shoelaces, but yarn slides most easily on the bags I've made. So I don't have to weave the yarn in again, I knot the ends together. Store your produce bags with your reusable grocery bags.

Tuesday, December 23, 2014

TIL: 3-way CFL bulb

I have a set of reading lamps, one everywhere we might sit and read, all with 3-way CFL bulbs. The lamp I use most often only had two settings: two clicks for OFF, two clicks for ON. Since I've had many 3-way incandescent bulbs before, I shrugged, and thought, "that's how it always goes: one filament burns out long before the other." I knew it was CFL, but I didn't put much thought into that because the "failure" mode was familiar. Tonight I decided to replace that bulb. And that's when I discovered it wasn't screwed in all the way. As soon as I screwed the original 3-way CFL bulb in all the way, it had four states again: HIGH, MEDIUM, LOW, and OFF. Now I wish I had checked sooner!

Friday, December 19, 2014

CLI to Google Calendar

After a few weeks of missing my old cli access to Google Calendar, and pushing the Try It! button with no success (yes, I customized it, but no, what I tried didn't work for me), I went looking (again) for another tool.

Hurrah! Look to gcalcli!

First I tried "pip install gcalcli; pip install vobject parsedatetime" but "which gcalcli" came up empty. I read the log file mentioned at the end of the pip install, ran a search on the most obvious error message, and re-ran it with sudo. Now it's working! I recommend "gcalcli list" to start.

The command I expect to use most often is

gcalcli --calendar 'Calendar' --title 'what is it' --where there --when '12/19/2014 10:00 PM' --duration 60 --description 'yay for description field finally!' add --details url
, and next
gcalcli --calendar 'Calendar' quick 'quick add text' --details url
(possibly). I have always wanted to be able to populate the description from the command line, but APIv2 only supported what's in Quick Add. Now that I've got another easy tool, I can forgive APIv3 for moving my cheese since it supports a feature I wanted.

Now if you'll excuse me, I need to pound on this new command line tool ...

Update: Oh, it works so well! I start at Spot the Station, I remove the irrelevant lines (too early, too short, or too low) with PrintWhatYouLike, and then I copy the remaining (relevant) lines.

That then becomes the starting point to fun with regular expressions! Although pbpaste is a Mac OS X tool hailing back to the NeXT days, Linux has tools like xsel and xclip that I hope are roughly equivalent.

clear; pbpaste | awk -F $'\t' '{ print "gcalcli --calendar \"Calendar Name\" --title \"ISS sighting\" --where \"Durham, NC\" --reminder 20 --when \""$1"\" --duration "$2" --description \""$3" max elevation, "$4" approach, "$5" depart\" add --details url" }' | sed 's/\ min\ /\ /g;s/\ above/°\ above/g'; echo

I like to glance at the commands before running them, just to be sure I haven't made some hideous formatting error about to be replicated at the speed of automation, and I like to check at least one of the resulting URIs to be sure the calendar entry survived the transfer. So far, so great!

Friday, December 5, 2014

TIL: Tube Wraps

I looked at these reindeer printable wraps for tp tubes for a minute before running to the bathroom to test my idea. (That's where I could find an empty tp tube, of course!) I measured it, then tested against another brand that of course had slightly different measurements so your mileage may vary.


You do need to be lucky on the intersection of paper sizes (US Letter in my case) and tube sizes, but today I learned you can get four tp tube wraps on a single sheet of paper! I'm thinking of printing some faces, and letting my young artist color to his heart's content! Then my young builder can assemble the village, and peace will reign while they are happily decorating.