Image too big for 8GB SD card

Hi, I received my Banana Pi M3 today (yeeeah) but I bought an 8GB Micro SD Card Class 4 and the file for dietpi is a little too big for 8GB SD card :frowning: Does anyone know how I can get dietpi on my banana pi? Thanks

Cordially, Baskwo

just few ubuntu image is big than 8G,you can try other image ,

It is possible to shrink the image, it is not quite a trivial task though. Iā€™m at work now, but Iā€™ll write down the steps to perform hopefully later today when I get home. Be warned though. If the root FS on the image is too full it might not be possible to shrink the image enough.

@sinovoip I tried the image for DietPi and itā€™s just a bit bigger @NoKey Thank you a lot! Iā€™m probably sure it will be enough!

Okayā€¦ That took a little more time than expected and I admit it can be a lot more advanced, but I wrote this shell script that should do it automatically:

#!/bin/bash

# shrink-Bpi-m3-img.sh - Shell script to shrink a BananaPi M3 image
# the trick is to downsize the ext4 fs in the second partition

# Sizes for old and new filesystems in megabytes:
ORIG_FS_SIZE=7100
NEW_FS_SIZE=3500

if [ $# -gt 0 ]; then
	if [ -f $1 ]; then
		IMG=$1
	else
		echo "Usage: $(basename $0) <image file>" 1>&2
		exit 1
	fi
else
	IMG=2016-05-14-dietpi-preview-bpi-m3-sd-emmc.img
fi

echo Using image file $IMG

EXTFS_IMG=$IMG.extfs
NEW_IMG=$IMG.new

# Extract the etx4 fs in the second partition of the image:
dd if=$IMG bs=1M count=$ORIG_FS_SIZE skip=356 of=$EXTFS_IMG

# Do a file system check so resize2fs won't complain:
/sbin/e2fsck -f $EXTFS_IMG

# Halve the size of the filesystem image:
/sbin/resize2fs $EXTFS_IMG ${NEW_FS_SIZE}M

# Recheck/clean the downsized filesystem
/sbin/e2fsck -f $EXTFS_IMG

# Now create a new image; start with the original "head":
dd if=$IMG bs=1M count=356 of=$NEW_IMG

# Append the resized image:
dd if=$EXTFS_IMG bs=1M count=$NEW_FS_SIZE >> $NEW_IMG

# Update the partition table of the image:
cat << EOT | /sbin/sfdisk -f $NEW_IMG
# partition table of 2016-05-14-dietpi-preview-bpi-m3-sd-emmc.img
unit: sectors

${NEW_IMG}1 : start=   204800, size=   524288, Id= c, bootable
${NEW_IMG}2 : start=   729088, size= $((NEW_FS_SIZE * 2048)), Id=83
${NEW_IMG}3 : start=        0, size=        0, Id= 0
${NEW_IMG}4 : start=        0, size=        0, Id= 0
EOT

# Do cleanup:
rm $EXTFS_IMG

# And it's done!

Thank you, Iā€™m trying it out right now! Iā€™ll keep you informed :slight_smile:

edit1 : It worked for the minimization (itā€™s now at 3.76GB) Iā€™m writing it to the sd card with Win32 Disk Imager (I used arch to use your bash script) Iā€™ll keep you posted if my BPI boot! To boot it up I just have to press the power button for a few seconds right? I donā€™t have to do anything else?

edit2: Alright so now my BPI is booting with 3 led (no more only red light as with other imgs) but it stop after like 10 seconds

Looks like u-boot is having trouble then. Iā€™ll look into that later (at work now).

What is the uboot exactly? Is it the bootloader? If so, what does the uboot button? Thank you for all your help

-baskwo

u-boot is the bootloader that loads the Linux kernel and passes possibly required parameters onto it. It can also preload some other required data to the RAM of the system before loading/booting the Linux kernel. I am not quite sure what the uboot button does. but I have a feeling it puts the processor into a specific state. Possibly for loading software through the USB interface before actually booting.

As for your problem, Iā€™m beginning to have some suspicions about win32 Disk imager. Another user seems might have made his SD cards unusable for booting the BPi with it. The ā€œproperā€ way to put one of these images onto an SD cars is to use ā€œddā€ in linux (or any UNIX-like system), using that to write the data directly onto the main partition of your SD card.

This is the way I copied the shrunk image to my SD card and it works just fine for meā€¦

Ohh I see :slight_smile: I only have to do : dd if=file of=/devā€¦ ? No other parameters?

To speed up the process itā€™s handy to set the transfer block size to 1 MB by adding the parameter bs=1M to the dd command line. But yes, thatā€™s all you need to do.

So I wrote my sd card with the dd command without the bs parameter and it does the same. shutting down after like 10 seconds. There is the commands I did with output : https://gyazo.com/43330e0f0a19b46eb29b9e440c369bd0

If sdb is your SD card, that should be quite right.

Do you think I should try to reinstall u-boot on my sd card? I could follow the arch guideline for that.

You can try it, but I cannot guarantee you success. Iā€™d recommend you get a USB TTL serial converter to see whatā€™s happening during the u-boot phase.

Alright, thank you Iā€™ll buy one as fast as I can for now Iā€™ll try to reinstall u-boot on my sd-card or try an other img! Thank you for your help Iā€™ll keep you informed!

So I have a USB TTL serial converter. And Iā€™m using Putty to read it on Windows. Iā€™m getting some infos but it is really weird : https://gyazo.com/405233a2c101098c0a795519e3a1cda8 I also tried on linux with screen and I got this : https://gyazo.com/56c6cba981013253b97f131b72b7939a So I wonder if itā€™s the right program to do so and Iā€™f Iā€™m use it correctly.

Looks like you might have the wrong serial port settings. The settings I use are: 115200 baud, 8 bit data, no parity, 1 stopbit (115200 8N1) Flow control: none

Does this output have any moment that it pauses? There is a point in the u-boot sequence where you can stop it from continuing. Hereā€™s a snippet from the boot loader where I actually interrupted it (this is the actual shrunk image youā€™re trying as well): > WORK_MODE_BOOT > board_status_probe > [ 1.154]pre sys mode > sunxi_bmp_logo_display > [ 1.279][mmc]: blkcnt should not be 0 > [ 1.297]fetch script data boot_disp.output_disp fail > [ 1.302]screen_id =1, screen_width =1280, screen_height =720 > [ 1.308]frame buffer address 46400000 > [ 1.312]Hit any key to stop autoboot: 0

I tried with : screen /dev/ttyUSB0 115200,cs8,-parentb,-cstopb and it output the same thing.

It seems to have a little pause 2-3 seconds

Hmm, I tried the same and worked 100% fine for me. I donā€™t know how to help you any further without physical access to your system. The fact that you are getting output on the serial port (even though itā€™s garbled) tells me that itā€™s hooked up correctly. I hope someone else has some ideas for you.