I have installed Fedora on my PC, then I added some app and packages, I would like to run the same Fedora system in my laptop, without installing Fedora on the laptop. So the way is to clone Fedora from PC to USB flash and then use laptop to boot to cloned system in USB flash.
I don’t know how to do that.
Any idea please?
I don’t think this is easily feasible because the boot and mount processes rely on disk identification numbers (UUID), which are different for each machine and disk.
So either you adjust all of this in fstab, grub or you do it again and install Fedora onto a USB pendrive. That pendrive can then be used to boot Fedora on any computer (though it will be much slower than an install on SSD).
Another way to do this is by exporting the list of "user"installed packages (rpm and flatpak) into a list and then use that list to install the same packages on another machine (see https://discussion.fedoraproject.org/t/backup-software-selections/70567). In addition you can copy over the config files. In theory, you can use something like Syncthing to keep config files in sync, so everything looks and behaves the same on both systems (but read about it before - I have never actually done it)
If you have a third linux to use temporarily (such as another USB device and a bootable “live” install) then it is pretty easy using gparted
(lots of other ways exist to do the same things, but I find gparted
a bit easier).
You can clone (or copy/paste) each of the partitions of your running system onto the USB, assuming they fit. If the files would fit, but the partitions wouldn’t, one choice (only moderately safe, not super safe) would be to shrink the partitions, then clone them, then grow the originals back to desired size.
When you’ve cloned partitions (as opposed to copying the file trees to new partitions), you have the same uuid in each clone as in the original. If you are confident you won’t ever use that USB device in the original system, that may be OK and is simpler than fixing uuids. If two partitions have the same uuid and are physically present in the same machine and you mount one of them, you are going to have a serious problem. As long as neither gets mounted while both are in the same machine, having a duplicate uuid is technically wrong, but quite workable (such as using that USB only in other systems).
After cloning, it is often correct to have gparted
randomly create a new uuid for each new partition. That gets you to just a slightly more reliably correct copy than if you had created new partitions and copied the tree of files by some other copy method.
So if you want to use the system after changing the uuids, you need to edit the places the old uuids appeared. I’ve done this several times recently, for similar reasons to what you described, and only needed to change uuids in a few places:
The EFI/fedora/grub.cfg
file is in the partition that is normally mounted /boot/efi/
so the original file is /boot/efi/EFI/fedora/grub.cfg
but in your copy you would mount that elsewhere to edit it. That contains the uuid of the boot
partition (obvious within a few commands that you otherwise don’t need to change, so just edit the uuid to whatever the uuid is of your new boot
partition).
Two or more files in the loader/entries/
directory in your new boot
partition each contain the uuid of the root
partition (similarly within a few simple commands that otherwise don’t need to change). Edit those for the uuid of the new root
.
Finally, the etc/fstab
of the new root
. I don’t know enough about what you have to tell you everything that needs uuids fixed in that file (and/or other changes because you are migrating to a different machine). Hopefully you understand the basics of fstab and just needed to be reminded to fix it when cloning a linux install.
BTW, I have also tried the method of doing a fresh install onto a USB stick, to get an ordinary (not “live”) fedora on USB. I find Anaconda much harder to use than cloning partitions and editing uuids. For a USB stick, Anaconda demands a much larger total media than will actually be needed for the running system.
Finally, regardless of how you get fedora onto a USB stick, most USB sticks are slower than USB drives. A “live” linux is slow to load off of a slow USB, but closer to OK once loaded. An ordinary linux on a slow USB stick may be just too slow to use. I have switched over to using a USB to SATA adapter with an ordinary SATA drive. That is theoretically slower than an internal SATA, but not noticeably slow. Many USB drives are fast enough. But vendor claims that they are fast can’t be trusted.
Thanks for your answer.
I’ll try it
I would be interested to hear how that works for you.