5

I've a bootable USB with Debian. Normally I clone the disk with dd, write the image on a new USB disk, mount this disk on my filesystem and edit some files. Is it possible to edit files on the image without writing the image to USB and mount the USB? I've tried ISO Master, but that raises an error: Failed to read volume info: 'Failed to read expected number of bytes'.

OrangeTux
  • 1,063
  • Are you always able to modify the usb content since Debian 9.4.0? It seems the read-only blocks that now. – Sandburg May 20 '18 at 12:11

1 Answers1

4

As root:

modprobe loop max_part=16
losetup /dev/loop0 file.img
vgchange -ay # if using LVM on there
mount /dev/the-device /mnt

(where the-device is the device (/dev/loop0p2 or /dev/someVG/someLV) with the filesystem that contains your file.

Then edit the file, and:

umount /mnt
vgchange -an someVG # if using LVM there
losetup -d /dev/loop0

Alternatively, you could boot your image in a VM:

kvm -hda file.img -m 1024

(don't forget to shutdown the VM gracefully after editing the file in there).

  • +1, you might also mention kpartx as described here: http://superuser.com/questions/344899/how-can-i-mount-a-disk-image – grebneke Feb 07 '14 at 10:52