Home » Development and Build » Development Environment Setup » Create a Dual Partition SD Card with Linux / Ubuntu

Create a Dual Partition SD Card with Linux / Ubuntu

Start ‘fdisk’. For me, the SD card reader/writer has the SD card show up on /dev/sdc. I recommend you insert a properly formatted card and execute ‘mount’ or ‘df’ to figure out what device your SD card shows up under. You’ll need to ‘umount’ the drives before you can run ‘fdisk’. Be sure to choose the whole device (/dev/sdc), not a single partition (/dev/sdc*1).

$ sudo fdisk /dev/sdc

Print the partition record, so you know your starting point.

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 the existing partition.

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

Create the FAT32 partition for booting and transferring files from Windows. Mark it as bootable.

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))

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 and save the new partition records.

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

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.

$ sudo mkfs.msdos -F 32 /dev/sdc1 -n LABEL

mkfs.msdos 2.11 (12 Mar 2005)

$ sudo mkfs.ext3 /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:

Leave a Comment