-1

I installed raspbian on an sd card and then booted into a pi zero to do my required configuration and setup.

I then made an .img off of this sd card which I'm planning to use in a manufacturing process.

In order to reduce burn time I made it about 3 GB using dd's count option.

Now when I burn the image to a new SD card I want to extend rootfs to the full card length, so I'm running the following commands:

# echo -e "d\n2\nw\n" | fdisk /dev/sdc
# parted -s /dev/sdc unit B mkpart primary 50331648 100%

Where 50331648 was the start of rootfs before deleting it, gotten from parted -m /dev/sdc unit B print.

Then I run

resize2fs -p /dev/sdc

And I get

resize2fs 1.46.2 (28-Feb-2021)
resize2fs: Bad magic number in super-block while trying to open /dev/sdc
Couldn't find valid filesystem superblock.

All my searches led to primarily answers about centOS or non applicable scenarios. The only relevant question I found was that one, which also has no answers..

How can I do this?

php_nub_qq
  • 267
  • 2
  • 13

2 Answers2

1

Have you already tried expanding rootfs via

sudo raspi-config

then first update and at last go for Expand Filesystem ?

This is the usual and simplest way of doing so.

Edit: I would suggest https://github.com/Drewsif/PiShrink for shrinking and also resizing if the pi should never be booted to prepare it.

bitdruid
  • 21
  • 2
1

Well, as silly as it might be, thanks to this answer I found out that I'm supposed to use resize2fs on the partition, not the device...

So the commands I had to run to resize the partition successfully were as follows:

parted /dev/sdc resizepart 2 100%
e2fsck -f /dev/sdc2
resize2fs /dev/sdc2
php_nub_qq
  • 267
  • 2
  • 13