Mount single partition from image of entire disk (device)


I made an image of my entire disk with

dd if=/dev/sda of=/media/external_media/sda.img

Now the problem is I'd like to mount an ext4 filesystem that was on that disk but

mount -t ext4 -o loop /media/external_media/sda.img /media/sda_image

obviously gives a superblock error since the image contains the whole disk (mbr, other partitions) not just the partition I need. So I guess I should find a way to make the disk image show up in the /dev/ folder... Does anyone know how to do that?

PS: I can always dd back the image to the original disk, but that would be very inconvenient (I updated the OS and I'd like to keep it as it is)

Get the partition layout of the image

$ sudo fdisk -lu sda.img ... Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes ... Device Boot Start End Blocks Id System sda.img1 * 56 6400000 3199972+ c W95 FAT32 (LBA)

Calculate the offset from the start of the image to the...

0 0

I have an image of the entire disk created using dd. The disk structure follows:

fdisk -l /home/hades/Downloads/legko_client.dd

Disk /home/hades/Downloads/legko_client.dd: 2 GiB, 2147483648 bytes, 4194304 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00047c7a

Device Boot Start End Sectors Size Id Type
/home/hades/Downloads/legko_client.dd1 8192 122879 114688 56M c W95 FAT32 (LBA)
/home/hades/Downloads/legko_client.dd2 122880 3788799 3665920 1.8G 83 Linux

No need to use offsets or kpartx anymore:

losetup --partscan --find --show /home/hades/Downloads/legko_client.dd
mount /dev/loop0p2 /media/floppy

0 0



Last Updated November 09, 2016 08:00 AM

If I make a disk image and compress it with gzip/xz/etc is there a way to mount it directly without first uncompressing it?

Say I've used

sudo dd if=/dev/sdc1 | gzip -9 > image1.dd.gz

how can I mount the original image, without creating an uncompressed copy first?

Or I've used

sudo dd if=/dev/sdc | gzip -9 > wholedisk.dd.gz

and the disk has multiple partitions, would that make it any harder?

With an uncompressed image of a whole disk then using kpartx or newer versions of losetup with it's -P flag should create a loop for each partition.

But is there a way to mount/losetup/read the compressed image?

If it won't work for gzip/xz, is there any compression method this would work for?

The currently suggested duplicate


mount will not mount a compressed image by itself.

Answers 2


0 0

The Problem:

I have a disk image file (created by dd). It is an image of an entire drive and contains partitions. I would like to be able to mount one of those partitions inside Linux. Can this be done?

Like lots of things in Unix based OS, the answer is a resounding ‘YES! If you try hard enough!’. I’m sick of trying hard so I’m posting the answer here in case it happens to help someone else.

The Solution:

First we need to find out the sector layout of our partition system inside the image filfdisk -l /path/to/image

In my case this gives me something like:

Now we can mount is as a loop device with a simple calculation of the byte offset of the partition. In my case I want to mount the first partition and I now know it starts at sector 2048

I also know the sector size is 512 bytes so I can work out the offset ( 512 x 2048 = 1048576 ) i.e. its exactly 1MB offset inside the file.

Lets mount it.

Thats it...

0 0

In Linux/Unix or perhaps in every computer system, a term mounting is defined as attaching additional filesystem to the currently accessible filesystem of a computer. As we know, a filesystem is hierarchy of directories (also referred to as a directory tree) that is used to organize files on a computer or storage media.

We might familiar or maybe remember how to mount a partition well. But that’s when the partition is inside a storage media or physical medium. What if the partition we want to access is in form of disk image? Here, we will discuss it.

In this article I use:

Slackware64 14.0 dumped image from 4GB SD-card, using dd

Disk Image

A disk image is a single file or storage device containing the complete contents and structure representing a data storage medium or device, such as hard drive, tape drive, floppy disk, optical disc, or USB flash drive. A disk image is usually created by creating a complete sector-by-sector copy of the source medium...

0 0
Mount a partition from dd disk image

You can mount partition from a dd image of the disk if you know the offset of the partition.

[Jan 05, 2012] Mount a partition from dd-created image of a HDD

I have an image of the entire disk created using dd. The disk structure follows:kent@cow:~$ sudo fdisk -l Disk /dev/sda: 750.1 GB, 750156374016 bytes 255 heads, 63 sectors/track, 91201 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x000b8508 Device Boot Start End Blocks Id System /dev/sda1 * 5 90872 729929303+ 83 Linux /dev/sda2 90873 91201 2642692+ 5 Extended /dev/sda5 90873 91201 2642661 82 Linux swap / Solaris

The image was created using:

dd if=/dev/sda of=image750.img

How would I, if it is possible, mount /dev/sda1 from the image so that I'm able to read the contents?

It's not an option to clone the HDD again, I know how to do it if I had only cloned the single partition by...

0 0
This might be in the wrong forum. I don't know, I really had no idea where to put it, so please move it if necessary.

What I did:
Used ddrescue to clone a 500GB hard drive that was failing (read errors, wouldn't boot, etc...)
The command I used to do it was:


sudo ddrescue /dev/sdh /location/I/picked.imgWell it took it 2 days, but it finally got past all the errors and completed.

What I'm trying to do:
Now that I have a copy of it all, I want to mount the image and access the files.

What's not working?
When I enter:


sudo mount picked.img /where/I/want/to/mount/it/it says: "mount: /location/I/picked.img is not a block device (maybe try `-o loop'?)"

And when I try


sudo mount -o loop picked.img /where/I/want/to/mount/it/it says: "mount: you must specify the filesystem type"

Well the disk was partitioned with NTFS, so I try


sudo mount -t ntfs -o loop picked.img...
0 0
Backing up hard disks and hard disk partitions

It's often useful to make an image of either an entire hard disk or an entire partition. One reason is to duplicate an installed system onto another PC (probably over a network connection); another is to make a backup of your complete hard disk including every aspect of the installed operating systems, which you can restore if you have to replace your hard disk or if you screw things up. Typically it's useful to be able to transfer these images over the network to another machine, although you may want to save images onto a different partition or hard disk.

Commercial tools to do this job include Norton Ghost, Acronis TrueImage (which now seems to have overtaken Ghost in usefulness), and DriveImage (which I believe can't save over the network). Nowadays these tools are quite sophisticated and can even work from within Windows on mounted filesystems and do incremental block-level backups. There is a open source Linux program...

0 0

A while ago I thought it would be a good idea to make a backup of my Linux server by just dumping the complete disk to a file. In retrospect, it would have been much easier had I just dumped the individual filesystems.

When I finally got around to using this backup, long after the 10GB disk had perished I realized that to use the loopback device to mount a filesystem it actually needs a filesystem to mount. What I had was a disk image, including partition table and individual partitions. To further complicate matters the data partition was also not the first partition inside this image.

For reference, I created this image using the Unix ‘dd’ tool:

# dd if=/dev/hda of=hda.img 30544113+0 records in 30544113+0 records out # ls -lh -rw-r--r-- 1 root root 9.6G 2008-01-22 14:12 hda.img

I followed the instructions on to try and mount the partitions inside the disk image, but ran into two problems.


0 0

I have backed up my system to an external ximeta drive using "dd" and the well-known linux live cd distribution, Knoppix to boot from. Below are the steps in brief:

Boot from the live cdrom distribution.
Switch to root.
Make sure NO partitions are mounted from the source hard drive.
Mount the external HD. # mount -t vfat /dev/sda1 /mnt/sda1 Backup the drive. # dd if=/dev/hda conv=sync,noerror bs=64K | gzip -c > /mnt/sda1/hda.img.gz

"dd" is the command to make a bit-by-bit copy of "if=/dev/hda" as the "Input File" to "of=/mnt/sda1/hda.img.gz" as the "Output File". Everything from the partition will go into an "Output File" named "hda.img.gz". "conv=sync,noerror" tells dd that if it can't read a block due to a read error, then it should at least write something to its output of the correct length. Even if your hard disk exhibits no errors, remember that dd will read every single block, including any blocks which the OS avoids using because it has...

0 0
Unix Toolbox

This document is a collection of Unix/Linux/BSD commands and tasks which are useful for IT work or for advanced users. This is a practical guide with concise explanations, however the reader is supposed to know what s/he is doing.

Listing | Priority | Background/Foreground | Top | Kill

Listing and PIDs

Each process has a unique number, the PID. A list of all running process is retrieved with



# ps -auxefw # Extensive list of all running process

However more typical usage is with a pipe or with


(for OS X install





# ps axww | grep cron 586 ?? Is 0:01.48 /usr/sbin/cron -s # ps axjf # All processes in a tree format (Linux) # ps aux | grep 'ss[h]' # Find all ssh pids without the grep pid # pgrep -l sshd # Find the PIDs of processes by (part of) name # echo $$ # The PID of your shell # fuser -va 22/tcp # List...
0 0