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.

  • hendu@lemmy.dbzer0.com
    link
    fedilink
    English
    arrow-up
    4
    ·
    edit-2
    1 year ago

    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.

      • LunchMoneyThief@links.hackliberty.org
        link
        fedilink
        English
        arrow-up
        5
        arrow-down
        1
        ·
        edit-2
        1 year ago

        I usually use

        dd status=progress conv=sync,noerror bs=64k if=/path/to/source/drive of=/path/to/destination/drive
        

        Take a reading of the drive health first with something like smartctl and if it has a lot of failing attributes, consider lowering the block size to something rather smaller like bs=512.

        Edit: To elaborate, using the sync and noerror arguments will instruct dd to ignore errors and continue in the event of read failures, while allocating zeroes to the remainder of the block space. Which is also why smaller block sizes are better for potentially failing drives. The copy will take longer, but a single error won’t take large swaths of data with it.

          • Possibly linux@lemmy.zip
            link
            fedilink
            English
            arrow-up
            2
            ·
            1 year ago

            That’s a bad sign. First off stop using it so that you don’t make it worse. Next take a backup. I think dd automatically skips over bad blocks but I don’t remember. Also, I would not go straight to another drive but instead go to a file.

            I don’t mean to freak you out but there is a chance you are going to lose data.

          • sylver_dragon@lemmy.world
            link
            fedilink
            English
            arrow-up
            1
            ·
            1 year ago

            If you suspect a failing drive, you may want to consider using ddrescue as opposed to dd. The tool is specifically designed to help with failing disks.