Tag: virtual disk

  • Proxmox VE 虚拟机磁盘挂载


    QEMU QCOW Image (v3)

    # file vm-101-disk-0.qcow2 
    vm-101-disk-0.qcow2: QEMU QCOW Image (v3), 107374182400 bytes (v3), 107374182400 bytes

    apt install qemu-utils
    
    modprobe nbd max_part=8
    qemu-nbd --connect=/dev/nbd0 vm-1061-disk-0.qcow2
    
    # unload 
    qemu-nbd -d /dev/nbd0
    

    After this

    
    Disk /dev/nbd0: 100 GiB, 107374182400 bytes, 209715200 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: 0x28288fb3
    
    Device      Boot    Start       End   Sectors  Size Id Type
    /dev/nbd0p1 *        2048   3905535   3903488  1.9G 83 Linux
    /dev/nbd0p2       3905536  11718655   7813120  3.7G 82 Linux swap / Solaris
    /dev/nbd0p3      11718656 209715199 197996544 94.4G 83 Linux

    RAW

    vm-1014-disk-1.raw: DOS/MBR boot sector; partition 1 : ID=0xee, start-CHS (0x0,0,1), end-CHS (0x3ff,254,63), startsector 1, 209715199 sectors, extended partition table (last)
    

    losetup -f -P --show vm-1014-disk-1.raw
    # output like /dev/loop16
    
    # unload 
    losetup -d /dev/loop16

    After this

    Disk /dev/loop16: 100 GiB, 107374182400 bytes, 209715200 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: gpt
    Disk identifier: 49400ED0-2144-4854-BA3D-64A88C3EC9C8
    
    Device        Start       End   Sectors  Size Type
    /dev/loop16p1  2048 209713151 209711104  100G Microsoft basic data
    GPT PMBR size mismatch (1952448511 != 1953525167) will be corrected by write.
    The backup GPT table is not on the end of the device.

    LVM

    From lsblk

    /dev/mapper/pve-vm--118--disk--0

    apt-get install kpartx
    kpartx -a /dev/mapper/pve-vm--118--disk--0
    

    After this,

    # ls /dev/mapper/pve-vm--118--disk--*
    /dev/mapper/pve-vm--118--disk--0  /dev/mapper/pve-vm--118--disk--0p1  /dev/mapper/pve-vm--118--disk--0p2  /dev/mapper/pve-vm--118--disk--0p3
    
    # fdisk -l 
    ...
    
    Disk /dev/mapper/pve-vm--118--disk--0: 50 GiB, 53687091200 bytes, 104857600 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 65536 bytes / 65536 bytes
    Disklabel type: dos
    Disk identifier: 0x28288fb3
    
    Device                             Boot    Start       End  Sectors  Size Id Type
    /dev/mapper/pve-vm--118--disk--0p1 *        2048   3905535  3903488  1.9G 83 Linux
    /dev/mapper/pve-vm--118--disk--0p2       3905536  11718655  7813120  3.7G 82 Linux swap / Solaris
    /dev/mapper/pve-vm--118--disk--0p3      11718656 104855551 93136896 44.4G 83 Linux
    
    # undo
    kpartx -d /dev/mapper/pve-vm--118--disk--0