Debian 9 - "Best Way" to replace 2 SATA HD with 1 NVMe M.2

Kernels & Hardware, configuring network, installing services

Debian 9 - "Best Way" to replace 2 SATA HD with 1 NVMe M.2

Postby w4kh » 2018-11-23 20:14

My searching brought up some interesting threads, but none that addressed how to migrate /dev/sda (/dev/sda1, /dev/sda2, /dev/sda3) and /dev/sdb (/dev/sdb1) to a new, larger, SSD... /dev/sda is a smaller 120GB SSD, and /dev/sdb is a 750GB spinner. The goal is to install an LTO5 tape drive to back up the 1TB SSD, and I don't want to have to go nuts with a SUPER HUGE case - what I have is already pretty good size... I just need the front panel drive space for the "older school" tape.
I know I can use dd or Clonezilla, but I'm trying to figure a way to install the new SSD on the motherboard, clone the existing drives, remove the "old" drives, install the tape, reboot and have it (I hope) work... I want to increase the size of /dev/sda to about 200GB (from the reported 111GB of the 120GB drive) and just move everything in /dev/sdb1 to a partition on the new SSD - this latter I can handle, as long as I can add a fourth partition for the present /dev/sdb1 data... it is migrating the /dev/sda drive to corresponding partitions on the new SSD without blowing it up that is troubling...
I suppose I could just clone the 120GB drive to the new SSD and use a partition manager to resize partitions and add /dev/sdb (/dev/sdb1) to the new SSD drive so a simple partition-to-partition clone could handle the rest.
The real "problem" is I am old, and my head is clogged with 60 years of working with different computer vendors, systems (mainframes to "desktops"), OSs (Univac, IBM, DEC, Unix, Windows, Linux), etc., and I tend a bit toward ADHD/ADD - I can hyper-concentrate, but a roadmap could save HUGE amounts of time and lots of false starts.
User avatar
w4kh
 
Posts: 65
Joined: 2006-09-09 19:10
Location: Tennessee, USA

Re: Debian 9 - "Best Way" to replace 2 SATA HD with 1 NVMe M

Postby CwF » 2018-11-24 17:28

w4kh wrote:I suppose I could just clone the 120GB drive to the new SSD and use a partition manager to resize partitions and add...
CwF
 
Posts: 168
Joined: 2018-06-20 15:16

Re: Debian 9 - "Best Way" to replace 2 SATA HD with 1 NVMe M

Postby Segfault » 2018-11-24 18:47

Please, you can use 'cp -a' to copy everything and it will work. Proven many times. Just create new partitions and make filesystems as you desire, then mount them in a temporary location and copy. Then edit fstab and install bootloader, if needed. I myself use EFI stub kernel, so when I upgrade the drives the bootloader is no concern.
Segfault
 
Posts: 812
Joined: 2005-09-24 12:24

Re: Debian 9 - "Best Way" to replace 2 SATA HD with 1 NVMe M

Postby w4kh » 2018-11-27 15:25

CwF's response, while encouraging, overlooks several important aspects: 1) After cloning /dev/sda to the NVMe/M.2 SSD, I want to remove /dev/sda and boot from the NVMe/M.2 SSD; 2) the block sizes on /dev/sda (512 bytes) and the NVMe/M.2 SSD (4096 bytes) are different, and I want to avoid conflicts where possible, and NOT suffer the penalty of having the SSD have to commit multiple reads due to block size and (possible) alignment differences.

I do not think a simple (pseudo code)
dd bs=4k if=/dev/sda of="NVMe/M.2 SSD" conv=sync
would work properly... I know I can partition the rest of the hard drive for holding /dev/sdb1, but making the NVMe/M.2 SSD bootable and a clone of /dev/sda with block sizes adjusted and aligned on sector boundaries is the real goal.
Segfault suggested:
Please, you can use 'cp -a' to copy everything and it will work.

While tempting, it seems to leave several questions unanswered, and some issues unaddressed... it did prompt me to do some deeper searching
Segfault wrote:
Just create new partitions and make filesystems as you desire, then mount them in a temporary location and copy.

Mounting in a "temporary location and copy" has issues...
IF I were to
Code: Select all
mount /dev/NVMe1 /mnt ; copy -a /dev/sda1 /mnt/
I would probably be OK, since that is the VFAT /boot/efi partition, however, after that were successful, were I to
Code: Select all
mount /dev/NVMe2 /mnt
and attempt the copy, since /mnt is part of the root of /dev/sad1, would not the copy become recursive and self destruct? What "temporary location" would solve that?
Segfault wrote:
edit fstab and install bootloader, if needed

No problem editing fstab, but bootloader raises questions...
EFI stub kernel
is that on a bootable CD (which would address the temporary mount locations)? Debian 9.6 live-CD?
Once this is solved, I will write up a recipe for migrating from multiple hard drives to a large solid state drive... BTW, I am a bit conflicted about how to manage my /dev/sdb drive. I know I can simply copy the contents of /dev/sdb1 to the former mount point directory, but I am leaning toward keeping the contents of /dev/sdb1 in a separate partition, which makes it easier to make individual partition backups onto a NAS in addition to the LTO Tape backup of the entire system.

So many questions... So MUCH learning still! :wink:
User avatar
w4kh
 
Posts: 65
Joined: 2006-09-09 19:10
Location: Tennessee, USA

Re: Debian 9 - "Best Way" to replace 2 SATA HD with 1 NVMe M

Postby milomak » 2018-11-27 21:31

i think by clone he meant move the files using something like rsync

then doing the changes to /etc/fstab etc
Desktop: iMac Late-2015 27" 5K Retina (17,1 - 3.3GHz) - MacOS and Windows 10 (Bootcamp)/ Debian Sid (External SSD)
Laptop: Lenovo ideapad Y700 [nVidia Optimus] (64-bit) - Debian Sid, Win10,
Kodi Box: AMD Athlon 5150 APU w/Radeon HD 8400 - Debian Sid
milomak
 
Posts: 1855
Joined: 2009-06-09 22:20

Re: Debian 9 - "Best Way" to replace 2 SATA HD with 1 NVMe M

Postby w4kh » 2018-11-29 15:09

milomak wrote:
i think by clone he meant move the files using something like rsync

"He" (me) meant clone as in make the first three partitions of the new SSD an exact clone of /dev/sda, and then adjust the size of the /dev/sda2 partition to make it slightly larger. Once that is complete, I want to add a partition (/dev/sda4) and then copy/clone /dev/sdb1 to /dev/sda4.
Then, I'll edit fstab to mount appropriate UUIDs to their mount points.

All this needs to be done and function properly BEFORE I can add the LTO tape and set up nightly tape backups.
User avatar
w4kh
 
Posts: 65
Joined: 2006-09-09 19:10
Location: Tennessee, USA

Re: Debian 9 - "Best Way" to replace 2 SATA HD with 1 NVMe M

Postby Particle » 2018-11-30 14:47

Edit: I see you want to move partitions from multiple disks to a new single disk. This guide below doesn't cover that, but I'm leaving it in case someone with a more traditional case comes across your thread in the future via Google.

If your old disk is partitioned with an MBR style table your task is actually going to be very simple. It should be as simple as doing a block copy of your old device to your new device (ie dd if=/dev/old of=/dev/new bs=1M) if the new device is at least as large as the old one. At that point, if you removed the old device and changed the boot order in your BIOS to point to the new disk, your system should boot as if nothing had changed.

If, however, your old disk is partitioned with a GPT style table then your task will require some extra steps. This is because GPT puts a table both at the start and end of the device, and if they don't match each other bad things happen. On Windows the system will outright refuse to boot. On Linux I can't recall what happens. In any case, this can be fixed by using gdisk (sudo gdisk /dev/new / x for expert menu / e for copy header to end of disk / w to write changes to disk / y to confirm).

Once cloned, you can easily grow your old partitions using gparted. Just right click the partition you want to expand and give it a new size to fill the rest of your new disk. Apply the changes.

(You can also use gparted to copy other existing partitons. I'd start by cloning your boot disk exactly as above, then use gparted to copy the partition from your second disk into the free space of your new disk. Shrink it first if applicable.)

To recap:
Step 1) Clone the old disk to the new disk. Use dd for this.
Step 2) If it's a GPT disk, use gdisk to copy the GPT header to the end of the disk.
Step 3) If the new disk is larger, use gparted to expand the partition on the new disk after cloning.
Step 4) Shut down and remove the old disk.
Step 5) Enter your BIOS and select the new disk as your boot device.
Particle
 
Posts: 19
Joined: 2018-02-03 18:59


Return to System configuration

Who is online

Users browsing this forum: No registered users and 3 guests

fashionable