Img образы дисков linux

How would I extract a .img file

I am trying to extract a .img file (hard disk image with with Chromium OS on it). I have not been able to find any way to do this other than mounting it but that is not usable because it shows up as multiple drives so I cannot repack it.

5 Answers 5

You do not extract an .img ; you mount it. Example:

mkdir /mnt/ChromeOS mount -o loop image.img /mnt/ChromeOS/ 

and this will list the contents:

Mind that .img can also be zipped. If that is the case (unlikely though) you also need to gunzip it.

This does not work if the img contains multiple partitions, at least it fails for me. Using kpartx works instead.

You can use kpartx — create device maps from partition tables

Install the package kpartx and run

kpartx [-a | -d | -l] [-v] wholedisk 

DESCRIPTION

This tool, derived from util-linux’ partx, reads partition tables on specified device and creates device maps over partitions segments detected. It is called from hotplug upon device maps creation and deletion.

EXAMPLE

To mount all the partitions in a raw disk image:

You can clone from the image file to a drive

You can clone from the .img [image] file to a drive, for example a USB pendrive, that is big enough. This is the basic intention of the file.

You can use mkusb for that purpose. It works with compressed image files too (when compressed with gzip and xz ), .img.gz and .img.xz files.

After the cloning you will see the partitions for example with

sudo lsblk -f sudo lsblk -m sudo parted -ls 

After cloning you can mount and unmount the partition(s) on the drive ‘as usual’.

Источник

Как монтировать образы дисков для просмотра и редактирования файлов (РЕШЕНО)

Как просмотреть информации об образах для монтирования. Как определить файловую систему образа

С помощью команды file можно анализировать, какая файловая система используется в файлах, являющихся образами дисков.

Пример проверки файла test.image:

/mnt/disk_d/test.image: ISO 9660 CD-ROM filesystem data 'ARCH_202010' (bootable)

Пример анализа образа disk.ntfs:

/mnt/disk_d/disk.ntfs: DOS/MBR boot sector, code offset 0x52+2, OEM-ID "NTFS ", sectors/cluster 8, Media descriptor 0xf8, sectors/track 63, heads 255, dos < 4.0 BootSector (0x0), FAT (1Y bit by descriptor); NTFS, sectors/track 63, physical drive 0x80, sectors 15654911, $MFT start cluster 786432, $MFTMirror start cluster 2, bytes/RecordSegment 2^(-1*246), clusters/index block 1, serial number 06258074758071a05; contains bootstrap BOOTMGR

Как можно убедиться, это образ с файловой системой NTFS.

Проверка образа rootfs.sfs:

/mnt/disk_d/rootfs.sfs: Squashfs filesystem, little endian, version 4.0, zstd compressed, 625010200 bytes, 58466 inodes, blocksize: 262144 bytes, created: Sat Jun 6 08:14:32 2020

Это образ с файловой системой Squashfs.

Читайте также:  Linux cat имя файла

Анализ образа ext3-img-kw-1.dd:

file /mnt/disk_d/ext3-img-kw-1.dd
/mnt/disk_d/ext3-img-kw-1.dd: Linux rev 1.0 ext3 filesystem data, UUID=e2307119-024a-427f-bd74-dbe8a95687a6, volume name "KW_SEARCH"

Это образ с файловой системой ext3.

Чтобы выполнять команды по монтированию файлов-образов, вы можете создать образы, например, сделав клон флешки примерно следующим образом:

sudo dd if=/dev/sdc of=/mnt/disk_d/disk.ntfs

В этой команде утилита dd считывает содержимое диска /dev/sdc и сохраняет его в файл /mnt/disk_d/disk.ntfs. Помните, что программа dd считывает не файлы, а байты со всего диска. Поэтому получаемый образ по размеру будет равен диску (разделу) с которого он был сделан, независимо от заполненности этого диска. То есть если флешка размером 8 Гигабайт и на ней ничего не записано, то всё равно получится образ размером 8 Гигабайт.

Вы также можете перейти на страницу http://dftt.sourceforge.net/ - на ней есть ссылки на уроки, с которых вы можете скачать образы самых разных файловых систем.

Как смонтировать файл образа диска (раздела)

Общий вид команды монтирования файлов образов следующий:

mount ОПЦИИ ОБРАЗ ДИРЕКТОРИЯ
  • ОПЦИИ — опции утилиты mount или опции монтирования
  • ОБРАЗ — файл с образом диска
  • ДИРЕКТОРИЯ — папка, где будут доступны файлы со смонтированного устройства

По сути, синтаксис монтирования образов с помощью mount отличается от монтирования диска тем, что вместо УСТРОЙСТВА указывается путь до ОБРАЗА. ОПЦИИ указывать необязательно, тип файловой системы будет определён автоматически.

К примеру, нужно смонтировать образ диска disk.ntfs, расположенный по пути /mnt/disk_d/disk.ntfs.

Начнём с создания временной точки монтирования в /tmp:

Монтируем образ /mnt/disk_d/disk.ntf в папку /tmp/disk:

sudo mount /mnt/disk_d/disk.ntfs /tmp/disk

Просмотрим содержимое образа disk.ntfs:

Мы можем видеть файлы, размещённые в образе disk.ntfs, их можно открывать и копировать.

Некоторые файловые системы (например, ISO образы) доступны только для чтения. Но в данном случае мы можем записать любые изменения в папку /tmp/disk и они сохраняться в файле disk.ntfs даже после размонтирования и повторного монтирования диска disk.ntfs.

Для размонтирования образа можно использовать любую из команд:

sudo umount /ПУТЬ/ДО/ОБРАЗА sudo umount /ТОЧКА/МОНТИРОВАНИЯ/

Пример просмотра содержимого образов с помощью монтирования

Для практики, возьмём установочный образ дистрибутива Linux. Они интересны тем, что там может быть сразу несколько файлов образов с разными файловыми системами. Для примера посмотрим содержимое установочного диска Manjaro.

Создадим папку для монтирования:

У меня установочный диск расположен по пути /mnt/disk_d/Share/manjaro-kde-20.0.3-200606-linux56.iso, а монтировать я его буду в /tmp/iso, тогда команда следующая:

sudo mount /mnt/disk_d/Share/manjaro-kde-20.0.3-200606-linux56.iso /tmp/iso

Получено следующее сообщение:

mount: /tmp/iso: WARNING: source write-protected, mounted read-only.

Оно означает, что монтирование было выполнено, но источник защищён от записи, поэтому монтирование выполнено с правами только чтение. Помните, что последующие монтирования файлов с этого образа могут быть формально доступны для записи, но поскольку начальное хранилище открыто только для чтения, то любые сделанные изменения не сохранятся.

Посмотрим содержимое установочного диска:

Там среди прочего есть файл efi.img, проверим, какая у него файловая система:

/tmp/iso/efi.img: DOS/MBR boot sector, code offset 0x3c+2, OEM-ID "mkfs.fat", sectors/cluster 4, root entries 512, sectors 8192 (volumes 

Мы можем посмотреть содержимое этого файла. Создадим точку монтирования для него

И смонтируем файл /tmp/iso/efi.img в папку /tmp/efi:

sudo mount /tmp/iso/efi.img /tmp/efi

Теперь нам доступно содержимое этого файла:

Вернёмся к нашему смонтированному ISO образу и посмотрим содержимое папки manjaro/x86_64/:

Крошечные файлы с расширением .md5 это просто контрольные суммы. Но файлы desktopfs.sfs, livefs.sfs, mhwdfs.sfs и rootfs.sfs интереснее. Они содержат основные файлы, необходимые для работы LIVE образа и установки дистрибутива Linux.

Мы можем посмотреть содержимое любого из этих файлов. Допустим, нас интересует desktopfs.sfs.

Создаём для него новую временную точку монтирования:

И монтируем файл /tmp/iso/manjaro/x86_64/desktopfs.sfs в папку /tmp/desktopfs:

sudo mount /tmp/iso/manjaro/x86_64/desktopfs.sfs /tmp/desktopfs

Смотрим содержимое файла desktopfs.sfs:

Вы можете самостоятельно смонтировать и изучить содержимое других образов .sfs на этом установочном диске. Либо для самостоятельных упражнений вы можете скачать установочный диск Linux Mint. Там образ файловой системы расположен в файле casper/filesystem.squashfs.

Что касается установочного диска Kali Linux, то там сопроводители дистрибутива не стали использовать образы, а просто разместили файлы внутри iso9660, то есть его не так интересно исследовать.

Связанные статьи:

Источник

Introduction

For an introductory explanation of ISO images, instructions for creating and also burning them see IsoImage.

Mounting ISO Files

For instructions on how to mount an ISO, see MountIso.

Manipulating Other Formats

There are many other formats of archives that have been created over the years for numerous reasons. To mount them, it is usually necessary to convert them to ISO and then use your preferred means. Unless otherwise specified, these programs are available in the Universe repository and can be installed by numerous means. For convenience apturl links have been made, click the package names and they will install as long as the protocol is supported. None of these programs are installed by default.

The following exclusively deals with the command line.

CloneCD/IMG Images

ccd2iso /path/to/example.img /path/to/example.iso
sudo mount -o loop /path/to/example.iso /media/example

CUE/BIN Images

bchunk /path/to/example.bin /path/to/example.cue /path/to/example.iso

MDF Images

mdf2iso /path/to/example.mdf /path/to/example.iso
sudo mount -o loop=/dev/loop0 /path/to/example.iso /media/example

NRG Images

nrg2iso /path/to/example.nrg /path/to/example.iso
sudo mount -o loop,offset=307200 /path/to/example.nrg /media/example

DMG Images

DMG (.dmg) images are primarily used by Apple, conversion of these files will allow data to be accessed. It will not allow the running of OSX programs on Linux without considerable effort not outlined in this guide. The following process will first convert to IMG and then to ISO, you may however stop at the first step if you wish and mount or burn.

Installation

For instructions on installation, see DMG2IMG.

To Convert to IMG

The following command will convert the example file from DMG to IMG.

dmg2img /path/to/example.dmg /path/to/example.img

Do NOT follow the instructions for mounting the file at the end of the conversion. It is not advisable to mount to the /mnt directory.

To Mount

As always a directory will be created in /media, the next step will ensure hfsplus support is available, lastly the IMG file mounted to the directory.

sudo mount -t hfsplus -o loop example.img /media/example

At this point, the image is available for browsing under the /media/example directory. These files can now be transferred to hard drive or elsewhere for storage. If you want an ISO file, continue to the next section.

Creating the ISO

The IMG file we now have is still an hfsplus archive, which cannot simply be converted into an ISO. As such, we will have to use an intermediary step to convert the data from its stored format to an ISO. Since we've already mounted it to a directory, the easiest way is simply to create a new ISO with any disc authoring program you are familiar with. Brasero, GnomeBaker and K3b are just a few options for this.

Simply open your software of choice and start a new data disc. Then add the files from the mounted archive to this new data disc project. Once satisfied, select Burn and instead of recording a CD or DVD, choose to make an ISO file.

For most users, Brasero will be available, for those inexperienced in it's use the following is a guide.

If you're using GNOME then you can run Brasero from Applications -> Sound & Video -> Brasero. Start a new data disc by selecting Data Project from the main Brasero window, or through the menu Project -> New Project. Ensure the side panel is enabled from View -> Enable Side Panel. From the side panel, navigate to the directory where the IMG was mounted, usually the name of the IMG will be listed in the Places pane. In our example, the location in Places would be called example located in the /media/example directory. Simply drag all the files and folders you want to the project.

Once ready, push Burn. and ensure you select to create Image File: at the new window so it creates an ISO. If you wish to change the default name or the location it is created, select Properties. Once satisfied, push Burn and the ISO will be created. Leave Increase compatibility with Windows systems checked unless you know better.

Disc Image Integration for Nautilus

Archive Mounter

By default in GNOME, Nautilus has support for mounting ISOs by simply right clicking on the file and selecting Open with Archive Mounter. This option still appears limited, mainly designed for archives and ISOs. This feature is still under development, thus the following guide will be preserved.

See Also

  • AcetoneISO is a feature rich program which let you mount and burn ISO, BIN, NRG, MDF, and IMG files through a graphical user interface. It's available through Ubuntu's universe repository.
  • Furius Iso Mount, available from the Ubuntu Software Center, enables you to mount ISO, BIN, NRG, MDF, and IMG files through a graphical user interface
  • cdemu is a kernel module for mounting Cue/Bin files directly. To install it you would have to setup linux headers, compile the module and modprobe it in. This is out of the scope of this page. There is a script under development in the Ubuntu forums for automating the building of cdemuLocated Here (Use this at your own risk.)
  • "Mount and Unmount ISO images without burning them" has a nice step-by-step explanation (with screen shots) showing how to mount and unmount ISO images.
  • clonezilla is an open source disk backup & restore distro

ManageDiscImages (последним исправлял пользователь 78 2015-11-30 18:17:47)

The material on this wiki is available under a free license, see Copyright / License for details
You can contribute to this wiki, see Wiki Guide for details

Источник

Оцените статью
Adblock
detector