2

I have a 64 GB SD card that has 15.6 GB of space used. I used GParted to shrink the partition, but I have no idea how to convert the two partitions /sda1 and /sda2 into an approximately 16 GB .img file.

Everytime I make an image file it turns out to be 64 GB. I'm pulling my hair out on this one since I can't find any solutions.

I've tried:

  • Reformatting another drive that is smaller (I don't have any 16 GB drives).
  • Gparted - Slimmed everything down, but the unallocated part still shows up as part of a second partition on Windows.
  • Countless other things, web searches, etc.

How can I make this work?

The two partitions in question are apart of a bootable Raspberry Pi SD card.

I made a custom Raspberry Pi image that has some preinstalled server software (I want to host the shrunk file so users can install it, expand the filesystem and let the server run on their own). The problem I am facing is that using Win32DiskImager it copies the whole drive, so I want to find a way to copy it so that it only takes the 16 GB current size of the drive.

  • 1
    If you just shrinked the 64GB partition then you should have only one partition followed by some unallocated space, why are you talking about another (/sda2) partition? Did you create the second partition afterwards? For which purpose? – kos Feb 26 '15 at 23:31
  • 1
    It's a raspberry pi SD card, it needs 2 partitions for the OS – DRKMSTR Feb 27 '15 at 0:50
3

Update

At first the question was only about how create a smaller partition-image. So this answer is missing the part how to create a bootable Raspberry Pi OS, which will need two partitions and an MBR.

Old guide on how to create a smaller-sized parition image

Create a new file which is exactly 16 GB in size:

fallocate -l 16G sixteen.img

Create a file-system within it:

mkfs.vfat sixteen.img

Mount it:

mkdir sixteen
sudo mount sixteen.img sixteen

This will open a Nautilus window with your newly mounted image file. Now insert your SD card. It will automatically mount and open a second Nautilus window.

Copy your files from the second window to the first one. After that, unmount your file image with either the eject-symbol in the sidebar of nautilus or with the command sudo umount sixteen.

  • 2
    Clean solution, but i think you should explain that this wouldn't work if he's booting an OS off the drive – kos Feb 26 '15 at 23:46
  • Wow, I'm installing ubuntu now since Partimage doesn't work on the DVD trial. I'll see if this works! – DRKMSTR Feb 27 '15 at 0:02
  • @DRKMSTR will the 16gb image be used to boot a OS? Please state what OS it is in this case, as my answer doesn't create a bootable image. – MadMike Feb 27 '15 at 0:10
  • It's a raspberry pi OS. I need to shrink it using Ubuntu (since it's extremely similar) and Windows can't see it. – DRKMSTR Feb 27 '15 at 0:28
  • Now I ran into another problem, I don't have enough filespace on my ubuntu computer, it only has 16gb total filespace (which holds the OS). – DRKMSTR Feb 27 '15 at 1:17
0

I think you'll want to use clonezilla.

From the clonezilla website:

Clonezilla is a partition and disk imaging/cloning program similar to True Image® or Norton Ghost®. It helps you to do system deployment, bare metal backup and recovery.

This will allow you to very simply create a .iso from a partition (I'm not too sure about multiple partitions but it works very well with one, check the documentation for me details depending on what you want to do).

There's a tutorial on the official website. Or you can check out this one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.