Solution for sd card file system with error on dd image copy

The error showed is that are no space left on device, and further the superblock is showed as non matching with partition table.

Lets go check the error.

No space left on device error

Result of dd image copy showing the error notice

# dd bs=4M if=./Asterisk_BpiM1_8gig_freepbxready of=/dev/sdd
 dd: error writing ‘/dev/sdd’: No space left on device
 1847+0 records in
 1846+0 records out
 7744782336 bytes (7.7 GB) copied, 2108.02 s, 3.7 MB/s

The fsck on first second partition (boot) is ok
Result of fsck on second second partition (root) give error

# fsck /dev/sde2
 fsck from util-linux 2.23.2
 e2fsck 1.42.9 (28-Dec-2013)
 The filesystem size (according to the superblock) is 1919488 blocks
 The physical size of the device is 1885440 blocks
 Either the superblock or the partition table is likely to be corrupt!
 Abort? yes

Trying to boot banana pi. The Banana Pi don’t boot.

Solution for sd card with error on dd copy

Use fdisk to resize partition and next use resize2fs to resize the file system.

The fdisk comand

After run there is a interactive cli to run commands and do choices.

The prompt for command is “Command (m for help):”.

  • Commands
  • p list partitions
  • d delete partitions
  • n create partitions
  • w write changes to disk
# fdisk /dev/sde

Welcome to fdisk (util-linux 2.23.2). bla bla bla…

Command (m for help): p (to list partitions)
 Device Boot Start End Blocks Id System
 /dev/sde1 2048 43007 20480 83 Linux
 /dev/sde2 43008 15398911 7677952 83 Linux

Take note of second partition start (ex: 43008), because we are going to delete it.

Command (m for help): d (to delete partitions)
 Partition number (1,2, default 2): 2
 Partition 2 is deleted

Now we need to recreate the partition again.

Command (m for help): n
 Partition type:
 p primary (1 primary, 0 extended, 3 free)
 e extended
 Select (default p): p
 Partition number (2-4, default 2): 2
 First sector (43008-15126527, default 43008): 43008
 Last sector, +sectors or +size{K,M,G} (43008-15126527, default 15126527): 15126527
 Partition 2 of type Linux and of size 7.2 GiB is set

At last we need to write the changes to the disk.

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

Calling ioctl() to re-read partition table.
 Syncing disks.
The resize2fs comand

# resize2fs /dev/sde2
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/sde2 to 1885440 (4k) blocks.
The filesystem on /dev/sde2 is now 1885440 blocks long.

The process is done, lets test it.

# fsck /dev/sde2

Result of fsck on second second partition (root) is ok.

Trying to boot banana pi. The Banana Pi boot.

Problem solved for me.

The magic here is that we delete the root partition, then recreate only the root partition (using the original start sector) before writing the data to the disk. As a result you don’t erase the existing data from the root partition. As the end of the partition will be clean (hopefully) the process will result on success.

Source

https://raspberrypi.stackexchange.com/questions/499/how-can-i-resize-my-root-partition