Linux file system image file

How to mount disk images for viewing and editing files (SOLVED)

How to view information about disk images. How to determine the file system of disk images

You can use the file command to analyze which file system is used in files that are disk images.

An example of checking the test.image file:

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

An example of analyzing the disk.ntfs image:

/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

As you can see, this is an image with the NTFS file system.

Checking the rootfs.sfs image:

/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

This is a Squashfs file system image.

Analysis of the ext3-img-kw-1.dd image:

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"

This is an ext3 file system image.

To practice in mounting image files, you can create images, for example, by making a clone of a flash drive something like this:

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

In this command, the dd utility reads the contents of the /dev/sdc disk and saves it to the /mnt/disk_d/disk.ntfs file. Remember that dd does not read files, but bytes from the entire disk. Therefore, the resulting image will be equal in size to the disk (partition) from which it was made, regardless of the fullness of this disk. That is, if a flash drive is 8 Gigabytes in size and nothing is written on it, you will still get an 8 Gigabyte image.

You can also go to the page http://dftt.sourceforge.net/ - there are links to tutorials from which you can download images of a variety of file systems.

How to mount a disk (partition) image file

The general view of the command to mount image files is as follows:

mount OPTIONS IMAGE DIRECTORY
  • OPTIONS – mount utility options or mount options
  • IMAGE – a file with a disk image
  • DIRECTORY – folder where files from the mounted device will be available
Читайте также:  Узнать сколько памяти осталось linux

In fact, the syntax for mounting images using mount differs from mounting a disk in that instead of a DEVICE, the path to the IMAGE is specified. It is optional to specify OPTIONS, the file system type will be determined automatically.

For example, one needs to mount the disk image disk.ntfs located at the path /mnt/disk_d/disk.ntfs.

Let's start by creating a temporary mount point in /tmp:

Mount the /mnt/disk_d/disk.ntf image to the /tmp/disk folder:

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

Let's look at the contents of the disk.ntfs image:

We can see the files located in the disk.ntfs image, they can be opened and copied.

Some file systems (eg ISO images) are read-only. But in this case, we can write any changes to the /tmp/disk folder, and they are saved in the disk.ntfs file even after unmounting and re-mounting disk.ntfs.

You can use any of the following commands to unmount the image:

sudo umount /PATH/TO/IMAGE sudo umount /MOUNT/POINT/

An example of viewing the contents of images using a mount

For practice, let's take the installation image of the Linux distribution. They are interesting because there can be several image files with different file systems at once. Let's take a look at the contents of the Manjaro installation CD for example.

Let's create a folder for mounting:

My installation disk is located along the path /mnt/disk_d/Share/manjaro-kde-20.0.3-200606-linux56.iso, and I will mount it in /tmp/iso, then the command is as follows:

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

Received the following message:

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

It means that the mount was done, but the source is write-protected, so the disk is read-only. Remember that subsequent mounts of files from this image may be formally writable, but since the initial store is read-only, any changes made will not be saved.

Let's see the contents of the installation disk:

There, among other things, there is a file efi.img, let's check what file system it has:

/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 

We can see the contents of this file. Let's create a mount point for it:

And mount the file /tmp/iso/efi.img to the /tmp/efi folder:

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

Now the contents of this file are available to us:

Let's go back to our mounted ISO image and see the contents of the manjaro/x86_64/ folder:

Tiny files with a .md5 extension are just checksums. But the files desktopfs.sfs, livefs.sfs, mhwdfs.sfs, and rootfs.sfs are more interesting. They contain the main files required for the LIVE image to work and to install the Linux distribution.

We can view the contents of these files. Let's say we are interested in desktopfs.sfs.

Create a new temporary mount point for it:

And mount the /tmp/iso/manjaro/x86_64/desktopfs.sfs file to the /tmp/desktopfs folder:

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

Let's look at the contents of the desktopfs.sfs file:

You can mount and examine the contents of other .sfs images on this installation disk yourself. Alternatively, you can download the Linux Mint installation disc for self-guided exercise. There, the file system image is located in the casper/filesystem.squashfs file.

As for the Kali Linux installation disk, the distribution maintainers did not use images there, but simply placed the files inside iso9660 filesystem, that is, it is not so interesting to explore.

Источник

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

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

С помощью команды 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.

Анализ образа 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, то есть его не так интересно исследовать.

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

Источник

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