Difference between revisions of "Formatting SD cards"

From Pandora Wiki
Jump to: navigation, search
(moved formatting up)
m (Added to tutorial category.)
 
(16 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= Formatting SD cards =
+
[[File:Lead_Photo_For_Formatting_SD_cards0-45858172790466456.png|thumbnail|SD card]]
  
The Pandora OS can read cards formatted with various filesystems including ext2, ext3, ext4, fat32. Also, NTFS with added support.
+
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.
 +
 
 +
== Insert Card ==
 +
[[File:SDcardslot.jpg|thumbnail|SD cardslot]]
 +
The openpandora has two fullsize SD-card slots to chose from.
 +
 
 +
== Chose a filesystem to format to ==
 +
 
 +
The [[Ångström|Pandora OS]] can read cards formatted with various filesystems including ext2, ext3, ext4, fat32. Also, NTFS if you install the codec pack.
 +
 
 +
If you want something easy, go with a single ext2 partition, as you need one anyway if you want to put an OS on it. (as per [[Boot_setup]]
 +
If you want to use an ext2 SD-card on Microsoft windows you need this [http://www.ext2fsd.com/]
 +
Same goes for Apple OSX [http://sourceforge.net/projects/fuse-ext2/]
 +
 
 +
If you don't want to install an OS on your card, FAT32 gives good interoperability.
 +
 
 +
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:
 +
 
 +
If you run into problems with formatting the SD card, try unmounting it first:
 +
<source lang="bash">
 +
sudo umount /media/[LABELNAME of SD card]
 +
</source>
  
== ext2, ext3, ext4 ==
+
=== ext2, ext3, ext4 ===
  
 
To format a card with ext4, insert the card into the Pandora, open terminal, and type: [http://www.gp32x.com/board/index.php?/topic/54928-64gb-sdxc-cards]
 
To format a card with ext4, insert the card into the Pandora, open terminal, and type: [http://www.gp32x.com/board/index.php?/topic/54928-64gb-sdxc-cards]
Line 22: Line 44:
 
You can reclaim some space by using fewer inodes, e.g. -N 500000 or -N 1000000 for a 32GB card.
 
You can reclaim some space by using fewer inodes, e.g. -N 500000 or -N 1000000 for a 32GB card.
  
== FAT32 ==
+
=== FAT32 ===
  
 
The software to format FAT32 is not included with the Pandora, but can be easily installed.  Open terminal, and type: [http://www.gp32x.com/board/index.php?/topic/57413-mkfs-vfat-or-mkdosfs][http://boards.openpandora.org/index.php?/topic/1126-format-sd-cards-to-fat32-or-ntfs/]
 
The software to format FAT32 is not included with the Pandora, but can be easily installed.  Open terminal, and type: [http://www.gp32x.com/board/index.php?/topic/57413-mkfs-vfat-or-mkdosfs][http://boards.openpandora.org/index.php?/topic/1126-format-sd-cards-to-fat32-or-ntfs/]
Line 36: Line 58:
 
</source>
 
</source>
  
== NTFS ==  
+
=== NTFS ===  
 
the [http://www.open-pandora.org/downloads/CodecPack.pnd Community Codec Pack] must be installed.
 
the [http://www.open-pandora.org/downloads/CodecPack.pnd Community Codec Pack] must be installed.
  
= Using a windows box =
+
== Formatting options ==
Use [http://www.sdcard.org/downloads/formatter_3/ the Panasonic SD Formatter].
 
  
= Using a live CD on a PC =
+
=== Using a Digital camera ===
Use [http://sourceforge.net/projects/gparted/files/gparted-live-stable/ gparted].
 
  
 +
A digital camera, provided you have one, is a quick and easy way to format an SD card. Put it in, select format, done.
  
==Format SD card==
+
=== Using a live CD on a PC ===
 +
Use [http://sourceforge.net/projects/gparted/files/gparted-live-stable/ gparted].
  
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<sup>[http://www.gp32x.com/board/index.php?/topic/54928-64gb-sdxc-cards/]</sup> and is more reliable<sup>[http://www.gp32x.com/board/index.php?/topic/54928-64gb-sdxc-cards/page-5#entry901072]</sup>. You can have additional paritions, such as swap partition, as well if you like.
+
=== Using a windows box ===
 
+
Use [http://www.sdcard.org/downloads/formatter_4/ the Panasonic SD Formatter].
===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:
 
<source lang="bash">
 
mkfs.ext2 -L LABELNAME /dev/mmcblk0p1
 
</source>
 
or
 
<source lang="bash">
 
mkfs.ext3 -L LABELNAME /dev/mmcblk0p1
 
</source>
 
If you run into problems with formatting the SD card, try unmounting it first:
 
<source lang="bash">
 
sudo umount /media/[LABELNAME of SD card]
 
</source>
 
  
  
Line 80: Line 89:
 
==Partition your SD card==
 
==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.
+
It may be a good idea to set up multiple partitions on your SD card - reasons include wanting to include a separate first FAT32 partition for use on Windows, or having a [[Swap]] partition
  
If you do want to slice your SD card into several partitions (see [[#Setting_up_mutliple-partition_SD_cards_for_booting|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 [http://repo.openpandora.org/?page=detail&app=gparted-gparted graphical tool ''gparted''].
+
If you do want to slice your SD card into several partitions (see [[#Boot_setup#Setting up mutliple-partition SD cards for booting]]), you can use the ''cfdisk'' command-line tool on the Pandora to create a partition table, or you can also download and use the [http://repo.openpandora.org/?page=detail&app=gparted-gparted 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).
 
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).
Line 100: Line 109:
 
===Using ''gparted''===
 
===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.
+
Download the [http://repo.openpandora.org/?page=detail&app=gparted-gparted 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.
 
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.
Line 109: Line 118:
  
  
= Labelling an SD card =
+
= Labeling an SD card =
  
 
<source lang="bash">
 
<source lang="bash">
Line 116: Line 125:
 
</source>
 
</source>
  
==SDIO devices==
 
All SDIO device should work with Pandora, it only requires the device driver to be present and loaded. 
 
 
==SDXC cards==
 
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.
 
 
----
 
----
This guide assumes you have got the operating system of choice at the ready.
+
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:
 
 
 
<source lang="bash">
 
sudo tar -xvjf <tarfile>.tar.bz2 -C <SD card>
 
</source>
 
 
 
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.
 
 
 
<source lang="bash">
 
sudo su
 
mkdir /mp
 
mount --bind / /mp
 
cp -va /mp/* /media/<SD card>
 
umount /mp
 
rmdir /mp
 
exit
 
</source>
 
 
 
 
 
  
 
[[Category:Tutorials]]
 
[[Category:Tutorials]]
[[Category:Filesystem]]
 
[[Category:Storage card]]
 
[[Category:Documentation]]
 

Latest revision as of 21:45, 20 July 2015

SD card

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.

Insert Card

SD cardslot

The openpandora has two fullsize SD-card slots to chose from.

Chose a filesystem to format to

The Pandora OS can read cards formatted with various filesystems including ext2, ext3, ext4, fat32. Also, NTFS if you install the codec pack.

If you want something easy, go with a single ext2 partition, as you need one anyway if you want to put an OS on it. (as per Boot_setup If you want to use an ext2 SD-card on Microsoft windows you need this [1] Same goes for Apple OSX [2]

If you don't want to install an OS on your card, FAT32 gives good interoperability.

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:

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

sudo umount /media/[LABELNAME of SD card]

ext2, ext3, ext4

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

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: [4][5]

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.

Formatting options

Using a Digital camera

A digital camera, provided you have one, is a quick and easy way to format an SD card. Put it in, select format, done.

Using a live CD on a PC

Use gparted.

Using a windows box

Use the Panasonic SD Formatter.


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

It may be a good idea to set up multiple partitions on your SD card - reasons include wanting to include a separate first FAT32 partition for use on Windows, or having a Swap partition

If you do want to slice your SD card into several partitions (see #Boot_setup#Setting up mutliple-partition SD cards for booting), 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.


Labeling 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.