r/linuxquestions • • 23d ago

Support Is it possible to move Linux to another drive without reinstalling it?

Several months ago I decided to give Linux a try since I've been very unhappy with Microsoft as a whole. I finally took the plunge after weeks of research, and gave Fedora KDE Plasma a shot in a dual-boot config with Windows, unsure if I'd stick with it. Now I find myself spending at least 90% of my time on my PC in Linux, and only booting into Windows for a handful of games I still enjoy that can only be played on Windows.

To make the dual-boot setup work, I salvaged my old 1TB Samsung SATA SSD from my old PC. This is now my only drive I'm using with Fedora. Since I like Linux so much, I now find myself kinda regretting that it's on the older, slower SSD while Windows 11 gets to enjoy the NVMe performance. So I began thinking, since I rarely boot into Windows these days, what if I temporarily nuked Windows off the NVMe drive, moved Linux over to the faster NVMe drive, and reinstalled Windows 11 from scratch on the old 1TB SSD?

My only question now is, is it possible to basically clone my Fedora install and essentially "copy/paste" it onto a different drive? Does it break stuff to try to do this? Do I need to reinstall all my programs? Do I need to redo all of my settings I've tweaked over the months? How does it work? What gets affected, if anything? I'd really rather go the route of just moving the OS and not reinstalling it.

EDIT: I also use the GRUB menu every time my PC boots in order to select from booting into the Linux kernels, and Windows. So how would moving the OS also affect the GRUB menu?

6 Upvotes

30 comments sorted by

6

u/DickBrainTime 23d ago

Yes, you can move Fedora without reinstalling your apps or redoing your settings. The tricky part is the boot setup, not the files. Run `lsblk -f` and `findmnt /boot/efi` first: in a dual-boot setup the EFI partition might actually live on the Windows NVMe, even if Fedora itself is on the SATA SSD.

Back up both drives before wiping either. From a live USB you can clone/migrate the Fedora partitions to the NVMe (Clonezilla is one option if the target has enough room), but the EFI boot files/entry need to move or be recreated too. Disconnect the old SATA drive for the first test boot so duplicate partition UUIDs don't cause confusion.

Once Fedora boots independently from the NVMe, then reinstall Windows on the SATA drive. You may need to adjust UEFI boot order and GRUB's Windows entry afterward, but the Fedora applications and settings should remain. Posting `lsblk -f` and `sudo efibootmgr -v` output would help people guide the exact migration.

1

u/Relentless_Troll 23d ago

Oof this is sounding slightly trickier than I thought it'd be lol. After reading your reply, and a couple others, I'm already starting to think maybe I should just let Fedora live on the SATA SSD and just buy another NVMe drive for extra game storage.

2

u/b3542 23d ago

Yes. Probably.

1

u/knuthf 23d ago

After considering the replies, I will conclude that they are lucky. Each file system has an "owner Id" that is generated and this maps as "root' and file owner, unless other is set. As long as the UUID remains, it will work fine. But.. should it fail, "chattr" and it does the trick.

1

u/chikamakaleyley 23d ago

yeah like Fedora the OS and its files is fine on the SATA, IMO

You can move your user files to the NVME, but i think in a lot of cases that's not necessary. Games on the NVME, and any personal files that you read and write to often, you want to take advantage of the faster speed, so move those over. Applications too, if you want them to launch faster, but that might involve changing some configuration in your package manager.

Anything you don't access often, keep it on the SATA

1

u/Shdwdrgn 22d ago

If this method concerns you, there is another option that takes a bit more work, but is "easier" if you're not comfortable with all the commands. Typically your personal data is going to be in the /home directory, and the rest of the folders are for the operating system.

What you can do is a clean install of linux on the NVMe, using the same OS version as what you have now (or use your original installation media and upgrade it the same way you did before). The real work here is that you have to remember and reinstall all of the software that you want to retain.

On the new system, check if the old drive was auto-mounted (but do this from the command line, NOT from a desktop under your user account -- shut down the desktop if you have it running). Basically you just want to copy the old /home folder to the new /home folder, then you can start up the desktop again and usually all of your old stuff will be right back where you left it.

I would give it a few days before you wipe the SSD though. Make sure to test your new desktop and verify all of your important info is in place. Since it doesn't sound like you have a backup, your SSD copy is the only way to recover that information if something went wrong.

6

u/ephemeralmiko deca: ostree/bootc w. cinnamon 23d ago edited 22d ago

dd if=/dev/$oldSSD of=/dev/$newSSD bs=1M conv=noerror,sync status=progress

replace $oldSSD and $newSSD with their filepaths (e.g. nvme0n1 or sda, not single partitions like nvme0n1p3 or sda3)

Then use something like Gparted to stretch the main partition to fill the rest of the space if the drives are different size

Make sure not to mix up $oldSSD and $newSSD or your PC will overwrite your entire drive.

E: added status=progress

4

u/Sp33d0J03 23d ago

At least advise op to use status=progress so they can actually see the progress.

2

u/ephemeralmiko deca: ostree/bootc w. cinnamon 22d ago

Just added it, I completely forgot.

3

u/xylarr 23d ago

You have to boot off a drive that is not the source or destination.

1

u/Relentless_Troll 23d ago

Wow is it really that simple to do? And once it's done, nothing gets broken? Like my installed programs, file paths, settings, etc.

Also what would happen to the GRUB menu? I just know the Linux drive needs to be the #1 boot option in my BIOS for it to appear. So would I still see it once I make the NVMe the main boot option after the transfer?

5

u/hazeyAnimal 23d ago

It's that simple but it's also that simple to mix them up and overwrite your drive with the empty one.

It's all just 1s and 0s in the memory bank

2

u/MarshalRyan 23d ago

Definitely works. If you want something a little less CLI, check out CloneZilla.

0

u/angelicWhirr 22d ago

sounds like you've bricked a drive or two before, maybe you could supervise if i ever get brave enough to try this myself

1

u/ephemeralmiko deca: ostree/bootc w. cinnamon 22d ago

I've actually never mixed them up before, I wrote a script way back when that confirms multiple times with the UUID and name of the drive if that's actually what I want to do.

1

u/Alarming_Treacle578 23d ago

What you can do is save your desktop config and flatpak apps with the Flatpak app called save Desktop https://github.com/vikdevelop/SaveDesktop Backup all your files and do a fresh install. After the fresh install install Save Desktop and then just import the config and after about 10 - 20 mins, depending how many apps you previously had installed, your desktop will be as was.

1

u/Relentless_Troll 23d ago

Now this sounds a little more doable than some of the other options I've seen. My one hangup with this is the GRUB menu. Someone said the GRUB menu might be tied to the Windows partition, and on the surface it sounds like a bit of a headache to get it back to how it was after a transfer.

1

u/sm_greato 23d ago edited 23d ago

GRUB is overrated. You can just use the UEFI boot menu to switch. Do one boot loader in each drive. You will have to create anew a boot partition on your Fedora drive, but that should be trivial.

On a related note, you might want to use Arch on the side. I was annoyed at first it didn't provide a simple installation tool (it kinda does nowadays), but now, I've grown to appreciate it. You have to ready the setup manually, so you learn how the setup ought to work. Then, you're free to make configurations as wacky as you like and aren't tied to the installation tools. It's a great tool for learning Linux and how to do stuff like this.

1

u/Alarming_Treacle578 22d ago

If doing my suggestion with a fresh install route you'll get a new GRUB menu.

1

u/michaelpaoli 23d ago

possible to move Linux to another drive without reinstalling it?

Absolutely, done it many times. Heck, VMs, I do it quite regularly. Thinking of which, even have VM that moves both drives, and physical hosts, live, easy peasy. So, yeah, not an issue.

what if I temporarily nuked Windows off the NVMe drive, moved Linux over to the faster NVMe drive, and reinstalled Windows 11 from scratch on the old 1TB SSD?

Microsoft doesn't play so nice with other OSes. You may have better results (and Microsoft less likely to f*ck sh*t up), if you have the Microsoft installed on there first, e.g. (re)install it there first before adding Linux to the drive, or take the existing there, resize if/as needed, then move Linux there. Anyway, if you go that route, you can't simply just image copy your whole SSD to the NVMe, you'll need to do partition(s) properly, possibly resize, and may need to reconfigure (e.g. GRUB, /etc/fstab, etc.) bit to have that then all play reasonably nice together o the NVMe with both, and without the SSD.

clone my

You can mostly do that with Linux fine. But don't want to have duplicate UUIDs, nor duplicate host private keys, etc. on distinct hosts. So should adjust as appropriate on that, e.g. once copied, clobber them on the source if the source isn't going to be used anymore. Notwithstanding that, and the config bits I noted further above, can generally do cold image copy/clone fine, e.g. disk to disk, partition to partition, etc. as relevant.

Anyway, may be simplest and least troublesome in your scenario:

  • Shrink the Windows stuff on the NVMe if/as needed (or reinstall it to less size)
  • set up relevant partition(s) as needed for Linux on NVMe
  • if/as needed, shrink source Linux filesystems/partitions
  • clone them to relevant target locations
  • boot from ISO or the like, and do any relevant configuration fix-ups, e.g.:

    • (re)install GRUB to NVMe
    • (re)configure EFI (if/as needed)
    • (re)configure GRUB
    • (re)configure Linux if/as needed, e.g.

      • /etc/fstab
      • GRUB configuration files

That's probably (about?) it, just sync && sync those changes, reboot, and if you got it all right, should be set. If not, well, e.g. boot that ISO again and finish fixin' up whatever needs be adjusted.

Oh, also, Fedora, defaults to using LVM, right (or maybe they don't even let you not use LVM?)? Yeah, that can actually make much of it quite a bit easier. Can even live migrate much of the data, rather than going the clone route - at least for the bulk of it.

1

u/Relentless_Troll 23d ago edited 23d ago

I'm aware that Windows doesn't play nice having another OS on the same drive, which is why what I was thinking was delete Windows 11 entirely first, THEN try to move Linux over onto an empty drive.

But after reading replies, including this one, it sounds like it's more trouble than what it's worth. I think the process is a little beyond me, and it seems like there's decent room for error. I also think the gains of using Linux on the NVMe would probably be negligible anyway. I'm thinking that I'll likely just let Fedora live on the SATA SSD and buy a separate NVMe drive for extra game storage down the line. Seems like that'd be the least amount of headache lol

2

u/chikamakaleyley 23d ago

i think you would... clone fedora onto the new NVME, install a fresh GRUB on the boot partition; Fedora generates a new grub config. I think Fedora might use fstab which is basically tells the OS what should be mounted when you start your system, so your new NVME has a UUID that you would need to replace and update the entry in fstab

aka the grub part you dont' want to clone

I think this is how it works, I've only used arch

1

u/moritz12d Manjaro 23d ago

To obtain the current UUID just run lsblk -f to modify /etc/fstab and dracut and your boot-manager will do the rest.

1

u/chikamakaleyley 23d ago

boom there you go

2

u/corpse86 23d ago

Rescuezilla

1

u/seismicpdx 23d ago

Could be diminishing returns, but it will work if you execute correctly.

I moved my 2.5-inch SATA SSD from a 3rd Gen Intel into a 12 Gen Intel SFF, and it's fast as ****.

I only game with 0AD. This is my coding learning computer; Kubuntu, emacs, VS Code, terminals.

My point is it will be faster, but you may not realize how much or little you will gain. Consider doing some benchmarks before and after.

Be sure to do backups, including an rsync copy.

1

u/green_meklar Debian 23d ago

Is it possible to move Linux to another drive without reinstalling it?

It should be. I've never actually moved Linux that way, but I've moved Windows that way, and it worked fine, and if anything, Linux should be easier.

what if I temporarily nuked Windows off the NVMe drive, moved Linux over to the faster NVMe drive, and reinstalled Windows 11 from scratch on the old 1TB SSD?

Aside from a bit of extra SSD wear, this should work fine. You do need to make sure to clone the Linux drive as a bootable drive, switch the drive priority correctly in the BIOS, and potentially update your fstab.

Does it break stuff to try to do this?

Drive mappings, maybe.

There's also the issue that, if the Windows partition is currently larger than the entire Linux drive, cloning it onto the Linux drive becomes more complicated.

Do I need to reinstall all my programs? Do I need to redo all of my settings I've tweaked over the months?

No. As long as everything is mapped correctly and the hardware is fully functional, it will just boot and work normally (except faster).

How does it work?

If I were doing it, I'd start by making a bootable Clonezilla USB drive. (In practice, I already possess one.)

If the Windows partition is larger than the entire 1TB SATA drive, you'll probably need to shrink the Windows partition first. Clear off whatever data needs to be cleared in order to get the entire filesystem usage small enough (under about 1TB in your case, but you'll want at least a few dozen GB of slack, too). Then use the Windows Disk Management Utility to shrink Windows's own partition down small enough to fit onto the 1TB drive (with the aforementioned slack).

Then turn everything off and boot to the Clonezilla drive. Clone the Windows partition to whatever third backup drive you're using. (Actually for this step you can just make a drive image and put it on the backup drive's filesystem, without having to reformat it, assuming the space is available and Clonezilla can recognize the filesystem.) Clone the Linux drive to the original Windows drive, making sure to make it a bootable drive and keep whatever extra partitions you need (EFI, possibly swap, etc). Finally, clone the backup Windows drive image to the 1TB SATA drive, again making sure to make it a bootable drive.

Shut down Clonezilla and boot back into the BIOS. Set the new Linux drive to the top of the boot priority order, if it isn't there already. Proceed with booting to the Linux bootloader. If the filesystems don't load properly, you may need to boot to a recovery drive (or to Windows, if that works) and edit the Linux fstab file.

At least, that's the theory. I haven't done this kind of stuff so frequently as to anticipate all the ways things might go wrong.

1

u/3grg 22d ago

Moving an install to another disk is possible. There are several things to consider. First, does the Linux disk have its own efi partition or does it use the windows one? If the Linux drive is independent of the windows drive, cloning the drive to another disk and then removing it is pretty straight forward with Clonezilla.

If the steps required to clone the drive seem too onerous, you are not alone. Since it is relatively easy to install a fresh copy of your chosen distro to a new drive and then copy data that you need from the old drive, many times people will just choose this path.

1

u/miscdebris1123 20d ago

Clonezilla