вторник, 23 января 2018 г.

Монтирование iso или raw диска





Если у Вас простой raw-образ, то используя losetup и mount, можно как-то так:
Код
[root@aliCD images]# losetup  /dev/loop1 CentOS.img
[root@aliCD images]# fdisk -lu /dev/loop1

Диск /dev/loop1: 4294 МБ, 4294967296 байт
255 heads, 63 sectors/track, 522 cylinders, всего 8388608 секторов
Units = секторы of 1 * 512 = 512 bytes
Disk identifier: 0x0008442d

Устр-во Загр     Начало       Конец       Блоки   Id  Система
/dev/loop1p1   *          63     8385929     4192933+  83  Linux
[root@aliCD images]#
[root@aliCD images]# mount -t ext3 -o loop,offset=32256 /dev/loop1 /home/ali/Loop/

Зачем же такой огород-то, -o loop создаст ещё одно loop-устройство, это абсолютно излишне.
Вместо этого нужно проще делать:
Код
# losetup -o 32256 /dev/loop1 CentOS.img
# mount -t ext3  /dev/loop1 /home/ali/Loop/

 

 

Mounting a raw partition file made with dd or dd_rescue in Linux


This situation might not affect everyone, but it struck me today and left me scratching my head. Consider a situation where you need to clone one drive to another with dd or when a hard drive is failing badly and you use dd_rescue to salvage whatever data you can.
Let’s say you cloned data from a drive using something like this:
Once that’s finished, you should end up with your partition table as well as the grub data from the MBR in your image file. If you run file against the image file you made, you should see something like this:
What if you want to pull some files from this image without writing it out to another disk? Mounting it like a loop file isn’t going to work:
The key is to mount the file with an offset specified. In the output from file, there is a particular portion of the output that will help you:
This means that the filesystem itself starts on sector 63. You can also view this with fdisk -l:
Since we need to scoot 63 sectors ahead, and each sector is 512 bytes long, we need to use an offset of 32,256 bytes. Fire up the mount command and you’ll be on your way:
If you made this image under duress (due to a failing drive or other emergency), you might have to check and repair the filesystem first. Doing that is easy if you make a loop device:
Once that’s complete, you can save some time and mount the loop device directly:

1 комментарий: