Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
HDD to SSD Without Reinstalling
View unanswered posts
View posts from last 24 hours

Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
John R. Graham

Joined: 08 Mar 2005
Posts: 10459
Location: Somewhere over Atlanta, Georgia

PostPosted: Mon Jul 15, 2019 6:57 pm    Post subject: HDD to SSD Without Reinstalling Reply with quote

jobb via PM wrote:
With reference to your statement at,
Getting started is a good idea. One thing that's different about Gentoo vs. your typical binary distribution is that you don't have to re-install to dramatically change your setup. I have a machine that hasn't been re-installed since its initial incarnation in 2005. Almost everything is different (new motherboard (twice), new disks (thrice), other new hardware), but I have never needed to start a fresh Handbook install.

This amazed me quite a bit because I've had to reinstall OSs before, after changing the H/W. I have 2 laptops and an old computer. The old computer mentioned in that thread was giving me Seg Fault errors and thus I ditched it. But because I was excited about gentoo, I converted 1 of my laptops from Arch to Gentoo. I love it so far. I have even upgraded the RAM in this laptop from 4GB to 8GB.

However, I feel that my Sata 2 (I don't have Sata 3 in this laptop), 5400 rpm HDD is a bit slow and Libreoffice would become a bit snappier with 120 GB SSD - This one supports TRIM too.

My question - I have already setup my Gentoo laptop just as I like it and I really don't want to reinstall Gentoo again when I change from HDD to SSD. How do I copy everything to my SSD (with integrity check) on the same partition. (I have LUKS, and a forceful LVM because I had to use dev_mapper). My SWAP is unencrypted because I had 4GB RAM at that time and I didn't want my CPU to work even harder trying to encrypt/decrypt SWAP while using it.

nub@nub-pc ~ $ lsblk
sda        8:0    0 931.5G  0 disk 
├─sda1     8:1    0   512M  0 part  /boot
├─sda2     8:2    0    16G  0 part  [SWAP]
└─sda3     8:3    0   915G  0 part 
  └─root 252:0    0   915G  0 crypt /
sr0       11:0    1  1024M  0 rom 

Any pointers from you would be helpful

Neofetch -

(With permission, replying in the public forums.)

Hi jobb,

It's actually possible to migrate any Linux install to new hardware, but Gentoo exposes and teaches all the basic techniques as part of learning to install and maintain it. Here are the steps I followed to migrate my install (simultaneously) to a new motherboard and new RAID array. For the "how" of the techniques listed below, use the Handbook as a guide.
  1. Arrange to be able to mount both the old and new drives. This can be accomplished with a USB SATA dock for the new drive (assuming your laptop doesn't have two drive bays). Alternatively, you can make a full backup of your current drive to some backup media (I use a tape drive, but this isn't an option for most).
  2. Boot your install media (Gentoo Minimal Install CD, SystemRescueCD, etc.).
  3. Partition the new drive. The partitioning doesn't need to be identical to the old drive so long as they're at least as large.
  4. Make the file systems you want on the new drive. Again, these don't need to be the same choices as you made in the initial install.
  5. Create a couple of mount points on the install media:
    mkdir /mnt/{old,new}
  6. For each partition to transfer, mount and copy the contents. For example, to copy your boot partition:
    mount /dev/sda1 /mnt/old
    mount /dev/sdb1 /mnt/new
    cp -a /mnt/old/. /mnt/new
    umount /mnt/{old,new}
  7. Shut down your computer, remove the old hard drive, and install the new SSD in its place.
  8. Boot your install media again.
  9. Mount all the partitions and chroot into the new drive just like the Handbook describes.
  10. This won't be necessary for you, but this is the point that I reconfigure and recompile my kernel to support any necessary new hardware.
  11. Install grub on the new SDD so it can boot. Handbook instructions work just fine.
  12. Exit the chroot and unmount everything.
  13. Shut down your computer, remove the install media, and restart. You're done!
Let me know if you have any questions.

- John
I can confirm that I have received between 0 and 499 National Security Letters.
Back to top
View user's profile Send private message

Joined: 05 Jul 2003
Posts: 45383
Location: 56N 3W

PostPosted: Mon Jul 15, 2019 7:18 pm    Post subject: Reply with quote

John R. Graham,

<nit> 3. Partition the new drive. The partitioning doesn't need to be identical to the old drive so long as they're at least as large.
The partitions need to be big enough to hold the used space in the filesystem in the partition on the old drive </nit>

This is an excellent opportunity to move free space around as you will be copying the contents of the filesystems not the contents of the partitions.
To make that clear, a filesystem contains unallocated blocks, which will not be copied when the filesystem content is copied.
A partition contains a a filesystem together with its unallocated blocks. Copying a partition includes te unallocated blocks.

Beware LUKS and SSDs with trim. Trim erases unused space on an SSD.
If you attempt to fill an SSD with random data, you can't then use trim or it will reveal unused regions of the drive, since they will be erased.
If you don't use trim, writes will be very slow as SSDs must perform an erase before they can write to previously used space. Erase is a slow operation, which is what makes trim a good idea.

You may want to evaluate what LUKS will do for you on a SSD and how you will use it.


Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message

Joined: 29 Oct 2003
Posts: 1610
Location: +48° 5' 23.40", -119° 48' 30.00"

PostPosted: Tue Jul 16, 2019 6:31 pm    Post subject: Reply with quote

2 weeks ago copied my 4790k system to an NVME for the ryzen 7 2700x install.

I changed my kernel to support generic x86-64 and added any specific AMD options needed.

My system was already built for march haswell and that was compatible enough for my znver1 cpu.

My install systems are one partition for everything. No separate boot or other.

After installing the nvme in the old system and creating the desired partitions and filesystems (follow gentoo handbook if needed) I booted back up to my system and did this.


mount /dev/nvme0n1p1 /mnt/NVME

rsync -aHS --info=progress2 --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} /* /mnt/NVME

Run that twice and once more right before reboot, reboot to usb media.

Once booted on usb run the rsync command above again with proper mount points for both drives.

Now chroot to the 'new' drive.

mount --bind /sys /mnt/NVME/sys
mount --bind /dev /mnt/NVME/dev
mount --bind /run /mnt/NVME/run
mount --bind /proc /mnt/NVME/proc
chroot /mnt/NVME

While you are chroot'd. Edit your fstab on the new drive so the uuid(s) is correct.

If a new system change the hostname if desired. Change any static network settings or ones pointing to specific interfaces that might not be named the same. Edit your make.conf for your new cpu specific or other hardware settings.

Install grub to the correct drive. *the device, not the partition or errors you get and error!!* Also this is not an EFI install! Again, the handbook or wiki helps here.

grub-install /dev/nvme0n1

Update the grub config to pickup your new uuid.

grub-mkconfig -o /boot/grub/grub.cfg

Install the drive in the new system or replace existing drive if just going from spinner to ssd.

If new system and you might need a rebuild... I rebuilt @system then I rebuilt with an @older1 set which is setup to emerge anything older than 1 day which will skip your just rebuilt @system and skip a sed hieroglyphics pasted from somewhere (honestly there might be an easier way these days but it wasn't handy). You could rebuild @system, then a new kernel build, then the rest which is what I think I did because of changing CFLAGS.

This is in my sets.conf


Maybe this is useful to someone that runs across it so I'm paying it forward from various bits gathered around the internet over the years and recently.
#gentoo-kde on freenode
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum