Ora*_*Tux 5 partition mount disk disk-image
我有一个带有 Debian 的可启动 USB。通常我用 克隆磁盘dd
,将图像写入新的 USB 磁盘,将此磁盘安装在我的文件系统上并编辑一些文件。是否可以在不将图像写入 USB 并安装 USB 的情况下编辑图像上的文件?我试过 ISO Master,但这会引发一个错误:Failed to read volume info: 'Failed to read expected number of bytes'
.
作为根用户:
modprobe loop max_part=16
losetup /dev/loop0 file.img
vgchange -ay # if using LVM on there
mount /dev/the-device /mnt
Run Code Online (Sandbox Code Playgroud)
(其中 -device 是包含您的文件的文件系统的设备(/dev/loop0p2 或 /dev/someVG/someLV)。
然后编辑该文件,并且:
umount /mnt
vgchange -an someVG # if using LVM there
losetup -d /dev/loop0
Run Code Online (Sandbox Code Playgroud)
或者,您可以在虚拟机中启动映像:
kvm -hda file.img -m 1024
Run Code Online (Sandbox Code Playgroud)
(不要忘记在编辑其中的文件后正常关闭虚拟机)。