Imager
Why re-invent the wheel?
This is a simple script to create a disk image from an existing, working SD card. It works on OSX, but would probably work on your particular linux distro.
Usage
./bin/create-image.sh disk2
Where disk2
is the location of the sd card found in diskutil list