3

I'm trying to mount a .dd image. I followed 2 methods without success ...

Method 1

1st step:

root@evilcode1:/root# blkid qassam.dd
qassam.dd: UUID="524F4B6665E82B4E" TYPE="ntfs"

2nd step:

I ran this command to attach the image to a loop device

sudo losetup -f -P qassam.dd

3rd step:

Then I ran this command to verify that the image was detected and the partition(s) were detected:

losetup -l

command output

4th step:

When I try to mount the image by this command mount /dev/loop10 q/ I got this error:

ntfs_mst_post_read_fixup_warn: magic: 0x00000000  size: 4096   usa_ofs: 0  usa_count: 0: Invalid argument
Actual VCN (0x0) of index buffer is different from expected VCN (0x3).
Failed to open $Secure: No such file or directory
Failed to mount '/dev/loop10': No such file or directory

Method 2

I used kpartx -a -v qassam.dd and I got this error:

device-mapper: resume ioctl on loop9p1 failed: Invalid argument create/reload failed on loop9p1
device-mapper: resume ioctl on loop9p2 failed: Invalid argument create/reload failed on loop9p2
device-mapper: resume ioctl on loop9p3 failed: Invalid argument create/reload failed on loop9p3
device-mapper: resume ioctl on loop9p4 failed: Invalid argument create/reload failed on loop9p4
4
  • Would this answer help?
    – jc__
    Apr 6, 2018 at 18:35
  • 1
    Did you create the image qassam.dd ? Is it an image of a drive with one NTFS partition? Of is it an image of a partition with [the file system] NTFS? Or something else? Or don't you know what kind of image it is? -- If an image of a drive (with one or more partitions, it is probably easiest to clone the image to an external drive (that is big enough), for example a USB pendrive, if the image is fairly small. You can do that in a safe way with mkusb, and then mount the partition(s) 'as usual'. But I have also used kpartx for this purpose.
    – sudodus
    Apr 6, 2018 at 18:35
  • 1
    @Zanna, it is a good idea to post a speculative answer. Let us hope it will be useful for some people :-)
    – sudodus
    Dec 15, 2018 at 23:31
  • See the answers in this question: askubuntu.com/questions/69363/…
    – erik
    May 5, 2020 at 22:53

1 Answer 1

4

The OP never told us any details about their file qassam.dd, so we can only guess why they failed to mount it.

  • Maybe they forgot elevated permissions, sudo for the mount command.
  • Maybe the file system in the image file was corrupted.
  • Maybe it should have been loop mounted directly (not via losetup).
  • Maybe the partition table was GPT.
  • Maybe the mount command line was wrong, the OP should have looked for the device map of the partition, and used /dev/loop10p1 or /dev/mapper/loop10p1 not /dev/loop10 in the mount command.

Image file of a partition with NTFS

An image of a partition should be possible to loop mount directly, and I tested it like this,

sudo mount -o loop ntfs.img /mnt/sd1

$ echo "Hello World" > /mnt/sd1/hello.txt
$ ls -l /mnt/sd1
totalt 1
-rwxrwxrwx 1 root root 12 dec 15 23:10 hello.txt
$ cat /mnt/sd1/hello.txt
Hello World


$ losetup -l
NAME  SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE                                DIO LOG-SEC
/dev/loop0    0      0         1  0 /media/multimed-2/test/test0/temp/ntfs.img 0     512

sudo mount /dev/loop0 /mnt/lp1

$ sudo lsblk -fm /dev/loop0
NAME  FSTYPE LABEL UUID                          MOUNTPOINT SIZE OWNER GROUP MODE
loop0 ntfs         3B1CD6465B1E284E              /mnt/sd1     4G root  disk  brw-rw----

Image files of drives with partition tables

With MSDOS partition tables it was possible to mount and see the file systems via the first method of the question,

sudo losetup -f -P filename.img

list the result with

losetup -l

and mount the file system(s) with

sudo mount /dev/loop0p1 /mnt/lp1
sudo mount /dev/loop0p2 /mnt/lp2
...

With a GUID partition table it was possible to see the file systems via the second method of the question (but the first method failed),

sudo kpartx -a -v -g filename.img

Testing with an available image file,

sudo kpartx -a -v -g Lubuntu_16.04.2_amd64_persist-live_mkusb-12.1.2_7.8GB_guid-pt.img

it did not work to mount the file system(s) with

sudo mount /dev/loop0p1 /mnt/lp3
sudo mount /dev/loop0p2 /mnt/lp4
...

The loop devices could be seen by lsblk but the loop devices were hidden in the mapper subdirectory, found via find

$ sudo find /dev/ -name "*loop0*"
/dev/disk/by-id/dm-name-loop0p5
/dev/disk/by-id/dm-name-loop0p4
/dev/disk/by-id/dm-name-loop0p3
/dev/disk/by-id/dm-name-loop0p2
/dev/disk/by-id/dm-name-loop0p1
/dev/mapper/loop0p5
/dev/mapper/loop0p4
/dev/mapper/loop0p3
/dev/mapper/loop0p2
/dev/mapper/loop0p1
/dev/loop0

It was possible to mount them, for example

sudo mount /dev/mapper/loop0p1 /mnt/lp1

$ sudo lsblk -fm /dev/loop0
NAME      FSTYPE  LABEL                     UUID                                 MOUNTPOINT  SIZE OWNER GROUP MODE
loop0                                                                                        7,3G root  disk  brw-rw----
├─loop0p1 ntfs    usbdata                   09BA4B4A391B6781                     /mnt/lp1    1,3G root  disk  brw-rw----
├─loop0p2                                                                                      1M root  disk  brw-rw----
├─loop0p3 vfat    usbboot                   8A41-08E7                                        122M root  disk  brw-rw----
├─loop0p4 iso9660 Lubuntu 16.04.2 LTS amd64 2017-02-15-20-52-49-00                           898M root  disk  brw-rw----
└─loop0p5 ext4    casper-rw                 5bb1ca94-c265-4317-8b87-39a5486b16b9               5G root  disk  brw-rw----

$ ls -l /mnt/lp1
totalt 12
-rwxrwxrwx 1 root root 3582 feb 25  2017 backup
-rwxrwxrwx 1 root root 4592 feb 25  2017 restore

Output during testing some available img files with MSDOS partition table:

$ losetup -l
NAME       SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE                                                                                                                   DIO LOG-SEC
/dev/loop1         0      0         0  0 /media/multimed-2/test/torios/persist/grub-n-iso/dd_ToriOS-persistent.img                                                     0     512
/dev/loop2         0      0         0  0 /media/multimed-2/boot-usb/OneButtonInstaller/xz/dd_Lubuntu_18.04_i386_persist-live_15.7GB_casper-rw_home-rw_msdos.img        0     512
/dev/loop0         0      0         0  0 /media/multimed-2/boot-usb/OneButtonInstaller/xz/dd_Lubuntu_16.04.1-persist-live-and-installed-mkusb-11.0.5_7.8GB-msdos.img   0     512

$ sudo lsblk -fm /dev/loop[0-2]
NAME      FSTYPE  LABEL                     UUID                                 MOUNTPOINT  SIZE OWNER GROUP MODE
loop0                                                                                       14,6G root  disk  brw-rw----
├─loop0p1 ntfs    usbdata                   35CF6A8A4AB6BF72                     /mnt/lp1    2,2G root  disk  brw-rw----
├─loop0p2                                                                                      1K root  disk  brw-rw----
├─loop0p3 vfat    usbboot                   2706-585F                            /mnt/lp2    122M root  disk  brw-rw----
├─loop0p4 iso9660 Lubuntu 16.04.1 LTS amd64 2016-07-20-12-16-02-00               /mnt/lp3    874M root  disk  brw-rw----
├─loop0p5 ext4    casper-rw                 e47ec6db-149d-4d30-98af-0419786ba250 /mnt/lp4    4,6G root  disk  brw-rw----
├─loop0p6 ext4    installed                 1acf7b6f-bb3b-4d18-90ec-454f8353c84f /mnt/lp5    5,9G root  disk  brw-rw----
└─loop0p7 swap    swap                      f2d7bd6e-eca9-48e8-a203-a1de2665d0e5            1023M root  disk  brw-rw----
loop1                                                                                        792M root  disk  brw-rw----
├─loop1p1 vfat    bootgrub                  C192-D34A                                         16M root  disk  brw-rw----
├─loop1p2 iso9660 torios-live               2015-06-14-16-48-49-00                           725M root  disk  brw-rw----
└─loop1p3 ext2    live-rw                   a9843e51-4141-408b-975b-52d89eca1b28              50M root  disk  brw-rw----
loop2                                                                                       14,6G root  disk  brw-rw----
├─loop2p1 vfat    lub1804-32                D4E5-7662                                         64M root  disk  brw-rw----
├─loop2p2 ext4    isodevice                 1b9f2fa2-1eab-49fa-be1c-57d38acb221f             2,2G root  disk  brw-rw----
├─loop2p3 ext4    casper-rw                 6c49bda6-68d5-44ea-9904-22b52aee2400               5G root  disk  brw-rw----
└─loop2p4 ext4    home-rw                   53476429-dc26-4395-b951-065b8c36060e             7,3G root  disk  brw-rw----
3
  • @Zanna, Thank you for reviving questions, where an answer can be useful for several people.
    – sudodus
    Dec 16, 2018 at 11:57
  • As of 2020 it is also possible just use losetup for GPT partition tables.
    – erik
    May 5, 2020 at 22:52
  • @erik, Thanks for this update about losetup for GPT :-)
    – sudodus
    May 6, 2020 at 6:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.