Menu

excluding a partition from disk-backup?

rosika
2019-09-19
2019-10-06
  • rosika

    rosika - 2019-09-19

    Hello,

    could you give me some advice as far as backup is concerned? I use clonezilla live-system from a USB-stick.

    I´m using Linux/Lubuntu as my main system. It is installed on an external USB-drive (HDD). My internal HDD is still home to WIN8.1 (the system my PC came with).

    As Lubuntu is my main system I perform a regular disk-backup of the external HDD once a month. There are 3 partitions on it:
    Root-partition (25 GB), home-partition (38 GB) and a third (data-)partition (107 GB).

    In order to obtain a backup that gives me - in case of need - my system back which should be bootable again of course, I always perform a complete disk-backup, which takes me around 1 and three quarters of a hour to complete (with check).

    As the contents of the rather large third partition don´t normally change much it would be enough to backup the root and home partition.
    But in order to achieve this goal I´d have to apply two partition backups rather than a disk backup.

    Yet I don´t know whether my system would be bootable again in case I´d have to restore the root partition alone.

    When I installed Lubuntu I chose "something else" during the installation and put the bootloader on /dev/sdc which was the external HDD during the time of installation.

    And gnome-disks tells me my first (root-)partition is bootable.

    So how should I proceed if I theoretically need a disk-backup for a bootable restoration of my system, but want to exclude my data-partition?

    Thanks a lot for your help in advance.

    Geetings.
    Rosika

     
  • Jeremy Boden

    Jeremy Boden - 2019-09-19

    Clonezilla is not primarily intended for backup & recovery.
    For example you could use rsync to take data backups of that large partition; after the first copy has been done it will only transfer the changes to the backup. This might only take a few minutes.

     
  • rosika

    rosika - 2019-09-19

    Hi Jeremy and thanks for the suggestion.
    That would seem to work.
    One question remains though. Perhaps you could clarify that as well:

    If I backup (or rather clone) my root-partition to an image - and by this I mean just the root partition - and later restore it, would my system still be bootable?

    Or in other words: In order to get a bootable system, would I need a complete disk-backup or just the backup of my root-partition (assuming that the home-partition is already there, of course)?

    As I said: gnome-disks tells me my first (root-)partition is bootable. Therefore my question.

    Thanks again.
    Rosika

     

    Last edit: rosika 2019-09-19
  • Jeremy Boden

    Jeremy Boden - 2019-09-19

    It's tricky using identifiers such as sda, sdb, sdc etc as they can change names when devices are swapped around.
    Labeling your partitions (with gparted) can be helpful, if you can recognise disks by their partitions sizes etc.
    Linux does provide unique identifiers (UUID) for partitions with the blkid command.

    However, when you copy/restore a Clonezilla disk image all the labels & UUID's are also copied/restored. This can be confusing, if both disks are mounted simultaneously.

     
  • rosika

    rosika - 2019-09-20

    Hi Jeremy and thanks again.
    I understand what you are saying and it makes sense.
    In the past there was the need of restoring the disk-image and it worked well. My system was bootable again.
    Yet even at the risk of repeating myself (sorry for that) and just to clarify: If I clone only my /-partition and later restore it to my system, will it be bootable again?

    To be clear: I don´t have a separate boot-partition, and when installing the system I chose "something else" during the installation and put the bootloader on the external HDD. So theoretically the bootloader should be on / and thus the system should be bootable again.

    I just wanted to know if you could confirm my theory. I hope you don´t mind.

    Thanks again and many greetings.
    Rosika

     
  • Jeremy Boden

    Jeremy Boden - 2019-09-20

    Clearly restoring an entire disk image will always work.

    But it's more complicated if you just restore a partition.
    It sounds like you might have a MBR legacy boot system and this uses data before the first partition during the boot process.
    If you have a EFI system, whilst it can be made to imitate a MBR system, it is intended that basic system boot information exists in a small system partition.
    The code in your /boot/grub directory doesn't get executed until the low level PC stuff has identified where it is - the only purpose of grub is to act as a boot loader, so it identifies where to find the actual kernel to load.

    So just restoring partition data to a blank disk will not make it bootable, but restoring partition(s) to the existing disk - perhaps because you need to roll back a system change ought to be OK.

    But I would find the whole thing to be a rather high risk exercise!

    An alternate way would be to reinstall your Linux system, overwriting only the / partition and leaving /home and /data untouched. You could then overwrite the / partition with mozilla which should give you your machine back (relatively untouched) with all customised configuration restored, but in a hopefully bootable state.

     
  • rosika

    rosika - 2019-09-20

    Hi Jeremy and thanks for the clarification. I think it´s all clear to me now.

    If you have a EFI system, whilst it can be made to imitate a MBR system

    Yes, that´s the case. My PC came with WIN8.1 and UEFI. Then I changed it to legacy and installed Linux/Lubuntu on an external USB-HDD. So Lubuntu itself says "BIOS":

    [ -d /sys/firmware/efi ] && echo UEFI || echo BIOS
    BIOS
    

    Nevertheless I don´t seem to have asmall system partition for system boot information. At least it doesn´t show.
    As my original question referred to restoring partition(s) to the existing disk I think I know all need to know now.

    Thanks again for your persistence in answering all my questions.
    Have a nice day and many geetings.
    Rosika

     

    Last edit: rosika 2019-09-20
  • Jeremy Boden

    Jeremy Boden - 2019-09-20

    OK - booting is something that has mutated over the years by quite a bit!

    Since you using a MBR style BIOS, the basic boot and partition size information is stored in the first 512 bytes of the disk. I'm guessing that your first partition starts at LBA 2048. The space from blocks 1 - 2047 is also partly used by the boot process.

    Use the sudo fdisk -l to display your partition layout.

    See https://en.wikipedia.org/wiki/BIOS_boot_partition#/media/File:GNU_GRUB_components.svg

     
  • rosika

    rosika - 2019-09-20

    Hi Jeremy and thanks.
    You´re perfectly right. sudo fdisk -l shows me for my external HDD:

    Gerät      Boot    Anfang      Ende  Sektoren Größe Kn Typ
    /dev/sdb1  *         2048  48828415  48826368 23,3G 83 Linux
    /dev/sdb2        48828416 123467775  74639360 35,6G 83 Linux
    /dev/sdb3       123467776 333182975 209715200  100G 83 Linux
    

    So basically I´d have to secure the bootloader with its partition table. Just in case. Then a partition backup of / (and of /home) would be o.k.

    Greetings
    Rosika

     
  • Jeremy Boden

    Jeremy Boden - 2019-09-20

    You could use dd (with great care) to copy the first 2048 blocks to a file.

     
  • rosika

    rosika - 2019-09-21

    Hi Jerremy and thanks,
    sudo dd if=/dev/sdb of=mbr_backup bs=512 count=1 # sdb being my HDD
    should backup the entire MBR including the partition table, at least to my knowledge.

    Geetings
    Rosika

     
  • Jeremy Boden

    Jeremy Boden - 2019-09-21

    Yes it will backup your MBR - but grub is also using some of the sectors between 1-2047, not just sector 0. This is because 512 bytes is too small to contain the code for all the things that grub has to do.

    So 512 bytes is OK for a restore to your existing disk - but if you want to cover yourself for a restore to a new blank disk then you should use:-

    sudo dd if=/dev/sdb of=mbr_backup bs=512 count=2048 # sdb being my HDD
    

    It's only 1 MB so it won't take long.

     
  • rosika

    rosika - 2019-09-21

    Hi Jeremy,
    thank you so much for clearing things up to me.
    I understand now, and yes: your command is perfect, I can see it now. I did´t take into account a possible restore to a new disk.
    And I presume things won´t change under normal circumstances, so I would have to perform the MBR backup just once and then I have it.

    You really helped me a lot and I appreciate it very much.
    Thanks again and have a a nice day.
    Greetings.
    Rosika

     
  • Steven Shiau

    Steven Shiau - 2019-09-22

    Another way to convert the image dir from partition as from disk is:

    1. Save the parts you want using "saveparts" in the Clonezilla menu.
    2. Once the image dir is created, say it's "my-img", put a plain text file called "disk" under that image, e.g., "/home/partimag/my-img/disk", and list all the disks in one line as its content, e.g., if only one disk, its content is:
      $ cat /home/partimag/my-img/disk
      sda
      Then the this image becomes a disk image.

    One thing to remember is, for swap partition of GNU/Linux, this hacking won't include it. Besides, this is not well tested, so it might have something missing.

    Steven

     
  • rosika

    rosika - 2019-09-22

    Thank you Stven for that suggestion.

    [...] and list all the disks in one line as its content [...]

    So if I understand you correctly: if I want to save just the two partitions / and /home (which belong to the same disk) I could apply your method.
    In your example it´s sda. But how do I know what to type into /home/partimag/my-img/disk in my case?
    I suppose I take sd[x] that clonezilla gives me for the respective disk in its initial analysis.

    Cheers.
    Rosika

     

    Last edit: rosika 2019-09-22
    • Steven Shiau

      Steven Shiau - 2019-10-06

      "I suppose I take sd[x] that clonezilla gives me for the respective disk in its initial analysis." -> Yes.
      Or you can take from the partitions name listed in the image dir. When it's something like "sda1.ext4-ptcl-img.gz.aa", then you know you can input "sda" in the file disk.

      Steven

       
      • rosika

        rosika - 2019-10-06

        Hi Steven,
        thanks a lot for the clarification. I think I can handle it now.
        Have a nice Sunday.
        Rosika

         
  • rosika

    rosika - 2019-09-30

    Hello again,
    excuse me for asking two additional questions after a while.
    It has just occurred to me that I´m not quite sure as to proceed when restoring to a NEW disk.
    What about the order?

    Consider the following scenario:
    Root-partition and home-partition are saved to partition images with clonezilla and for my third (data-)partition an rsync-backup is created, as you suggested. MBR is also saved (as discussed above).

    Now in order to restore root and home partitions I can use clonezilla and for restoring MBR I use

    dd if=mbr_backup of=/dev/sdb bs=512 count=2048 # sdb being my HDD
    

    So two questions remain to be cleared:

    Is my restore command correct? And:
    What about the order in case of using a NEW disk: should I restore the MBR first and then restore the partitions? Or is it the other way round?

    Thanks again for your help.
    Greetings.
    Rosika

     
  • Jeremy Boden

    Jeremy Boden - 2019-09-30

    I'm 99.9% certain - but the only way to test a backup strategy is to actually try it on a blank disk.
    Unless Clonezilla restores partition info to the MBR (almost certainly it wouldn't) you should restore the first 2048 blocks as above, followed by the two Clonezilla backups and the data backup.

    Then check that it's bootable, operational and all important data were restored.
    It's the only certain way.

     
  • rosika

    rosika - 2019-09-30

    Hello again Jeremy,
    thank you so much for your very quick answer.
    O.K. I understand that trying it out is the only way to make completely sure that my backup strategy works.

    you should restore the first 2048 blocks as above, followed by the two Clonezilla backups and the data backup

    Fine, that´s what I would have done, too. Yet I wanted to listen to your opinion first.

    So thanks a lot. It seems I´ve learnt a quite a bit.
    Many greetings.
    Rosika

     

Log in to post a comment.

MongoDB Logo MongoDB