My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
LinuxBootDiskFormat  
How to create a dual-partition card for BeagleBoard to boot Linux from first partition and have root file system at second partition.
Phase-Deploy, Type-Howto
Updated Jul 27, 2011

Introduction

This guide is meant for those looking to create a dual-partition card, booting from a FAT partition that can be read by the OMAP3 ROM bootloader and Linux/Windows, then utilizing an ext3 partition for the Linux root file system.

Details

Text marked with shows user input.

Determine which device the SD Card Reader is on your system

Plug the SD Card into the SD Card Reader and then plug the SD Card Reader into your system. After doing that, do the following to determine which device it is on your system.

$ [dmesg | tail]
...
[ 6854.215650] sd 7:0:0:0: [sdc] Mode Sense: 0b 00 00 08
[ 6854.215653] sd 7:0:0:0: [sdc] Assuming drive cache: write through
[ 6854.215659]  sdc: sdc1
[ 6854.218079] sd 7:0:0:0: [sdc] Attached SCSI removable disk
[ 6854.218135] sd 7:0:0:0: Attached scsi generic sg2 type 0
...

In this case, it shows up as /dev/sdc (note sdc inside the square brackets above).

Check to see if the automounter has mounted the SD Card

Note there may be more than one partition (only one shown in the example below).

$ [df -h]
Filesystem            Size  Used Avail Use% Mounted on
...
/dev/sdc1             400M   94M  307M  24% /media/disk
...

Note the "Mounted on" field in the above and use that name in the umount commands below.

If so, unmount it

$ [umount /media/disk]

Start fdisk

Be sure to choose the whole device (/dev/sdc), not a single partition (/dev/sdc1).

$ [sudo fdisk /dev/sdc]

Print the partition record

So you know your starting point. Make sure to write down the number of bytes on the card (in this example, 2021654528).

Command (m for help): [p]

Disk /dev/sdc: 2021 MB, 2021654528 bytes
255 heads, 63 sectors/track, 245 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *           1         246     1974240+   c  W95 FAT32 (LBA)
Partition 1 has different physical/logical endings:
     phys=(244, 254, 63) logical=(245, 200, 19)

Delete any partitions that are there already

Command (m for help): [d]
Selected partition 1

Set the Geometry of the SD Card

If the print out above does not show 255 heads, 63 sectors/track, then do the following expert mode steps to redo the SD Card:

  • Go into expert mode.
Command (m for help): [x]
  • Set the number of heads to 255.
Expert Command (m for help): [h]
Number of heads (1-256, default xxx): [255]
  • Set the number of sectors to 63.
Expert Command (m for help): [s]
Number of sectors (1-63, default xxx): [63]
  • Now Calculate the number of Cylinders for your SD Card.
#cylinders = FLOOR (the number of Bytes on the SD Card (from above) / 255 / 63 / 512 )

So for this example:  2021654528 / 255 / 63 / 512 = 245.79.  So we use 245 (i.e. truncate, don't round).
  • Set the number of cylinders to the number calculated.
Expert Command (m for help): [c]
Number of cylinders (1-256, default xxx): [enter the number you calculated]
  • Return to Normal mode.
Expert Command (m for help): [r]

Print the partition record to check your work

Command (m for help): [p]

Disk /dev/sdc: 2021 MB, 2021654528 bytes
255 heads, 63 sectors/track, 245 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System

Create the FAT32 partition for booting and transferring files from Windows

Command (m for help): [n]
Command action
   e   extended
   p   primary partition (1-4)
[p]
Partition number (1-4): [1]
First cylinder (1-245, default 1): [(press Enter)]
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-245, default 245): [+50]

Command (m for help): [t]
Selected partition 1
Hex code (type L to list codes): [c]
Changed system type of partition 1 to c (W95 FAT32 (LBA))

Mark it as bootable

Command (m for help): [a]
Partition number (1-4): [1]

Create the Linux partition for the root file system

Command (m for help): [n]
Command action
   e   extended
   p   primary partition (1-4)
[p]
Partition number (1-4): [2]
First cylinder (52-245, default 52): [(press Enter)]
Using default value 52
Last cylinder or +size or +sizeM or +sizeK (52-245, default 245): [(press Enter)]
Using default value 245

Print to Check Your Work

Command (m for help): [p]

Disk /dev/sdc: 2021 MB, 2021654528 bytes
255 heads, 63 sectors/track, 245 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *           1          51      409626    c  W95 FAT32 (LBA)
/dev/sdc2              52         245     1558305   83  Linux

Save the new partition records on the SD Card

This is an important step. All the work up to now has been temporary.

Command (m for help): [w]
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.

WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.

Format the partitions

The two partitions are given the volume names LABEL1 and LABEL2 by these commands. You can substitute your own volume labels.

$ [sudo mkfs.msdos -F 32 /dev/sdc1 -n LABEL1]
mkfs.msdos 2.11 (12 Mar 2005)

$ [sudo mkfs.ext3 -L LABEL2 /dev/sdc2]
mke2fs 1.40-WIP (14-Nov-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
195072 inodes, 389576 blocks
19478 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=402653184
12 block groups
32768 blocks per group, 32768 fragments per group
16256 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912

Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: 

Bootloader settings

If you use bootloader U-Boot, use following settings to mount root file system at second partition from kernel:

console=ttyS2,115200n8 root=/dev/mmcblk0p2 rw rootdelay=1
Comment by project member jkrid...@gmail.com, Aug 12, 2008

Typical usage with uImage in 1st partition and rootfs in 2nd partition:

setenv bootargs 'console=ttyS2,115200n8 root=/dev/mmcblk0p2 rw rootdelay=1' setenv bootcmd 'mmcinit;fatload mmc 0 80300000 uImage;bootm 80300000'

Comment by project member LiveWi...@gmail.com, Nov 13, 2008

When I used the FAT32 partition and it worked fine for me.

Comment by jxr041...@gmail.com, Mar 4, 2009

when I followed the above procedure, sometimes I can have two partitions when I plug the SD card again. sometime only the first partition appears, what about the problem?

Comment by kvang...@gmail.com, Mar 12, 2009

Be careful not to type 't' '1' 'c' - if you follow the above to the letter, you don't need to specify the partition number to change the type for. You know you have done it wrong if the partition type for partition 1 is now set to 'FAT12'. The spurious 'c' will then toggle some compatibility flags that may affect your system.

Comment by challi...@gmail.com, Aug 5, 2009

As noted elsewhere, there is a typo under "Create the FAT32 partition for booting and transferring files from Windows". Type simply 51? and not the +50 as indicated. Also, for unknown reasons, after the first fdisk on a SanDisk? 2GB SD Card (about the most common card you can find) the total bytes shows up under fdisk as 1977614336 and not the full 2GB. When you do the calculation above, you end up with number of cylinders = 240, not 245. My resulting SD Card was not recognized by the X-Loader until I corrected this.

Comment by rob...@robkaos.ruhr.de, Aug 13, 2009

When I try to boot with the usual bootargs and bootcmd environment, the kernel is booted and root is mounted. But then I get the message: "Unable to open an initial console" and it hangs.

BTW, is the serial port ttyS0 or ttyS2? I can see the boot messages only with ttyS2.

Robert

Comment by idav...@gmail.com, Sep 23, 2009

Robert, were you able to solve the issue with "Unable to open an initial console"? I'm still stuck as that stage.

ID

Comment by roy.vane...@gmail.com, Oct 19, 2009

As noted by challinan, enter 51 in the Create the FAT32 partition for booting and transferring files from Windows section.

Comment by pierrotl...@gmail.com, Oct 27, 2009

Hi When do we have to enter command : console=ttyS2,115200n8 root=/dev/mmcblk0p2 rw rootdelay=1 ??? When Flash is mounted on PC, after changing labels ? This is not clear for me Thaks PL

Comment by mpanzane...@gmail.com, Nov 19, 2009

"Unable to open an init console"....

I got this from another forum. You need to untar the root file system to the second partition. Therefore after you copy the necessary files in Windows to the first partition (angstrom.whatever_this_is.tar.bz2) then you need to untar the files. In knoppix I did the following:

$ sudo mount -t msdos /dev/sda1 /media/sda1/ $ sudo mount -t ext3 /dev/sda2 /media/sda2/ $ cd /dev/sda1/ $ sudo tar xvjf ./Angstrom.whatever_this_is.tar.bz2 -C /dev/sda2/

This will take some time. Then unmount the drives and remove the SD card.

Comment by mpanzane...@gmail.com, Nov 20, 2009

Sorry, that last line should read "-C /media/sda2"

Comment by saikiran...@gmail.com, Jan 17, 2010

Hi, I got the android Eclair version from Embinux site for Beagle board, i was trying to run some multimedia on it, but there were no suitable applications to run audio and video in that version of android kernel, so we downloaded an application called videoview and created an .apk file and copied it to the sysatem/app path and after booting, we were able to see the application icon, but it was playing only video without audio. but we are 100% sure that our Beagle board does not ahve any problem with the audio playback, as we have tested it initially when we got the board. So we read somewhere that we may require ALSA audio drivers, so we downloaded them and again rebuild the whole linux kernel, after this change when we try to boot the Beagle board with this new build version with ALSA is not booting the beagle board, and its giving a message saying that "unable to open an initial console", and it hangs at the initial Anroid splash screen. So could anybody help us in resolving this issue and also let us know how to playback both audio and video files with source on the latest eclair version 2.0 version. Waiting for a quick response. Thanks Sai

Comment by anunakin, Feb 9, 2010

"""PLEASE REVISE IT!"""

On Create the FAT32 partition step we dont need 50 cylinders but 50M, this is right on old README where we have a old 256MB SD card...

The command must be:

Last cylinder or +size or +sizeM or +sizeK (1-245, default 245): +50M

Comment by kuoy...@gmail.com, Apr 30, 2010

Please help me,

When I input bootm 0x80300000, I get ## Booting kernel from Legacy Image at 80300000 ...

Image Name: Linux-2.6.22.18-omap3 Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 1889932 Bytes = 1.8 MB Load Address: 80008000 Entry Point: 80008000 Verifying Checksum ... OK Loading Kernel Image ... OK
OK

Starting kernel ...

What configuration I need to setting?

Comment by wing...@gmail.com, May 5, 2010

Hi,

I use the Devkit8000 with Angstrom beagleboard, cpu is omap3530.

I have already formatted the SD card.I download the package from "The Angstrom Distribution" - Online buider.

Select the machine you want to build your rootfs image for: beagleboard

Choose your image name. This is used in the filename offered for download, makes it easier to distinguish between rootfs images after downloading. random-7996d285

Choose the complexity of the options below. simple will hide the options most users don't need to care about and advanced will give you lots of options to fiddle with. simple

User environment selection: Console only

Additional packages selection: Apache

I use u-boot method: 1.setenv bootargs 'console=ttyS2,115200n8 root=/dev/mmcblk0p2 rw rootdelay=1' video=omapfb:mode:7inch_LCD 2.setenv bootcmd 'mmcinit;fatload mmc 0 80300000 uImage;bootm 80300000' 3.saveenv 4.boot

............................. .............................. Starting system message bus: dbus. Starting Dropbear SSH server: dropbear. Starting advanced power management daemon: No APM support in kernel (failed.) Starting syslogd/klogd: done

  • Starting Avahi mDNS/DNS-SD Daemon: avahi-daemon
ok find: /lib/modules/2.6.28-rc9-omap1/kernel/drivers/usb/gadget: No such file or directory Loading g_cdc? FATAL: Module g_cdc not found. Starting web server: apache2.

.-------. | | .-. | | |-----.-----.-----.| | .----..-----.-----. | | | | ---'| '--.| .-'| | | | | | | | |--- || --'| | | ' | | | | '---'---'--'--'--. |-----''----''--' '-----'-'-'-'

-' | '---'

The Angstrom Distribution beagleboard ttyS2

Angstrom 2010.4-test-20100423 beagleboard ttyS2

beagleboard login:

It gives "FATAL: Module g_cdc not found." I don't know how to solve it.Please help!

Comment by phani.te...@gmail.com, May 14, 2010

how to copy root file to the ext2 partition?

Comment by satya...@gmail.com, May 22, 2010

i follow procedure but did not get anything when connected hyperterminal anybody know different procedure

Comment by Ahmad.El...@gmail.com, Sep 12, 2010

Hello,

Did anybody got the problem that the SD card can't be seen in ubuntu ? - i am working on windows7 and running ubuntu linux on the vmware player but i can't mount the sd card on the linux. What could be the problem ?

Comment by Ahmad.El...@gmail.com, Sep 12, 2010

please help .. i can't format the SD card on either ubuntu nor opensuse. I am sure something is worng there !!

Comment by zih...@gmail.com, Oct 3, 2010

I got the same issue. Then I took the SDHC card to Windows XP, and it showed up after some time. I use windows Format Tools to Format it again to FAT32 and name it with a label. Then the SDHC card popped up in Ubuntu.

Don't forget "mkfs.vfat" first in ubuntu.

Comment by zih...@gmail.com, Oct 16, 2010

The problem is solved by following suggestions given in the thread by kvangend and Anunakin. My dual-partition is now working.

Comment by nagabhus...@gmail.com, Nov 17, 2010

can I setup nfs through ethernet..?

Comment by s8tan2...@gmail.com, Dec 28, 2010

Hi Ahmed, did you find a resolution to the ubuntu / win7 problems? I too have the same setup and can't for the life of me read the Linux partition on the card that ships with the Beagleboard-xM - or indeed the reverse - I seem unable to make a ubuntu formated linux partition that can be read by the BB. :( Any clues?

Comment by raparti....@gmail.com, Jan 24, 2011

console=ttyS2,115200n8 root=/dev/mmcblk0p2 rw rootdelay=1 hi guys, i have used the above as bootargs. But i use ttyS0 as the port. Do i need to change my console args to ttyS0 from ttyS2?

Comment by raparti....@gmail.com, Jan 24, 2011

We have OMAP3530 board from Boardcon company. It is the same as EMA DEV3530. They have given the board with preloaded boot files in NAND. So, when we boot it from NAND , it works fine. But, when we followed the instructions in the manual given by you and try to boot the board from a SD card, it doesn't work. We have used the Boot files given in the CD-ROM. Please let us know what went wrong , and suggest a possible solution.

U-Boot 2009.11-svn12 ( 8��月 16 2010 - 17:25:40) OMAP3530-GP ES3.1, CPU-OPP2 L3-165MHz OMAP3 SBC3530 + LPDDR/NAND I2C: ready DRAM: 128 MB NAND: 256 MiB

In: serial
Out: serial Err: serial Ethernet MAC address: 02:c0:05:01:b0:05 Die ID #170000040000000004036ac00501b005 Net: smc911x-0 Hit any key to stop autoboot: 0 mmc1 is available reading boot.scr
Unable to read "boot.scr" from mmc 0:1
reading uImage 3195484 bytes read Booting from mmc ... ## Booting kernel from Legacy Image at 82000000 ...

Image Name: Angstrom/2.6.32/beagleboard

Image Type: ARM Linux Kernel

Image (uncompressed) Data Size: 3195420 Bytes = 3 MB Load Address: 80008000 Entry Point: 80008000 Verifying Checksum ... OK Loading Kernel Image ... OK

OK Starting kernel ...

booting stops here.. what could be the problem for that? please suggest me some solutions

Comment by a...@potatoriot.com, Apr 18, 2011

I found that the minimum size for the FAT partition is 2 cylinders, or about 24MB in this configuration. Using 1 cylinder produces a non-booting sdcard in my experience.

Comment by ahmeto...@gmail.com, Jun 13, 2011

When preparing the SD card, the first partition can be set as '+50M' in fdisk. This gave me 55M first partition (due to rounding off for sector and head numbers). The 51 that people say solves their problems may apply to your specific SD card, as I suspect 50 may make the disk slightly smaller than what u-boot expects for some SD designs. Selecting the size as 51 will solve that problem (I am not sure if this is the actual reason, only guessing). You do not need a large first partition. Make sure to get the head & sector sizes correct. There are several automated scripts out there that do this for you but it is really trivial to do by hand. Just don't do it when you are tired; you can damage your system hard disk by accident. Then it is a mess to recover!

Make sure to copy MLO (TI bootloader) as the first file into the first partition after formatting. If you are doing this from a Linux machine using the recommended procedure above, it is a no-brainer.

If you have problems booting, read carefully the very first few lines at boot up. The first line gives you the version of MLO that the board is trying to use, the next few lines give the version of u-boot. Depending on whether your machine tries to boot from NAND flash or SD card (mmc)(user button or automatically), the versions may be different. Newer versions of Beagleboard come with a MLO that can detect the presence of u-boot on an SD card and load that automatically instead of the one on the NAND flash. I have version C4 which does this. Again, this is displayed in the first few lines.

One reason for errors trying to find the Linux kernel (u-boot is loaded OK but it fails to find the kernel) can be messed up environment variables. If you ever did 'saveenv' then this can be a problem. If you have no idea what is going on with the environment variables, you can do 'env default -f' inside u-boot which will restore environment variables to factory defaults, and then 'boot' which will try to boot normally. If it works, power down, power up again, and do: 'env default -f' then 'saveenv' to save default env values permanently to flash. This will put the machine in a known condition from which you can build up your bootloader parameters.

Comment by Keanunaz...@gmail.com, Jun 15, 2011

What if my console is telling me that the partition is not suitable for a bootm command?

Comment by sydun...@gmail.com, Sep 14, 2011

I have been using ubuntu to boot my beagle board and I really wonder that why we dont copy the files (MLU,uImage ..) manually instead of copying by termianal. Is there any difference between them?

Same question for mounting manually and using terminal. I really wonder ??

Comment by dwolfie...@gmail.com, Yesterday (35 hours ago)

Note that in more recent release of ubuntu

fdisk does not use DOS-compatible mode and cylinders as display units
by default. The old deprecated DOS behavior can be enabled with the '-c=dos -u=cylinders' command-line options.
I had to use >sudo fdisk -c=dos -u=cylinders /dev/sdc to be able to follow the directions.


Sign in to add a comment
Powered by Google Project Hosting