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

Post History

50%
+0 −0
Q&A How do I migrate my main filesystem to a new drive?

I'll add a specific, simple way that worked for me: Create some kind of Linux Live USB Boot into Live OS Use lsblk and blkid to figure out which drive exactly is the old and new one. Stay in t...

posted 7mo ago by matthewsnyder‭

Answer
#1: Initial revision by user avatar matthewsnyder‭ · 2024-04-10T19:30:47Z (7 months ago)
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.