I am trying to create a third FAT32 partition on the SD card that consumes the free space on the card not used by the image. I want this instead of the root partition being resized.

Creating the partition works, and fsck shows no problems with any partition and the other two partitions are untouched.

The procedure I am using:

    sudo dd if=2017-03-02raspbian-jessie.img of=/dev/sdd BS=1M

Code to automate creating a partition using the free space:

    parted -m /dev/sdd print free

which outputs:

/dev/sdd:62.9GB:scsi:512:512:msdos:>TS-RDF5 SD Transcend;

Parse to find the line 6 which is always the free space on a new dd of the image, which is:


Get the start location and end location columns (columns 2 and 3):

start 6226MB
end 62.9GB

Then create the partition and file system:

    parted -m /dev/sdd mkpart primary 6226MB 62.9GB
    mkdosfs -F 32 /dev/sdd3

Then I copy over a cmdline.txt file which changes:

dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=798cce24-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet init=/usr/lib/raspi-config/init_resize.sh


dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

Without changing the root=, the pi just sits on a black screen with the logo in the upper left corner. Adding this line, it gets further than that but fails to mount rootfs.

[FAILED] Failed to start Remount Root and Kernel File System
[FAILED] Fao;ed tp start Various fixups to make sysmted work better on debian

And some other failures.. ending up booted into an "Emergency mode" prompt.


If I dd the image over, let it run the init_resize script, then shrink the fs back down, add the new fs ... it works...

Doing it this way, I don't even need to change the cmdline.txt file to point to /dev/mmcblk0p2..

What am I missing here?

I have to be able to add the partition before the first boot in an automated way.

2 Answers 2


After digging around some more.. I looked at the init_resize script and noticed that the disk id was being replaced in /etc/fstab.

Apparently, when a new partition is created, the disk id is changed, so creating a new image, creating the new partition, then:

    fdisk -l /dev/sdd

Disk /dev/sdd: 62.9 GB, 62881005568 bytes
64 heads, 32 sectors/track, 59968 cylinders, total 122814464 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0001632d

the important part is

Disk identifier: 0x0001632d

changed the cmdline.txt




then changed the same in /etc/fstab

Successful boot without resizing the root fs, and third partition as fat32 exists.

I'm still not sure at this point why allowing the resize script to run, resizing the partition back down then creating a new fat32 partition works if the disk id is changed when a new partition is created.

The resize script caches the disk id before and after then uses sed to update the two relevant files.


Thanks to Richard for giving this to the community. I stumbled also over this problem and was looking for a solution for hours. For those who are not so familiar here a step by step description to workaround this bug.

First workaround I prefer:
1. dd your image to the sd card as usual (shown in question)
2. add new partition to the sd card (shown in question)
3. get the modified Disk identifier (also named Volume ID)

~$ sudo fdisk -l /dev/sdd | grep '^Disk identifier:'
Disk identifier: 0x63b03f8e

4. mount /dev/sdd1 and /dev/sdd2 to e.g. /mnt/{sdd1,sdd2}
5. edit /mnt/sdd1/cmdline.txt and change the root= Parameter from e.g. root=PARTUUID=37665771-02 to root=PARTUUID=63b03f8e-02
6. edit /mnt/sdd2/etc/fstab and change all PARTUUID as shown in 5. Leave last 3 character untouched.
7. umount /mnt/{sdd1,sdd2}
8. boot the sd card in your raspberry pi

Second workaround, quick but dirty:
1. dd your image to the sd card as usual (shown in question)
2. get the old Disk identifier (also named Volume ID)

~$ sudo fdisk -l /dev/sdd | grep '^Disk identifier:'
Disk identifier: 0x37665771

3. add new partition to the sd card (look above)
4. use fdisk /dev/sdd, select x extra functionality (experts only) and then i change the disk identifier. Set it back to e.g. 0x37665771
5. boot the sd card in your raspberry pi

This isn't good because we spread the same Disk identifier for different storages all over the world. As I read anywhere in the Internet MS-Windows has problems with changed Disk identifier and may not boot, like Raspbian ;-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.