KVM QEMU and Xen how to mount disk images off-line and access data

fdisk -lu VPS.img

last_lba(): I don't know how to handle files with mode 81ed
You must set cylinders.
You can do this from the extra functions menu.

Disk VPS.img: 0 MB, 0 bytes
255 heads, 63 sectors/track, 0 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes

     Device Boot      Start         End      Blocks   Id  System
VPS.img1   *          63      208844      104391   83  Linux
VPS.img2          208845    20964824    10377990   8e  Linux LVM
Partition 2 has different physical/logical endings:
     phys=(1023, 254, 63) logical=(1304, 254, 63)

Above tells you what to do next, we can see we have an LVM partition so it's more complicated (I recommend a straight ext3 partition for Xen images).

Since I have LVM I need kpartx, and here's how to mount LVM partitions from Xen:

kpartx -av VPS.img
add map loop2p1 : 0 208782 linear /dev/loop2 63
add map loop2p2 : 0 20755980 linear /dev/loop2 208845

vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "VolGroup00" using metadata type lvm2

vgchange -ay
  2 logical volume(s) in volume group "VolGroup00" now active
 

lvdisplay
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                1cXWyF-2eO2-t5MD-oSNf-OWOG-cPnK-6Sn3Sg
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                8.84 GB
  Current LE             283
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2
  
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol01
  VG Name                VolGroup00
  LV UUID                QvU7in-2TPl-VeT5-mocH-jyuR-YZ02-M4pCGt
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                1.03 GB
  Current LE             33
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3
 

 

fsck /dev/VolGroup00/LogVol01
fsck 1.39 (29-May-2006)
fsck: fsck.swap: not found
fsck: Error 2 while executing fsck.swap for /dev/VolGroup00/LogVol01
[root@evotor11 ~]# fsck /dev/VolGroup00/LogVol00
fsck 1.39 (29-May-2006)
e2fsck 1.39 (29-May-2006)
/dev/VolGroup00/LogVol00 contains a file system with errors, check forced.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/VolGroup00/LogVol00: 44465/2319712 files (0.8% non-contiguous), 629232/2318336 blocks

Of course instead I could have mounted the image as normal etc...
 


Tags:

xen, mount, disk, images, datafdisk, lu, vps, img, last_lba, mode, cylinders, functions, mb, bytes, sectors, linux, lvm, partition, endings, phys, ext, kpartx, partitions, av, linear, dev, vgscan, volumes, volume, quot, volgroup, metadata, vgchange, ay, active, lvdisplay, lv, logvol, vg, uuid, cxwyf, eo, md, osnf, owog, cpnk, sn, sg, gb, segments, allocation, inherit, auto, currently, qvu, tpl, vet, moch, jyur, yz, pcgt, fsck, swap, executing, evotor, contains, errors, inodes, sizes, directory, connectivity, reference, summary, contiguous, mounted, etc,

Latest Articles

  • How To Upgrade Debian 8,9,10 to Debian 12 Bookworm
  • Linux dhcp dhclient Mint Redhat Ubuntu Debian How To Use Local Domain DNS Server Instead of ISPs
  • Docker dockerd swarm high CPU usage cause solution
  • Docker Minimum Requirements/How Efficient is Docker? How Much Memory Does Dockerd Use?
  • qemu-nbd: Failed to set NBD socket solution qemu-nbd: Disconnect client, due to: Failed to read request: Unexpected end-of-file before all bytes were read
  • apache2 httpd apache server will not start [pid 22449:tid 139972160445760] AH00052: child pid 23248 exit signal Aborted (6) solution Mint Debian Ubuntu Redhat
  • How to use the FTDI USB serial cable to RJ45 adapter to connect to the console on Cisco/Juniper Switch Router Firewall in Linux Ubuntu Debian Redhat
  • How To Setup Python3 in Ubuntu Docker Image for AI Deep Learning
  • How to Configure NVIDIA GPUs with Docker on Ubuntu: A Comprehensive Guide for AI Deep Learning CUDA Solution
  • Linux Ubuntu Mint how to check nameservers when /etc/resolv.conf disabled solution
  • Docker cannot work on other overlayfs filesystems such as ecryptfs won't start overlayfs: filesystem on '/home/docker/overlay2/check-overlayfs-support130645871/upper' not supported as upperdir
  • Linux How To Access Original Contents of Directory Mounted Debian Mint CentOS Redhat Solution
  • ecryptfs how to manually encrypt your existing home directory or other directory
  • How to Reset CIPC Cisco IP Communicator for CME CUCM CallManager
  • Internet Explorer Cannot Download File "Your security settings do not allow for this file to be downloaded." Security Settings Solution
  • Linux How To Upgrade To The Latest Kernel Debian Mint Ubuntu
  • Firefox how to restore and backup saved passwords and history which files/location
  • Linux How To echo as root solution to use tee permission denied solution Ubuntu Debian Mint Redhat CentOS
  • Linux how to keep command line bash process running if you are disconnected or need to logout of SSH remotely
  • Linux swapping too much? How to check the swappiness and stop swapping