1

I have an Ubuntu Server 20.04 machine running with a long-running memory-intensive data processing script running. I would like to replace my old hard drive with a new, larger hard drive.

Is it possible to hibernate the system, copy the old drive to the new, swap the drives, and then un-hibernate the system?

My plan would be systemctl hibernate (first verifying swapon --show returns a swap file), power off, unplug the old hard drive, copy (using CloneZilla) the old hard drive to the new hard drive on another machine (or maybe using a bootable USB OS on the same machine), plug in the new hard drive, and then power on the machine.

Will this work?

mark
  • 261
  • Nope. Because you're new hard disk will have a new UUID - so the kernel will not find that disk. You'd have to reboot ,after updating the the UUID in fdisk and possibly in your grub boot loader ... – kanehekili Mar 27 '21 at 02:42
  • By copy do you mean clone? If cloned the drives will have the same UUID's. I was playing with bootable USB's with hibernate. I found the drives had to be plugged into the same socket for hibernate to work. This is different. If you try, please let us know the results by answering your own question. +10 for a great, useful question. – C.S.Cameron Mar 27 '21 at 14:12
  • @C.S.Cameron yes meant clone. I will make sure to connect the new SSD hard drive to the same SATA port, and I'll post my results – mark Mar 27 '21 at 21:14
  • Unfortunately it did not work for me. I hibernated the system following https://askubuntu.com/a/1321773/1195026, then I plugged the new SSD into the old SATA port, and plugged the old SSD into another SATA port. I cloned my old SSD onto the new SSD with a bootable CloneZilla usb stick. Then I unplugged the old SSD and booted the machine. When booting it displayed a lot of error messages about kernel panics and stopped there. Unfortunately I didn't have time to debug further. – mark Mar 30 '21 at 00:23

1 Answers1

0

Hibernating Swap while Cloning Disk

I tried this using a USB flash drive as all my HDD's are in use.

  • Created Full install USB using sudodus 20.04 image file.
  • Enlarged swapfile to 5GB.
  • Set up hibernation.
  • opened a bunch of programs.
  • Invoked hibernation.
  • Created an image file of the flashdrive using Gnome-Disks*.
  • Zeroed the flash drive using mkusb.
  • Flashed the image to the flash drive using mkusb.
  • Returned the flash drive to it's original socket.
  • It booted to it's state at the time of hibernating.

This may be a little different than your case with a server, but it proves that your premise works.

I do think it is important to plug the new disk into the same SATA port the old disk was plugged into at time of hibernation.

*A pro would use dd and clone disk to disk, but Disks and mkusb give a level of comfort.

C.S.Cameron
  • 19,519