1

I have been able to backup and restore a Linux Mint system partition with 'Disks' (command to run: gnome-disks; package to install: gnome-disk-utility) from a live session, but I am not sure that was the best way to do it: on the contrary!

I need advice on what I did wrong in order to have a proper procedure available next time I need it.

My initial configuration was this:

enter image description here

The backup/restoration procedure involved the /dev/sda2 partition (ext4). With the swap space (that I'll not discuss anymore in order to simplify the description), it involves about 70 GB. The rest are ntfs partitions, one a Windows system partition, the other a "Depo" partition accessible from both Windows and Linux.

This is what I did:

BACKUP:

  • with gparted in a live session shrunk the partition to the smallest size (from 70 to 30 GB)

  • made the backup (30 GB) with Disks (as an iso image that I saved on an external device)

(After creating an extended partition and testing different Linux systems like Ubuntu Gnome and Solus, I wanted to go back to the initial situation, as I decided I preferred my original single Linux Mint stable and well customized system.)

RESTORATION:

  • with Gparted, deleted the entire (70 GB) extended partition and created a new 70 GB ext4 primary partition

  • with Disks, restored the 30 GB partition (from the iso image) onto the 70 GB one!!!! ---- maybe I should have restored it onto unformatted space? - IS THIS THE ERROR?

  • at this point the entire 70 GB partition seemed almost full, although the restored image had only 30 GB; boot-repair complained about lack of space when trying to install grub on that partition and failed to install grub

  • and gparted reported only 600 MB free, while c 40 GB free space was somehow visible but ONLY in the image gparted showed, not in the numbers; RESIZING WAS NOT POSSIBLE
  • after restarting in a new live session: gparted reported only 600 MB free but resizing was possible: reducing the partition to real full space of 30 GB, 40 GB appeared unallocated all of a sudden, then extending entire partition to full 70 GB was possible
  • at this point only grub was missing, and running boot-repair in live session all went fine (I selected advanced options: install grub on sda, boot from the given partition (sda2), un-checked "purge grub" as there was no grub installed anyway)

After booting from local drive, the old grub list was available and the old system was in place. The only problem, it took a lot of time first time to enter session, and I also think the boot time is now generally somewhat longer..


So, my question is: should one restore a system partition image onto an empty partition the way I did or on an not-formatted space? or in a somehow different way?

  • Did you unmounted the 70GB partition before restoring? Restoring Linux is straight forward. Just copy back all files, install bootloader & configure it. Done. – Abhik Bose Nov 21 '17 at 23:20
  • @AbhikBose - I do not remember whether I unmounted or not... You mean I could back-up by just copy/paste all files (without copying as iso the entire partition?) – user32012 Nov 22 '17 at 11:16
  • 1
    Yah.. I had written a procedure of restoring linux at unix.stackexchange.com/questions/403166/…. Please have a look once. This worked for me. You need not to have minimal installation as you're restoring on same hardware. And remember to reinstall grub after restoring. – Abhik Bose Nov 22 '17 at 11:40
  • @AbhikBose - Very interesting. The drivers issue is minimal: I recently simply moved a HDD with both Win7 and Linux from a HP to a Sony laptop with no issues for Linux (some for Windows). But your procedure per se doesn't seem simpler than what I did. It is mostly a matter of time. - My action was a success, but what I want to know is how to prepare the location where the iso is to be restored? – user32012 Nov 22 '17 at 14:03
  • 1
    Ok. I think you shall format the partition and unmount it before restore. Theoretically that shall work without issue. – Abhik Bose Nov 22 '17 at 14:10
0

While creating backup of a Linux system and restoring following shall be helpful.

  1. The destination partition must be unmounted before restoration. Format the partition while mounted and then unmount it.
  2. Size of the destination partition doesn't matter unless it's not smaller than the image file to be restored.
  3. After restoration the free volume can be shrunk.
  4. During shrinking the disk shall be shrunk from end. If it's shrunk from starting the bootloader must be re installed in case of legacy BIOS based system
  5. A Linux system can be backed up and restored without image creation as mentioned in this article How to install CentOS 7 into a directory (without booting an install system)?
  • that sounds very reasonable; my gparted problem was either related to the partition not being unmounted (although in that case the restoration should have failed completely I guess - shouldn't it?), or, more probable, that misconfiguration/misreporting in gparted was something like a bug, easily fixed by restart and shrinking/resizing. – user32012 Nov 22 '17 at 21:38
  • I can confirm that even with un-mounted partition the free space that remains on it after restoring the backup is somehow reported as non-allocated and the restored system lacks space in case the back-up partition was shrunk before being exported. That can be fixed by gparted with the "Check" option. Therefore, it is not a good idea to reduce partition to minimum before backup. - Also: grub-repair is always needed. – user32012 Dec 8 '17 at 12:33
  • In fact gparted would report as un-allocated the difference of space between the destination partition and the restored one, which must be there no matter if the restored partition has empty space or not. – user32012 Oct 23 '18 at 8:35
0

In these case I always say: Unplug the hard drive first! That must be the first step if you want to restore data from it. This is because every operation may overwrite a sector that you might want to restore. Let's skip this part since you are already over it.

Gather the following:

  • Another computer with a separate OS (Windows, Linux, depends on your restore application)
  • A HDD Dock where you can plug your faulty hard disk
  • A partition specific software

Next: always save as many data as many you can! I would search in google what applications can restore data from an Ext4 partition. There is one for windows, that can be used. Get yourself a data recovery software and install it. It doesn't matter if it is a Windows or Linux application. And lastly you'll need another hard drive that is at least as big as the disk where you've lost the data. You'll save your lost files here. When it is all done and ready to scan drives for data, only then start up the hard drive. Then just follow instructions and save/backup/copy (NOT MOVE!!) all your files to the new disk. This is required if you cannot restore the disk to it's former status, then you can at least re-install faster by having all your configs and files ready on another disk. Now you can start trying to recover the disk to it's previous status.

Using Gparted and the Disks utility was a good idea since they are pretty good restoring partitions if they are not so badly corrupted. A more specific application like TestDisk could be better, but I've not lost any Ext4 disks so far, so I can't really tell you if this works or not. For Ext3 and NTFS I've used GetDataBack and that worked like a charm. But that is not good for Ext4. LVM could also be an issue but there you can use snapshots to get back to a previous state.

  • thank you for all the good advice, but my question is more limited; it specifically refers to Disks: how should I configure the target space/partition where I want to restore a partition saved as iso?. I have marked in my question the step in my action that I am concerned with. – user32012 Nov 22 '17 at 14:49
0

On RHEL/CentOS based systems, I use rear (Relax-and-Recover http://relax-and-recover.org/download/). This is also released for Ubuntu , so you may consider this tool, which permits to create bootable backups (on USB stick for example).

  • Has it also a gui or only cli? – user32012 Nov 22 '17 at 14:45
  • I only know about the CLI (which fits my needs)... – tonioc Nov 22 '17 at 18:10
  • my question specifically refers to 'Disks' (gnome-disks): how should I configure the target space/partition where I want to restore a partition saved as iso?. I think I have received an answer on that (namely: it should be a formatted partition, it should not be mounted, being larger than the iso is not a problem). Thanks. – user32012 Nov 22 '17 at 21:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy