Migrate Debian from one disc to another

Kernels & Hardware, configuring network, installing services

Migrate Debian from one disc to another

Postby Sk1X1 » 2018-03-28 12:47

I bought new computer with Win 10 preinstalled. I installed Debian on new partition (same disc) a everything goes well. But now I added new disc and I would like to move Debian to this disk.

Is here easy way how to do it?

I tried to use
Code: Select all
dd
to copy Linux partition to new disc, but I'm not sure how to update grub, because `update-grub` didn't add new partition with Debian partition to his menu.

This is
Code: Select all
fdisk -l
output:

Code: Select all
Disk /dev/nvme0n1: 238.5 GiB, 256060514304 bytes, 500118192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 0F8FCBCA-F7B2-429C-B02B-4A420C815CB7

Device             Start       End   Sectors   Size Type
/dev/nvme0n1p1      2048    739327    737280   360M EFI System
/dev/nvme0n1p2    739328   1001471    262144   128M Microsoft reserved
---------Win 10 partition-----------
/dev/nvme0n1p3   1001472 405315583 404314112 192.8G Microsoft basic data
---------Old Debian partition-----------
/dev/nvme0n1p4 405315584 484538367  79222784  37.8G Linux filesystem
/dev/nvme0n1p5 484538368 500117503  15579136   7.4G Linux swap


Disk /dev/sda: 232.9 GiB, 250059350016 bytes, 488397168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 77489E99-4F1D-4E2A-A984-6BE441B8A849

Device        Start       End   Sectors   Size Type
/dev/sda1      2048  15626239  15624192   7.5G Linux swap
---------New Debian partition-----------
/dev/sda2  15626240 488397134 472770895 225.4G Linux filesystem


Code: Select all
/dev/nvme0n1
is old disc with Win10 and Debian i'm using now
Code: Select all
/dev/sda
is new disc, where I would like to migrate my current Debian

For now I can safely boot into old Debian. Any advice how to migrate it on /dev/sda?
I can format or change structure of new disk if it is needed.
Sk1X1
 
Posts: 6
Joined: 2018-02-10 10:06

Re: Migrate Debian from one disc to another

Postby pawRoot » 2018-03-28 18:54

I believe that you will need to create EFI partition on the new drive aswell.
User avatar
pawRoot
 
Posts: 493
Joined: 2016-12-28 18:26
Location: Poland

Re: Migrate Debian from one disc to another

Postby bw123 » 2018-03-29 21:05

I searched the internet with your topic title, "Migrate Debian from one disc to another" and found this... it's a thread about migrating to raid1, but I think steve_v's answer is pretty darn close to what you want to do.

viewtopic.php?f=5&p=669791#p669791

steve_v wrote:make degraded array(s)
copy system
chroot in
install grub
rebuild initramfs
update fstab
reboot
add old disk.
Same as it ever was...


In your case you want to mkfs instead of 'make degraded array' and reclaim/remove the old partition instead of 'add old disk' and I think that 'update fstab' should maybe come before rebuild initramfs like p.H said.

I haven't used dd for this, I'd just use copy with some switches, maybe
copy -ax but look that up for the best way, it's been a long while.

OTOH, if you did use dd and all the UUID's match, I'm not sure why you could not skip a step or two, but I'm not sure which ones...

Good luck.
Last edited by bw123 on 2018-03-29 21:10, edited 1 time in total.
User avatar
bw123
 
Posts: 2928
Joined: 2011-05-09 06:02
Location: TN_USA

Re: Migrate Debian from one disc to another

Postby Segfault » 2018-03-29 21:08

Tip!
Looking up similar threads is much faster than posting another one and waiting for responses.
Segfault
 
Posts: 664
Joined: 2005-09-24 12:24

Re: Migrate Debian from one disc to another

Postby Bulkley » 2018-03-29 23:04

I'd use Clonzilla.
Bulkley
 
Posts: 5512
Joined: 2006-02-11 18:35

Re: Migrate Debian from one disc to another

Postby Sk1X1 » 2018-04-06 11:21

Thanks for all of you replies.

@Segfault
I search for answer on multiple sites. Even your link doesn't contain answer I was looking for, but thanks anyway

@Bulkley
I tried Clonzilla, but copy failed (probably because new disc is bigger than old one)

At the end I end up with fresh install of system.
Sk1X1
 
Posts: 6
Joined: 2018-02-10 10:06

Re: Migrate Debian from one disc to another

Postby Segfault » 2018-04-06 12:28

That's a shame. Simple 'cp -a' never failed me.
Segfault
 
Posts: 664
Joined: 2005-09-24 12:24


Return to System configuration

Who is online

Users browsing this forum: No registered users and 8 guests

fashionable