I want to clone a new distro installation into an image file for backup purpose.
The goal is to have a image file to be eventually burned into a SSD to have a ready to run copy.
Assuming it would work, one would do a dd if=/dev/sda of=/dev/sdb , where sda is the bare SSD taken off the working machine and sdb an identical SSD both connected via usb-sata adapter to a second linux machine.
The problem is SSD are 250GB ones and this could be a time wasting as well as space-wasting , as used space of fresh distro is about 6.5GB :
[root@freepbx ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 3.7G 0 3.7G 0% /dev tmpfs 3.7G 0 3.7G 0% /dev/shm tmpfs 3.7G 8.9M 3.7G 1% /run tmpfs 3.7G 0 3.7G 0% /sys/fs/cgroup /dev/mapper/SangomaVG-root 212G 6.5G 206G 4% / /dev/sda2 1.9G 50M 1.8G 3% /boot /dev/sda1 200M 12M 189M 6% /boot/efi tmpfs 741M 0 741M 0% /run/user/0
I could also do dd if=/dev/sda of=bkupimage.img but it would result into a 250GB file !
Is there a way to shrink the original partitions (mostly the giant 200+GB lvm one) into a 10-15GB image file discarding the unused space ?
Of course if possible.