Difference between revisions of "Formatting SD cards"

From Pandora Wiki
Jump to: navigation, search
m (Added to tutorial category.)
 
(40 intermediate revisions by 4 users not shown)
Line 1: Line 1:
The Pandora OS can read cards formatted with various filesystems, including
+
[[File:Lead_Photo_For_Formatting_SD_cards0-45858172790466456.png|thumbnail|SD card]]
ext2, ext3, fat32, and if the [http://www.open-pandora.org/downloads/CodecPack.pnd Community Codec Pack] is installed, NTFS. If you have access to a desktop computer, it's a good idea to use the Panasonic SD Formatter, which can improve performance of SD cards.
 
  
==ext3==
+
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.
  
To format a card [[ext3]], insert the card into the Pandora, then open terminal, and type: [http://www.gp32x.com/board/index.php?/topic/54928-64gb-sdxc-cards]
+
== 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 ===
 +
 
 +
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]
  
 
<source lang="bash">
 
<source lang="bash">
sudo fdisk /dev/mmcblk0 (use mmcblk1 for the second slot)
+
sudo fdisk /dev/mmcblk0 # (use mmcblk1 for the second slot)
  
't' then '83' to change the partition type to linux, then 'w' to save.
+
# 't' then '83' to change the partition type to linux, then 'w' to save.
  
sudo mkfs.ext3 -m 0 /dev/mmcblk0p1 (or mmcblk1p1 for the second slot)
+
sudo mkfs.ext4 -m 0 -L volumename /dev/mmcblk0p1 # (use mmcblk1p1 for the second slot)
 
</source>
 
</source>
If you want to set a volume name then type:
 
  
<source lang="bash">sudo mkfs.ext3 -m 0 -L volumename /dev/mmcblk0p1</source>
+
ext4 works well, and fsck is very quick.
 +
 
 +
If you'd rather use ext2 or ext3, run <code>mkfs.ext2</code> or <code>mkfs.ext3</code> 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==
+
=== 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/]
  
 
<source lang="bash">
 
<source lang="bash">
Line 27: Line 54:
 
Once installed, you can format a card like so:
 
Once installed, you can format a card like so:
  
<source lang="text">sudo mkfs.vfat /dev/mmcblk0p1 (or mmcblk1p1 for the second slot)</source>
+
<source lang="bash">
 +
sudo mkfs.vfat /dev/mmcblk0p1 # (or mmcblk1p1 for the second slot)
 +
</source>
 +
 
 +
=== NTFS ===
 +
the [http://www.open-pandora.org/downloads/CodecPack.pnd 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 [http://sourceforge.net/projects/gparted/files/gparted-live-stable/ gparted].
 +
 
 +
=== Using a windows box ===
 +
Use [http://www.sdcard.org/downloads/formatter_4/ 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:
 +
 
 +
<source lang="bash">
 +
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
 +
</source>
 +
 
 +
==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 [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).
 +
 
 +
===Using ''cfdisk''===
 +
 
 +
Assuming your card is in the left slot:
 +
 
 +
<source lang="bash">sudo cfdisk -z /dev/mmcblk0</source>
 +
 
 +
'''WARNING: mmcblk0 will [http://bugs.openpandora.org/index.php?do=details&task_id=237 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 [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.
 +
 
 +
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 =
 +
 
 +
<source lang="bash">
 +
tune2fs -L volumename /dev/mmcblk0p1    # for ext2, ext3, ext4
 +
mlabel -i /dev/mmcblk0p1 ::volumename  # for fat32
 +
</source>
 +
 
 +
----
 +
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.
  
 
[[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.