What is the best way to upgrade a primary hard drive (M.2 Drive)

I love my current Manjaro installation and I’ve been using it for a while.

$ inxi
CPU: 8-core Intel Core i9-9900KF (-MT MCP-) speed/min/max: 800/800/5000 MHz
Kernel: 6.1.92-1-MANJARO x86_64 Up: 12h 27m Mem: 4.39/62.71 GiB (7.0%)
Storage: 10.92 TiB (44.6% used) Procs: 351 Shell: Bash inxi: 3.3.34

$ inxi -D
Drives:
  Local Storage: total: 10.92 TiB used: 4.87 TiB (44.6%)
  ID-1: /dev/nvme0n1 vendor: Samsung model: SSD 970 EVO Plus 1TB
    size: 931.51 GiB
  ID-2: /dev/sda vendor: Western Digital model: WD40EFZX-68AWUN0
    size: 3.64 TiB
  ID-3: /dev/sdb vendor: Samsung model: SSD 870 EVO 1TB size: 931.51 GiB
  ID-4: /dev/sdc vendor: Western Digital model: WD40EFRX-68N32N0
    size: 3.64 TiB
  ID-5: /dev/sdd vendor: Samsung model: SSD 870 EVO 2TB size: 1.82 TiB

This is my main work machine for video editing, streaming, VMs, etc.

I want to replace the primary NVME 1TB drive with a 2TB drive. In my search across this forum and Reddit, I’ve found several methods and some conflicting information. One person will say one method is the best, while another person will say that same method is the worst and “dangerous” etc.

So, I’m here to upgrade my drive but also to learn. I’ve seen 3 approaches:

  1. Install the new drive, do a fresh Manjaro install, then use rsync to copy all your files from the old drive mounted in an external enclosure.
    That sounds easy enough, but do I rsync the entire drive or just my home directory? And if just my home directory, isn’t it going to be a big chore to get everything else working with all the files that aren’t in my home directory?

  2. Use dd to clone the old drive to the new one. Swap drives and boot into the new drive.
    This is the only one I have experience with. I’ve used dd to clone an old HDD to a new SSD on a Windows computer. I also use dd every time I want to make a new Manjaro USB installer. I’ve seen people on Reddit say this method is “dangerous” but unless you make a typo in your dd command and accidentally erase your primary drive, I don’t see why it’s “dangerous”. Am I missing something?

  3. Use btrfs replace (and some additional steps)
    The problem here is that I’m unfamiliar with this command and the other steps that are necessary. If this is indeed the best method of the 3, then I’m happy to learn. But when I was reading threads of people using this method, it also seemed like it was the one most prone to mistakes, forgetting a step, etc.

What do you think?

If the file system is btrfs, two drives with the same UUID may be a disaster.

2 Likes

I’d KISS:

  1. Make a list of all installed packages:
    1.1. All official packages from the repository:

    pamac list --installed --quiet --explicitly-installed > ~/installed.txt
    

    1.2. All foreign packages, like the AUR:

    pamac list --installed --quiet --explicitly-installed --foreign > ~/installed-foreign.txt
    
  2. Disconnect the current disk.

  3. (Re)connect the new disc, leaving the current one disconnected.

  4. Install Manjaro on the new, connected disk and make sure it’s bootable and everything is good.

  5. Connect the current one along with the new one, but be sure to boot from the new disk.

  6. Copy the current, now the older, previous drive’s home directory tp the new user’s.

    cp /mnt/<old_disk>/home/<userName>/* ~/
    

    Where:

    • /mnt/<old_disk> is the mount point where the previous disk is mounted; and
    • <userName> is the username of your current user on the older, previous installation.
  7. When done, reinstall all packages from the list previously backed up:

    • For the packages from the repositories:
      pamac install $(cat ~/installed.txt)
      
    • For the foreign packages:
      pamac build $(cat ~/installed-foreign.txt)
      

Of course, I don’t know if this’ll install any snaps or flatpaks currently in use, as I don’t have any so can’t test. But that’d be my steps. Also: this method can work with/on any file system, be it BTRFS, FAT, EXT4, or something else entirely.

2 Likes

and:
with BTRFS, you not only do not need dd
not least because it has got it’s own tool set to do just that.
dd cloning (from a smaller to a larger drive, no less) will probably destroy your data on both drives
(there is a good potential for it anyway)

What I’d do (and have done many times):
partition the drive as you want it and use a usb booted iso to transfer the content of the old to the new
rsync or simple cp -a - the tool used doesn’t matter-
reinstall bootloader and adapt /etc/fstab - done

This thread already looks like it’s going to be fun for OP to figure out what to choose out of the multitude of opinions. :sunglasses:

2 Likes
  • CloneZilla to clone the full disk. Many bootable ISOs contain CloneZilla; or it can be installed to memory when booting from a Manjaro Live Installer.
  • Restore the image to the new M.2. (Again, using Clonezilla)
  • Resize your /home partion to fill the remaining capacity; or carefully resize / if /home isn’t separate.
  • Possibly recreate swap space in the process.

I typically use the PartedMagic which contains CloneZilla, GParted, and many other tools that I might typically need.

If you mess something up, you still have the image to do it again. The only downside to this procedure is that you need another sizable disk (USB maybe) to temporarily store the cloned image.

Otherwise, cloning is also possible via GParted.

Hope this helps. Cheers.

Edit:- I’ll just add that with CloneZilla it’s also possible to clone directly from disk to disk; in this case the need for temporary image storage is negated. That said, having a cloned image available (just in case) would still be my preference.

2 Likes

@rob215x
https://clonezilla.org/downloads/download.php?branch=stable

2 Likes

sudo cp -RPp <source> <destination>

Then adjust fstab accordingly and reboot. I’ve changed hard drives more than once like this and never had a problem.

1 Like

You can find good Information about Btrfs in the wiki

:footprints:

This command copies the full drive? You plug both drives and make something like sudo cp -RPp /dev/sda /dev/sdb? Booting from one drive or from a pendrive? Never used cp to clone drives and I’m curious about it. :thinking:

@rob215x @RiCK-Man-jaro

From a Manjaro Live Installer:

sudo pacman -S clonezilla

The same can, maybe should rather be done using rsync. But as @mbb rightfully pointed out, /etc/fstab should be adapted accordingly.

Also, I’m no expert, but I don’t think this’ll work for BTRFS.

1 Like

Yes, it copies the whole drive. Just mount them both and copy to and from mountoints, don’t use /dev syntax.

Then adjust fstab to the partitions of the new drive and check /etc/default/grub also.

Those cp options will retain permissions and copy links as links (it doesn’t follow the links). Usually, I do this from the live system, because if you mount the new drive in the system contained in the old drive, you will have a loop condition because that command will try to copy contents from the mounted dir into itself. One way to avoid this it to add the -x option, which will copy only content from the same filesystem, but I prefer to mount both drives in a live system to avoid problems.

2 Likes

I was wondering why cp -RPp was used instead of cp -a
but the effect would be the same, I guess - I always used the latter.

You boot the iso with both drives connected,
mount one to /mnt/source
the other to /mnt/destination
and then cp -a /mnt/source/* /mnt/destination

Of course, if there are several partitions,
assemble them first below the respective mountpoint, which you also first have to create:
mkdir /mnt/source

like:
mount /dev/sda2 /mnt/source
mount /dev/sda1 /mnt/source/boot

if you have two partitions, one / and one /boot …

I’d, in this case, not use sudo, but would sudo su to get root and then not need sudo anymore during the operation.

With rsync, you have the --progress option
also possible to do with cp but a helper program is needed to get some feedback as far as I remember.

1 Like

Yes, from what I’ve read it is the same.

Ok, convenience.

Using the copy command (cp) will copy the contents of one partition to another; however, this will require creating the partitions on the new NVMe beforehand.

This would be fine for copying contents of /home I imagine, but an entire disk? The better way using that method would be to install a fresh Manjaro to the new NVMe and then copy the contents of /home to the new /home (directory or partition).

I don’t think this is what the OP wants; if I read correctly; they want to move their current working installation to the new NVMe. Cloning is arguably the most reliable way to do that.

2 Likes

If cloning works from a smaller to a larger disk without having to then adjust the partition sizes afterwards, then yes.
I mentioned to create the partitions as wanted/needed - and then a simple copy operation
and you have the very same system with all configurations to /etc (except /etc/fstab)
on the new disk.

This is all very different if the file system is BTRFS.

2 Likes

Also the exact way I suggested:

Cloning does just that. A partition would still need to be extended - it it’s a /home partition, that’s relatively easy; only if it’s / should extra care be taken (to only resize from the end not the start of the partition). Otherwise, it’s non-destructive.

Again, cloning will faithfully copy all partitions and data from to no matter if the destination is an image file or another disk. Whichever the case, extending a partition after cloning will likely still be required.

That said, it’s also possible to clone one partition at a time with CloneZilla - so, the $ESP, / and /home (if separate) - and restore each image one by one.

Despite all of the above, I’d personally favour a complete new installation on the new disk, and simply copy /home when done; but, that’s just me. :wink:

1 Like

And that is exactly why I’d rather do it in the way I described,
because that gives one the opportunity to create the partitions in the sizes that is desired on the new disk
(more space for one, less for the other, change the layout … or even separate /home from the rest, even if it was all on one partition before)

… instead of essentially copying everything once, and then once more when adjusting the partition sizes

It’s just quicker and (for me) easier.
But this is just my preference. :man_shrugging:

1 Like

Well, my preference is noted at the end of my previous comment; though a full clone is equally tried and true. It just depends what the OP is most comfortable with.