Please note, there is an issue where I need a solution that is both command line driven and using efi (uefi??) to get my system to work.
I seen this question come up so many times, but all the answers, are all partial, leave out details like whether the disks are mounted or not, and fail to do a complete study of how to do practical backups and restores of an ubuntu install, so if we can explore this example I think it hits all the issues that someone would like to see with respect to backing up your system.
Question : How do I backup an entire bootable disk, maintaining all the 3 partitions, but make a small file/image taking advantage of the fact that most of the big partition is empty?
Conditions:
I am currently booted from sdb which is a 1TB disk that has 3 partitions.
I have already dd cloned the disk to sda with the dd command.
Partitions 1, and 2 are small but seem to be necessary to make the disk bootable and are of minor issue with respect to compressing, not that compressing them isn't worthwile.
Partition 3 is 950gb, but 98% of it is empty. In other words, its the remainder of the diskdrive not consumed by partitions 1 and 2.
Sdc is an empty 240gb disk drive with one partition sdc1
Goal: I would like to be able to make some kind of back zip file, or image file or whatever that I can use to backup up the currently unmounted sda disk maintaining the 3 partitions, but at the same time be able to compress at least the big partition so that the backup image is a much smaller size and something I can store on either sdb or sdc.
I should be able to then use that compressed backup to make a new bootable disk on a new 1TB disk that recreates the three partitions such that partitions 1 and 2 are recreated exactly, and that partition 3 uses the rest of the disk. I would need the instructions for how to do that as well.
Thoughts: I believe the hard part of this is the sizing of the third partition, as an acceptable solution, since I know the 950gb partition is 98% emmpty, aka I'm only using 20gb of the 950gb, I cut that third partition on the source disk to, say 25gb (just to be sure) and then backup just the three partitions, make the backup and then extend the third partion back up to 950gb on the source disk, When I go to restore this image (which at worst is 1G+5G+25G== 31gb) I then have a bootable disk that can fit on a 31gb disk. In my case I can then extend the third partition on this newly restored disk on that 240gb machine to make use of the full 240gb.?
Thanks in advance
jleslie48
Bootdisk-rack3:~$ df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 16374812 0 16374812 0% /dev
tmpfs 3281996 9328 3272668 1% /run
/dev/sdb3 978410716 15753812 912933464 2% /
tmpfs 16409968 56 16409912 1% /dev/shm
tmpfs 5120 4 5116 1% /run/lock
tmpfs 16409968 0 16409968 0% /sys/fs/cgroup
/dev/sdb1 815104 29096 786008 4% /boot/efi
tmpfs 3281996 0 3281996 0% /run/user/1001
Bootdisk-rack3:~$ sudo fdisk -l
[sudo] password for bootdisk-01:
Disk /dev/sda: 953.9 GiB, 1024209543168 bytes, 2000409264 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: D02C689D-715F-4380-B810-D0624582A381
Device Start End Sectors Size Type
/dev/sda1 2048 1640447 1638400 800M EFI System
/dev/sda2 1640448 12126207 10485760 5G Microsoft reserved
/dev/sda3 12126208 2000408575 1988282368 948.1G Linux filesystem
Disk /dev/sdb: 953.9 GiB, 1024209543168 bytes, 2000409264 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: F92B5F4A-7AF6-43E2-9E77-E04D4FF4395D
Device Start End Sectors Size Type
/dev/sdb1 2048 1640447 1638400 800M EFI System
/dev/sdb2 1640448 12126207 10485760 5G Microsoft reserved
/dev/sdb3 12126208 2000408575 1988282368 948.1G Linux filesystem
Disk /dev/sdc: 223.6 GiB, 240057409536 bytes, 468862128 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
Disklabel type: dos
Disk identifier: 0x85a40f8e
Device Boot Start End Sectors Size Id Type
/dev/sdc1 * 2048 468858879 468856832 223.6G 7 HPFS/NTFS/exFAT
Bootdisk-rack3:~$~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 0 953.9G 0 disk
--sdb2 8:18 0 5G 0 part
--sdb3 8:19 0 948.1G 0 part /
--sdb1 8:17 0 800M 0 part /boot/efi
sdc 8:32 0 223.6G 0 disk
--sdc1 8:33 0 223.6G 0 part
sda 8:0 0 953.9G 0 disk
--sda2 8:2 0 5G 0 part
--sda3 8:3 0 948.1G 0 part
--sda1 8:1 0 800M 0 part