0

I have installed a new Debian 10 on /dev/sda with LUKS + LVM. It has the following partition structure:

NAME            MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINT
sda               8:0    0   79G  0 disk
├─sda1            8:1    0  953M  0 part  /boot
├─sda2            8:2    0    1K  0 part
└─sda5            8:5    0 78.1G  0 part
  └─sda5_crypt  254:0    0 78.1G  0 crypt
    ├─box1-root 254:1    0   14G  0 lvm   /
    ├─box1-tmp  254:2    0  1.9G  0 lvm   /tmp
    ├─box1-swap 254:3    0  3.7G  0 lvm   [SWAP]
    └─box1-home 254:4    0 58.5G  0 lvm   /home

The total disk is 80GB and there are much more disk space left. If I use dd command like this:

dd if=/dev/sda of=/mnt/Backup_Volume/backup.img

It would take the entire disk space (80GB) to store the backup.img. I want to shrink this .img file and make the size of .img file as smallest as possible (excluding the free space)

Another information:

Filesystem            1K-blocks    Used Available Use% Mounted on
udev                    2004244       0   2004244   0% /dev
tmpfs                    404148   15708    388440   4% /run
/dev/mapper/box1-root  14351816 8721012   4882056  65% /
tmpfs                   2020732      68   2020664   1% /dev/shm
tmpfs                      5120       4      5116   1% /run/lock
tmpfs                   2020732       0   2020732   0% /sys/fs/cgroup
/dev/mapper/box1-home  60112780   57616  56971900   1% /home
/dev/mapper/box1-tmp    1886280    6012   1766400   1% /tmp
/dev/sda1                944120   51092    827852   6% /boot
tmpfs                    404144       0    404144   0% /run/user/1000

I saw similar post for this but it doesn't cover the LUKS and LVM partition here:

https://superuser.com/questions/610819/how-to-resize-img-file-created-with-dd

My objective is to have a smaller img file as a backup so I can restore this later. And (maybe, I'm not sure) if I would need to resize the partition later to fit the 80G, I'm ok with it. Do you think this is possible ?

Kalib Zen
  • 137
  • 7
  • 1
    Oof, just saw that my answer was useless because of the encryption. – Simon Richter Mar 16 '21 at 16:58
  • I thought that too, thanks.. – Kalib Zen Mar 17 '21 at 01:09
  • You might want to run backups with `tar -c ... | gpg -e ...` then, if you don't have encrypted storage media. My setup just has two encrypted machines in different cities that rsync to each other through an IPsec tunnel, that also works, but restoring means reinstalling the OS. – Simon Richter Mar 17 '21 at 08:13

0 Answers0