Как открыть img linux

Tutorial: How to mount raw images (.img) images on Linux

If you have a few .img files coming as disk images from devices like floppies, CDs, DVDs, SD cards, etc, you will realize that you cannot mount the in Linux, because they contain a file system that has to be mounted.

In linux you would need to use the mount command as for any physical device, however you need to know the correct syntax that is based on understanding the information related to the partition(s) available in the image.

First step is to read the partition Start point using fdisk:

You will see an output similar to the one below:
Device boot Start End Blocks Id System
imgfile.img1 * 63 266544 722233 C W95 FAT32 (LBA)
imgfile.img2 25679 25367890 245667890+ 83 Linux

As you can see there are two partitions, one that is FAT32 and the other one that it’s ExtFS. This means that to mount the first partition we have to tell Linux that we need to start at the sector 63. The standard sector size is 512 bytes, however there are other possibilities like 128 or 1024. Assuming that the place from where you are downloading the image doesn’t specify any sector size, we can type in the terminal:

sudo mount -t vfat -o loop,offset=$((63 * 512)) imgfile.img /mnt/disk

To mount the second partition, as you can imagine:

mount -t ext4 -o loop,offset=$((25679 * 512)) imgfile.img /mnt/disk1

It’s important to copy the “Start” sector number correctly, otherwise you’ll get an error message like:

mount : wrong fs type, bad option, band superblock on /dev/loop,
missing codepage or helper proggram, or other error
In some cases useful info is found in syslog – try
dmesg | tail or so

One last thing, the standard sector size for CDs and DVDs is 2352 instead of 512. If you are opening such image, you’ll have to use this value instead of 512.

Incoming search terms:

  • https://stefanoprenna com/blog/2014/09/22/tutorial-how-to-mount-raw-images-img-images-on-linux/
  • how to mount raw img disk linux

Источник

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

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

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

Читайте также:  Manjaro xfce vs linux mint

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

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

Источник

How to Mount IMG Files in Linux

ISO images are often used to contain CD-ROM or DVD data, but Linux users will occasionally find themselves working with IMG files instead. These contain direct disk images, which can be worked with in a similar way. At one point these were generally used for writing an entire file system directly to a discrete diskette, but few people would ever wish to do that in today’s world. There are two major reasons modern Linux users would need to work with them, however. One is if an IMG file was used to distribute a driver or other piece of an operating system that needed to be restored. The IMG file can be mounted and the individual file from inside of it’s contained system could then be copied over to a booted file structure. The other reason, which is becoming extremely popular, is for working with virtual machines and other forms of hardware virtualization.

Linux provides several different ways to work with these contained structures. Depending on your distribution, you might be able to work with them in a purely graphical environment. The same CLI tools that mount ISO images could also mount IMG if this isn’t possible for you, however.

Method 1: Mount With Graphical Menus

If you’re using PCManFM or another file manager that supports mounting an image directly via the /media folder with a menu driven system such as some versions of Nautilus, then you should hold launch your manager to start. You’ll either need to launch this from the Panel Menu in LXDE or from the Applications menu in GNOME. Once you’re open, navigate to the Downloads folder by clicking the link in the left panel and then right click on the disk image you downloaded. It’s generally smart to have ensured that your browser didn’t detect any malware before proceeding.

picture-a

Once the context menu appears, select the “mount disk image” option. The label for this command will change depending on your particular distribution. The image will automatically mount at /media/USERNAME/disk, with USERNAME being replaced with your actual user name. Click on the left panel of the file manager where it reads the size of the image in question. In our example we used an image of an older Linux distribution called tomsrtbt (pronounced Tom’s Root Boot), which fit an entire operating system in less than three megabytes. Hence the “2.9 MB Volume” label refers to the image in question.

picture-b

You may now drag or right click and copy any of these files to any other section of your file system for safekeeping. When you’re done you can click on the X logo next to the label to close it. If you’re using a file manager that doesn’t support this method of unmounting an image, then start the GNOME Disks utility from the Panel Menu or the Applications tab. Click on the device that has the same name as the label from the file manager and then click on the square stop button to close down the file system.

picture-c

Method 2: Via the Loopback Device

Disk images could be mounted via the loopback device as well, in much the same way as ISO images can be. This technique will be necessary if you use Thunar, Konqueror or any other file manager that doesn’t support direct mounting via graphical techniques. If you haven’t been able to mount an image graphically, then hold down CTRL, ALT and T at the same time. Type ls /mnt to make sure your /mnt directory is empty. If it’s not or if you don’t feel comfortable using it directly, then you can use sudo mkdir /mnt/toms to create a mountable directory. You could theoretically call the directory whatever you’d like. Type sudo mount -o loop tomsrtbt-2.0.103.ElTorito.288.img /mnt and press enter. You will be prompted to enter your password, which you will be required to do. The /mnt directory can then be explored via the CLI or the file manager you prefer. Naturally you’ll need to replace tomsrtbt-2.0.103.ElTorito.288.img with the image you’re using and /mnt with the directory tree segment you’re using.

picture-d

Hold down CTRL and E to open your graphical manager or start it from the Applications or Whisker menu depending on which desktop environment you are using. Select the File System option from the left pain, navigate to /mnt and then select the /mnt folder. You’ll now be able to examine the contents of the image file.

picture-e

At the CLI type sudo umount /mnt and press enter to umount the image. You would need to substitute whatever mount point you used for /mnt when you do so.

Источник

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