Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

Image too big

by pgrunwald on Sat Aug 11, 2012 4:13 pm

I have a Kingston 4Gb card and I'm getting "not enough space on disk: Size 7741440 sectors Available 7626752 Sector Size 512"

Any easy way to shrink the image a bit?

I really would like to use Occidentalis. This is the card:http://www.kingston.com/us/flash/microsd_cards#sdc4
pgrunwald
 
Posts: 33
Joined: Tue Jul 14, 2009 9:32 pm

Re: Image too big

by adafruit on Sat Aug 11, 2012 4:24 pm

pgrunwald wrote:I have a Kingston 4Gb card and I'm getting "not enough space on disk: Size 7741440 sectors Available 7626752 Sector Size 512"
Any easy way to shrink the image a bit?
I really would like to use Occidentalis. This is the card:http://www.kingston.com/us/flash/microsd_cards#sdc4


tested to work on the cards we sell for sure, others we don't know - so far we've not had any reports of it not working on any specific cards yet (besides yours).

cheers,
adafruit support
User avatar
adafruit
 
Posts: 11666
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: Image too big

by pgrunwald on Sat Aug 11, 2012 4:43 pm

Could you shrink the image a bit and then if people have larger cards they can expand the partition as per this: http://elinux.org/RPi_Resize_Flash_Partitions
pgrunwald
 
Posts: 33
Joined: Tue Jul 14, 2009 9:32 pm

Re: Image too big

by adafruit on Sat Aug 11, 2012 5:00 pm

pgrunwald wrote:Could you shrink the image a bit and then if people have larger cards they can expand the partition as per this: http://elinux.org/RPi_Resize_Flash_Partitions


hiya! it works on the 4gb cards we sell and support, no plans to shrink it down at this time for this build.

cheers,
adafruit support, phil
User avatar
adafruit
 
Posts: 11666
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: Image too big

by huronbikes on Wed Aug 22, 2012 4:19 pm

Ok, I have been battling this and it is extremely frustrating to the point that the reaction of "oh sorry, use our cards" is infuriating. The image size is not that much bigger than the capacity of the card in my case (all but one 512k record can make it) yet it makes all the difference. On top of that, FDISK is telling me that the second partition in the image has different physical/logical beginnings and endings. Maybe you should just state that the image will not work on any other card except your 4gb card if that is the case.
huronbikes
 
Posts: 2
Joined: Wed Aug 22, 2012 4:16 pm

Re: Image too big

by adafruit on Wed Aug 22, 2012 4:57 pm

huronbikes wrote: Maybe you should just state that the image will not work on any other card except your 4gb card if that is the case.


many others have not had any issues on other cards, so we can't really say it will not work on any other cards. we'll be close to 10k downloads very soon :) we have not sold 10k cards yet. for our customers, we do make sure if we sell a card we've tested it and know for sure it works! thank you for the feedback, we do appreciate it.

cheers,
adafruit support, phil
User avatar
adafruit
 
Posts: 11666
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: Image too big

by huronbikes on Thu Aug 23, 2012 11:57 am

It is possible to resize the image in Linux using the command line tools dd and parted. First, have a look at the partition table in the image file:

Code: Select all | TOGGLE FULL SIZE
user@host:~$ parted Occidentalist.img unit b print
WARNING: You are not superuser.  Watch out for permissions.
Model:  (file)
Disk /home/andy/Occidentalist.img: 3963617280B
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start      End          Size         Type     File system  Flags
 1      4194304B   62914559B    58720256B    primary  fat16        lba
 2      62914560B  3963617279B  3900702720B  primary  ext4

user@host:~$


note the start and end of the of second partition, this will be important. Next we want to grab the second partition, as we are going to use it to make a smaller file system.

Code: Select all | TOGGLE FULL SIZE
user@host:~$ dd if=Occidentalist.img bs=1M skip=60 of=OccImgPart2.img count=3720
3720+0 records in
3720+0 records out
3900702720 bytes (3.9 GB) copied, 87.1542 s, 44.8 MB/s
user@host:~$


We use a block size of 1 Megabyte (the cap M is important to dd!) , and the EXT4 partition starts right at the 60 megabyte mark and is 3720 megabytes long. If you use a different block size, you will have to recalculate the skip, seek, and count arguments to DD, as they are specified in blocks, not bytes.

Next, we are going to mount the image we just made of the EXT4

Code: Select all | TOGGLE FULL SIZE
user@host:~$ mkdir OccFilesystem
user@host:~$ sudo mount OccImagePart2.img OccFilesystem
user@host:~$ sudo mount OccImgPart2.img OccFilesystem
user@host:~$


After this, you should have the Occidentalist image's filesystem mounted in the directory OccFilesystem. Now we need to make a new Filesystem image, but reduced size.

If you know your card's capacity in megabytes, take that number and subtract 60 (the size of the first partition and partition info in the current Occidentalist image). Otherwise use a suitably small number. For this case, I am going to use 3500 megabytes

Code: Select all | TOGGLE FULL SIZE
user@host:~$ dd bs=1M if=/dev/zero of=SmallerOccImgPart2.img count=3500
3500+0 records in
3500+0 records out
3670016000 bytes (3.7 GB) copied, 36.3484 s, 101 MB/s
user@host:~$


and format it ext4

Code: Select all | TOGGLE FULL SIZE
user@host:~$ mke2fs -T ext4 ./SmallerOccImgPart2.img
mke2fs 1.42 (29-Nov-2011)
./SmallerOccImgPart2.img is not a block special device.
Proceed anyway? (y,n) y
Discarding device blocks: done                           
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
224000 inodes, 896000 blocks
44800 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=918552576
28 block groups
32768 blocks per group, 32768 fragments per group
8000 inodes per group
Superblock backups stored on blocks:
   32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done                           
Writing inode tables: done                           
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done

user@host:~$


Next, mount the smaller filesystem and copy the files from the Occidentalist filesystem to the smaller filesystem:

Code: Select all | TOGGLE FULL SIZE
user@host:~$ mkdir SmallerOccFilesystem/
user@host:~$ sudo mount SmallerOccImgPart2.img SmallerOccFilesystem
user@host:~$ sudo cp -aux OccFilesystem/ SmallerOccFilesystem/
user@host:~$


Time to make a new smaller image file. Remember, we made the smaller filesystem 3500 megabytes. We now add sixty to that number to make the whole image:

Code: Select all | TOGGLE FULL SIZE
user@host:~$ dd bs=1M if=/dev/zero of=SmallerOccImg.img count=3560
3560+0 records in
3560+0 records out
3732930560 bytes (3.7 GB) copied, 37.4573 s, 99.7 MB/s
user@host:~$


Add some partitions to that image. The sizes are done in bytes, since parted uses salesman kilobyte / megabyte sizes :

Code: Select all | TOGGLE FULL SIZE
user@host:~$ parted SmallerOccImg.img mklabel msdos
WARNING: You are not superuser.  Watch out for permissions.
user@host:~$ parted SmallerOccImg.img unit b mkpart primary fat16 4194304 62914559
WARNING: You are not superuser.  Watch out for permissions.
user@host:~$ parted SmallerOccImg.img unit b mkpart primary ext4 62914560 3732930559
WARNING: You are not superuser.  Watch out for permissions.
user@host:~$


Now you have an empty image with two partitions. Time to copy the data:

Code: Select all | TOGGLE FULL SIZE
user@host:~$ dd bs=1M if=Occidentalist.img skip=4 of=SmallerOccImg.img seek=4 count=56 conv=nocreat,notrunc
56+0 records in
56+0 records out
58720256 bytes (59 MB) copied, 0.449081 s, 131 MB/s
user@host:~$ dd bs=1M if=SmallerOccImgPart2.img of=SmallerOccImg.img seek=60 count=3500 conv=nocreat,notrunc
3500+0 records in
3500+0 records out
3670016000 bytes (3.7 GB) copied, 62.812 s, 58.4 MB/s
user@host:~$


We use conv=nocreat,notrunc for DD to prevent DD from wiping out our partitioned image file.

After that, SmallerOccImg.img is ready to be installed on your "4GB" SDCard. Have fun!
huronbikes
 
Posts: 2
Joined: Wed Aug 22, 2012 4:16 pm

Re: Image too big

by digitalmisery on Sun Aug 26, 2012 5:23 pm

I am also getting the "not enough space on disk: Size 7741440 sectors Available 7626752 Sector Size 512" message when using Win32 Disk Manager on Windows 7. I am using the 4GB microSD card from the Adafruit store (http://adafruit.com/products/102). It shows up in Windows as a 3.63 GB FAT32 drive, while the Occidentalist image is 3.69 GB after extracting it from the .zip file. Any help would be appreciated!
digitalmisery
 
Posts: 9
Joined: Thu Dec 23, 2010 9:10 am
Location: Chicago, IL

Re: Image too big

by tgalonso on Sun Aug 26, 2012 6:47 pm

Simple get an 8 Gig card like I did. To be honest 4Gig is barely functional.
Tgalonso
tgalonso
 
Posts: 18
Joined: Thu Jun 21, 2012 10:45 am