Blog

Tables in Markdown

A short post to remind myself how to write tables in GitHub Flavoured Markdown (GFM), hence, on this blog.

Basically, it comes down to using ----- to separate the header row from the rest of the rows, and separating columns using |.

E.g.

| First column         | Second column      | Last column      |
|----------------------|--------------------|------------------|
| First row, first col | 1st row, 2nd c     | Something else   |
| _Second row_         | isn't this **nice**| 2nd row, last col|
| Third row            | ~~strikethrough~~  |                  |

renders as

First column Second column Last column
First row, first col 1st row, 2nd c Something else
Second row isn’t this nice 2nd row, last col
Third row strikethrough

As this demonstrates, you can use normal markdown within table cells, though as usual with markdown, block level elements probably don’t nest well.

Alignment for columns is specified using : in the header separator row:

| Left aligned      | Centre aligned        | Right aligned |
|-------------------|:---------------------:|--------------:|
| Left data         | Centre data           | Right data    |

renders as

Left aligned Centre aligned Right aligned
Left data Centre data Right data

Finally, you don’t need to nicely align the raw markdown in order for the table to be nicely aligned when it’s rendered. It just makes it nicer when reading the raw, which is most of the point of markdown, after all!

Viewing progress of dd

This is a quick note to remind myself how to get the progress of a dd command.

Sending the USR1 signal to a running dd process causes it to output I/O stats to stderr and then continue.

To send a signal to a process use pkill -<signal> <process name>. The options -x and -n restrict to exact matches of the process name and the newest matching process respectively.

Thus for the most recent dd to be started the following will work:

pkill -USR1 -n -x dd

Raspbian partition shenanigans

This post is a summary of all the stuff related to moving the root partition to a USB drive and what to do if/when the boot partition gets corrupted in this situation.

Moving root partition

This is straightforward, just the normal procedure for copying a partition from one device to another. Various options include:

  1. use dd to just copy the partitions (not reccomended, simply because it will require some calculation of offsets)

  2. create a new ext4 partition on the new device and copy everything across, probably using rsync

  3. I think gparted allows you to do this from a gui, but I can’t remember precisely. In any case this is basically the same as option 2 above.

The only thing left to do is to tell the raspi to use this new partition. The way to do this is to edit the file /boot/cmdline.txt and change it to look like this:

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/sda3 rootfstype=ext4 elevator=deadline rootwait rootdelay=5

i.e., change root=/dev/whatever to root=/dev/new-partition-device, making sure to check which partition really is the new root partition and also adding the rootdelay=5 option in case the USB device is a bit slow to come online.

That’s it!

Boot partition corruption

When/if the boot partition gets corrupted, and you’re running the filesystem from a USB device, it’s useful to be able to re-image only the boot partition from a Raspbian image. To do this, kpartx is very useful.

What kpartx -av someimage.img does is to create a new loop device and then link all the partitions in the image file to partitions in the loop device. In effect, you end up with devices /dev/mapper/loop0p1, /dev/mapper/loop0p2, etc. which are simply the partitions in the image file. You can then mount these, or just dd them to your SD card boot partition.

Another useful thing is to make an image of your boot partition at regular intervals, so you can simply re-image when necessary rather than starting again with the default raspbian boot partition.

Hopefully I won’t need to this again for a while, but now when I do, at least I’ve got an offline reference!

Future Raspi projects

This is a post to list interesting sounding potential projects for a Raspberry Pi.

  1. Waterproof, portable time-lapse photography setup.

    Requires:

    • Camera module or webcam
    • Running from battery pack
    • Maybe some attempt to minimise power consumption

    Variation on this idea: Night-vision wildlife camera. Very cool! Quite a lot of work involved.

  2. Run Haskell on it.

    The main difficulty with this is how long it will take to compile anything , especially if using cabal, and apparently it’s easy to run out of memory doing this. Alternatively, it might be possible to get a ghc cross compiler working, but this probably won’t be simple.

  3. Light alarm clock

    This is a very cool project, and would be very useful for people who can’t get up in the morning, like me! I don’t have the woodworking skills necessary for this as it is done here, but maybe using something like this Ikea light as the enclosure might be feasible.

  4. Run RetroPie on it.

    This one is just a matter of time. I don’t think I can resist doing this one. The only thing it will need is some time and a Xbox 360 Wireless Gaming Receiver so I can use the Xbox wireless controllers I already have. The receiver should cost at most €15.

  5. Make a Pi powered digital photo frame. Something like this one but costing less, hopefully. This would allow all sorts of things, like automatically showing photos from Flickr, or videos, or anything!

  6. Apparently, you can use a Kinect with linux now, and this is even possible on the Pi! No idea what I would actually do with it, but as I already have a Kinect, this is tempting to play around with just because it doesn’t need any expenditure.

See this Reddit post for some more ideas.