0. Download the image file from official site. Do the checksum verification so that the downloaded file is not corrupted.
$ sha1sum 2012-12-16-wheezy-raspbian.zip 514974a5fcbbbea02151d79a715741c2159d4b0a 2012-12-16-wheezy-raspbian.zip
1. Uncompress the file.
$ unzip 2012-12-16-wheezy-raspbian.zip Archive: 2012-12-16-wheezy-raspbian.zip inflating: 2012-12-16-wheezy-raspbian.img
2. Put in the SD card and use the disk free (df) command to find the device name. Our device name is NOT /dev/mmcblk0p1, that is the first partition, hence p1. The actual device name is /dev/mmcblk0.
$ df -h Filesystem Size Used Avail Use% Mounted on /dev/mmcblk0p1 15G 32K 15G 1% /media/kianmeng/3265-3765
3. Unmount the device before we can write the image to the SD card.
$ umount /dev/mmcblk0
4. According to the wiki, there are two command line ways to write the image, namely using disk dump (dd) or enhanced disk dump (dcfldd). I had tried both ways and prefer disk dump (dd) program as you can see more information shown below. Image writing roughly took 646 seconds which is around 10 minutes.
4a. Using enhanced disk dump (dcfldd)
$ sudo apt-get install dcfldd $ sudo dcfldd bs=4M if=2012-12-16-wheezy-raspbian.img of=/dev/mmcblk0 256 blocks (1024Mb) written. 462+1 records in 462+1 records out
4b. Using plain old disk dump (dd)
$ sudo dd bs=4M if=2012-12-16-wheezy-raspbian.img of=/dev/mmcblk0 462+1 records in 462+1 records out 1939865600 bytes (1.9 GB) copied, 646.172 s, 3.0 MB/s
5. Make sure everything is written to the SD card.
$ sudo sync
6. To view the file system layout of the image, we will install the graphical partition editor. You can use this program to create the new /data partition to utilize the free space in the card.
$ sudo apt-get install gparted $ sudo gparted /dev/mmcblk0
7. We will follow command line method to create a extra /data partition.
$ sudo apt-get install parted $ sudo parted /dev/mmcblk0 GNU Parted 2.3 Using /dev/mmcblk0 Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) unit chs (parted) print Model: SD SU16G (sd/mmc) Disk /dev/mmcblk0: 1936,229,20 Sector size (logical/physical): 512B/512B BIOS cylinder,head,sector geometry: 1936,255,63. Each cylinder is 8225kB. Partition Table: msdos Number Start End Type File system Flags 1 0,130,2 7,165,29 primary fat16 lba 2 7,165,30 235,214,42 primary ext4
7a. Contrary to the wiki instruction, we will not round up the chs (cylinders, head, sector) addressing.
(parted) mkpart primary 235,214,43 1936,229,20 (parted) print Model: SD SU16G (sd/mmc) Disk /dev/mmcblk0: 1936,229,20 Sector size (logical/physical): 512B/512B BIOS cylinder,head,sector geometry: 1936,255,63. Each cylinder is 8225kB. Partition Table: msdos Number Start End Type File system Flags 1 0,130,2 7,165,29 primary fat16 lba 2 7,165,30 235,214,42 primary ext4 3 235,214,43 1936,229,20 primary
7b. Rounding of chs value will cause incorrectly partition alignment. See example below.
(parted) mkpart primary 236,0,0 1936,229,20 Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel?
8. Quit parted program, format and label the partition. See the partition layout after this step using gparted program.
$ sudo mkfs.ext4 /dev/mmcblk0p3 $ sudo e2label /dev/mmcblk0p3 data
9. To make sure we can automount the /data partition in the SD card, add this line to the file system table (/etc/fstab) file.
$ vi /etc/fstab /dev/mmcblk0p3 /media/pi ext4 defaults 1 2
10. Mount the new partition and see the content. You should obtain below result.
$ sudo mkdir /media/pi $ sudo mount /media/pi $ cd /media/pi $ ls lost+found/