With the command pv it is possible to clone a drive, how do I mount it? [duplicate]

tisaconundrum 09/13/2018. 3 answers, 286 views
mount disk-image pv

This question already has an answer here:

I was able to backup a drive using the following command.

pv -EE /dev/sda > disk-image.img

This is all well and good, but now I have no way of seeing the files unless I use this command

pv disk-image.img > /dev/sda

This, of course, writes the data back to the disk which is not what I want to do. My question is what can I do to mount the .img file itself instead of just writing back to a disk?

I've tried mounting using loop but it seems to complain about an invalid NTFS.

$ mount -o loop disk-image.img
mount: disk-image.img: can't find in /etc/fstab.
$ mount -o loop disk-image.img /mnt/disk-image/
NTFS signature is missing.
Failed to mount '/dev/loop32': Invalid argument
The device '/dev/loop32' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?

3 Answers

Antonio Petricca 09/14/2018.

You backed up the whole disk including the MBR (512 bytes), and not a simple partition which you can mount, so you have to skip the MBR.

Please try with:

sudo losetup -o 512 /dev/loop0 disk-image.img
sudo mount -t ntfs-3g /dev/loop0 /mnt 

Edit: as suggested by @grawity:

sudo losetup --partscan /dev/loop0 disk-image.img
sudo mount -t ntfs-3g /dev/loop0 /mnt 

telcoM 09/14/2018.

As others have already pointed out,

sudo losetup /dev/loop0 /path/to/disk-image.img

will set up a virtual block device that can be used to access the file, but it does not give you easy access to the partitions.

However, there is another command you can use after that to gain access to all the partitions within the disk image file, without manually calculating partition offsets:

sudo kpartx -a /dev/loop0

This will read the partition table within the disk image, and will create devices like /dev/mapper/loop0p1, /dev/mapper/loop0p2 etc. for all the partitions. You can use those to mount the partitions normally.

(If you don't remember what each partition is, you could use fdisk -l /dev/loop0 to view the partition table within the disk image; just note that many versions of fdisk will display the names of the partition devices a little oddly in this situation.)

Once you've done accessing the disk image, you can undo this set-up by unmounting the partitions you've mounted, and then using two commands:

sudo kpartx -d /dev/loop0   # remove the /dev/mapper/loop0pN partition mappings
sudo losetup -d /dev/loop0  # disconnect the image file from the loop device

The kpartx command was originally developed as a tool for multipathed devices (as used with SAN storage systems), but it is perfectly usable with disk images too.

K7AAY 09/13/2018.

Install p7zip-full if you don't have it already, then take a look with

sudo 7z  /pathtowhereitis/whatever.img

HighResolutionMusic.com - Download Hi-Res Songs

1 The Chainsmokers

Beach House flac

The Chainsmokers. 2018. Writer: Andrew Taggart.
2 (G)I-DLE


(G)I-DLE. 2018. Writer: Riot Music Team;Harloe.
3 Ariana Grande

​Thank U, Next flac

Ariana Grande. 2018. Writer: Crazy Mike;Scootie;Victoria Monét;Tayla Parx;TBHits;Ariana Grande.
4 Anne-Marie

Rewrite The Stars flac

Anne-Marie. 2018. Writer: Benj Pasek;Justin Paul.
5 Clean Bandit

Baby flac

Clean Bandit. 2018. Writer: Jack Patterson;Kamille;Jason Evigan;Matthew Knott;Marina;Luis Fonsi.
6 Nicki Minaj

No Candle No Light flac

Nicki Minaj. 2018. Writer: Denisia “Blu June” Andrews;Kathryn Ostenberg;Brittany "Chi" Coney;Brian Lee;TJ Routon;Tushar Apte;ZAYN;Nicki Minaj.
7 BlackPink

Kiss And Make Up flac

BlackPink. 2018. Writer: Soke;Kny Factory;Billboard;Chelcee Grimes;Teddy Park;Marc Vincent;Dua Lipa.
8 Imagine Dragons

Bad Liar flac

Imagine Dragons. 2018. Writer: Jorgen Odegard;Daniel Platzman;Ben McKee;Wayne Sermon;Aja Volkman;Dan Reynolds.

Waste It On Me flac

BTS. 2018. Writer: Steve Aoki;Jeff Halavacs;Ryan Ogren;Michael Gazzo;Nate Cyphert;Sean Foreman;RM.
10 Halsey

Without Me flac

Halsey. 2018. Writer: Halsey;Delacey;Louis Bell;Amy Allen;Justin Timberlake;Timbaland;Scott Storch.
11 Little Mix

Woman Like Me flac

Little Mix. 2018. Writer: Nicki Minaj;Steve Mac;Ed Sheeran;Jess Glynne.
12 Brooks

Limbo flac

Brooks. 2018.
13 Fitz And The Tantrums

HandClap flac

Fitz And The Tantrums. 2017. Writer: Fitz And The Tantrums;Eric Frederic;Sam Hollander.
14 Backstreet Boys

Chances flac

Backstreet Boys. 2018.
15 Lady Gaga

I'll Never Love Again flac

Lady Gaga. 2018. Writer: Benjamin Rice;Lady Gaga.
16 Diplo

Close To Me flac

Diplo. 2018. Writer: Ellie Goulding;Savan Kotecha;Peter Svensson;Ilya;Swae Lee;Diplo.
17 Rita Ora

Velvet Rope flac

Rita Ora. 2018.
18 Bradley Cooper

Always Remember Us This Way flac

Bradley Cooper. 2018. Writer: Lady Gaga;Dave Cobb.
19 Imagine Dragons

Machine flac

Imagine Dragons. 2018. Writer: Wayne Sermon;Daniel Platzman;Dan Reynolds;Ben McKee;Alex Da Kid.
20 Erika Sirola

Speechless flac

Erika Sirola. 2018. Writer: Teemu Brunila;Stefan Dabruck;Jürgen Dohr;Guido Kramer;Dennis Bierbrodt;Chris Braide;Robin Schulz.

Related questions

Hot questions


Popular Tags