0

According to this post, it should be okay, to use dd to convert a raw Xen image to LVM.

What I have done

dd if=/vm.img of=/dev/vg00/vm

I can mount vm.img with mount -o loop vm.img /root/tmp. It only have one bootable partition.

But I can't mount /dev/vg00/vm.

Can it have something to with MBR?

Any ideas what could be wrong?

Edit:

Now I have created a new LV and formatted it. And I still can't mount it.

It is the same mount error I get when I dd'ed the image over.

localhost:~# mkfs.ext3 /dev/vg00/oes2
mke2fs 1.39 (29-May-2006)
Warning: could not erase sector 2: Attempt to write block from filesystem resulted in short write
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2228224 inodes, 4456448 blocks
222822 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
136 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
    4096000

Warning: could not read block 0: Attempt to read block from filesystem resulted in short read
Warning: could not erase sector 0: Attempt to write block from filesystem resulted in short write
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: 
Warning, had trouble writing out superblocks.done

This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
localhost:~# mount /dev/vg00/oes2 tmp-lvm/
mount: you must specify the filesystem type
localhost:~# mount -t ext3 /dev/vg00/oes2 tmp-lvm/
mount: wrong fs type, bad option, bad superblock on /dev/vg00/oes2,
       missing codepage or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so

localhost:~# mount -t ext3 /dev/vg00/oes2 tmp-lvm/
localhost:~# fdisk /dev/vg00/oes2

Unable to read /dev/vg00/oes2
localhost:~# 
2
  • What's the error message when you try to mount it?
    – AndiDog
    Aug 14, 2010 at 19:31
  • When you say you can mount the image but not the lvm partition, is there an error?
    – Joris
    Aug 14, 2010 at 20:05

2 Answers 2

1

Warning: could not erase sector 2: Attempt to write block from filesystem resulted in short write

This doesn't sound good. It most probably means that some important blocks were not written to disk correctly. You should check the SMART status of your hard drive, it might contain errors. Smartmontools can be used for that purpose. If you use Ubuntu, you can start a simple SMART utility with System > Administration > Disk Utility. Should the hard drive support SMART, you can execute a test that checks all sectors.

If the hard drive is not the problem, your LVM volume group might be corrupted in some way?!

1
  • Removing the volume group and then creating it again fixed the problem. Thanks =)
    – Sandra
    Aug 14, 2010 at 21:48
0

The issue is that since this is a VM there is a partition from the image now transfered to the LVM. When mounting the LVM locally, you need to mount with an offset.

You need to obtain the start of your partition within the disk. This will print out your partitions. Take the start # of your boot partition.

parted -s /dev/vg00/oes2 unit s print

example:
ie:
parted -s /dev/vmstore/kfsnap unit s print
Model: Linux device-mapper (snapshot) (dm)
Disk /dev/dm-11: 25165824s
Sector size (logical/physical): 512B/4096B
Partition Table: msdos

Number  Start  End        Size       Type     File system  Flags
 1      2048s  25163775s  25161728s  primary  ext4         boot

The sector size is: 512, so I then multiply the start by 512 sectors.

expr 512 '*' 2048
It spits out this:  1048576

I then know the offset of within the lvm image and can now mount the disk via loopback.

#mount - o loop,offset=1048576 /dev/vmstore/kfsnap /mnt/snap

Here are some one lines for the first partition:

parted -s /dev/vg00/oes2 unit s print 2>/dev/null | grep " 1 " | tr -d 's' | awk '{print $2}'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .