Разделы внутри образа





Есть такой вот файлик, в котором сделано два раздела:

Диск ./testfile.img: 209 МБ, 209715200 байт

255 heads, 63 sectors/track, 25 cylinders, всего 409600 секторов

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0xedccbf3a

Устр-во Загр Начало Конец Блоки Id Система

./testfile.img1 2048 206847 102400 83 Linux

./testfile.img2 206848 409599 101376 83 Linux

Вот как бы с него подмонтировать эти два раздела? :)


modunt -t file_system testfile.img /mount_point -o offset=$((2048*512))
modunt -t file_system testfile.img /mount_point -o offset=$((206848*512))
kostik87 ★★★★★ ()
Последнее исправление: kostik87 (всего исправлений: 1)
Ответ на: комментарий от kostik87


Интересно, а сработает в отношении разделов внутри софтверного RAID-массива?

То есть, то же самое, но для md0 ?

И как на таких разделах создать файловую систему?

slamd64 ★★★★★ ()
Последнее исправление: slamd64 (всего исправлений: 1)
Ответ на: комментарий от slamd64

То есть, то же самое, но для md0 ?


И как на таких разделах создать файловую систему?

Либо использовать losetup либо использовать kpartx, а уже на созданных loop устройствах создавать файловые системы.

kostik87 ★★★★★ ()
Ответ на: комментарий от kostik87

With loop module autodetecting partitions
The Linux loop driver actually supports partitions in loopback devices, but it is disabled by default. To enable it, do the following:
Get rid of all your loopback devices (unmount all mounted images, etc.).
Unload the loop kernel module, and load it with the max_part=15 parameter set. Additionally, the maximum number of loop devices can be controlled with the max_loop parameter.
Tip: You can put an entry in /etc/modprobe.d to load the loop module with max_part=15 every time, or you can put loop.max_part=15 on the kernel command-line, depending on whether you have the loop.ko module built into your kernel or not.
Set up your image as a loopback device:
# losetup -f -P disk_image
Then, if the device created was /dev/loop0, additional devices /dev/loop0pX will have been automatically created, where X is the number of the partition. These partition loopback devices can be mounted directly. For example:
# mount /dev/loop0p1 mountpoint
To mount the disk image with udisksctl, see Udisks#Mount loop devices.
With kpartx
kpartx from the multipath-toolsAUR package can read a partition table on a device and create a new device for each partition. For example:
# kpartx -a disk_image
This will setup the loopback device and create the necessary partition(s) device(s) in /dev/mapper/.
Mounting a partition inside a qcow2 image
You may mount a partition inside a qcow2 image using qemu-nbd. See Wikibooks.
Using any real partition as the single primary partition of a hard disk image
Sometimes, you may wish to use one of your system partitions from within QEMU. Using a raw partition for a virtual machine will improve performance, as the read and write operations do not go through the file system layer on the physical host. Such a partition also provides a way to share data between the host and guest.
In Arch Linux, device files for raw partitions are, by default, owned by root and the disk group. If you would like to have a non-root user be able to read and write to a raw partition, you need to change the owner of the partition's device file to that user.
Although it is possible, it is not recommended to allow virtual machines to alter critical data on the host system, such as the root partition.
You must not mount a file system on a partition read-write on both the host and the guest at the same time. Otherwise, data corruption will result.
After doing so, you can attach the partition to a QEMU virtual machine as a virtual disk.
However, things are a little more complicated if you want to have the entire virtual machine contained in a partition. In that case, there would be no disk image file to actually boot the virtual machine since you cannot install a bootloader to a partition that is itself formatted as a file system and not as a partitioned device with a MBR. Such a virtual machine can be booted either by specifying the kernel and initrd manually, or by simulating a disk with a MBR by using linear RAID.

anonymous ()
Ответ на: комментарий от slamd64

То есть, то же самое, но для md0 ?

man md, «одмин».

anonymous ()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.