Posts Tagged ‘Raspberrypi’

How to write an image out to SD card using DD

January 1, 2014 Leave a comment

Here’s my quick n dirty reminder on how to write out an image for my Raspberry Pi to an SD card in my Mac (but should work for any version of Linux).

The steps are simple:

  1. Put the SD card in, and find out what device it has been assigned to
  2. Unmount it
  3. Write the image out to the SD card

Find out which disk device we should be writing to with:

diskutil list
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *250.1 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Untitled                249.2 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *15.9 GB    disk1
   1:             Windows_FAT_32                         73.4 MB    disk1s1
   2:                      Linux                         7.9 GB     disk1s2

unmount the disk with something like this

diskutil umount /dev/disk1s1

Write the image to disk with the following.

sudo dd if=/Users/david/Desktop/raspxbmc.img of=/dev/rdisk1 bs=32m

You can monitor the progress by pressing ctrl+t (not command+t)

Note: We’re using rdisk (raw-disk) as our out file and not disk, and that we’re reading/writing blocks 32Mb at a time, instead of 1 byte to speed things up.

Categories: Raspberry Pi Tags:

Raspberry Pi as a mail server

August 31, 2013 Leave a comment

Having recently been married, I wanted to setup a more family oriented email address for my wife and I, and with an eye on the future, for the kids to use too.

After spending ages trying to find a decent domain name that a) made sense and b) wasn’t already taken, this morning I registered

Having registered a domain name the next step was to find a mail provider, however my default go to was google who host my other mail domains, but google apps is no longer free, so I started researching other providers. Zoho are still free up to 5 users which might be OK, so I book marked them and moved onto the next challenged, finding a DNS provider.

It seems DNS services don’t come cheaply, and my usual provider, DynDNS wanted 30 bucks a year! So I go to thinking…..

I had a domain name and just needed …
DNS services
SMTP/POP3/IMAP services
Spam filters
Antivirus services

I looked over at my £30 raspberry Pi that sat under the TV, nonchalantly running a media service… I wonder…

If I added DynDNS to the list so that I could point my domain name to my RPi, then I could use Bind, Postfix, ClamAV and SpamAssassin all for free. In effect running the whole mail server on one little tiny low power box.

So let the project begin!

Backing up your Pi’s

August 2, 2013 Leave a comment

Backing up your Raspberry Pi isn’t very straight forward on a Mac, but if like me you’re short on memory cards and you want to keep what you’ve been working on so that you can go back to it later, then you’ll need to start backing them up.

The easiest way is going to be to make a full disk image of the memory card, so that you can be sure you have an exact replica of the file system.

Here’s how I do mine now.

Open a Terminal window and type “diskutil /list”. This will give you a list of disks currently attached to your Mac. The first one will be the main disk inside the Mac, and then any after that will either be your SD card, or could also be another disk image you have mounted. If you look at the Size column, you should be able to find which one matches the size of your SD card.
Once you’ve found the right card, over on the left is the device number that the MacOS allocated it when you plugged it in. In my case, my 8GB SD Card is allocated to /dev/disk1
diskutil list
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *250.1 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS MacOS                   249.7 GB   disk0s2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *7.9 GB     disk1
   1:             Windows_FAT_32                         73.4 MB    disk1s1
   2:                      Linux
Once we know the disk number, we’re going to add an ‘r’ in front of the disk part to access it much quicker (just means that your back up will be quicker.  To back up the disk use this command:
sudo dd if=/dev/rdisk1 of=media.img bs=1m
This will create a file called ‘media.img’ which is an image of your SD card (you can call it whatever you like).
To restore the image you’d just use
sudo dd if=image of=/dev/rdisk1 bs=1m
(assuming that your SD card is still /dev/disk1 when you plug it back in).
  • On my Mac, the 8GB card took about 20 mins to back up.
  • If you want to compress the image, you can use something like this: udo dd if=/dev/rdisk1 bs=1m | gzip > media.img.gz (to restore an compressed image with “bunzip2 -dc media.img.bz2 | dd of=/dev/disk1”