Menu

Restore partition issues - no filesystem ?

Andrew
2020-01-20
2020-02-23
  • Andrew

    Andrew - 2020-01-20

    Hi,

    We are using clonezilla and I think it works well, thanks.

    We have been making a golden system and then restoring that same image to other machines and then changing the hostname etc with ocs_postrun.

    If I restore an entire disk everything works great.

    ocs-sr -g auto -e1 auto -e2 -r -j2 -scr -p reboot restoredisk someimage sda
    

    However we want to save a partition for persistent data, I want to save sda2.

    cat /tmp/sda-pt.sf 
    label: dos
    label-id: 0x000be814
    device: /dev/sda
    unit: sectors
    
    /dev/sda1 : start=        2048, size=     2097152, type=83, bootable
    /dev/sda2 : start=     2099200, size=    20529152, type=83
    /dev/sda3 : start=    22628352, size=  1930895360, type=8e
    

    I have tried running

    ocs-sr -g auto -e1 auto -e2 -j2 -scr -p reboot -k restoreparts $image sda1 sda3
    

    Log1 - Below

    I see data restored but the system comes up without a partition table.

    https://drbl.org/faq/fine-print.php?path=./2_System/88_mbr_related_options.faq#88_mbr_related_options.faq
    -k (default: checked for restoredisk, and unchecked for restoreparts): "Do NOT create a partition table on the target disk" By default Clonezilla will create the partition table in the destination disk. If a partition table exists on the destination disk, and you do not want Clonezilla to overwrite it, you can check this option.

    The way I read the -k option as Don't create a partition table... but I dont read it as wipe one out if it exists.

    How do I restore the partition table without loosing any data given the scenario mentioned above ?

    Do I want to log something like -j1?

    -j1 (default: unchecked): "Write MBR (512 B) again after image is restored. Not OK for partition table differ from that of the image" In some cases, sfdisk uses different CHS values to create the partition table (due to different kernels have different CHS values of hard drive), and it will make the restore OS fail to boot. With this option checked, a command:

    dd if=$IMAGE_DIR/$HARDDRIVE-mbr of=/dev/$HARDDRIVE bs=446 count=1

    If I run

    ocs-sr -g auto -e1 auto -e2 -r -j2 -scr -p reboot restoreparts $someimage sda1 sda3
    

    The data is restored but /dev/sda2 has no file system and thus there's no persistent data.

    Thanks in advance,

    Log1
    Starting /usr/sbin/ocs-sr at 2020-01-20 13:24:52 UTC...
    ********.
    Clonezilla image dir: /home/partimag
    Shutting down the Logical Volume Manager
    Shutting Down logical volume: /dev/vg00/localmntvol
    Shutting Down logical volume: /dev/vg00/slashvol
    Shutting Down logical volume: /dev/vg00/swapvol
    Shutting Down logical volume: /dev/vg00/varvol
    Shutting Down volume group: vg00
    Finished Shutting down the Logical Volume Manager
    Running: task_restoreparts "some_bew_image" "sda1 sda2 sda3" ""
    This program is not started by clonezilla server.
    Shutting down the Logical Volume Manager
    Shutting Down volume group: vg00
    Finished Shutting down the Logical Volume Manager
    Creating partition in /dev/sda...
    Trying to clean the MBR and GPT partition table on the destination disk first: /dev/sda
    Informing the OS of partition table changes... done!
    ********.
    Mon Jan 20 13:25:11 UTC 2020
    Writing the partition table...
    No partition table exists in target disk /dev/sda, try to initialize one so that we can get the disk size by parted... Running: parted -s /dev/sda mklabel msdos
    done!
    Running: LC_ALL=C sfdisk --force /dev/sda < /home/partimag/some_bew_image/sda-pt.sf 2>&1 | tee -a /var/log/clonezilla.log
    Checking that no-one is using this disk right now ... OK

    Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
    Disk model: Hitachi sadddddddddsafdsafsafsasa
    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: 0x368f21f0

    Old situation:

    Script header accepted.
    Script header accepted.
    Script header accepted.
    Script header accepted.
    Created a new DOS disklabel with disk identifier 0x000be814.
    /dev/sda1: Created a new partition 1 of type 'Linux' and of size 1 GiB.
    /dev/sda2: Created a new partition 2 of type 'Linux' and of size 9.8 GiB.
    /dev/sda3: Created a new partition 3 of type 'Linux LVM' and of size 920.7 GiB.
    /dev/sda4: Done.

    New situation:
    Disklabel type: dos
    Disk identifier: 0x000be814

    Device Boot Start End Sectors Size Id Type
    /dev/sda1 * 2048 2099199 2097152 1G 83 Linux
    /dev/sda2 2099200 22628351 20529152 9.8G 83 Linux
    /dev/sda3 22628352 1953523711 1930895360 920.7G 8e Linux LVM

    The partition table has been altered.
    Calling ioctl() to re-read partition table.
    Syncing disks.
    Checking that no-one is using this disk right now ... OK

    Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
    Disk model: Hitachi sadddddddddsafdsafsafsasa
    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: 0x368f21f0

    Old situation:

    Script header accepted.
    Script header accepted.
    Script header accepted.
    Script header accepted.
    Created a new DOS disklabel with disk identifier 0x000be814.
    /dev/sda1: Created a new partition 1 of type 'Linux' and of size 1 GiB.
    /dev/sda2: Created a new partition 2 of type 'Linux' and of size 9.8 GiB.
    /dev/sda3: Created a new partition 3 of type 'Linux LVM' and of size 920.7 GiB.
    /dev/sda4: Done.

    New situation:
    Disklabel type: dos
    Disk identifier: 0x000be814

    Device Boot Start End Sectors Size Id Type
    /dev/sda1 * 2048 2099199 2097152 1G 83 Linux
    /dev/sda2 2099200 22628351 20529152 9.8G 83 Linux
    /dev/sda3 22628352 1953523711 1930895360 920.7G 8e Linux LVM

    The partition table has been altered.
    Calling ioctl() to re-read partition table.
    Syncing disks.
    This was done by: LC_ALL=C sfdisk --force /dev/sda < /home/partimag/some_bew_image/sda-pt.sf 2>&1 | tee -a /var/log/clonezilla.log
    Checking the integrity of partition table in the disk /dev/sda...
    Informing the OS of partition table changes.... done!
    ********.
    The first partition of disk /dev/sda starts at 2048.
    Restoring the hidden data between MBR (1st sector, i.e. 512 bytes) and 1st partition, which might be useful for some recovery tool, by:
    dd if=/home/partimag/some_bew_image/sda-hidden-data-after-mbr of=/dev/sda seek=1 bs=512 count=2047
    2047+0 records in
    2047+0 records out
    1048064 bytes (1.0 MB, 1.0 MiB) copied, 0.230565 s, 4.5 MB/s
    Informing the OS of partition table changes.... done!
    *******.
    *******.
    Restoring partition /dev/sda1...
    *******.
    Starting unicast restoring image some_bew_image to /dev/sda1...
    If this action fails or hangs, check:
    * Is the saved image /home/partimag/some_bew_image/sda1.ext3-ptcl-img.gz.
    corrupted ?
    *********.
    ( for img in /home/partimag/some_bew_image/sda1.ext3-ptcl-img.gz.
    ; do
    cat
    done
    ) | pigz -d -c 2> /tmp/unzip_stdin_cmd_error.O2bfOp | LC_ALL=C partclone.ext3 -z 10485760 -N -L /var/log/partclone.log -s - -r -o /dev/sda1
    Partclone v0.3.12 http://partclone.org
    Starting to restore image (-) to device (/dev/sda1)
    memory needed: 21014528 bytes
    bitmap 32768 bytes, blocks 2
    10485760 bytes, checksum 10240 bytes
    Calculating bitmap... Please wait...
    get device size 1073741824 by ioctl BLKGETSIZE64,
    done!
    File system: EXTFS
    Device size: 1.1 GB = 262144 Blocks
    Space in use: 225.3 MB = 55007 Blocks
    Free Space: 848.4 MB = 207137 Blocks
    Block size: 4096 Byte
    Syncing... OK!
    Partclone successfully restored the image (-) to the device (/dev/sda1)

    Time elapsed: 9.99 secs (~ .166 mins)
    Finished unicast restoring image some_bew_image to /dev/sda1.
    Informing the OS of partition table changes.... done!
    ********.
    Restoring partition /dev/sda2...
    *******.
    Starting unicast restoring image some_bew_image to /dev/sda2...
    If this action fails or hangs, check:
    * Is the saved image /home/partimag/some_bew_image/sda2.ext3-ptcl-img.gz.
    corrupted ?
    ********.
    ( for img in /home/partimag/some_bew_image/sda2.ext3-ptcl-img.gz.
    ; do
    cat
    done
    ) | pigz -d -c 2> /tmp/unzip_stdin_cmd_error.dkK1tj | LC_ALL=C partclone.ext3 -z 10485760 -N -L /var/log/partclone.log -s - -r -o /dev/sda2
    Partclone v0.3.12 http://partclone.org
    Starting to restore image (-) to device (/dev/sda2)
    memory needed: 21302528 bytes
    bitmap 320768 bytes, blocks 2*10485760 bytes, checksum 10240 bytes
    Calculating bitmap... Please wait...
    get device size 10510925824 by ioctl BLKGETSIZE64,
    done!
    File system: EXTFS
    Device size: 10.5 GB = 2566144 Blocks
    Space in use: 322.6 MB = 78749 Blocks
    Free Space: 10.2 GB = 2487395 Blocks
    Block size: 4096 Byte
    Syncing... OK!
    Partclone successfully restored the image (-) to the device (/dev/sda2)
    Time elapsed: 8.80 secs (~ .146 mins)
    Finished unicast restoring image some_bew_image to /dev/sda2.
    Informing the OS of partition table changes.... done!
    *******.
    Finding swap partition(s) in MBR table /home/partimag/some_bew_image/sda-pt.sf...
    Probing sda with blockdev before restoring EBR...
    Finding extended partition(s) in parted table /home/partimag/some_bew_image/sda-pt.parted...
    LVM exists, restoring PV/VG/LV.
    Preparing the LVM (PV/VG/LV)...
    Creating the PV...
    done.
    Restoring the VG config...
    Restored volume group vg00
    done.
    Restoring device vg00-localmntvol...
    *******.
    Starting unicast restoring image some_bew_image to /dev/vg00/localmntvol...
    If this action fails or hangs, check:
    * Is the saved image /home/partimag/some_bew_image/vg00-localmntvol.ext4-ptcl-img.gz. corrupted ?
    *******.
    ( for img in /home/partimag/some_bew_image/vg00-localmntvol.ext4-ptcl-img.gz.
    ; do
    cat
    done
    ) | pigz -d -c 2> /tmp/unzip_stdin_cmd_error.B0HY2A | LC_ALL=C partclone.ext4 -z 10485760 -N -L /var/log/partclone.log -s - -r -o /dev/vg00/localmntvol
    Partclone v0.3.12 http://partclone.org
    Starting to restore image (-) to device (/dev/vg00/localmntvol)
    memory needed: 49128448 bytes
    bitmap 28146688 bytes, blocks 210485760 bytes, checksum 10240 bytes
    Calculating bitmap... Please wait...
    get device size 922310672384 by ioctl BLKGETSIZE64,
    done!
    File system: EXTFS
    Device size: 922.3 GB = 225173504 Blocks
    Space in use: 19.0 GB = 4638228 Blocks
    Free Space: 903.3 GB = 220535276 Blocks
    Block size: 4096 Byte
    Syncing... OK!
    Partclone successfully restored the image (-) to the device (/dev/vg00/localmntvol)
    Time elapsed: 198.91 secs (~ 3.315 mins)
    Finished unicast restoring image some_bew_image to /dev/vg00/localmntvol.
    Informing the OS of partition table changes... Not MBR or GPT type of device. Skipping informing kernel. done!
    *******.
    Restoring device vg00-varvol...
    *******.
    Starting unicast restoring image some_bew_image to /dev/vg00/varvol...
    If this action fails or hangs, check:
    * Is the saved image /home/partimag/some_bew_image/vg00-varvol.ext3-ptcl-img.gz.
    corrupted ?
    ********.
    ( for img in /home/partimag/some_bew_image/vg00-varvol.ext3-ptcl-img.gz.
    ; do
    cat
    done
    ) | pigz -d -c 2> /tmp/unzip_stdin_cmd_error.QTu0lT | LC_ALL=C partclone.ext3 -z 10485760 -N -L /var/log/partclone.log -s - -r -o /dev/vg00/varvol
    Partclone v0.3.12 http://partclone.org
    Starting to restore image (-) to device (/dev/vg00/varvol)
    memory needed: 21309440 bytes
    bitmap 327680 bytes, blocks 2*10485760 bytes, checksum 10240 bytes
    Calculating bitmap... Please wait...
    get device size 10737418240 by ioctl BLKGETSIZE64,
    done!
    File system: EXTFS
    Device size: 10.7 GB = 2621440 Blocks
    Space in use: 1.2 GB = 293617 Blocks
    Free Space: 9.5 GB = 2327823 Blocks
    Block size: 4096 Byte
    Syncing... OK!
    Partclone successfully restored the image (-) to the device (/dev/vg00/varvol)
    Time elapsed: 36.23 secs (~ .603 mins)
    Finished unicast restoring image some_bew_image to /dev/vg00/varvol.
    Informing the OS of partition table changes... Not MBR or GPT type of device. Skipping informing kernel. done!
    *******.
    Restoring device vg00-slashvol...
    *******.
    Starting unicast restoring image some_bew_image to /dev/vg00/slashvol...
    If this action fails or hangs, check:
    * Is the saved image /home/partimag/some_bew_image/vg00-slashvol.ext3-ptcl-img.gz. corrupted ?
    *******.
    ( for img in /home/partimag/some_bew_image/vg00-slashvol.ext3-ptcl-img.gz.
    ; do
    cat
    done
    ) | pigz -d -c 2> /tmp/unzip_stdin_cmd_error.zn81IT | LC_ALL=C partclone.ext3 -z 10485760 -N -L /var/log/partclone.log -s - -r -o /dev/vg00/slashvol
    Partclone v0.3.12 http://partclone.org
    Starting to restore image (-) to device (/dev/vg00/slashvol)
    memory needed: 22292480 bytes
    bitmap 1310720 bytes, blocks 210485760 bytes, checksum 10240 bytes
    Calculating bitmap... Please wait...
    get device size 42949672960 by ioctl BLKGETSIZE64,
    done!
    File system: EXTFS
    Device size: 42.9 GB = 10485760 Blocks
    Space in use: 5.1 GB = 1245636 Blocks
    Free Space: 37.8 GB = 9240124 Blocks
    Block size: 4096 Byte
    Syncing... OK!
    Partclone successfully restored the image (-) to the device (/dev/vg00/slashvol)
    Time elapsed: 108.62 secs (~ 1.810 mins)
    Finished unicast restoring image some_bew_image to /dev/vg00/slashvol.
    Informing the OS of partition table changes... Not MBR or GPT type of device. Skipping informing kernel. done!
    *******.
    *******.
    Running: ocs-restore-mbr --ocsroot /home/partimag some_bew_image sda
    Setting the TERM as linux
    Restoring the first 446 bytes of MBR data (executable code area) for sda by:
    dd if=/home/partimag/some_bew_image/sda-mbr of=/dev/sda bs=446 count=1 &>/dev/null
    done.
    *******.
    Running: ocs-tux-postprocess sda1 sda2 sda3 vg00/swapvol vg00/localmntvol vg00/varvol vg00/slashvol
    Trying to remove udev hardware record in the restored OS...
    The specified destination device: sda1 sda2 sda3 vg00/swapvol vg00/localmntvol vg00/varvol vg00/slashvol
    Trying to remove udev persistent files. The devices to be searched: sda1 sda2 sda3 vg00/swapvol vg00/localmntvol vg00/varvol vg00/slashvol...
    Now searching possible device /dev/sda1...
    Now searching possible device /dev/sda2...
    Now searching possible device /dev/sda3...
    Skip /dev/vg00/swapvol (swap).
    Now searching possible device /dev/vg00/localmntvol...
    Now searching possible device /dev/vg00/varvol...
    Now searching possible device /dev/vg00/slashvol...
    MAC address some_mac_address of eth0 was not found in /tmp/hd_img.RTalhZ/etc/sysconfig/network-scripts/ifcfg-eth
    . This MAC data does not fit the hardware. Comment it.
    done!
    *******.
    Running: ocs-update-syslinux -b sda1 sda2 sda3
    Device /dev/sda1 is not a FAT partition.
    Skip updating syslinux on that.
    Device /dev/sda2 is not a FAT partition.
    Skip updating syslinux on that.
    Device /dev/sda3 is not a FAT partition.
    Skip updating syslinux on that.
    *******.
    Running: ocs-install-grub -p "sda1 sda2 sda3 " auto
    Found grub partition: /dev/sda1
    Found grub partition "/dev/sda1", which is on the restored partitions list (sda1 sda2 sda3 ). Will run grub-install later.
    Found boot loader grub in the MBR of disk /dev/sda.
    There is a separate boot partition in target device. Trying to mount root partition for grub-install to work with that...
    Setting up the Logical Volume Manager
    4 logical volume(s) in volume group "vg00" now active
    /dev/mapper/vg00-slashvol is mounted as root partition for grub-install...
    Found grub 2 installed in the restored OS.
    Test if we can chroot the restored OS partition /dev/mapper/vg00-slashvol...
    Yes, we are able to chroot the restored OS partition /dev/mapper/vg00-slashvol.
    Trying to use the grub2 in the restored OS...
    Running: run_grub2_from_restored_os "/dev/sda1" "/dev/mapper/vg00-slashvol" "/dev/sda"
    Re-installing grub2 on disk/partition /dev/sda with grub2 dir in partition /dev/sda1 and root partition /dev/mapper/vg00-slashvol...
    The options for grub2-install in the chroot: --force --recheck --no-floppy /dev/sda
    done!
    *******.
    Running: run_ntfsreloc_part -p "sda1 sda2 sda3" auto
    The NTFS boot partition was not found or not among the restored partition(s). Skip running partclone.ntfsfixboot.
    *********.
    End of restoreparts job for image some_bew_image.
    End of restoredisk job for image some_bew_image.
    Checking if udevd rules have to be restored...
    This program is not started by Clonezilla server, so skip notifying it the job is done.
    This program is not started by Clonezilla server, so skip notifying it the job is done.
    Finished!
    Finished!
    Now syncing - flush filesystem buffers...
    Ending /usr/sbin/ocs-sr at 2020-01-20 13:32:29 UTC...

     
  • Steven Shiau

    Steven Shiau - 2020-01-26

    If the destination disk has partitions, when you use the option "-k" for ocs-sr, it should honor the partition table of your destination disk, then just use the existing partitions.
    Normally it won't wipe other partitions, unless there are some bugs...

    Steven

     
  • Andrew

    Andrew - 2020-02-03

    Thanks for the reply Stephen.

    I think I've made a little more progress but I think the issue now is that I'm trying to restore a partition to a system that the partition didn't come from.

    I think if I were able to change the UUID of /dev/sda3 in this case I might stand a chance. Is that option available ?

    To give you a little more context we make the image from 1 golden system and deploy it to many others. Historically we have used the entire disk but I think it would be helpful to save one partition with log data for example yet still upgrade the system using clonezilla.

    Thanks again,

    Andrew

    root@debian:~# cat /var/log/clonezilla.log 
    Starting /usr/sbin/ocs-sr at 2020-02-03 12:44:23 UTC...
    *****************************************************.
    Clonezilla image dir: /home/partimag
    Shutting down the Logical Volume Manager
      Shutting Down logical volume: /dev/vg00/localmntvol 
      Shutting Down logical volume: /dev/vg00/slashvol 
      Shutting Down logical volume: /dev/vg00/swapvol 
      Shutting Down logical volume: /dev/vg00/varvol 
      Shutting Down volume group: vg00 
    Finished Shutting down the Logical Volume Manager
    This program is not started by clonezilla server.
    Restoring partition /dev/sda1...
    *****************************************************.
    Starting unicast restoring image image_name to /dev/sda1...
    If this action fails or hangs, check:
    * Is the saved image /home/partimag/image_name/sda1.ext3-ptcl-img.gz.* corrupted ?
    *****************************************************.
      ( for img in /home/partimag/image_name/sda1.ext3-ptcl-img.gz.*; do
          cat 
        done
      )   | pigz -d -c 2> /tmp/unzip_stdin_cmd_error.5FFvdo   | LC_ALL=C partclone.ext3 -z 10485760 -N -L /var/log/partclone.log -s - -r -o /dev/sda1
    Partclone v0.3.12 http://partclone.org
    Starting to restore image (-) to device (/dev/sda1)
    memory needed: 21014528 bytes
    bitmap 32768 bytes, blocks 2*10485760 bytes, checksum 10240 bytes
    Calculating bitmap... Please wait...
    get device size 1073741824 by ioctl BLKGETSIZE64,
    done!
    File system:  EXTFS
    Device size:    1.1 GB = 262144 Blocks
    Space in use: 225.5 MB = 55064 Blocks
    Free Space:   848.2 MB = 207080 Blocks
    Block size:   4096 Byte
    Syncing... OK!
    Partclone successfully restored the image (-) to the device (/dev/sda1)
    >>> Time elapsed: 22.04 secs (~ .367 mins)
    Finished unicast restoring image image_name to /dev/sda1.
    Informing the OS of partition table changes.... done!
    *****************************************************.
    Probing sda with blockdev before restoring EBR...
    Finding extended partition(s) in parted table /home/partimag/image_name/sda-pt.parted...
    LVM exists, restoring PV/VG/LV.
    Preparing the LVM (PV/VG/LV)... 
    Creating the PV... 
    done.
    Restoring the VG config... 
      Couldn't find device with uuid YXXXL-YYYY-RRRR-FFFF-SSSS-SSSS-SSSS.
      Cannot restore Volume Group vg00 with 1 PVs marked as missing.
      Restore failed.
    done.
    Program terminated!.
    root@debian:~# 
    
     
  • Steven Shiau

    Steven Shiau - 2020-02-23

    The log you showed we can see that /dev/sda1 was restored successfully. However, the error is about the LVM device with the specific UUID. Maybe it's about some device other than /dev/sda1? When /dev/sda1 is restored successfully, definitely the original UUID would be restored, too.

    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.