Formatting SD cards

From Pandora Wiki
Revision as of 04:05, 16 October 2013 by Kingu (talk | contribs)
Jump to: navigation, search

All SDIO device should work with Pandora, it only requires the device driver to be present and loaded. There is no electronic or physical difference between SDHC and SDXC. Cards with larger capacities are marketed as SDXC. Most SDHC and SDXC cards will work in the Pandora USB_compatibility_list. provided they are formatted with a compatible filesystem, such as FAT32 or EXT2/3. Cards that preformatted with exFAT need to be formatted to compatible filesystem.

Formatting SD cards

The Pandora OS can read cards formatted with various filesystems including ext2, ext3, ext4, fat32. Also, NTFS with added support.

ext2, ext3, ext4

To format a card with ext4, insert the card into the Pandora, open terminal, and type: [1]

sudo fdisk /dev/mmcblk0  # (use mmcblk1 for the second slot)

# 't' then '83' to change the partition type to linux, then 'w' to save.

sudo mkfs.ext4 -m 0 -L volumename /dev/mmcblk0p1  # (use mmcblk1p1 for the second slot)

ext4 works well, and fsck is very quick.

If you'd rather use ext2 or ext3, run mkfs.ext2 or mkfs.ext3 instead, with the same options.

Another option you can use, -N sets the number of inodes (max file count). You can reclaim some space by using fewer inodes, e.g. -N 500000 or -N 1000000 for a 32GB card.

FAT32

The software to format FAT32 is not included with the Pandora, but can be easily installed. Open terminal, and type: [2][3]

sudo opkg update
sudo opkg install dosfstools

Once installed, you can format a card like so:

sudo mkfs.vfat /dev/mmcblk0p1 # (or mmcblk1p1 for the second slot)

NTFS

the Community Codec Pack must be installed.

Using a windows box

Use the Panasonic SD Formatter.

Using a live CD on a PC

Use gparted.


Format SD card

If you didn't use gparted to partition and format your card, you need to format your SD card to have at least an ext2 partition; ext3 also works[4] and is more reliable[5]. You can have additional paritions, such as swap partition, as well if you like.

Using the command line

Take care with using these command line tools, to be certain you are accessing the correct device. They will not ask you and will DESTROY any data on the device. This command will replace an existing partition with an empty EXT2 formatted filesystem (this includes the single FAT partition most SD cards come shipped with). Assuming /dev/mmcblk0p1 for your SD device (left slot, first partition), LABELNAME for the partition:

mkfs.ext2 -L LABELNAME /dev/mmcblk0p1

or

mkfs.ext3 -L LABELNAME /dev/mmcblk0p1

If you run into problems with formatting the SD card, try unmounting it first:

sudo umount /media/[LABELNAME of SD card]


Partitions

SD cards perform much better when the partitions are aligned correctly, starting at 4MB. This is important!

If your partitions are messed up, you can fix them using the Panasonic SD Formatter, or using parted:

Dev=/dev/mmcblk0   # or mmcblk1 for 2nd slot
FS=ext4            # or fat32
sudo parted -s $Dev mklabel msdos
sudo parted -s $Dev unit cyl mkpart primary $FS -- 0 -2

Partition your SD card

This is an optional step for cards<=32GB formatted to FAT32. It may be a good idea to set up multiple partitions/slices on your SD card - reasons include wanting to include a separate first partition for use on Windows, having a swap partition, or separating your kernel image from your root filesystem in case of filesystem corruption.

If you do want to slice your SD card into several partitions (see Setting up mutliple-partition SD cards), you can use the cfdisk command-line tool on the Pandora to create a partition table, or you can also download and use the graphical tool gparted.

Note that - as of Zaxxon HF5 - the Pandora firmware doesn't have a command to format FAT partitions, so if you want to use the FAT/ext2/swap - scheme, you'll have to format the first partition on another system later on (under Windows, use the Disk Management tool).

Using cfdisk

Assuming your card is in the left slot:

sudo cfdisk -z /dev/mmcblk0

WARNING: mmcblk0 will not necessarily be the left slot. It's the first card that the system recognizes, which is usually the left slot (but not if you inserted an SD into the left slot after you had one in the right slot, for example). Please make sure before you do anything dangerous e.g. use 'mount' to see what filesystems you recognise are mounted from where.

cfdisk -z starts off with a clean partition table - if you want to see what's set up currently, use cfdisk /dev/mmcblk0.

Use only primary partitions (so you're limited to four slices).

Using gparted

Download the gparted PND and install it. Note: this generally requires having a second SD card to install it to, though it should be possible to install it to the /pandora folder in your filesystem root, which will install it to NAND.

Find the program under 'System' in the menu and launch it. WARNING: It will start off pointing at /dev/mmcblk0 which is usually your left slot, but may not be. You can switch between the two card slots (if you have a card in each) and deduce which is which from the graphical display and the partition labels, but please be sure before applying any changes. Selecting 'information' from the right-click menu will also show you where each partition is mounted on the root filesystem, if it is currently mounted.

If the system has automounted the existing partition it'll show as locked and you'll need to unmount it using the right-click menu before you'll be able to change it. In this case, you'll probably want to delete it and create new partitions. Note that whatever partition your end up installing your boot/autoboot.txt to must be either ext2 or FAT, but you have a freer choice of filesystems to use on other partitions.

Once you've decided on your partitions and marked up the changes you'll need to apply them. Use the Apply All Operations menu item from the Edit menu. Then sit back and wait as it repartitions and reformats your card.


Labelling an SD card

tune2fs -L volumename /dev/mmcblk0p1    # for ext2, ext3, ext4
mlabel -i /dev/mmcblk0p1 ::volumename   # for fat32

This guide assumes you have got the operating system of choice at the ready. Check out the many different OSes available and pick your favourite from software section.

Copy the files to your SD card

Navigate (cd) to the directory with the .tar.bz2 file you just downloaded (or made) and do:

sudo tar -xvjf <tarfile>.tar.bz2 -C <SD card>

If you're doing this on your Pandora, <SD card> is something like /media/mmcblk0p1 (first SD card slot on Pandora). On Ubuntu it would be something like /media/disk if it has no label. You can also try using GUI tools for this, but I didn't have very good luck with them.

OR copy your firmware from the NAND to the SD card

The following will ask for your password. All the operations need root permissions so I thought it would be wasteful to sprinkle sudo to everything. We will bind mount the root fs to an alternative location ("/mp"), under which other filesystems mounted under root (like the kernel virtual filesystems /proc and /sys, and your SD card.) wont be visible. This allows us to take a live copy of the NAND contents to the SD filesystem.

sudo su
mkdir /mp
mount --bind / /mp
cp -va /mp/* /media/<SD card>
umount /mp
rmdir /mp
exit