Menu

convert qcow2 to Clonezilla image

Help
Mircea Dan
2016-05-09
2016-06-26
  • Mircea Dan

    Mircea Dan - 2016-05-09

    so i have a test.qcow2 image

    modprobe nbd max_part=63
    qemu-nbd --connect=/dev/nbd0 /home/test/test.qcow2

    now i have the nbd0 device working perfectley.
    and i usualy use dd to write this image to a hdd
    dd if=/dev/nbd0 of=/dev/sda bs=8M
    but this takes time becuase the dd it's just doing bit by bit copy

    now i would like to use clonezilla to create an disk to image and also do a disk to disk

    if i start clonezilla /dev/nbd0 device is not seen. in the gui only /dev/sda is seen
    if i use ocs-sr i get an error "no input device"

    test@PC:~$ sudo ocs-sr savedisk test1.clz nbd0
    Setting the TERM as xterm
    Starting /usr/sbin/ocs-sr at 2016-05-09 15:11:50 PDT...
    ********.
    Clonezilla image dir: /home/partimag
    *******.
    Shutting down the Logical Volume Manager
    Finished Shutting down the Logical Volume Manager
    Selected device [nbd0] found!
    The selected devices: nbd0
    *******
    ***.
    setterm: terminal xterm does not support --blank
    Activating the partition info in /proc... done!
    Selected device [nbd0] found!
    The selected devices: nbd0
    Searching for data partition(s)...
    Excluding busy partition or disk...
    Unmounted partitions (including extended or swap):
    Collecting info. done!
    Searching for swap partition(s)...
    Excluding busy partition or disk...
    Unmounted partitions (including extended or swap):
    Collecting info. done!
    The data partition to be saved:
    The swap partition to be saved:
    setterm: terminal xterm does not support --blank
    Activating the partition info in /proc... done!
    No input device!

    test@PC:~$ sudo parted -s /dev/nbd0 print
    Model: Unknown (unknown)
    Disk /dev/nbd0: 494GB
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos
    Disk Flags:

    Number Start End Size Type File system Flags
    1 1049kB 525MB 524MB primary fat16
    2 525MB 1050MB 524MB primary ext4 boot
    3 1050MB 34.6GB 33.6GB primary ext4
    4 34.6GB 480GB 445GB extended
    5 34.6GB 68.2GB 33.6GB logical
    6 68.2GB 102GB 33.6GB logical ext4
    7 102GB 480GB 378GB logical lvm

    test@PC:~$ cat /proc/partitions
    major minor #blocks name

    1 0 65536 ram0
    1 1 65536 ram1
    1 2 65536 ram2
    1 3 65536 ram3
    1 4 65536 ram4
    1 5 65536 ram5
    1 6 65536 ram6
    1 7 65536 ram7
    1 8 65536 ram8
    1 9 65536 ram9
    1 10 65536 ram10
    1 11 65536 ram11
    1 12 65536 ram12
    1 13 65536 ram13
    1 14 65536 ram14
    1 15 65536 ram15
    8 0 156290904 sda
    8 1 153163776 sda1
    8 2 3125248 sda2
    11 0 1048575 sr0
    8 32 60653568 sdc
    8 33 58061824 sdc1
    8 37 2588672 sdc5
    43 0 482344960 nbd0
    43 1 512000 nbd0p1
    43 2 512000 nbd0p2
    43 3 32768000 nbd0p3
    43 5 32768000 nbd0p5
    43 6 32768000 nbd0p6
    43 7 369518592 nbd0p7

    test@PC:~$ blkid
    /dev/sda1: UUID="c1e522a2-1941-47fb-967f-28da7b8f37ef" TYPE="ext4" PARTUUID="5251f42b-01"
    /dev/sda2: UUID="ac9fbe8e-c4a9-4f35-938e-ebabeb71b3f7" TYPE="swap" PARTUUID="5251f42b-02"
    /dev/sdc1: UUID="21c443e4-7ae1-4b37-a426-e9e5b497e162" TYPE="ext4" PARTUUID="461bb889-01"
    /dev/sdc5: UUID="c8db8cde-9df5-4c93-8183-1f0f819364f3" TYPE="swap" PARTUUID="461bb889-05"

    see also this i think same question was asked in teh past but has not been answered:
    https://sourceforge.net/p/clonezilla/discussion/Help/thread/41850f6d/

     
  • Steven Shiau

    Steven Shiau - 2016-05-15

    Good point. The device name /dev/nbd* is not supported by Clonezilla. We should add that in the future. However, if you can make your virtual disk as /dev/sd* format, the you can use Clonezilla without any issue.
    For the time being, you can use partclone to specify the device you want to save. Partclone is very similar to dd, so I believe there is no problem for you to use that.

    Steven

     
  • Mircea Dan

    Mircea Dan - 2016-05-16

    If you have permision can you please add this feature request.
    Thanks very much.

     
  • Steven Shiau

    Steven Shiau - 2016-05-21

    OK, sure. In the future we will add that.
    BTW, could you show me the whole command to start virtual machine?
    Thanks.

    Steven

     
  • Mircea Dan

    Mircea Dan - 2016-06-07

    all you need is

    modprobe nbd max_part=63
    qemu-nbd --connect=/dev/nbd0 /home/test/test.qcow2
    

    this will create /dev/nbd0 and from here just use clonezilla to clone or restore it like any other disk.

     

    Last edit: Mircea Dan 2016-06-09
  • Steven Shiau

    Steven Shiau - 2016-06-13

    OK, I will try to add support for nbd device in the future release.
    Thanks.

    Steven

     
  • Steven Shiau

    Steven Shiau - 2016-06-21

    The device name /dev/nbd* is now supported in Clonezilla live 2.7.1 or 20160621-* .
    http://clonezilla.org/downloads.php
    Please give it a try and let us know the results.
    Thanks.

    Steven

     
  • Mircea Dan

    Mircea Dan - 2016-06-22

    i tried device to device and i woudl say it worked. Thank you very much for implementing this.

    1 issue i have to solve on my side is to make the lvm2 available in the nbd device and try again, curentley the lvm2 partition is copied with dd (not a clonezilla issue)

     

    Last edit: Mircea Dan 2016-06-22
  • Mircea Dan

    Mircea Dan - 2016-06-23

    ok debugged more and looks like a clonezilla problem, it fails to clone the LVM ( i used sda drive to eliminate any doubt on nbd/lvm combo) using the version specified by you above "20160621-* ."

    clonezilla log:
    /usr/sbin/ocs-sr -q2 -c -j2 -z1p -i 4096 -fsck-y -p choose savedisk test-img sda
    ......
    Run partclone: partclone.ext4 -z 10485760 -N -L /var/log/partclone.log -c -s /dev/sda6 --output - | pigz -c --fast -b 1024 -p 16 --rsyncable | split -a 2 -b 4096MB - /home/partimag/test-img/sda6.ext4-ptcl-img.gz. 2> /tmp/split_error.Ncaz7o
    Cloned successfully.
    Checking the disk space...

    Time elapsed: 99.20 secs (~ 1.653 mins)
    ********.
    Finished saving /dev/sda6 as /home/partimag/test-img/sda6.ext4-ptcl-img.gz
    ********.
    Setting up the Logical Volume Manager
    2 logical volume(s) in volume group "vg_01" now active
    Parsing LVM layout for sda1 sda2 sda3 sda5 sda6 sda7 ...
    vg_01 /dev/sda7 IG6O6X-LdCN-LVEw-RfGS-lY13-cR5u-H4UAfl
    Parsing logical volumes...
    /dev/vg_01/lv_home Linux rev 1.0 ext4 filesystem data, UUID=9b796507-03c0-4b08-a98f-3e9a5c6ee2fa (extents) (64bit) (large files) (huge files)
    /dev/vg_01/lv_swap Linux/i386 swap file (new style), version 1 (4K pages), size 1048575 pages, no label, UUID=9f6db424-f55d-42b0-84a3-1dd552844a75
    Saving the VG config...
    Volume group "vg_01" not found
    Cannot process volume group vg_01
    Program terminated!.
    Press "Enter" to continue......

    test@test:~$ sudo -i
    root@test:~# parted -s /dev/sda print
    Model: ATA ST91000640NS (scsi)
    Disk /dev/sda: 1000GB
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos
    Disk Flags:

    Number Start End Size Type File system Flags
    1 1049kB 525MB 524MB primary fat16
    2 525MB 1050MB 524MB primary ext4 boot
    3 1050MB 34.6GB 33.6GB primary ext4
    4 34.6GB 988GB 953GB extended
    5 34.6GB 68.2GB 33.6GB logical
    6 68.2GB 102GB 33.6GB logical ext4
    7 102GB 988GB 886GB logical lvm

    root@test:~# blkid
    /dev/sda1: SEC_TYPE="msdos" UUID="A42A-0924" TYPE="vfat" PARTUUID="00092660-01"
    /dev/sda2: UUID="10ff2b97-4d73-4a9d-849a-a9f0209bd5d2" TYPE="ext4" PARTUUID="000
    /dev/sda3: UUID="738210cc-dec4-4bd0-8cd8-1b1e21b25e91" TYPE="ext4" PARTUUID="000
    /dev/sda6: UUID="d2fee0d5-0943-457c-a3f3-d5430a6cd5e9" TYPE="ext4" PARTUUID="000
    /dev/sda7: UUID="IG6O6X-LdCN-LVEw-RfGS-lY13-cR5u-H4UAfl" TYPE="LVM2_member" PART
    /dev/sdb1: UUID="21c443e4-7ae1-4b37-a426-e9e5b497e162" TYPE="ext4" PARTUUID="461
    /dev/sdb5: UUID="c8db8cde-9df5-4c93-8183-1f0f819364f3" TYPE="swap" PARTUUID="461
    /dev/mapper/vg_01-lv_home: UUID="9b796507-03c0-4b08-a98f-3e9a5c6ee2fa" TYPE="ext
    /dev/mapper/vg_01-lv_swap: UUID="9f6db424-f55d-42b0-84a3-1dd552844a75" TYPE="swa
    /dev/sda5: PARTUUID="00092660-05"
    root@test:~# pvscan
    PV /dev/sda7 VG vg_01 lvm2 [825.27 GiB / 40.00 MiB free]
    Total: 1 [825.27 GiB] / in use: 1 [825.27 GiB] / in no VG: 0 [0 ]
    root@test:~# lvscan
    ACTIVE '/dev/vg_01/lv_home' [821.23 GiB] inherit
    ACTIVE '/dev/vg_01/lv_swap' [4.00 GiB] inherit
    root@test:~#

     

    Last edit: Mircea Dan 2016-06-23
  • Steven Shiau

    Steven Shiau - 2016-06-26

    This is confusing. Why now your device name is sda instead of nbd?

    Steven

     
  • Steven Shiau

    Steven Shiau - 2016-06-26

    Oh, ok, just to test it. Next time please open another thread. Otherwise it's very confusing.

    Steven

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.