2

I want to re-install my Ubuntu install for various reasons. Before doing this, I would like to back up my Ubuntu partition, in case something goes wrong (highly unlikely). I have backed up entire disks before, but not single partitions. My partition layout:

sda 8:0 0 232,9G 0 disk
├─sda1 8:1 0 35G 0 part     (Windows 8.1)
├─sda2 8:2 0 194G 0 part /  (Ubuntu 14.04)
└─sda3 8:3 0 4G 0 part      (SWAP)

Can I just boot up a portable Linux drive using a USB Key, and use "dd" to copy "sda2" to my external hard drive?

And since it is the second partition, do I have to do anything with the MBR, if I wish to restore the backup partition?

psmears
  • 138
  • 4
Mats Punt
  • 21
  • 2

2 Answers2

1

I am not really sure what you mean by "just bootup a portable linux drive".

If what you want is: hard-copy your sda2 into a usb and then eventually boot from it, it is probably possible.

What you can surely do is:

  • dd your sda2 to a key (be careful with the dd command and see here)
  • If you want to restore: dd it back to an appropriate sized partition
  • Boot up from a live usb key and run the boot-repair utility (this tells your GRUB to give you an option to load the system you cloned back)

I believe this should work even if you omit step 1 (e.g. you can instruct your grub to boot the system that is in the usb-key) but I never tried myself.

Also, maybe lookup something like "Install ubuntu from a USB key" (also see a possibly related thread).

A final word of warning: notice that you have a dual boot with win 8.1, therefore you might have a UEFI installation of UBUNTU, and have a ESP partition that holds all of your boot files (also for windows). To check if this is the case look if there is /sys/firmware/efi directory as suggested by other users. Keep this in mind when working with partitions and with boot-repair.

1

You can back up your personal files to an external disk with normal file-copying commands (cp in a Terminal or drag-and-drop with whatever file manager you like). That's normally adequate, unless you do heavy customization of system-wide settings (in /etc). In a worst-case scenario, you'd re-install Ubuntu and then copy your personal files back.

Clonezilla is a popular backup tool if you want to back up an entire partition or an entire set of partitions. You'll then be able to restore the whole partition much like you could with a dd backup, but a Clonezilla backup will chew up less disk space and will proceed more quickly, since it won't back up unused sectors from the disk, which a dd backup will.

As to the MBR, I wouldn't bother. GRUB relies on code in the MBR, but also code elsewhere, so if something goes badly wrong, you might need to use Boot Repair or restore the boot loader manually even if you have an MBR backup. This is likely to be safer, too, since all sorts of things can go wrong if you start mucking with the MBR using dd and don't know what you're doing. Furthermore, as Three Diag says, you may have an EFI-based installation, in which case you'd want to back up the EFI System Partition (ESP). Aside from the MBR's role holding a protective "partition" in the GPT system, the MBR is unimportant in EFI-mode booting. (That said, I suspect you've got a BIOS-mode installation, given the lack of an ESP in the data you've shown -- but I could be wrong about this.)

Rod Smith
  • 45,120
  • 7
  • 66
  • 108