[SOLVED] Migrate to new / HDD

This forum is dedicated to basic help and support :

Ask here your questions about basic installation and usage of Mageia. For example you may post here all your questions about getting Mageia isos and installing it, configuring your printer, using your word processor etc.

Try to ask your questions in the right sub-forum with as much details as you can gather. the more precise the question will be, the more likely you are to get a useful answer

[SOLVED] Migrate to new / HDD

Postby xboxboy » Nov 12th, '18, 00:32

Hi all,
my system has been freezing and only a hard reboot can be performed. I've ignored it thinking it may be a software/update/kernel issue, but after a few months it's becoming more regular.

Using gsmartmontools, I see the drive is near end of life, so it's replacement time.

The issue is that it's not a traditional desktop install, I'm running several servers off it and rebuilding would take quite some time:

I'm wondering if I can clone the drive somehow?

System is UEFI.
SSD is / (this is the failing drive), sda
HDD is /home and swap, sdb

Thanks.
Last edited by xboxboy on Feb 23rd, '19, 08:50, edited 1 time in total.
xboxboy
 
Posts: 391
Joined: Jun 2nd, '13, 06:41

Re: Migrate to new / HDD

Postby benmc » Nov 12th, '18, 03:52

xboxboy wrote:I'm wondering if I can clone the drive somehow?


Offline- absolutely. try Clonezilla. you dont *need* to pre-partition the replacement drive if it is the same size, as Clonezilla will do this.
If the new SSD is a different / larger size, then do pre-partition, image the failing drive partitions to a third drive, (also acts as a backup if there is custard around), then clone back to partitions to the new drive. You may need to do a "dirty" reinstall - takes about 5 minutes, if the new efi partition gets borked, or if you are unfamiliar with "grub-rescue" see below:

Online- I do not know.


if boot to new drive gives a "grub prompt" or "grub rescue prompt"
grub rescue:
Code: Select all
ls
this will give partition list
Code: Select all
set prefix=(hdX,Y)/boot/grub
from "ls" above enter the location of boot file: grub2, (EFI implies GPT so set prefix=(hd0,gpt1)/boot/grub2 is the likely entry).
Code: Select all
set root=(hdX,Y)
(again EFI implies root=(hd0,gpt1) ).
Code: Select all
insmod normal

Code: Select all
normal
should cause system to boot.
presumably system is running with no desktop?
open a root terminal and run
Code: Select all
# update-grub2
reboot to be sure system boot up is running correctly

I have performed the above a few times with a bios legacy GPT HDD setup, not with a UEFI system.
Last edited by benmc on Nov 12th, '18, 05:54, edited 1 time in total.
benmc
 
Posts: 1175
Joined: Sep 2nd, '11, 12:45
Location: Pirongia, New Zealand

Re: Migrate to new / HDD

Postby JoesCat » Nov 12th, '18, 05:40

I recommend using clonezilla too.
The UEFI process only goes up to checking, then running grub. Once grub is running then UEFI is no longer involved, and grub transfers control to the kernel.
You can change settings using mageia control center to see grub on bootup - and may be a good idea before you start cloning so you see it on the new drive.

This is offline too and works fine with UEFI if you have trouble with clonezilla above:
If the new drive is the same or larger than the old drive, and you don't care about wasted space on the new drive if it's larger, you can do this from a live distro.
assuming old drive is sda and new drive is sdb
su
fdisk -l (check and be sure you're not going the other way otherwise you lose everything).
dd bs=100M if=/dev/sda of=/dev/sdb
because sda is failing, you might try do a sanity check of sdb, but I'd skip this for now:
fsck /dev/sdb1
fsck /dev/sdb2
fsck /dev/sdb3
etc.....until you've checked/fixed all partitions.

To avoid cloning the wrong way...I recommend cloning the image to a backup drive....

assuming your running a live distro and the backup drive is /mnt/bkup then....
su
md /mnt/bkup
mount /dev/sdb1 /mnt/bkup
md /mnt/bkup/2018nov11backup
dd bs=100M if=/dev/sda | gzip -c | split -b 638m - /mnt/bkup/2018nov11backup/backup.img.gz.
umount /mnt/bkup

power down live distro, pull-out old sda, insert new sda, reboot live distro.
su
md /mnt/bkup
mount /dev/sdb1 /mnt/bkup
cat /mnt/bkup/2018nov11backup/backup.img.gz.* | gzip -dc | dd bs=100M of=/dev/sda
umount /mnt/bkup

dd takes quite a bit of time on large drives because you copy/clone everything.
User avatar
JoesCat
 
Posts: 177
Joined: Sep 15th, '11, 04:27
Location: Richmond, BC, Canada

Re: Migrate to new / HDD

Postby xboxboy » Nov 16th, '18, 14:09

Ok thanks guys.
Dave helped me over XMAS do something similar (make full system backup, and functional) before the Mageia6 update. So I've got a rough idea what's gotta happen.

I've got the new drive, wow, haven't ssd prices come down. I got double the size (120g) for about a 1/3rd of the last drive IIRC. Amazing.

I'll attempt it over the coming days when I have a few hours to spare.
xboxboy
 
Posts: 391
Joined: Jun 2nd, '13, 06:41

Re: Migrate to new / HDD

Postby xboxboy » Feb 23rd, '19, 08:49

This went well:
I unplugged my data (/home) drive, and plugged in the new drive.
I booted a mageia live iso.
Checked using diskdrake which disk was which. /dev/sda was my new disk, /dev/sdb was my / drive.

Then as root run
Code: Select all
dd if=/dev/sdb of=/dev/sda


Once complete I shut down.
Unplugged original / drive.
Reconnected /home drive.
Remove usb and rebooted.

Voila, perfectly running system. How good is that!

Only thing is my new drive is 120gb, where as my old was 60gb. I don't think / will ever fill it. But if I need to extend /dev/sda1 (/ partition), what do I do with /swap given that's now in the middle of /dev/sda.

Best delete partition, extend / partition, then recreate swap and update fstab? Is that all I need to do?
xboxboy
 
Posts: 391
Joined: Jun 2nd, '13, 06:41

Re: Migrate to new / HDD

Postby filip » Feb 23rd, '19, 11:16

xboxboy wrote:This went well:
Great.


xboxboy wrote:Best delete partition, extend / partition, then recreate swap and update fstab? Is that all I need to do?

Yes. I use Gparted for that. Booted from live media of course.

Another option is to create another partition and bind mount it to where you need space the most. I use that approach for HD on Raspberry Pi.
filip
 
Posts: 474
Joined: May 4th, '11, 22:10
Location: Kranj, Slovenia

Re: Migrate to new / HDD

Postby doktor5000 » Feb 23rd, '19, 15:32

xboxboy wrote:Best delete partition, extend / partition, then recreate swap and update fstab? Is that all I need to do?

No sadly it's not, you also need to check bootloader configuration and also recreate initrd's if you use a different UUID for the swap partition.
It might be easier if you just reuse the old UUID for the new swap partition. mkswap -U lets you specify a custom UUID.
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 17629
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: [SOLVED] Migrate to new / HDD

Postby xboxboy » Feb 23rd, '19, 15:49

Ah, yes, good point doktor.
xboxboy
 
Posts: 391
Joined: Jun 2nd, '13, 06:41


Return to Basic support

Who is online

Users browsing this forum: No registered users and 1 guest

cron