IMG File compression and decompression
The initrd.img in the 2.6 kernel is cpio compressed and is no longer a ext2 format used by the 2.4 kernel and cannot be mounted using the Mount-o loop. Need to decompress with gunzip and then use Cpio to unpack
The code is as follows:
Cp/boot/initrd-***.img initrd.img.gz
Gunzip initrd.img.gz
mkdir INITRD
MV Initrd.img INITRD
CD INITRD
CPIO-IVMD < initrd.img
By using the above command, the initrd.img is decompressed, and you can edit it now, and then use the following command to suppress it again.
The code is as follows:
Find. | Cpio-cv-o > ... /initrd.new.img
Gzip.. /initrd.new.img
IMG File Mount method
In Linux, for an img file (for example, an IMG file for a virtual machine), it is sometimes necessary to mount it in order to modify its contents. Can you mount it like an ISO file?
In fact, the method is very simple, only need two steps:
The code is as follows:
#kpartx-av xxx.img
Get the following information:
The code is as follows:
Add Map Loop0p1 ...
At this point only need Mount Loop0p1 can
The code is as follows:
#mount/dev/mapper/loop0p1/mnt
OK, so you can enter MNT to modify the contents of the IMG file
Uninstalling is also simple, and is also two steps:
The code is as follows:
Umount/mnt
Kpartx-d xxx.img