Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

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

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
User avatar
w4kh
Posts: 98
Joined: 2006-09-09 19:10
Location: Alabama, USA

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

#1 Post by w4kh »

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.
4.19.0-9-amd64 #1 SMP Debian 4.19.118-2+deb10u1
CPU: AMD FX(tm)-8350 Eight-Core Processor
RAM: 32GB (8x8GB) DDR3 DRAM
Video: GeForce 8400 GS to VIZIO E320VA Monitor

CwF
Global Moderator
Global Moderator
Posts: 2636
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 192 times

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

#2 Post by CwF »

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...

Segfault
Posts: 993
Joined: 2005-09-24 12:24
Has thanked: 5 times
Been thanked: 17 times

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

#3 Post by Segfault »

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.

User avatar
w4kh
Posts: 98
Joined: 2006-09-09 19:10
Location: Alabama, USA

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

#4 Post by w4kh »

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:
4.19.0-9-amd64 #1 SMP Debian 4.19.118-2+deb10u1
CPU: AMD FX(tm)-8350 Eight-Core Processor
RAM: 32GB (8x8GB) DDR3 DRAM
Video: GeForce 8400 GS to VIZIO E320VA Monitor

milomak
Posts: 2158
Joined: 2009-06-09 22:20
Been thanked: 1 time

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

#5 Post by milomak »

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

then doing the changes to /etc/fstab etc
Desktop: A320M-A PRO MAX, AMD Ryzen 5 3600, GALAX GeForce RTX™ 2060 Super EX (1-Click OC) - Sid, Win10, Arch Linux, Gentoo, Solus
Laptop: hp 250 G8 i3 11th Gen - Sid
Kodi: AMD Athlon 5150 APU w/Radeon HD 8400 - Sid

User avatar
w4kh
Posts: 98
Joined: 2006-09-09 19:10
Location: Alabama, USA

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

#6 Post by w4kh »

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.
4.19.0-9-amd64 #1 SMP Debian 4.19.118-2+deb10u1
CPU: AMD FX(tm)-8350 Eight-Core Processor
RAM: 32GB (8x8GB) DDR3 DRAM
Video: GeForce 8400 GS to VIZIO E320VA Monitor

Particle
Posts: 19
Joined: 2018-02-03 18:59

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

#7 Post by Particle »

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.

User avatar
w4kh
Posts: 98
Joined: 2006-09-09 19:10
Location: Alabama, USA

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

#8 Post by w4kh »

I have tabulated the steps taken so far...
I am kinda over-schedule for the next few days, but I intend to add the M.2 NVMe SSD on a PCIe card in the PCIe X4 slot as soon as I can be down for a few hours to work out the kinks... once that is complete, I will post a full recipe for the process... Stand by... :roll:
4.19.0-9-amd64 #1 SMP Debian 4.19.118-2+deb10u1
CPU: AMD FX(tm)-8350 Eight-Core Processor
RAM: 32GB (8x8GB) DDR3 DRAM
Video: GeForce 8400 GS to VIZIO E320VA Monitor

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

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

#9 Post by p.H »

w4kh wrote:the block sizes on /dev/sda (512 bytes) and the NVMe/M.2 SSD (4096 bytes) are different
Are you sure that the SSD has a 4096-byte logical sector size ? If it has a 4096-byte physical sector size and 512-byte logical size, you are only concerned with partition alignment, not logical sector size mismatch. If the partitions on the hard disk were created with the now default 1-MB alignment (2048 x 512-byte sectors), they you do not have to worry with alignment.
w4kh wrote:IF I were to

Code: Select all

mount /dev/NVMe1 /mnt ; copy -a /dev/sda1 /mnt/
I would probably be OK
No, you wouldn't. This would just copy the /dev/sda1 special device file, not its contents.
w4kh wrote:since /mnt is part of the root of /dev/sad1, would not the copy become recursive
This is where cp -x (do not cross filesystem boundaries) comes in handy.

Post Reply