There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

Replacing M.2 system drive (btrfs) on motherboard with single slot

I finally have the budget to build my first NAS and upgrade my desktop PC. I have used Linux for quite some time, but am far from an expert.

One of the steps is to move my M.2 NVME system drive (1TB) from my desktop to my NAS. I want to replace it with a bigger NVME drive (2TB). My current motherboard only has a single M.2 slot, that’s why I bought a M.2 enclosure.

My goal is to put my new drive into the enclosure, clone my whole system disk onto it and then replace the old drive. At first I found several posts about using clonezilla to clone the whole drive, but some posts mentioned it not working well with btrfs (/ and /home subvolume), which is the bulk of my drive.

I have some ideas how I might to pull it off. My preliminary idea is:

  1. clone my boot partition with clonezilla
  2. use btrfs-clone or moving my butter to transfer the btrfs partition
  3. resize the partitions with gparted (and add swap?)

The two aspects I’m uncertain about are:

  1. UUIDs
  2. fstab

I plan to replace the old drive, so the system will not have two drives with the same UUID. If the method results in a new UUID I need to edit fstab.

As you can see I’m not sure how to proceed. Maybe I can just use clonezilla or dd to clone my whole drive? If someone has experience with such a switch or is just a lot for familiar with the procedures, I would love some tips and insight.

Thanks for reading.

boredsquirrel ,
@boredsquirrel@slrpnk.net avatar

Clonezilla can clone BTRFS without issues

Afterwards on the system use sudo btrfs filesystem resize max / to make it use that space. Maybe add a balance.

rotopenguin ,
@rotopenguin@infosec.pub avatar

Do you have pci-e slots? An nvme to pcie card is cheap - it’s pretty much just passing from one connector shape to another.

drwho ,
@drwho@beehaw.org avatar

It would probably be more reliable to partition and format the new drive manually and use rsync to copy everything over. Updating /etc/fstab with the new UUIDs isn’t a big deal (though you can also manually specify the partition UUIDs at time of format - mkfs.btrfs --uuid …) (you didn’t say what file system your /boot partition was using, so I don’t want to guess).

koper ,

With this approach you would lose the subvolume structure and deduplication if I’m not mistaken.

Sickos ,
@Sickos@hexbear.net avatar

Personally, if the NAS is up and running, I’d migrate the home directory and anything else important from the desktop to that, and intend to network host those folders; set aside the 1TB, install the 2 TB, and do a fresh install and see if I can still get to everything happily.

Alternatively–if you want to preserve stuff locally–new drive in an enclosure, attach to desktop, boot from an install USB, fresh install to 2TB, reboot from 2TB, mount 1TB, migrate data, install 2TB. I don’t think there should be a UUID problem doing that, but even if there was you could still boot from the install stick and try manually fix it

TheOubliette ,

I would recommend using this as an opportunity to build out and use a backups system. Whenever I get a new laptop, for example, I just make a(nother) backup on the old laptop and restore whatever I want to the new one. If there are any files I want that are normally excluded from backups, I either tweak my rules to include those files/put them in a different directory and repeat the process or just make a new manual external backup copy temporarily.

If you have good backups then your new drive can be populated from them after creating new partitions. Optionally, you can also take this opportunity to reinstall the OS, which I personally prefer to do because it tends to clean up cruft.

Also, if you go this route, your data on your old drive is 100% intact throughout the process. You can verify and re-verify that all the files you want are backed up + restored properly before finally formatting the old drive for use in the NAS.

Ooops ,
@Ooops@feddit.org avatar

When you say system drive this will also have your efi system partition (usually FAT-formated as that’s the only standard all UEFI implementations support), maybe also a swap partition (if not using a swap file instead) etc… so it’s not just copiying the btrfs partition your system sits on.

Yes clonezilla will keep the same UUID when cloning (and I assume your fstab properly uses UUIDs to identify drivees). In fact clonezilla uses different tools depending on filesystem and data… on the lowest level (so for example on unlocked encrypted data it can’t handle otherwise) clonezilla is really just using dd to clone everything. So cloning your disk with clonezilla, then later expanding the btrfs partition to use up the free space works is an option

But on the other hand just creating a few new partitions, then copying all data might be faster. And editing /etc/fstab with the new UUIDs while keeping everything else is no rocket science either.

The best thing: Just pick a method and do it. It’s not like you can screw up it up as long if your are not stupid and accidently clone your empty new drive to your old one instead…

just_another_person ,

Yeah, just clone to a new drive and plug it in where the old one was. If it works, it works. If not, you can boot a live distro and fix your fstab from there.

NeoNachtwaechter ,

Is your system drive really that: just a system drive? Then you’d better install it from scratch and have a clean, shiny and new system.

Backup a few settings maybe. Or maybe not.

minimalfootprint OP , (edited )

Then you’d better install it from scratch and have a clean, shiny and new system.

You know how it is, I just got my system right. Of course lots of settings can just be duplicated, but I would prefer not to set up some systemd services, cron jobs, etc. again.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • random
  • lifeLocal
  • goranko
  • All magazines