I'm trying to create an image of /dev/sda
and write the output to a new .iso
file on the same device. How can I exclude the new image file; so as to prevent the output from becoming its own input, and vice versa? As you can see, it ends up creating something of an infinite feedback loop (like an ouroboros), until there's no free space left.
root@linux:~# df /dev/sda1
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 303569136 4313624 283812008 2% /
root@linux:~# dd if=/dev/sda of=/root/image.iso
306419534336 bytes (306 GB, 285 GiB) copied, 10098.4 s, 30.3 MB/s
dd: writing to '/root/image.iso': No space left on device
598483361+0 records in
598483360+0 records out
306423480320 bytes (306 GB, 285 GiB) copied, 10099.5 s, 30.3 MB/s
root@linux:~# df /dev/sda1
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 303569136 303552756 0 100% /
root@linux:~# ls -sh /root/
total 286G
286G image.iso
gzip - < /dev/sda1 > /root/image.iso.gz
might work. But the dynamic nature of it would probably mean corruption if you ever tried to restore it on a live partition later – infixed Feb 21 '17 at 22:43dd
, and I tried to use that limited knowledge to create an image of the HDD in my laptop. I've useddd
for writing images to external storage and thought I could just do the reverse. – voices Feb 25 '17 at 3:56