Re: lazy old guy asks question
Hi,
mick.crane wrote:
> For the purpose of backing up 3 ~200Gb disks, with Debian operating systems
> on them, I wondered if I can put them all on one 1Tb disk and be able to
> copy them back.
Yes. There are a lot of ways to do it.
> > Can I dd copy them to .isos on the 1 Tb disk then put them back on other
> > disks so they boot?
Yes. The new disk would have to be of the same size or larger than the
old disk. Then the partitions and their content should be accessible
after the back-copying is complete.
Whether a computer system boots from the new disk is subject to various
conditions. A new disk which is similar to the old disk and plugged
into the same computer as replacement of the old disk is supposed
to boot fine. The more hardware differences, the more adventure ...
But the copies on your 1 TB disk would not deserve the ending ".iso".
Rather something like ".img" (for disk image) and a descriptive name
before that ending.
I give an example with hypothetical device name "/dev/sdX", 1 TB disk
mount point "/mnt/1tb", and existing directory "/mnt/1tb/backups/".
"/dev/sdX" is the base device file of one of your 200 GB disks.
something like /dev/sdd or /dev/nvme2n1.
The dd run would be:
sudo dd if=/dev/sdX of=/mnt/1tb/backups/dev_sdX_2025_08_29.img \
bs=1M status=progress oflag=dsync
Important is that if= gives the disk device and of= gives the desired
path of the image file with the disk content. Vice versa could be fatal
for the 200 GB disk's content.
Copying back is just a matter swapping if= and of= paths.
(That's the part when you need strong nerves. of=/dev/sdX is quite a
frightening dd argument.)
If you want to access files in the partitions, you may also do this
without putting the image file back onto a hard disk.
List partitions:
/sbin/fdisk -l /mnt/1tb/backups/dev_sdX_2025_08_29.img
To mount a partition you have to compute the byte offset from partition
start block and block size.
Let's assume the partition 3 starts at block 243269632 and block size
is 512 bytes:
expr 243269632 '*' 512
yields
124554051584
which you may use in the mount command with existing directory
"/mnt/dev_sdX3_mounted" as mount point:
sudo mount -o loop,offset=124554051584 \
/mnt/1tb/backups/dev_sdX_2025_08_29.img \
/mnt/dev_sdX3_mounted
When mount creates the loop device it will apply the offset number
and thus create the effect of a partition device file.
You may want to apply a lossless compression for not wasting too much
of your terabyte. Like
sudo dd if=/dev/sdX bs=1M status=progress oflag=dsync | \
gzip >/mnt/1tb/backups/dev_sdX_2025_08_29.img.gz
Restoring to disk would be (again frightening):
gunzip < /mnt/1tb/backups/dev_sdX_2025_08_29.img.gz | \
sudo dd of=/dev/sdX bs=1M status=progress oflag=dsync
Have a nice day :)
Thomas
Reply to: