this post was submitted on 22 Oct 2024
26 points (96.4% liked)

Linux

11752 readers
68 users here now

Welcome to c/linux!

Welcome to our thriving Linux community! Whether you're a seasoned Linux enthusiast or just starting your journey, we're excited to have you here. Explore, learn, and collaborate with like-minded individuals who share a passion for open-source software and the endless possibilities it offers. Together, let's dive into the world of Linux and embrace the power of freedom, customization, and innovation. Enjoy your stay and feel free to join the vibrant discussions that await you!

Rules:

  1. Stay on topic: Posts and discussions should be related to Linux, open source software, and related technologies.

  2. Be respectful: Treat fellow community members with respect and courtesy.

  3. Quality over quantity: Share informative and thought-provoking content.

  4. No spam or self-promotion: Avoid excessive self-promotion or spamming.

  5. No NSFW adult content

  6. Follow general lemmy guidelines.

founded 2 years ago
MODERATORS
 

The title pretty much speaks for itself... I have a linux install that I've spent a considerable time configuring, which is unfortunately installed on a drive that's starting to show signs of dying.

My question is: how, if there is a way, can I migrate said linux install over to a different drive, while preserving all the configurations and such.

EDIT: Thank you to everyone who commented! I made the transfer, using dd and it went mostly smoothly, even if it did take a while.

all 25 comments
sorted by: hot top controversial new old
[–] Drathro@dormi.zone 11 points 8 months ago (1 children)

Get a same sized drive (or larger) and just dd it? I used to do that all the time, even to Windows installs, if I knew a drive was starting to become unreliable. I'd advise mounting the original/donor drive as read-only to mitigate any potential data losses while transferring. But dd makes a perfect bit for bit copy of any partitions, drives, etc that you feed it. Just don't get the inputs/outputs backwards! And always remember: dd stands for "disk destroyer" because if you get it wrong, bye-bye data.

[–] hendu@lemmy.dbzer0.com 4 points 8 months ago* (last edited 8 months ago) (1 children)

Assuming the new drive is an equal size or larger: Boot from a USB drive and use dd to clone the old drive to the new one. Then, remove the old drive and boot from the new one. You'll also need to resize the partitions on the new drive if it's larger.

[–] bloodfart@lemmy.ml 3 points 8 months ago (1 children)

I’m glad you got it sorted with dd.

One thing people don’t often realize about dd is that it copies all the data from one drive to the other, including uuids that were written when the old drives filesystem were created.

For that reason it excels at cloning one’s boot disk, because when the old drive gets removed from the pc, the clone drives os says at some point during the boot process “okay, let’s mount the filesystem with uuid ABC123 at /“ and it works.

Dd is also not the best tool for cloning disk that you intend to leave hooked up because if you do it’ll put the poor host os in a “I’m seein’ double here, four spidermen!” Type situation.

[–] electric_nan@lemmy.ml 3 points 8 months ago

I used dd recently to upgrade the drive in a Steam Deck. Easy and worked perfectly.

[–] possiblylinux127@lemmy.zip 2 points 8 months ago (1 children)

Take one of your backups and restore it to the new drive.

You do have backups right?

Side note I would recommend creating automation to setup your device they way you want. Either bash or Ansible pull.

[–] shrugs@lemmy.world 2 points 8 months ago

Linux is pretty forgiving. You don't even need to use dd, if you know what you are doing you can create a totally new partitioning format and just copy the files. Since getting the fstab just right in that case is more error prone, just using dd is simpler. If using dd, don't worry, you can resize partition afterwards.

[–] JTskulk@lemmy.world 1 points 8 months ago

If it were me, I'd do a fresh minimal install of the same OS, boot to the livecd and then delete pretty much everything except for /etc and /boot. I'd then cp -ar all my files from the failing drive and then manually merge /etc back. I say manually merge because most things would get replaced by my old files, but I'd manually modfify my fstab to keep the new partition information and add my extra mounts after it. Maybe that's just me though. You can also just dd and then resize partitions if necessary.

[–] sxan@midwest.social 1 points 8 months ago

I did this recently. dd is fine, but you have to make sure you catch all of the places the UUID of the device is referenced. Maybe fstab, but certainly in the boot loader. This bit me, because the device IDs changed, and UEFI couldn't find the new partitions.

Make sure you have a bootable USB rescue disk, and you'll be fine. Even if you mess up like I did, it's just a matter of booting, mounting, and finding the config file you missed, and replacing the blkids.

[–] Steamymoomilk@sh.itjust.works 0 points 8 months ago

You can partition your drive identically and rsync your directorys over. Rsync will keep all softlinks and hardlinks. You made need to reinstall grub tho.