lollipop image doesn't fit on 8 GB card.

Discuss Android on the Wandboard, as well as app development for or on the Wandboard.

lollipop image doesn't fit on 8 GB card.

Postby asplundj » Tue Nov 24, 2015 8:32 pm

I'm trying to install the lollipop image on kingston 8 GB sd card but win32 disk imager says the file is slightly too big for the card. Does the image really need to be THAT big?
asplundj
 
Posts: 14
Joined: Thu Nov 12, 2015 10:56 am

Re: lollipop image doesn't fit on 8 GB card.

Postby Checko » Fri Nov 27, 2015 11:23 am

I use dd command to write that image to my 8G SD. it said the storage is not enough. but the sd card still bootable.
only the data partition is not mounted correctly.
Checko
 
Posts: 2
Joined: Mon Nov 09, 2015 9:06 am

Re: lollipop image doesn't fit on 8 GB card.

Postby nevmair » Fri Dec 04, 2015 2:40 am

I had the same problem. The image is too big to fit on an 8GB SD card partly because of the way it was built.

There is a bug (I think) in the fsl_sdcard_partition.sh script that calculated the data partition size incorrectly.

The short version of the fix is:
1) use gparted to make partition 4 smaller, then
2) use truncate to make the image fit on a 8 GB (or even a 4 GB) SD card.

Because of the issue with partition 4, gparted will not load the image, unless we fix the file size first.
The long version is:
1) make a backup copy of the original image
2) use losetup to mount the image as a loop device
3) find the minimum size needed for the file using fdisk
4) use truncate to make the file larger, yes larger.
5) use gparted to make partition 4 smaller
6) find the new minimum file size using fdisk
7) use truncate to make to make the file smaller
8) use the new file to make the SD card

1) make a backup copy of the original image
Code: Select all
cp  wandboard-lp-5.0.2-ga-20150622-sdcard.img Android-5.0.2.ga.img


2) use losetup to mount the image as a loop device
# find a free loop device, this returns loop0 on my system
Code: Select all
sudo losetup -f

# mount the image to the loop device
Code: Select all
sudo losetup /dev/loop0 Android-5.0.2.ga.img
sudo partprobe /dev/loop0


3) find the minimum size needed for the file using fdisk
Have to make the file larger so gparted will work.
use fdisk to get sector information on partition 4 and the image size

Code: Select all
 nmair@LINUX-DT-1:~/Images$ fdisk -l Android-5.0.2.ga.img
 
 Disk Android-5.0.2.ga.img: 8068 MB, 8068792320 bytes
 249 heads, 62 sectors/track, 1020 cylinders, total 15759360 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: 0x00000000
 
                Device Boot      Start         End      Blocks   Id  System
 Android-5.0.2.ga.img1           15438      154379       69471   83  Linux
 Android-5.0.2.ga.img2          154380      185255       15438   83  Linux
 Android-5.0.2.ga.img3          185256     2408327     1111536    5  Extended
 Android-5.0.2.ga.img4         2408328    15885701     6738687   83  Linux
 Android-5.0.2.ga.img5          185257     1235039      524891+  83  Linux
 Android-5.0.2.ga.img6         1235041     2284823      524891+  83  Linux
 Android-5.0.2.ga.img7         2284825     2315699       15437+  83  Linux
 Android-5.0.2.ga.img8         2315701     2331137        7718+  83  Linux
 Android-5.0.2.ga.img9         2331139     2346575        7718+  83  Linux
   


NOTICE that the end sector for partition is larger than the total sectors of the image.
Because of this, gparted wont load the device.

4) use truncate to make the file larger, yes larger.

# make the image file large using the info from the fdisk command
Code: Select all
 truncate --size=$[(15885701+100)*512] Android-5.0.2.ga.img


5) use gparted to make partition 4 smaller
Now gparted will load the image file.

Code: Select all
sudo gparted /dev/loop0


The next step is to shrink partition 4, but gparted won't allow you to resize the partition until you format it (as ext4).
It is important to only adjust the end of partition 4, not the beginning.

I chopped 250 MB from the end of partition 4, this makes it fit on an * GB card.
If you want it to fit on a 4 GB card, just chop off more.

After resizing the partition you are ready to shrink the image.

6) find the new minimum file size using fdisk
use partition 4 new end sector to calculate the file size.

Code: Select all
nmair@LINUX-DT-1:~/Images$ sudo fdisk -l /dev/loop0

Disk /dev/loop0: 8133 MB, 8133530112 bytes
255 heads, 63 sectors/track, 988 cylinders, total 15885801 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: 0x000a0c37

      Device Boot      Start         End      Blocks   Id  System
/dev/loop0p1           15438      154379       69471   83  Linux
/dev/loop0p2          154380      185255       15438   83  Linux
/dev/loop0p3          185256     2408327     1111536    5  Extended
/dev/loop0p4         2408328    15374335     6483004   83  Linux
/dev/loop0p5          185257     1235039      524891+  83  Linux
/dev/loop0p6         1235041     2284823      524891+  83  Linux
/dev/loop0p7         2284825     2315699       15437+  83  Linux
/dev/loop0p8         2315701     2331137        7718+  83  Linux
/dev/loop0p9         2331139     2346575        7718+  83  Linux


# unmount the loop device before making changes to the file
Code: Select all
 sudo losetup -d /dev/loop0   


7) use truncate to make to make the file smaller

# use the (end sector for partition 4 plus 5)*512 for the file size
Code: Select all
truncate --size=$[(15374335+5)*512] Android-5.0.2.ga.img
nevmair
 
Posts: 43
Joined: Mon Feb 16, 2015 3:42 pm


Return to Software - Android

Who is online

Users browsing this forum: No registered users and 4 guests