Web Analytics
Privacy Policy Cookie Policy Terms and Conditions

Skeleton SD card image for the Raspberry Pi

This image is used by the Woof build system, which is used to create Puppy Linux. The image file has three partitions, all formatted with filesystems, but empty -- Woof will fill them with the required files to boot Puppy.

The SD image file is named 'raspi-sd-4gb-skeleton-ext4_nojournal-09jul2012.img', or in compressed form 'raspi-sd-4gb-skeleton-ext4_nojournal-09jul2012.img.xz'.

As well as having ext4 filesystem in the second partition (without journal), the partitions are aligned on 4MB boundaries. The reasons for these settings is described here:
http://bkhome.org/blog/?viewDetailed=02884
http://bkhome.org/blog/?viewDetailed=02883
http://wiki.laptop.org/go/How_to_Damage_a_FLASH_Storage_Device

For news about later SD image files, please monitor my blog:
http://bkhome.org/blog/

How to write image to an SD card

You need a 4GB or larger card, and Class 6 or faster is highly recommended (apart from being very slow, Class 4 is reported to be unreliable in the Raspberry Pi).

For the example of the card being /dev/sdb:

...make sure card is not mounted!...

Be absolutely certain that the SD card is /dev/sdb, not your hard drive! Then do this is in a terminal (if you are not running as root (administrator), you will have to append "sudo" before each line):

# unxz --stdout raspi-sd-4gb-skeleton-ext4_nojournal-09jul2012.img.xz | dd of=/dev/sdb bs=4M
# sync

...always run "sync" afterward, before removing SD card.

The partitions on the SD card

There are three partitions:
  1. vfat 75MB
  2. ext4 (no journal) 3.26GB
  3. swap 256MB
The partitions are aligned as follows:
  1. Start-offset: 1,048,576 bytes  Size: 78,643,200 bytes
  2. Start-offset: 83,886,080 bytes Size: 3,502,243,840 bytes
  3. Start-offset: 3,590,324,224 bytes   Size: 268,427,264 bytes
The start of partition #2 (ext4) is aligned on a 8MB boundary, the end on a 4MB boundary.
The start of partition #3 (swap) is aligned on a 8MB boundary.
There is a 4MB gap between each partition.

The advantage of knowing these offsets is that you can mount a partition in the file, without having to write the file to an SD card. For example, to mount the first partition:
# unxz raspi-sd-4gb-skeleton-ext4_nojournal-09jul2012.img.xz
# mkdir /mnt/sdimagep1
# mount -t vfat -o loop,offset=1048576 raspi-sd-4gb-skeleton-ext4_nojournal-09jul2012.img /mnt/sdimagep1
...access the files in /mnt/sdimagep1
# sync
# umount /mnt/sdimagep1

Ext4 without journal

The reason for not having a journal is primarily to minimise writes to the Flash memory. There is also a small speed improvement.

This is how it was created, assuming the second partition to be /dev/sdb2 (partition must be unmounted):
# mke2fs -t ext4 -O ^has_journal -L puppy -m 0 -b 4096 /dev/sdb2
Be careful when you plug your SD card into a computer, as most Linux distros will mis-report the filesystem as ext2, and will not be able to mount it. It must be mounted as ext4:
# mount -t ext4 /dev/sdb2 /mnt/sdimagep2
The very latest build of Puppy Linux (as at July 9, 2012) reports the f.s. correctly.

Regarding f.s. corruption, as for example power-failure while using your RP, unfortunately having a journal does not guarantee safety and can lead to a false sense of security. A journal will mostly safeguard the filesystem hierarchy but files can get corrupted, and in fact there is a high likelihood of that happening.

You might find this web page interesting reading, "Ext3 and RAID: Silent Data Killers?" (it applies to ext4 also):
http://lwn.net/Articles/349970/

In the case of power-failure or any other abnormal shutdown, Puppy will automatically run a filesystem check at next bootup. The way this is done is if Puppy detects a prior abnormal shutdown, a ramdisk is created with a mini-Linux inside it, the main partition (#2) is unmounted and it's f.s. checked, then reboot.
This f.s. check will repair errors, but as for ext4 with journal there is no guarantee that files haven't been corrupted. It would be wise to examine whatever files you might have been working on at the time of the abnormal shutdown.

How to copy image off the SD card

The image file is actually less than the size of a 4GB card. This is so it can fit on a wide range of 4GB cards, including the cheatiest cheap ones that actually have far less than 4GB on them

The size of the image is 3,858,759,680 bytes, which is 3.59GB. This equates to 920 4MB blocks, and it is recommended to read from the SD card with 4MB block size, like this:
# dd if=/dev/sdb of=raspi-sd-4gb-skeleton.img count=920 bs=4M
# sync

Have fun!
Barry Kauler
09 July 2012