Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to extract or mount img files on Linux system

2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "how to extract or mount img files on the Linux system". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Compression and decompression of img files

The initrd.img in the 2.6kernel is compressed by cpio, which is no longer the ext2 format used by the 2.4kernel and cannot be mounted using mount-o loop. Need to use gunzip to unzip, 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 通过以上命令就将initrd.img解压了,现在就可以对其进行编辑,完成后使用以下命令重新压制 代码如下: find . | cpio -cv -o >

.. / initrd.new.img

Gzip.. / initrd.new.img

Img file mount method

In linux, for img files (for example, virtual machine img files), it is sometimes necessary to mount them in order to modify their contents. Can you mount it like an iso file?

In fact, the method is very simple, only two steps:

The code is as follows:

# kpartx-av xxx.img

Get the following information:

The code is as follows:

Add map loop0p1...

All you need at this time is mount loop0p1.

The code is as follows:

# mount / dev/mapper/loop0p1 / mnt

OK, so you can go to mnt to modify the contents of the img file.

It is also easy to uninstall, and it is also two steps:

The code is as follows:

Umount / mnt

Kpartx-d xxx.img

This is the end of the introduction of "how to extract or mount img files on Linux systems". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 209

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report