Jump to content

backing up SD to filename.img


Rein

Recommended Posts

Hi, I am running Armbian Jessie (4.11.6-sunxi) on Banana Pi M1.

For reading and writing SD cards I use linux dd cmd on another box.

I do not have a Windows system.

My question is this: My SD card is a 16Gb device. With gparted I can reduce the size of the system to a partition that would easily fit on a 4Gb device.

But when writing the .img file dd will still see and write an image of 16 Gb

There must be a way to make an image that can be written to and booted from a smaller device to save resources on the backup disk.

Can anyone point me in the right direction ?

 

Link to comment
Share on other sites

Using "truncate" with the "endsect" number shown by fdisk after gparted shrinking.

Here is the sequence :

sudo modprobe loop
sudo losetup -f
sudo losetup /dev/loop0 myimage.img
sudo partprobe /dev/loop0
sudo gparted /dev/loop0
sudo losetup -d /dev/loop0
fdisk -l myimage.img
sudo truncate --size=$[(endsect+1)*512] myimage.img

 

Link to comment
Share on other sites

Thank you, martinayotta, I'll try this today ! As I understand it I still have to make an imagefile of the full 16Gb before I can shrink it to below 4Gb. Maybe you can confirm this?

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines