How does chroot work?

I’m thinking about upgrading to a more modern and powerful system from a 2013 low end Thinkpad X240, as it’s very low memory and just does basic computing….

And because I have super extensive setup on this system, I was thinking If I can just get away with Copying the entire HDD to the boot SSD of new system and if any program can fix the majority of drivers and stuff…
I can always resolve stuff that needs manual intervention.

That said, I haven’t done this before, So will chroot help me in this?
I’m thinking pluging in directly copied boot drive and before it boots into it, I can boot into Manjaro Live Session via a Bootable Flash Drive and do chroot stuff (I haven’t researched into how this is done yet - I’m yet to purchase the new system yet so…)

MOD: Edited for clarity.

1 Like

I think trying to clone the system would be unreliable with new and different hardware…

My plan, when I rebuilt, was to firstly waste a couple of days making sure I’d got some lists - specifically I regularly update my package list:

➤ pacman -Qqet | grep -v "$(pacman -Qqg)" | grep -v "$(pacman -Qqm)" > ~/Dropbox/pkglist.txt

Then I dive into my 'Arr stack (Sonarr etc) and make sure I have stuff worked out with that, I create a temporary text file (again in backups) with various keys and passwords I’m going to want to work through.

Whilst it might be worth taking and trying a clone, make sure you’re prepared for the worst disasters.

Chrooting…

Then on the new laptop, you’ll end up booting from LiveUSB, mounting the SSD’s root partition and use manjaro-chroot; then you can install an appropriate kernel, install drivers (mesa for AMD/Intel) and update the bootloader, regenerate initramfs…

nVidia would possibly complicate things…
I’m just not sure about nVidia, the name gives me the heebie jeebies so I won’t discuss it further.

So yes, as an experiment - try the clone. But really, it’s likely not going to be as painful as you think if you have a full backup and snapshot to work from…

Fresh install takes only 5 minutes, then hopefully you’ll spend not more than an hour or two getting it 98% up to your expectations - with maybe a few days clearing out little bugs you left behind (like old scripts that need new vectors for hardware - conky was my main one).

I’d say piece of mind dictates a clean install, then migrate config files /home and specific /etc files and package lists.

I’m surprised that you mention copying your entire HDD… this means a bit of new configuration work - as HDD is the cheaper but MUCH slower storage…

So I’d be setting up my /home (as I do now) with different default locations for common folders (I have 250GiB SATA SSD, hoping to have spare cash to throw in a 1TB next year) to keep it at a reasonable ratio (I like 66% to 75% full).

So Music/Videos and Pictures folder remapped to /mnt/W4 (newest HDD).

The easiest way would be to clone the entire disk directly to the new SSD. This can be achieved with CloneZilla and a bootable Manjaro USB.

The following tutorial shows how to do this:

  • This should also work for a new SSD of the same size (but, not smaller).

I hope this is helpful.

Regards.

1 Like

Yes, That is a very important thing, and I will indeed do this.

Yes This is very much the basic precautions to have full snapshot with timeshift for sure! and I already have all important data on cloud and another normal flash drive.

That is what I’ll do if this doesn’t work.

Yes I’ve heard that the configuration is quite different to go from HDD to SSD as the boot drive, That is the point I’m not familiar with.

I’ve heard Manjaro users successfully do this. I know there’s a lot of things that would break on my system, but I’ve never tried. Network/GPU will most likely need intervention. Seems like you’re willing to expect the unexpected, so why not. I am curious too!

So you mean the cloning process itself? I’ve done it thousands of times with dd. Clonezilla often people use for cloning/imaging. (And it is a menu interface.) If you are going to a bigger drive it’s one dd command. (Then you can resize it bigger after.)

So chroot may not be even needed, at least just to attempt booting. You would need chroot to reinstall grub, but even going from SATA to NVMe, you shouldn’t you need to. (If everything goes off UUIDs.)

You will most likely need chroot first to remove/install/change packages. (And mhwd if you want.)

1 Like

Yes that’s the exact plan, to use CloneZilla and Manjaro USB.
I was asking here if someone has done this, and any tips

Yes, I’m going the CloneZilla method too…

Yea, the grub is one of the main thing that I’ve to resolve via chroot, grub will have problems loading from completely different hardware configuration, as initramfs needs to be re-generated or something…

I’d still run it and let it check for any breakage, like when system updates go wrong, it can resolve most stuff… I’d still do it for safety. As chroot removes changes and installs appropriate stuff.

Thats a good news.. hopefully this also goes smoothly… I really think it will. We’ll see

As you are no doubt aware, cloning makes a byte for byte copy of one disk to another. Everything will be in tact when restoring it to another disk.

Let me be clear – chroot is not in any way needed for the process.

One thing I might suggest is to first make sure both Intel and AMD firmware is installed, if the target system has a different brand of CPU than the other.

There may be issues to sort out once the clone is done, but they should be easily rectified if need be – you will still have this computer to access the forum with.

So, yes, you can simply clone the disk and it will work with minimal fuss. However, as others have suggested, there are other ways to achieve the same result, and with a newly installed OS as a distinct bonus.

If the intention is only to save time; save effort; cloning will do what you want.

But it can introduce other annoyances if, for example, if you keep both machines on the same network – Taking a copy only of /home might ultimately prove most beneficial.

As always, the choice is yours.

Regards.

1 Like

That’s not been my experience.

I’ve been using SSDs exclusively since 2018. I currently have eight PCs kicking around the house, all with SSDs. I’ve never done anything differently from HDDs when it comes to setting up operating systems. That includes back when I used to dual-boot to that other operating system. :thinking:

What you may be thinking is that older systems used the MBR method of partitioning rather than the newer GPT which (as I recall) is limited by whether the computer supports UEFI, which wasn’t always the case. Although I have an old laptop from 2011 that supports UEFI and GPT, so yours may as well.

It’s strongly suggested you use UEFI/GPT rather than BIOS/MBR when partitioning and setting up the boot record.

EDIT: This article, while geared towards Windows and MacOS, explains it better than I can:

2 Likes

I meant while transitioning via CopyZilla, From HDD to SSD… the boot system is a little differently assigned to hardware is what I’ve heard

I know setting up a new system on SSDs is just as easy, maybe I didn’t make it clear… but yea, I think the grub or something uses some stuff that identifies the boot drive, and the calls for HDD and SSD differ in that, and that is why I’m thinking of using chroot, It will probably resolve those issues, by updating grub and maybe initramfs for plymouth theme and stuff, I do use custom or say hybrid plymouth theme (a copied and modified version of Manjaro default theme with some assets in common)

Master Boot Record (MBR) partitioning schemes typically place a boot sector at the beginning of a disk – A GUID Partition Table (GPT) does not; except in the case of UEFI Legacy CSM boot which creates a Hybid/MBR.

When cloning a disk, every byte is copied and optionally restored to a new disk – let me say that again – every byte – that includes the boot sector in the case of MBR or the $ESP (with all efi files and folders) in the case of UEFI/GPT.

For the purposes of cloning, there is fundamentally no difference between HDD or SDD disks, as the partition table, all partitions and file systems are duplicated in the cloning process.

I hope this explanation helps.

Regards.

2 Likes

It shouldn’t matter like 3 of us are saying, but only if you use UUIDs (which is the default).

So usually, you have to go out of your way yourself to change this. Or use an odd package/AUR that hard codes device names itself.

The kernel won’t care either way. Nothing changes, it looks for that UUID on USB drives, and everywhere else it can see too.

After it’s installed just make sure you enable the fstrim.service (or use async TRIM option in fstab).

This is actually a great point.

Make sure you are running GPT partitioning, and booting UEFI.

The new system could most likely be configured to boot legacy, but why? There’s 2TB limit from where it can boot with MBR, and the boot partition is ugly. If you do some hybrid setup, it is just asking for trouble (seen 2 posts just recently that required a difficult manual grub configuration to get booting again). So go with GPT (which was designed with UEFI in mind), if you’re moving to a new system.

It’s actually not too difficult to convert an existing system from BIOS to UEFI (if your current BIOS supports it).

So what are we running currently?

[ -d /sys/firmware/efi ] && echo UEFI || echo BIOS
lsblk -o NAME,PTTYPE

Very good point. First thing I do after cloning for a different machine is change the machine ID so it is unique on the network, and also in Firefox for sync purposes.

I recognise that!

I had ls -l /sys/firmware/efi first, as it’s what I normally do. But I cleaned up 2 commands and probably got it the same way you did:

:smirking_face:

I’m only amused that it seems to be popping up everywhere, since I posted it as an example a few months ago. :wink:

That was the way to go for me. I did this in the last days.

And I’m glad I didn’t clone the old system.

Over the years, a lot of stuff accumulates on a PC. While the Manjaro base system does grow over the years, after 5 or 10 years it’s good to make a clean break.

Suddenly, hibernation is working for me (which I had given up on after several attempts), and the printer can print at high resolution on regular paper again. (It had refused to do that for years.)

All data from /home and all currently installed AUR and other packages have been reinstalled. The configuration is only being supplemented with the absolutely necessary lines (from /etc/old_etc/).
:footprints:

I often used to swap Linux from one machine to another (kept in a removable caddy). I did this for years, without any major issues.

1 Like

Found this:
https://linuxconfig.org/how-to-clone-a-linux-system
Gives you three options: dd, Partimage and Clonezilla. With nice screenshots and all, at least for the latter two options.

Personally, I would do a fresh install and set things up again, to rid myself of old settings, old settings files and general old crud that has accumulated over the years, no matter how long it takes. There are probably old things one has forgotten about even existed, knowing myself here, of course. 8)

4 Likes

Thanks for the Tip!
I wouldn’t have known that. I’ll remember to do this.

1 Like