29

Citing the xz manpage (which you really should consult with such questions), in which I very quickly searched for sparse: --no-sparse Disable creation of sparse files. By default, if decompressing into a regular file, xz tries to make the file sparse if the decompressed data contains long sequences of binary zeros. It also works when writing to standard ...


11

The dd command has a conv=sparse sparse try to seek rather than write the output for NUL input blocks So I would attempt xz -dc < image.xz | dd of=image conv=sparse Using dd in this way will work with any form of input (whether or not the first command could generate sparse files itself).


9

Instead of using generic tools like cat or dd, one should prefer tools which are more reliable on read errors like ddrescue readcd (which has error corrections/retry mechanisms for CD/DVD drives built-in) In addition, their default settings are more suitable than e.g. dd's.


6

You could use the largest end sector for count: dd bs=512 count=26509312 if=/dev/sdk of=devsdk.img Or with a different blocksize: dd bs=1M count=$((26509312*512)) iflag=count_bytes if=/dev/sdk of=devsdk.img It is strange that the Armbian leaved 8129 sectors free, and calls it unpartitioned space, what is in that area? For embedded devices, unpartitioned ...


4

With an uncompressed (and probably sparse itself) source file, simply using (GNU) cp --sparse=always sourcefile /dev/sdX would be enough: --sparse=WHEN control creation of sparse files. See below By default, sparse SOURCE files are detected by a crude heuristic and the corresponding DEST file is made sparse as well. That is the behavior selected by --sparse=...


4

7z (from p7zip) can unpack disk and filesystem images from many but not all common VM disk image, partitioning schemes, and file formats. https://www.7-zip.org/ has the list (and can be used from Windows - p7zip being the Linux/Posix port) Note that it's usually a two step process: $ 7z l [raw HD image file] Path = [raw HD image file] Type = MBR Physical ...


3

Forget dd: it's hard to use reliably and somewhat slow. Despite a common myth, there's no magic in dd: the magic is in /dev/*. To copy up to sector 26509311 in units of 512-bytes sector, use head. Remember to add 1 because sectors start at 0. sudo head -c $(((26509311 + 1) * 512)) /dev/sdk >/home/user/backup.iso


2

dd doesn't know anything about mounts or folders or unix file structure in filesystems. dd only knows about raw data and a few trivial transformations of raw data and data blocks. It was originally designed to read and write data from or to block devices (including disks and tapes) and could handle changing the structure of that data back and forth between ...


2

Running losetup -P will automatically detect partitions and create appropriate /dev/loop0pX devices for you. No need to perform the calculations manually.


2

Just figured it out. Summary QEMU boots with BIOS by default. This contrasts with the real system which booted with UEFI. UEFI and BIOS require different disk organizations. My disk image (from a UEFI system) hung on QEMU booting with BIOS. Fix: append the option -bios /usr/share/ovmf/OVMF.fd OVMF provides the correct firmware. More detailed answer Quoting ...


1

Looks like you have somehow managed to format drive in use for linux. usually you would find out which drive the external drive is by typing lsblk which displays all drives (used and unused) then you would see the drive, if you do just df - it only displays mounted drives, which is not always a good scenario if you have unformatted drive but even better you ...


1

That's a case where using a lower level tool can help instead of causing problems. Usually today it's not a good idea to use dpkg directly, but in this case this will help for the same reason: dpkg won't check as much as apt. You know you won't use earlier kernel versions installed so you can remove them directly. Assuming a bash shell remove all earlier: ...


1

Mounting an image file is possible, but you need to use the "loopback interface" for that. You can try the following (as root) ~# losetup -Pf /path/to/imagefile.img This will choose the first available loopback device (usually number 0) and set it up to attach the image file. It will also peform a partition scan in case your image contains several ...


1

I may just have found an answer to this oddity. As the gzip manual page says: Bugs: The gzip format represents the input size modulo 2^32, so the --list option reports incorrect uncompressed sizes and compression ratios for uncompressed files 4 GB and larger. It further states: To work around this problem, you can use the following command to discover a ...


1

Loop mount of simple image file via `/etc/fstab' In a test system of Ubuntu Server 20.04.3 LTS I created an image file similar to yours, $ dd if=/dev/zero of=file.img bs=1M count=1000 1000+0 records in 1000+0 records out 1048576000 bytes (1.0 GB, 1000 MiB) copied, 5.90297 s, 178 MB/s $ sudo mkfs.ext4 file.img [sudo] password for tester: mke2fs 1.45.5 (07-...


1

This is nothing to worry about, this is just parted not being able to get the "disk" geometry because it's not a disk but a file. If you create a loop file from the image, the free space start should be the same. With the disk image file: (parted) p free Model: (file) Disk /home/vtrefny/...


1

dd will read from the if (input file) and dump it to the of (output file), it will be a binary copy of the "if". These files can be filesystem files, filesystems themselves, raw devices, etc. This command will not make anything from the data structures that reside in the "if", if it is a filesystem it willl copy it, regardless if the ...


1

With -o loop mount creates a loop device and tries to mount it, but the device doesn't contain an ext4 filesystem, it contains a partition table which is not mountable. You need to mount the partition on the image and mount can't do that, you need to create the loop device manually first with --partscan to tell kernel to probe the partition table and the ...


1

As explained here the overhead margin used is big: How to shrink a partition below the minimum size reported by resize2fs? Also se the linked c-code for detail. To visualize it a bit more I did a little test using a 1G image file, filled it with less and less data in one file and used resize2fs -M on it: From data file being 900M down to 600M estimated ...


1

Yes You can simply pause or stop your virtual machine then simply copy the .img, .raw or .qcow2 as the backup. But i have suggestion for you: you can use easily get a snapshot. get snapshot with qemu-img: qemu-img snapshot -c backup /vms/vm10001.qcow2 or virsh command: virsh snapshot-create vm10001


1

I came here looking for a faster alternative. My current best effort on this is: xdelta3 -e -s /dev/mmcblk0 <(zcat backup.img.gz) /tmp/delta xdelta3 -d -s /dev/mmcblk0 /tmp/delta /dev/mmcblk0 This ends up being quite slow, but seems to avoid the write-amplication effect. Since the bot noticed this answer - xdelta3 has been available in Debian ...


1

This question is ancient, but I found myself wanting something similar, and found a possible solution (no one stop shop, but a way to solve it). See https://stackoverflow.com/questions/66754449/list-contents-of-floppy-image-file-without-mounting-in-linux?noredirect=1#comment118002316_66754449 Basically you'll need to put a config file in /usr/lib/mc/extfs.d/ ...


Only top voted, non community-wiki answers of a minimum length are eligible