I've got an img file (4,02GB) containing a Linux OS. My goal is to shrink this img filed down to < 4GB. The img contains a linux partition that only holds about 2,5GB of data.
I need to be able to copy that img file to an eMMC that is just under 4GB. So compressing the image for storage is not what I want. I want a smaller image that can be copied using dd
to the eMMC.
When I load the image on a 8GB SD Card (using dd) it looks like this :
root@udoo:/# fdisk /dev/mmcblk0
Command (m for help): p
Disk /dev/mmcblk0: 8026 MB, 8026849280 bytes
4 heads, 16 sectors/track, 244960 cylinders, total 15677440 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: 0x00052161
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 2048 67583 32768 e W95 FAT16 (LBA)
/dev/mmcblk0p2 67584 7849983 3891200 83 Linux
and fdisk output
root@udoo:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 3.6G 2.5G 920M 74% /
devtmpfs 342M 4.0K 342M 1% /dev
none 4.0K 0 4.0K 0% /sys/fs/cgroup
none 101M 236K 101M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 502M 72K 502M 1% /run/shm
none 100M 20K 100M 1% /run/user
/dev/mmcblk0p1 32M 6.3M 26M 20% /boot
I can use a linux OS to mount the SD card , shrink the filesystem and re-create the partitions, but how do I export that into a new img file ? AFAIK, performing a dd if=/dev/mmcblk0 of=/file.img
operation will always result in an image file that is the same size as the SD card (in this case 8gb).
What would be the best way to do this ?
Is there a way to create a blank 3.5GB img file and add the 2 partitions (/dev/mmcblk0p1 en /dev/mmcblk0p2) somehow to reach my goal ?