8

I have created a dd image of /dev/vda using the following command:

ssh root@1.2.3.4 "dd if=/dev/vda" | dd of=/home/backup/vda.img

and I can't mount it on my local Ubuntu server where I transferred it.

I get this in dmesg | tail :

[763158.222159] EXT4-fs error (device loop0): ext4_map_blocks:504: inode #8:block 10541546: comm mount: lblock 23018 mapped to illegal pblock (length 1)
[763158.222299] jbd2_journal_bmap: journal block not found at offset 23018 on loop0-8
[763158.222367] JBD2: bad block at offset 23018
[763158.222581] JBD2: recovery failed
[763158.222588] EXT4-fs (loop0): error loading journal

If I try to check it out with file I get:

vda.img: data

Any idea what it could be?

Using kpartx as Sven suggested I get:

kpartx -l /home/backup/vda.img
loop deleted : /dev/loop0

I have rebooted the system and tried the command again:

kpartx -lv /home/backup/vda.img
ioctl: LOOP_CLR_FD: Device or resource busy
can't del loop : /dev/loop0

And in dmesg | tail i get

[ 73.445903] device-mapper: uevent: version 1.0.3
[ 73.446574] device-mapper: ioctl: 4.22.0-ioctl (2011-10-19) initialised: dm-devel@redhat.com

Debrian
  • 154
  • 2
  • 12

2 Answers2

6

You likely need to mount partitions inside the image file. This can be done with kpartx.

kpartx -l /path/to/image

will list partitions inside the file and

kpartx -a /path/to/image

will add them to /dev/mapper/loopXpY (where X and Y varies), from where you can mount them with mount.

See man kpartx for more info.

Sven
  • 97,248
  • 13
  • 177
  • 225
  • I get the following output when i try to list them: kpartx -l /home/backup/vda.img loop deleted : /dev/loop0 – Debrian Mar 20 '15 at 15:26
  • @Debrian: Edit any output into your question, don't post it as comment. – Sven Mar 20 '15 at 15:26
1

I have managed to fix the issue in the following way:

I checked the size of the partition that i wished to copy and then i created a local file with that size on the backup server and created the partition inside it using the following commands:

fallocate -l 85899345920 vda.img
fdisk -H 16 vda.img
kpartx -a vda.img
mount /dev/mapper/loop1p1 /mnt/test/ -t ext4

Then i used dd to copy the data from the server to the backup partition.

Checked everything around and all seems fine.

Debrian
  • 154
  • 2
  • 12