CentOS 7.x Mount file or partitions of file as typically done for disks

From Notes_Wiki

Home > CentOS > CentOS 7.x > System Administration > File system management > CentOS 7.x Mount file or partitions of file as typically done for disks

kpartx

One option is to use Kpartx as it is straightforward and has been seen to work without any difficulty since quite some time.


losetup

Other option is to use 'losetup'

To use losetup see example given in 'man losetup' below:

         The following commands can be used as an example of using the loop device.
  
              # dd if=/dev/zero of=~/file.img bs=1024k count=10
              # losetup --find --show ~/file.img
              /dev/loop0
              # mkfs -t ext2 /dev/loop0
              # mount /dev/loop0 /mnt
               ...
              # umount /dev/loop0
              # losetup --detach /dev/loop0

That is, use

losetup --find --show -P <file-or-device>

if there are further partitions. Other option is to let device get created and then do

  partprobe /dev/loop1



Home > CentOS > CentOS 7.x > System Administration > File system management > CentOS 7.x Mount file or partitions of file as typically done for disks