SD cards are not really a reliable storage, especially when used constantly e.g. while sitting in always powered-on Raspberry Pi. Because of that I’ve recently needed to perform lots of backup/restore operations
I wrote this script for backing up:
#!/bin/bash if [[ -z $1 ]]; then echo "usage: $0 device_to_clone" exit fi device=$1 timestamp=`date +%Y%m%d` dest_file="/tmp/$timestamp.dd.xz" echo "about to clone $device to $dest_file" echo "ctrl-c or [enter]" read sudo umount $device? sudo umount $device sudo sync sudo pv -tpreb $device | dd bs=4M | pixz > $dest_file sudo sync
And this one for restoring:
#!/bin/bash if [[ -z $1 ]] || [[ -z $2 ]]; then echo "usage: $0 restore_file.xz device_to_restore_to" exit fi source_file=$1 if [[ ! -f $source_file ]]; then echo "cannot open $source_file" exit fi device=$2 echo "about to restore $source_file onto $device" echo "ctrl-c or [enter]" read sudo umount $device? sudo umount $device pv -tpreb $source_file | pixz -d | sudo dd bs=4M of=$device sudo sync sudo eject $device
Some of the more fun features include progressbars and making sure you’ve unmounted the device properly before
This also uses parallel threads to deflate the data, so the XZ compression should not be a bottleneck on any modern machine.
The scripts above were used to backup and restore SD cards but will work for any block device, be it an external or internal disk drive, etc.
usage example [remember to use the whole device, not just its partition as an argument]:
./backup_sdcard /dev/sdc about to clone /dev/sdc to /tmp/20150214.dd.xz ctrl-c or [enter] [sudo] password for cyryl: umount: /dev/sdc1: not mounted umount: /dev/sdc2: not mounted umount: /dev/sdc: not mounted 19,6MiB 0:00:02 [9,72MiB/s] [> ] 0% ETA 0:52:26
It was some time since the last photo-story so, please accept these pictures of my standing desk.
On the actual desk, there is a laptop stand serving a role of a keyboard and mouse rest. Laptop itself is flipped on its back, motherboard attached to the back of what once was a lid. The whole thing is flying on standard monitor desk mount, using custom vesa-to-acrylic mounting system
Recently I’ve started working on changing my default development workflow. I’m evaluating vagrant as a main env manager, and then docker for extra speed. In short, my
vagrant up boots up new dev box and then couple of docker containers. What I’ve found is that there is not really a plethora of GUI-enabled vagrant boxes, so I’ve created one !
If you want to use it, go:
vagrant init cyplo/ubuntu-gnome-utopic-gui vagrant up
I will write about the whole setup later, as I’m not yet sure what approach is best for me.
I gave a talk this Monday, an important one I think. The one from the kind of spreading knowledge on the safe internet usage to people not necessarily of the tech background.
This was my first one given to a such audience and to add to it all, it was given in Polish. The biggest challenge ? Finding good equivalent for the English tech terms.
I think the talks went quite okay and the discussion afterwards was quite lively. I said a bit on how the internet works and what’s wrong with that, to transition later to what problems Tor addresses and which it does not. I tried to emphasize that using Tor does not make you automatically immune to the dangers of the internet.
Big thanks to the organizers, Praxis student group from the Wroclaw University of Economy.
You can find my slides’ sources here, along with speaker notes.
Eagle is still the first choice when it comes to Open Hardware electronics design. That’s a bit unfortunate because the software itself is proprietary. Sometimes you need to run it though. For example to migrate projects over to non-proprietary software !
Say, you’d like to run new Eagle 7.1 under Ubuntu ?
Repos have the old major version 6 only.
The harder to get proprietary software the better, I suppose.
Download the blob then:
$ wget -c http://web.cadsoft.de/ftp/eagle/program/7.1/eagle-lin-7.1.0.run $ chmod a+x eagle-lin-7.1.0.run
Inspect and run the stuff:
$ vim eagle-lin-7.1.0.run $ ./eagle-lin-7.1.0.run Ensure the following 32 bit libraries are available: libXrender.so.1 => not found libXrandr.so.2 => not found libXcursor.so.1 => not found libfreetype.so.6 => not found libfontconfig.so.1 => not found libXi.so.6 => not found libssl.so.1.0.0 => not found libcrypto.so.1.0.0 => not found
32bit craziness, you say.
New Ubuntu does not have ia32 libs prepackaged, you say ?
Here, have this handy list of all of the dependencies then:
$ sudo apt-get install libxrandr2:i386 libxrender1:i386 libxcursor1:i386 libfreetype6:i386 libfontconfig:i386 libxi6:i386 libssl1.0.0:i386 libcrypto++9:i386 # should show you the installation wizard [sic !] $ ./eagle-lin-7.1.0.run
I’m a bit cautious when it comes to storing my passwords and other secrets. I do not use any web or desktop applications to do this for me. How do I remember those passphrases then ?
I have a central file server, accessible via a tunnel. I store there a gpg-encrypted file containing a tar archive of a directory with various files containing secrets. Syncing these files across computers became a bit cumbersome lately. I’m using git to version them, but because I do not want to have the sync server to contain unencrypted secrets I needed to bake some custom solution.
Bash to the rescue !
There are still some assumptions made here about permissions, directories layout and some stuff not failing, but I’m sure you’ll be able to figure this out and tweak to your needs.
#!/bin/bash TUNNEL_CREDS="user@tunnelhost" TUNNEL_PORT=123 STORAGE_CREDS="storage_user@localhost" STORAGE_ADDRESS="storagehost.example.org" SOCKET="/tmp/black_socket" REMOTE_VAULT_PATH="/somepath/.vault.tar.gpg" TMP_VAULT="/tmp/.vault.tar.gpg" TMP_VAULT_TAR="/tmp/.vault.tar" TMP_VAULT_DIR="/tmp/.vault" TMP_LOCAL_PORT=10022 LOCAL_VAULT_DIR="$HOME/.vault" LOCAL_VAULT_BACKUP_DIR="$LOCAL_VAULT_DIR.bak" pushd `pwd` echo "removing old vault backup at $LOCAL_VAULT_BACKUP_DIR" rm -rI "$LOCAL_VAULT_BACKUP_DIR" set -e echo "backing up local vault..." cp -r "$LOCAL_VAULT_DIR" "$LOCAL_VAULT_BACKUP_DIR" echo "establishing tunnel ..." ssh -L $TMP_LOCAL_PORT:$STORAGE_ADDRESS:22 $TUNNEL_CREDS -p $TUNNEL_PORT -N -f -M -S "$SOCKET" echo "tunnel ready, copying remote version of the vault..." rsync --progress -avz -e "ssh -p $TMP_LOCAL_PORT" "$STORAGE_CREDS:$REMOTE_VAULT_PATH" "$TMP_VAULT" echo "decrypting new vault..." gpg -d "$TMP_VAULT" > "$TMP_VAULT_TAR" echo "unpacking new vault..." mkdir -p "$TMP_VAULT_DIR" tar xf "$TMP_VAULT_TAR" -C "$TMP_VAULT_DIR" echo "pulling from remote vault..." cd "$LOCAL_VAULT_DIR" git pull "$TMP_VAULT_DIR" echo "pulling to remote vault..." cd "$TMP_VAULT_DIR" git pull "$LOCAL_VAULT_DIR" echo "cleaning up a bit..." rm -fr "$TMP_VAULT_TAR" rm -fr "$TMP_VAULT" echo "packing refreshed remote vault..." tar pcf "$TMP_VAULT_TAR" -C "$TMP_VAULT_DIR" . echo "encrypting refreshed remote vault..." gpg -c "$TMP_VAULT_TAR" echo "sending out updated vault" rsync --progress -avz "$TMP_VAULT" -e "ssh -p $TMP_LOCAL_PORT" "$STORAGE_CREDS:$REMOTE_VAULT_PATH" echo "cleaning up.. " rm -fr "$TMP_VAULT_DIR" rm -fr "$TMP_VAULT_TAR" rm -fr "$TMP_VAULT" echo "closing tunnel.." ssh -S "$SOCKET" -O exit $TUNNEL_CREDS popd
I had some troubles compiling git 2.0 under cygwin. I present you with a very dirty hack to do so. Proper patch will probably follow.
Did I mention that the hack is dirty and will make your hands burn if you’re gonna type it in ?
git clone https://github.com/git/git.git cd git git checkout v2.0.1 autoconf ./configure # so far so good... make # oops # .... SUBDIR perl make: /home/cplotnicki/dev/git/perl/0: Command not found perl.mak:375: recipe for target 'blib/lib/.exists' failed make: *** [blib/lib/.exists] Error 127 Makefile:16: recipe for target 'all' failed make: *** [all] Error 2 Makefile:1653: recipe for target 'all' failed make: *** [all] Error 2
Want perl as ‘0’ ? Well, why not. Here you are:
# link perl as 0 to some directory that is in your path ln -s /usr/bin/perl ~/tools/0 # also link here, obviously. # 'perl' is a direct subdir for your git checkout ln -s /usr/bin/perl perl/0 make # should now compile # cygwin's permission scheme is very peculiar # here, have a dirty hack for your default install # where there is no su or sudo chmod a+rwX -R /usr/local/share/man/man3 chmod a+rwX -R /usr/local/lib/perl5/site_perl make install git --version # should display 2.0.1. # update man pages' cache manually /etc/postinstall/man-db.sh
No need to re-introduce PoC or GTFO here.
Just download it already !
I find it useful to hang as much stuff as possible on the walls, instead of using shelf/floor/desk space for that.
Here is just a quick hack I did to allow filament spools to be mounted securely to a wall. It turns out that if you cut off the bent part the rod it fits perfectly into the spool’s handle hole.