As promised here is a howto explaining the growing and shrinking of SD card images and filesystems.
Growing is useful if you want to grow the filesystem from your image to take advantage of all space available on your SD card.
Shrinking is useful if you want to write i.e. an 8GB image to a 2GB SD card (given the content of the image is less than 2GB).
You will need a Linux computer with gparted installed. Many Live-CDs for Linux and BSDs that include gparted can be used so you can use these steps without devoting a computer to Linux permanently (though you really should
).
We will first deal with growing an image to your SD cards full size, since that is slightly easier to do (nvm, shrinking is not that hard either).
Growing an image on the SD cardFirst write the image you have downloaded from the OP to your 8GB SD card with something like
sudo dd if=~/Desktop/AnxA2-09012015.img of=/dev/sdX bs=512
Make sure that you use the correct device for sdX in the above /dev/sdX! The below two commands help you to identify the device name of your SD card:
If you just have plugged it in, check the output of the below command (the last lines to find out what device name your SD card has)
[1883229.800218] scsi119 : usb-storage 8-2:1.0
[1883230.804097] scsi 119:0:0:0: Direct-Access USB2.0 CARD-READER 1.01 PQ: 0 ANSI: 2
[1883230.804824] sd 119:0:0:0: Attached scsi generic sg2 type 0
[1883230.814085] sd 119:0:0:0: [sdb] Attached SCSI removable disk
[1883230.831082] sdb: detected capacity change from 7948206080 to 0
[1883230.844116] sd 119:0:0:0: [sdb] 15523840 512-byte logical blocks: (7.94 GB/7.40 GiB)
[1883230.850080] sd 119:0:0:0: [sdb] No Caching mode page found
[1883230.850084] sd 119:0:0:0: [sdb] Assuming drive cache: write through
[1883230.866076] sd 119:0:0:0: [sdb] No Caching mode page found
[1883230.866080] sd 119:0:0:0: [sdb] Assuming drive cache: write through
[1883230.880111] sdb: sdb1 sdb2
The other command below shows your partition tables, look for one that looks like the size of your SD card:
On my PC with one 80GB harddisk (sda) the output looks like:
major minor #blocks name
8 0 78150744 sda
8 1 498688 sda1
8 2 1 sda2
8 5 39061504 sda5
8 6 3905536 sda6
11 0 1048575 sr0
8 16 7761920 sdb
8 17 57344 sdb1
8 18 2831360 sdb2Obviosuly,
/dev/sdb is the SD card with 8GB capacity.
Once the image is written to your SD card, run the following command (again replacing /dev/sdX with your device name):
A window like the following will appear:
Make sure that all partitions are unmounted by right-clicking them and selecting "unmount". You will not be able to resize the partition and filesystem while it is mounted:
Now you are ready to resize. Right-click on the partition /dev/sdX2 (sdb2 in my case) and select
Resize/Move:
A new window will appear that allows you to resize:
Grab the right edge with your mouse and drag it completely to the right:
You can also enter values directly below instead of dragging with your mouse.
Once you are done, press
Resize/Move.
A warning will eventually appear that you can safely ignore if you did everything right until here.
Now select
Edit|Apply All Operations and give it some minutes to do its job:
Once this has finished, your image is resized to the full SD card size and you can start to use it in your miner.
Shrinking an image file to fit on a smaller cardNow this gets a bit more work as we need to do all work on the image file as we obviously can't just dd it to a smaller card and work on the card directly. Still it is very easy to do so:
First of all we need to mount the image to work on its filesystem. Linux offers the loop device system for such tasks. To create a device from the ANX image do as follows:
sudo losetup /dev/loop0 ~/Desktop/AnxA2-09012015.img
Now you can again run gparted but against the loop device:
As above in growing the filesystem you can now shrink the second partition to your needs. In our case I want to make the image to fit on a 2GB SD card. Since the boot partition needs some space and we do not want to stretch our luck too much, we make the partition ~1700MB:
Note:Actually one could make some maths to get the right matching number for partition size, but that's beyond the scope of this howto and in this case I don't mind wasting a few MB. In fact the image, after written to SD card can simply be grown to the full 2GB size of the target card with above growing procedure.
Again apply these changes by selecting "Edit|Apply All Operations" and get yourself a coffe (better two).
Once things are done from gparted we are left with an image that would fit on 2GB SD card but has ~6GB unused space at the end and actually is still an 8GB image.
So to be able to dd it to our 2GB sd card we need to truncate the image to the space currently used.
First we need to find out where out second partition we just resized now ends:
Which will give you an output like below:
Disk AnxA2-09012015.img: 7948 MB, 7948206080 bytes
255 heads, 63 sectors/track, 966 cylinders, total 15523840 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: 0x0002c262
Device Boot Start End Blocks Id System
AnxA2-09012015.img1 8192 122879 57344 c W95 FAT32 (LBA)
AnxA2-09012015.img2 122880 3809279 1843200 83 LinuxThe important number is the last block of the last partition:
3809279From the above output we also know that the block size is 512 bytes. That leaves us with the following formula to determine where we will be truncating the image:
(3809279+1) * 512 =
1950351360Note: the +1 is because blocks count from 0 so we adjust for that with one block added.
Now can trim our image to the size we calculated above:
truncate --size=1950351360 ~/Desktop/AnxA2-09012015.img
You should now be able to dd the above image to a 2GB SD card disk.
I hope this helps one or the other when fiddling with images. If you have feedback or corrections please let me know.