3

So I am a beginner with linux and have started learning quite a bit. I use MacOS and Windows mainly and I have started to fall in love with linux, ubuntu to be precise. One thing I was wondering is if there is a way to copy everything from one computer (files installations,configurations and programs) exactly as they are on one machine and migrate them to another easily? just like in macos for example or in windows. Please If anyone can help it would be of immense help as I switch computers often and do not want to have to reinstall and reconfigure everything all the time. Thank You.

edit: Please consider that I am not a techie or an expert in any way, I'm new to all this and still learning. so I apologise in advance if I do not immediately understand or grasp something you might've said.

Nura
  • 33
  • Have you already explored the option of installing Ubuntu to a flash drive? – Nmath May 08 '21 at 20:18
  • I have, but not every Pc recognised it (bios issues I couldn’t figure out as I’m not that tech savvy) and it didn’t play well with the hardware of some devices I tried it on so I didn’t use it anymore. A friend created it for me and I eneded up returning it, I figured there might be easier ways. Is there? – Nura May 08 '21 at 20:21
  • Not used it myself but there is systemback reference here – graham May 08 '21 at 20:26
  • Before you make your copies, ensure that /etc/fstab identifies partitions the old way (/dev/sda3), rather than by UUID (UUID=). Universal Unique IDentifiers will be different elsewhere. – waltinator May 08 '21 at 20:37
  • Okay, so I have been trying to get the systemback to work as suggested by @24601 , but as I am creating writing the live image it keeps crashing saying "live write failed" I don't know why. – Nura May 08 '21 at 22:44
  • Also @waltinator sir what? I have no Idea how to do what you just said. thank you guys for helping btw – Nura May 08 '21 at 22:45
  • I've removed a drive and had it work flawlessly in other boxes (ie. upgrading box because of hardware failure), but also had some boxes where I expected it to work give problems. Even if I have failures though; a desktop system re-install (without format so no user config is touched, and packages installed get restored) is easy to do & quick (a fast method of re-install to upgrade) and issues that can occur when moving releases shouldn't occur when using the same release. It's my fallback (moved or cloned drive). – guiverc May 08 '21 at 23:13
  • FYI: Cloned drives work pretty well most of the time, it's how the system (pre-configured) Ubuntu is/was placed on machines at https://www.computerbank.org.au/ though final checking (& possible tweaking) is done. My prior comment is what I use myself if cloned (or a moved) drive has issues though. Non-destructive install is great; but if using server apps (which can stored configs in system directories which are erased), some restoration is required; but desktop apps don't do that so its ideal for desktop systems. – guiverc May 08 '21 at 23:16
  • The easiest way to clone a drive to a larger drive is to use dd, run from a Live USB. This can be dangerous and overwrite the wrong drive. Research and make sure you understand it before using. – C.S.Cameron May 09 '21 at 04:29
  • 2
    You should develop backup procedures and then just use the restore from backup to install to a new system. I prefer rsync of /home and my data. I manually edit a few system files in /etc, but copy those into /home so backed up without backing up all of /etc. You may not have same settings in /etc from one system to another. And export list of installed apps. http://askubuntu.com/questions/545655/backup-your-home-directory-with-rsync-and-skip-useless-folders & http://askubuntu.com/questions/17823/how-to-list-all-installed-packages – oldfred May 09 '21 at 14:42
  • Based on all the answers i've recieved so far it seems that there just isn't an easy and simple way for the average joe to do it. I've tried systemback, clonezilla, timeshift, dd just seems like a lot and I'm starting to believe with linux it's just not possible, or maybe you just have to be more advanced to get it to work. Either way I'm forced to keep looking for a way that is convenient for me or just go back to using windows and macos(which I really do not want to do at this point). All answers were apreciated, thank you guys. If I hit a bottleneck somewhere I'll be sure to reach out. – Nura May 09 '21 at 21:31
  • @olfred I'll be sure to try that – Nura May 09 '21 at 21:32
  • @ C.S.Cameron sir might you have a link to a tutorial I can follow, seems like most are different from others. – Nura May 09 '21 at 21:33
  • @Nura: I will post what I do, as an answer below. – C.S.Cameron May 10 '21 at 03:49

3 Answers3

2

Cloning to a Smaller Disk using GParted

Here is a method that I tested with Legacy mode.

  1. Boot Ubuntu Live USB.

  2. Insert Source and Target disks if not already there.

  3. Open GParted and shrink Source partition to less than 64GB.

  4. Select Source disk and right click source / partition and select Copy.

  5. Select Target disk and right click empty space and select Paste.

  6. Stretch pasted partition to fill drive.

  7. Click Apply All Operations, (The check mark at the top).

  8. Close GParted and install Grub using Terminal

     sudo mount /dev/sdxy /mnt
    

    sudo grub-install --boot-directory=/mnt/boot /dev/sdx

Where sdx is the Target drive and y is the partition number.

C.S.Cameron
  • 19,519
  • Okay so this wasn't easy to figure out and for the past few days I was trying every method possible but before asking the question I tried this one but didn't know how to fix grub and I tried following this article to purge and reinstall it but to no avail. I nearly gave up until I tried the command you mentioned above and voila. It worked! Also your Idea to create an image and truncate it was superb. Now I don't have to worry anymore. I can just run everything off a usb drive. Can't thank you enough kind sir. – Nura May 14 '21 at 09:56
  • Also I think specifying sdXY would be better instead of sdX1. because It might be different for others. – Nura May 14 '21 at 09:58
  • Thank you @Nura for letting us know what worked for you. Happy computing 8-D. Edited per your recommendations. – C.S.Cameron May 14 '21 at 10:00
1

You could take a look at Clonezilla. This would allow you to make a backup of your pc and install it on any others. There are many tutorials online, just google it.

SEWTGIYWTKHNTDS
  • 367
  • 1
  • 7
  • I will try this if the suggestions made in the comments under the post fail to work because from what i've read the systemback method seems alot easier and simpler. I'll report back tho, thanks a ton. – Nura May 08 '21 at 22:47
  • Okay so as I am having trouble with the above I did as you suggested, I followed this tutorial here link. I tried it and the cloning finished but it took like 5 seconds to complete which I think means it did not do it correctly or something is wrong. I followed everything there but the backup folder in the drive was around 700kb. Can't figure out what's wrong here. Thanks again for helping. – Nura May 08 '21 at 23:57
0

Using dd to Clone File System from One Drive to Another

  • Create Live Ubuntu USB and Boot it

  • Plug in Target drive, (must be at least as large as Source drive).

  • Open Gnome-Disks to confirm drive designations, sda, sdb, etc.

  • In Terminal run sudo dd if=/dev/sdx of=/dev/sdy

    Where sdx is the Source drive and sdy is the Target drive.

    Some people prefer to add a block size, such as bs=256k, but I do not bother.

    The process may take a long time.

    Ref: https://docs.oracle.com/cd/E19455-01/805-7228/bkupsavefiles-60904/index.html

C.S.Cameron
  • 19,519
  • So I followed this and to my amazement it took 4hours for it to finish copying. When I try to boot the disk it brings me to a blank page with something like command line saying grub> _. What does that mean? – Nura May 10 '21 at 18:11
  • @Nura: Is your Target Drive larger than your Source drive? Use the Live USB to inspect both drives and confirm all the same folders and files are on the new drive. – C.S.Cameron May 11 '21 at 01:16
  • Sorry for not mentioning this before but I think that might be why it didn’t work. The source disk is 500gb but only about 60gb is used the rest is unallocated(i thought dd wouldn’t need to worry about it since it’s empty) and the target drive is 64gb. Right now when i chech in the live usb using disks it shows as free space, while on gparted is says ‘invalid argument during seek for read on /dev/sde’. I’m really confused right now. Again sorry. – Nura May 11 '21 at 01:45
  • dd copies everything on the disk, including empty space. If you have a spare large disk, you can clone to it as an image using Disks, you can then truncate the image down to 64GB and "restore" it to your target drive using Disks or mkusb. You should be able to dd just the partition to the 64GB drive and then install GRUB, but that starts to get complicated. Do you boot in Legacy or UEFI mode? – C.S.Cameron May 11 '21 at 03:21
  • Legacy mode. I think only the live usb thingy (vmtoy or something) boots uefi. Also thanks for the help, I’ll give it a go and report back. – Nura May 11 '21 at 03:29
  • @Nura, some info on truncating can be found here: https://askubuntu.com/questions/1300540/how-to-duplicate-a-ubuntu-system-for-distribution – C.S.Cameron May 11 '21 at 03:33
  • when creating the image it says "error creating disk Image" , "no space left on device error quark, 12" even tho the location drive is 6x the size. I tried formatting it with ext4 and ntfs but none work. what do you think might be problem? – Nura May 11 '21 at 23:04
  • Are you creating an .img file and then truncating it down to size using the methods in my last link? – C.S.Cameron May 12 '21 at 04:53