aeromaxx
Posts: 20
Joined: Sat Jun 11, 2016 11:37 am

Raspbian Stretch Expand Filesystem

Tue Jul 10, 2018 11:24 pm

I have two 8gb micro SD cards, and I was wanting to clone the first to the second, so I used Win32ImageWriter to make a copy of the card, but the created image couldn't be written to the 2nd micro SD card due to lack of space. Strange as they should both be 8gb, nevermind I thought I would just put the latest version of raspbian stretch on it and copy my home folder to the new card.

The old card can't be mounted when booted from the newly created sd card with the latest version of raspberry. I get an error about bad geometry block count exceeds size of the device as can be seen below.

Code: Select all

EXT4-fs (sdb2): bad geometry: block count 1907456 exceeds size of device (1907455 blocks)
So I booted from the old card and put the new card in via a usb adapter, when I tried to mount this new card I got the same error as below.

Code: Select all

EXT4-fs (sda2): bad geometry: block count 1879040 exceeds size of device (1879039 blocks)
Is someone able to help me out, I've been trying to do this since friday and getting no where! Raspbian is auto expanding the card on first boot, but it's expanding it beyond the size of the card it seems, which is preventing me from mounting it.

*edit* not sure if the below additional information is of any use to anyone, including it anyway.

Old 8GB Micro SD Card - Booted from this drive

Code: Select all

Disk /dev/mmcblk0: 7.3 GiB, 7861174272 bytes, 15353856 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
Disklabel type: dos
Disk identifier: 0x63896872

Device         Boot Start      End  Sectors  Size Id Type
/dev/mmcblk0p1       8192    93813    85622 41.8M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      94208 15353855 15259648  7.3G 83 Linux
Old 8GB Micro SD Card - Booted from the new SD card

Code: Select all

Disk /dev/sda: 7.3 GiB, 7861173760 bytes, 15353855 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
Disklabel type: dos
Disk identifier: 0x63896872

Device     Boot Start      End  Sectors  Size Id Type
/dev/sda1        8192    93813    85622 41.8M  c W95 FAT32 (LBA)
/dev/sda2       94208 15353855 15259648  7.3G 83 Linux
New 8GB Micro SD Card - Straight after imaging, before first boot.

Code: Select all

Disk /dev/sda: 7.2 GiB, 7746878976 bytes, 15130623 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
Disklabel type: dos
Disk identifier: 0x4d3ee428

Device     Boot Start     End Sectors  Size Id Type
/dev/sda1        8192   96663   88472 43.2M  c W95 FAT32 (LBA)
/dev/sda2       98304 3637247 3538944  1.7G 83 Linux
New 8GB Micro SD Card - after first boot, root partition has been resized.

Code: Select all

Disk /dev/sdb: 7.2 GiB, 7746878976 bytes, 15130623 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
Disklabel type: dos
Disk identifier: 0x269755de

Device     Boot Start      End  Sectors  Size Id Type
/dev/sdb1        8192    96663    88472 43.2M  c W95 FAT32 (LBA)
/dev/sdb2       98304 15130623 15032320  7.2G 83 Linux
Error mounting old SD card when booted from the new SD card

Code: Select all

EXT4-fs (sdb2): bad geometry: block count 1907456 exceeds size of device (1907455 blocks)
Error mounting new SD card when booted from the old SD card

Code: Select all

EXT4-fs (sdb2): bad geometry: block count 1879040 exceeds size of device (1879039 blocks)
Last edited by aeromaxx on Wed Jul 11, 2018 12:10 am, edited 1 time in total.

klricks
Posts: 7118
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Raspbian Stretch Expand Filesystem

Tue Jul 10, 2018 11:59 pm

aeromaxx wrote:
Tue Jul 10, 2018 11:24 pm
I have two 8gb micro SD cards, and I was wanting to clone the first to the second, so I used Win32ImageWriter to make a copy of the card, but the created image couldn't be written to the 2nd micro SD card due to lack of space. Strange as they should both be 8gb, nevermind I thought I would just put the latest version of raspbian stretch on it and copy my home folder to the new card.

The old card can't be mounted when booted from the newly created sd card with the latest version of raspberry. I get an error about bad geometry block count exceeds size of the device.

So I booted from the old card and put the new card in via a usb adapter, when I tried to mount this new card I got the same error as below.

Code: Select all

EXT4-fs (sda2): bad geometry: block count 1879040 exceeds size of device (1879039 blocks)
Is someone able to help me out, I've been trying to do this since friday and getting no where! Raspbian is auto expanding the card on first boot, but it's expanding it beyond the size of the card it seems, which is preventing me from mounting it.
There are many many threads here concerning your issues.
Win32Diskimager copies the entire card full or not. So an 8GB card will produce an 8GB image.
SD cards even from the same manufacture with same advertised size are not necessarily exactly the same size.
If the destination card is even the slightest bit smaller than the source card then the image write will fail.
There are ways to shrink the image but it is far easier to use the SD card copy app in Raspbian. This will make an exact copy of the running OS.
You only need to attach a USB cardreader to the RPi.

Also auto expand only happens on the first boot. A cloned card is not in a first boot state so auto expand is not done again.
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

aeromaxx
Posts: 20
Joined: Sat Jun 11, 2016 11:37 am

Re: Raspbian Stretch Expand Filesystem

Wed Jul 11, 2018 12:16 am

klricks wrote:
Tue Jul 10, 2018 11:59 pm
Win32Diskimager copies the entire card full or not. So an 8GB card will produce an 8GB image.
SD cards even from the same manufacture with same advertised size are not necessarily exactly the same size.
If the destination card is even the slightest bit smaller than the source card then the image write will fail.
There are ways to shrink the image but it is far easier to use the SD card copy app in Raspbian. This will make an exact copy of the running OS.
You only need to attach a USB cardreader to the RPi.

Also auto expand only happens on the first boot. A cloned card is not in a first boot state so auto expand is not done again.
Thank you for the reply.

Yes I realise that Win32ImageWriter copies the entire card full or not.

I have tried to shrink the image using gparted, but it fails as I previously mentioned due to the bad geometry, and this also means I can't mount either the old or new SD cards once they have been auto resized.

The problem I am having is with the auto expanding, as it's expanding the size of the root partition beyond the size of the card.

Return to “Raspberry Pi OS”