Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

How do I migrate my main filesystem to a new drive?

+4
−0

I want to switch hard drives. How do I migrate my root FS from the drive it's on, to the new one, so that everything is exactly as it is?

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

Try to not store too much and too spread on a system (9 comments)

3 answers

You are accessing this answer with a direct link, so it's being shown above all other answers regardless of its score. You can return to the normal view.

+0
−2

To migrate your main filesystem to a new drive, utilize disk cloning software or backup utilities like Clonezilla or EaseUS Todo Backup for a perfect transfer.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+1
−0

Gnome disks can create a disk image, and then restore it to the new one.

The new drive has to be same size or larger, although this is obvious. If it is larger, the partition will still be small, but I find it easier to resize it after the fact.

It's better if the sector size also matches: https://wiki.archlinux.org/title/Advanced_Format

There are also other tools listed in https://wiki.archlinux.org/title/Disk_cloning

Note that, if you want to clone the root filesystem, it will usually be necessary to boot from a Live USB and do the cloning from there. Disk cloning tools will generally require unmounting the original filesystem first, because "hot" cloning is much more complicated. Using a live boot makes it possible to keep the root filesystem unmounted (since the OS is no longer running from it). GParted offers a specialized (and small) Live USB for this purpose.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+0
−0

I'll add a specific, simple way that worked for me:

  1. Create some kind of Linux Live USB
  2. Boot into Live OS
  3. Use lsblk and blkid to figure out which drive exactly is the old and new one. Stay in the same Live session (don't reboot) in case the drives move around between boots.
  4. Double and triple check, because if you mess up here you can lose all your data forever
  5. Suppose your old drive is /dev/sda and the new drive is /dev/sdb. Go into a terminal, and type pv /dev/sda > /dev/sdb.

When it is done, everything on your old drive will be copied exactly to the new drive. In fact, even partition UUIDs will be identical, which ordinarily is not supposed to happen - it's not a unique identifier if multiple partitions have it. So for example, if you have an fstab identifying partitions by UUID, this may not work right after you clone a drive in this way. My solution is to have a "follow up" process like this:

  1. After clone is done, shutdown the computer. Do not boot into your hard drive.
  2. Physically disconnect the old drive (pull out the data cable)
  3. Boot up from the new drive, and check that everything works as before, and shut down.
  4. Re-connect the old drive, and boot into the Live USB.
  5. Delete partitions on the old drive.

This way all your data will be on the new drive exactly as it was on the old, down to the UUIDs.

Of course, the new drive cannot be smaller for this to work. If it is larger, the partitions won't take up the whole drive. After the clone is complete, you can use some other partition tool to resize them so they can use the larger capacity of your drive.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

Sign up to answer this question »