Move filesystem between drives reliably

Hey yall,

I’ve been trying to move my filesystem (manjaro cinnamon) between drives using lots of different methods over the past few weeks and have run into errors every step of the way. At the moment, my plan is to move it from my 256gb xpg nvme ssd to a 512 gb wd blue ssd.

I previously successfully moved my system from a 500gb HGST hard drive (from an old laptop that got fried) to the 256gb ssd, by first installing a fresh manjaro cinnamon on the ssd, then using clonezilla to replace the ext part of the ssd with the ext on the hard disk (my filesystem). After I edited /etc/fstab and updated grub ( and probably did some other stuff i dont remember) which worked after a lot of struggling.

Now, I’d like to move the files back to that hard drive, in order to move them to the 512 gb ssd as i only have 1 nvme m.2 slot. Copying the full 256gb drive at once (not by part) gives a blue screen with kernel panic (this was expected) but the previous method I detailed involving clonezilla puts me into an emergency prompt. Also of note is that I’ve started using rEFInd in order to avoid having to update grub.

I haven’t run through this in a week or so, so I don’t have pictures or anything readily available. I’d just like to know if anyone here has experienced similar difficulty (particularly with the bootloader) and how you fixed it… if more details are needed I will gladly give them. I’d also like to change desktop environment to plasma at a later point; if it would be simpler to do it as a part of this process then I’m open to it

Thanks

This is confusing - not clear to me.

lsblk -f
with all involved drives connected
could help clarify what you want to move from where to where

The basic procedure is:

  • create partitions as needed
  • create the wanted/needed file systems on them
  • copy the data from one to the other (rsync will do, cp will also do …)
  • adapt /etc/fstab and possibly /etc/default/grub
  • you may have to install the boot loader on the “new” drive
1 Like

output of lsblk -f

sda // windows files                                                                            
├─sda1
│    vfat   FAT32          126A-8D88                                           
├─sda2
│                                                                              
├─sda3
│    ntfs                  18DA6F95DA6F6DC6                      329.9G    29% /mnt
└─sda4
     ntfs                  98FC3AEEFC3AC672                                    
sdb  //1tb other filesystem, ignore                                                                      
├─sdb1
│    vfat   FAT32          A58E-C70E                                           
├─sdb2
│    ext4   1.0            16a71085-7944-4142-96f1-e0ffd138fcaf                
└─sdb3
     swap   1     swap     cf6015df-4c97-49b0-9e83-72271a9b3dcf                
sdc   //500gb hdd, currently results in emergency prompt, even when ssd is removed                                                                         
├─sdc1
│    vfat   FAT32          4DBB-4335                                           
└─sdc2
     ext4   1.0            142a7559-241c-42a0-ba6b-5262cf10645c                
nvme0n1 // 256gb ssd
│                                                                              
├─nvme0n1p1
│    vfat   FAT32 NO_LABEL 7FF0-6C9F                             297.8M     1% /boot/efi
└─nvme0n1p2
     ext4   1.0            142a7559-241c-42a0-ba6b-5262cf10645c   30.8G    82% /

I want to move nvme0n1 to sdc, then on to a different nvme ssd

Here is what I understand what you want to do:

You want to move your system from one nvme to another, but need an intermediary because you can only connect one nvme at a time.
That intermediary is /dev/sdc
Correct?

That intermediary is just that - you don’t really need to boot and run the system from it.
Correct?

You probably only really need your data, what is stored in your $HOME
As opposed to: the whole system needs to be transferred.

Copying the contents of your $HOME to the intermediary
or the whole system, including $HOME, to the intermediary
is most easily done by using some live system booted from USB.

It’s basically what a backup is …

Format your /dev/sdc with an ext4 file system
and then simply copy from nvme to there
while you are in a live system.

Then change your nvme, install a fresh system on it
and copy your user data back to it from /dev/sdc

1 Like

Take a look at this:

I would simply adapt it in your situation. It’s an example, not a “copy&paste into the terminal, and you’re done”.

:bangbang: Format the HDD /dev/sdc completely anew, as image files are now stored there.

:bangbang: Shrink the partitions/filesystem with gparted on /dev/nvme0n1 as much as possible to reduce transfer time. You can expand it after writing to the new NVME.

Make a backup of the partition table:

sudo sgdisk --backup=/mountpoint/of/sdc/nvme0n1-gpt.backup /dev/nvme0n1

:bangbang: Adjust the paths of course everytime :wink:

Then the images:

sudo dd if=/dev/nvme0n1p1 of=/mountpoint/of/sdc/nvme0n1p1.img status=progress
sudo dd if=/dev/nvme0n1p2 of=/mountpoint/of/sdc/nvme0n1p2.img status=progress

You would then have a complete copy on your hard disk.

Now replace the NVME.

Write partition table:

sudo sgdisk --load=/mountpoint/of/sdc/nvme0n1-gpt.backup /dev/nvme0n1

and the images:

sudo dd if=/mountpoint/of/sdc/nvme0n1p1.img of=/dev/nvme0n1p1 status=progress
sudo dd if=/mountpoint/of/sdc/nvme0n1p2.img of=/dev/nvme0n1p2 status=progress

You will have to open the block device again with cgdisk and write again without changes. This will also correct the table or the end of the table.

1 Like

As I understand it, the “old” nvme has a capacity of 256 GB
the target, the “new” one, has a capacity of 512 GB

The method you describe - using dd - would result in a file system 256 GB in size on the “new”, larger, nvme,
leaving half of it’s capacity unused.
Would it not?

It could easily be expanded to use the whole capacity in an additional step, of course.
Or does the last step

take care of that and I just don’t understand what that does?



By saving and transferring only the actual contents of the file system (what I broadly described)
the amount of data which has to be stored and moved around twice would be ~31 GB only,
compared to the 256 GB image of the whole device.
… or even less than 31 GB, when only $HOME is transferred …

Sure. That’s how copying works. It makes a 1:1 copy and doesn’t enlarge it.

Sure.

If you copy the partition table 1:1, the sizes of the partitions will be exactly the same, but if the drive is bigger or smaller, the endpoint won’t be correct. cgdisk is able to read it and repair/correct it, then just write the corrected partition table.

No, it doesn’t expand a file system, ONLY the partition size.

You are correct. In that case, I would actually shrink the filesystem/partition before doing a dump. Which for me would be a logical step not to mention. Thanks for the hint.

Yes although sda and sdc have swapped upon reboot

Yeah pretty much, though I’d like to make sure it works before waiting for it to copy a second time

My understanding was that this would wipe most of my settings. If it doesn’t then alright

So would I use gparted afterward to do so? I’m a bit confused on this

It wouldn’t.
You literally copy everything in your $HOME - how would that “wipe your settings”?
You copy it so you get to keep them …

Probably - that would be easiest.
But his approach is different from mine.
He can better answer this.

There is more than one way to skin a cat :pouting_cat: (or something like that the saying goes …).

Both ways work - different approaches to the “problem” with pretty much the same end result.

… you can’t lose anything by going either way - you will always still have the original nvme …

1 Like
sdc2
     ext4   1.0            142a7559-241c-42a0-ba6b-5262cf10645c                
nvme0n1 // 256gb ssd
│                                                                              
└─nvme0n1p2
     ext4   1.0            142a7559-241c-42a0-ba6b-5262cf10645c   30.8G    82% /

be very careful with clonezilla :
it duplicate UUID , so do not mount 2 disks with same UUID , because you dont know which one will be updated , as is come from /etc/fstab

also copying from dd 256 go to 512go with clonezilla will put only a 256go size disk

Its the same uuid because i already cloned it awhile ago, when trying to boot off the hdd i remove the ssd but still fails

… but that is not important - this is just the intermediary storage location
Why would you want to boot that system from the hdd? (rhetorical question).
You want to have it on the other, new, bigger, nvme. No?

Start over.
Choose one of the methods - what I suggested or what @megavolt suggested.

The reason is simple: Linux can recognize and read any file system on block devices or images without a partition table. A partition table is just a table, like marked boxes on a checkerboard. Then you fill the marked boxes with content (file system). So you usually need 2 steps. Increase the partition size and increase the file system size. Gparted does both.

2 Likes

There’s a much easier way,
Copy the contents from your home directory to your intermittent drive. Don’t forget your browsers bookmarks and passwords. And make a list of any applications that you’ve added to the basic installation.

Remove the old drive and do an installation. Here you may have to hold press the key combination to permit you to boot from whatever your using as your installation medium.

Then after you’re set up, copy the information over.

The installation will do all of the partition sizing without any need for you to do interact, unless you have special partitions, like a second home partition or a separate backup partition