[Solved] Replace SSD on dual boot Linux/Windows Laptop

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Post Reply
gflash
Level 2
Level 2
Posts: 55
Joined: Sun Feb 11, 2024 5:08 am

[Solved] Replace SSD on dual boot Linux/Windows Laptop

Post by gflash »

Hello,

I'm replacing a hard drive on my laptop which runs a Linux Mint 21.2 / Windows 10 dual boot system and would like to ask for advice regarding the best approach doing so. I would prefer to avoid having to re-install from scratch either system, but especially the Linux since it is my main working system. Windows could be re-installed if reviving it after copying is too tricky/time consuming as it only contains some games. To my knowledge the laptop runs UEFI Bios (It's from 2016).

Old disk layout:
NVME-SSD 500 GB - Windows 10
SATA SSD 1000GB - Linux Mint 21.2 (installed regularly from USB using "run alongside" option)

New desired layout:
NVME SSD 2000GB - Linux Mint ~1300GB / Windows 10 ~700GB (Replacing old 500 GB SSD, which I'll put in a USB casing)
SATA SSD 1000GB - Partof Linux Mint system for backups

After making a backup of all important personal data, several approaches came to my mind:

Approach A:
1) Replace SSD and boot from USB Linux Live system
2) Use dd to clone the 1000GB SSD to the new 2000GB SSD
3) Use fdisk to make room for Windows after the linux partitions, create same partitions and sizes as there are on old 500GB SSD for windows.
4) Use dd to clone windows from USB 500GB SSD partition-wise
5) Update /etc/fstab and grub.conf, install grub
6) Work some magic to revive the windows installation. Is that even possible? I don't know how.

Approach B:
1) Replace SSD and boot from USB Linux Live system
2) Use dd to clone the 1000GB SSD to the new 2000GB SSD
3) Use fdisk to make room for Windows
4) Install windows regularly from USB into free space
5) Boot again Linux Live system, update /etc/fstab and grub.conf, install grub

Approach C:
1) Replace SSD
2) Install Windows Regularly, but leave room for Linux
3) Install Linux Mint regularly as dual-boot
4) Boot from USB Linux Live system, copy /etc/fstab and grub.conf, then brutally rsync freshly installed Linux Mint with the old one on 1000 GB SSD save those two files

Which would be the most hassle-free and time efficient approach? I'm also open for other ideas of course.

Thanks in advance for your support!
Last edited by gflash on Sat Mar 23, 2024 6:23 am, edited 1 time in total.
User avatar
AndyMH
Level 21
Level 21
Posts: 13759
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Replace SSD on dual boot Linux/Windows Laptop

Post by AndyMH »

You can do this with a drive cloning utility like foxclone and gparted, or just with gparted - with gparted you can copy/paste partitions from one drive to another. No need to use dd. But before I offer more advice...

Confirm you are booting UEFI, in a terminal efibootmgr, if it says EFI variables are not supported you are booting legacy, anything else is UEFI. In win I think msinfo32 tells you how it boots. I'm expecting UEFI.

Check where grub is installed, I suspect it will be in the EFI partition on the win nvme drive. In a terminal df, you are looking for the partition mounted at /boot/efi.

Post the output of sudo parted --list. This tells us how the current drives are set up. This tells you how to post terminal output so it is more readable:
viewtopic.php?p=2119362&hilit=terminal#p2119362

Can you fit two nvme drives in your laptop at the same time or has it only got one M.2 slot?
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
gflash
Level 2
Level 2
Posts: 55
Joined: Sun Feb 11, 2024 5:08 am

Re: Replace SSD on dual boot Linux/Windows Laptop

Post by gflash »

Thanks for your reply.

It's UEFI:

Code: Select all

gflash@Valinor:~$ efibootmgr
BootCurrent: 0001
Timeout: 0 seconds
BootOrder: 0001,0000,0004,0005,0002,0003,0006
Boot0000* Windows Boot Manager
Boot0001* ubuntu
Boot0002* UEFI:CD/DVD Drive
Boot0003* UEFI:Removable Device
Boot0004* UEFI: IP4 KIller PCIe Network Controller
Boot0005* UEFI: IP6 KIller PCIe Network Controller
Boot0006* UEFI:Network Device
Grub seems to be installed on the 500GB SSD, so it has to be reinstalled on new SSD

Code: Select all

gflash@Valinor:~$ LC_ALL=C df
Filesystem     1K-blocks      Used Available Use% Mounted on
tmpfs            3281572      1916   3279656   1% /run
/dev/sda1      960302096 430646164 480801508  48% /
tmpfs           16407856         0  16407856   0% /dev/shm
tmpfs               5120         4      5116   1% /run/lock
/dev/nvme0n1p1     98304     31841     66463  33% /boot/efi
tmpfs            3281568       100   3281468   1% /run/user/1000
And here are my partitions:

Code: Select all

gflash@Valinor:~$ LC_ALL=C sudo parted --list
Model: ATA Samsung SSD 850 (scsi)
Disk /dev/sda: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name  Flags
 1      1049kB  1000GB  1000GB  ext4


Model: Samsung SSD 960 EVO 500GB (nvme)
Disk /dev/nvme0n1: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End    Size    File system  Name                          Flags
 1      1049kB  106MB  105MB   fat32        EFI system partition          boot, esp
 2      106MB   123MB  16.8MB               Microsoft reserved partition  msftres
 3      123MB   500GB  499GB   ntfs         Basic data partition          msftdata
 4      500GB   500GB  564MB   ntfs                                       hidden, diag
The laptop doesnt have two slots for NVME. But I do have a USB housing for the old one.
User avatar
AndyMH
Level 21
Level 21
Posts: 13759
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Replace SSD on dual boot Linux/Windows Laptop

Post by AndyMH »

Well done!! - for using LC_ALL=C, not many do that. I expected grub to be on nvme.
  • Download foxclone and burn it to a stick, you can use mint's usb imagewriter or ventoy.
https://foxclone.org/
  • Fit your new nvme in the second slot. Current is nvme0n1, the second will probably be nvme1n1.
  • Boot foxclone and clone the old nvme to the new one. It is as simple as select source, select target and go. If you need to, read the section on cloning in the user guide.
  • Shutdown, remove original nvme and boot - does it boot win? You have to remove the original, you cannot boot with two identical drives in the system - two identical EFI partitions, which bootloader does BIOS choose? two identical C: partitions - which one does the bootloader choose?
  • If you want to give win more drive space, do it now using win's disk management utility to do it.
  • Boot the foxclone stick again (or use your mint install stick) and run gparted, use gparted to copy/paste sda1 (your mint / partition) to the unallocated space on the nvme drive. The drive selector in gparted is a dropdown top right.
  • Shutdown, remove the samsung SSD (same logic as above on identical drives) and boot. Does it boot mint?
  • Assuming it does, boot either your foxclone or mint install stick and run gparted again to resize your / partition to use all the unallocated space.
How long it will take depends on the used space on the partitions. Last time I took a foxclone backup it took an hour with 375GB of used space. This was nvme to nvme but not the latest spec.

While this is low risk (you are not changing anything on your existing drives), I would make sure you have backups before you start.

Only after you have proved that the new setup works can you re-purpose your old nvme and samsung SSD. Fit them both and boot from the foxclone or mint install stick and reformat with gparted. Again you need to boot from a stick because you cannot use the OS on the system drives (identical partitions with the same UUIDs). Quickest way of wiping a drive is put a new partition table on it, in gparted device > create partition table, you want GPT. Create new partitions as desired. Three things to note with gparted:
  • When you create a partition, gparted will tell you what will happen at the bottom of the window. Nothing happens until you edit > apply all changes.
  • Always add a label to data partitions you create. If you do mint will automount them at /media/you/mylabel, without a label it will use the UUID, e.g. /media/you/ebf8a5ec-e041-4324-93f3-222e5adc035d - not user friendly. Keep your labels short and avoid spaces, remember linux is case sensitive. For fixed internal drives it is better to mount partitions on them via fstab - you get to choose where they mount. Guidance can be provided.
  • Any ext4 partitions created by gparted are owned by root and read-only to you. For write access*, with the partition mounted, in a terminal:

Code: Select all

sudo chown $USER: /media/you/mylabel
Any questions, ask. I'm the foxclone dev.

* udisks, the utility used to automount partitions might take care of this for you (partitions on my internal drives are mounted via fstab so I am guessing), if not and it is read-only then you need chown as described.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
gflash
Level 2
Level 2
Posts: 55
Joined: Sun Feb 11, 2024 5:08 am

Re: Replace SSD on dual boot Linux/Windows Laptop

Post by gflash »

Thank you very much for your support. Everything is done now, and it didnt take much time at all.

Least I can do is to offer some feedback on your steps:
  • Download foxclone and burn it to a stick, you can use mint's usb imagewriter or ventoy.
This one actually gave me the biggest headache, but I guess it was because of a faulty USB drive.

1. First I downloaded foxclone standard and used UNetbootin to make the USB. It gave me a secure boot error when trying to boot from it, so I disabled secure boot (enabled it again after everyting was done), and tried again. This time I ended up the the basic grub shell.

2. Second (successful) try was with the focal version and balena etcher. Balena actually told me that verifying the USB image after writing failed, so I switched to a new USB. From there, everything worked fine. Borked USB went to the bin immediately.
  • Fit your new nvme in the second slot. Current is nvme0n1, the second will probably be nvme1n1.
I didnt habe a second slot, but using my USB casing worked fine.
  • Boot foxclone and clone the old nvme to the new one. It is as simple as select source, select target and go. If you need to, read the section on cloning in the user guide.
Worked as a charm, no user guide needed. Took less than 10 minutes to copy the 500GB image which was about 50% full.
  • Shutdown, remove original nvme and boot - does it boot win? You have to remove the original, you cannot boot with two identical drives in the system - two identical EFI partitions, which bootloader does BIOS choose? two identical C: partitions - which one does the bootloader choose?
No issues here.
  • If you want to give win more drive space, do it now using win's disk management utility to do it.
This didnt work, probably because of the windows recovery partition in-between the windows partition and the free space. I didn't bother to solve it, 500GB are sufficient for a game or two.
  • Boot the foxclone stick again (or use your mint install stick) and run gparted, use gparted to copy/paste sda1 (your mint / partition) to the unallocated space on the nvme drive. The drive selector in gparted is a dropdown top right.
Took less than 20 mintes and didnt give me any trouble.
  • Shutdown, remove the samsung SSD (same logic as above on identical drives) and boot. Does it boot mint?
To my surprise, it does! How did grub know where to look?
  • Assuming it does, boot either your foxclone or mint install stick and run gparted again to resize your / partition to use all the unallocated space.
Yup.

Re-purposing the 1000GB SSD also worked as described. Thanks for the tip with the drive label! But what is the difference bewteen "label" and "name"? I put the same string in both fields.
User avatar
AndyMH
Level 21
Level 21
Posts: 13759
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: [Solved] Replace SSD on dual boot Linux/Windows Laptop

Post by AndyMH »

This one actually gave me the biggest headache
That's because you went "off piste", I had suggested mint's usb imagewriter or ventoy. For the future here is an excellent tutorial for ventoy:
viewtopic.php?p=2389786&hilit=ventoy#p2389786
It is a multi-boot solution and is now my "goto" utility for booting isos. Once you have ventoy installed to a stick, you just copy isos to it, as many as you want. When you boot the stick ventoy asks which iso?

foxclone will not boot with secure boot enabled as you found. I must change the user manual to say this. I have looked at getting it to boot with it enabled and it fell into the "too difficult" category at the time. I always disable secure boot on all my PCs. I don't use win and the only time it ever gets installed is to use as a victim for testing foxclone.
probably because of the windows recovery partition
Should have thought about that one, don't know if win's disk manglement utility will let you move it, gparted certainly will.
To my surprise, it does! How did grub know where to look?
Because it searches for your / partition by its UUID (which is unique), so it doesn't care what drive the partition is on. I assume the win bootloader is the same looking for C:. Same with booting grub, all the system cares about is that your bootloaders live in an EFI partition, doesn't matter which drive it is on, it looks for EFI partitions on all drives.
But what is the difference bewteen "label" and "name"?
The difference is that I have yet to find a use for a partition name. A partition label is useful, you can use the label instead of the UUID to mount partitions, and udisks automounts partitions with labels using the label name as I previously explained. On drives will a legacy/msdos/mbr partition table (the old standard) you only have a label, with a gpt partition table you can have a label and name. The partition name is a solution in search of a problem.

I suggest you use one of the old drives for backup and nothing else. Put an ext4 partition on it and save your timeshift snapshots to it. If it is internal you can automate the process. Might be a bit too small for data backup, for that I use backintime. Works like timeshift, takes snapshots and the destination needs to be ext4. I also suggest you use foxclone and take an image backup of the new system drive. The image files are compressed so typically will require between 50% - 70% of the used space on the drive. With ventoy you could have both your mint install iso and foxclone isos on the same stick.

All my PCs have an internal/removable 2TB drive used only for backup. That is where my timeshift & backintime snapshots live along with my foxclone image backups. Because the drive is internal I have timeshift/backintime running daily automatically (significant overkill for timeshift). Once every few months I'll take a foxclone image backup. Have a major issue, foxclone gets me back a working system current at the time of the backup. Timeshift/backintime get me back to yesterday. I also have another copy of mint installed on the backup drive, so bork the main system, I can boot from the backup to fix it.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
Post Reply

Return to “Installation & Boot”