1

I'm looking for a way, to take my current Ubuntu 22.04.1 LTS System, and extract the following things:

  • installed programs and packages
  • settings
  • settings of programs
  • anything saved in Startup Applications, like scripts to fix something, that run on startup
  • user accounts, and their respective settings, names etc.

then I wanna take all of that, and smash it together to ERECT THE ULTIMATE UBUNTU CONFIG. Following that, I plan to impregnate all that data into an ISO file, that when engraved into an USB Stick, is just so good.

Thereupon, whenever I have to install an OS to something, I can whip out my ULTIMATE UBUNTU CONFIG ISO USB STICK, and then BOOM. I'm good to go, I can install Ubuntu to anything, nothing to change, everything perfect, remove the USB stick and continue to make the world a better place.

Is there a professional, correct, bestest way to do this? Thanks in advance!

User1986
  • 371

2 Answers2

3

Creating a Custom Ubuntu System for Reproduction

1) Create Image file from existing operating system:

  • Boot Live Ubuntu USB and insert Full install, (or Persistent), USB to be copied.

  • Create an image file of the Full install USB, (or Persistent USB), using Gnome-Disks.

enter image description here

enter image description here

2) If using an install from a Virtual Machine: Convert .vdi file to .img file that can be flashed to bootable USB. (Optional)

  • Open VirtualBox

  • cd to folder that contains ubuntu.vdi and run:

VBoxManage clonemedium --format RAW ubuntu.vdi ubuntu.img

3) Install Image File to target drive

Caution: The target drive will be overwritten.

  • Use the pancake icon in Disks or use Etcher, Rufus, dd or mkusb when you want to restore or clone the image to another drive, USB, SSD or HDD.

For more information see: https://askubuntu.com/a/1300542/43926 and How to Create a Full Install of Ubuntu 22.04 to USB Device Step by Step

C.S.Cameron
  • 20,530
  • 12
  • 78
  • 125
1

There are three ways, (that I know of, there might be more ways to this) to clone an installation (making an image of it). These are not the perfect way to clone a large drive. I'm using the 3rd method with an 128 GB disk. This will work fine with the same machine, but if you clone this into another machine, it might not work, or you'll need to configure the boot partition to work with that machine.

Gparted/Clonezilla Method

Gparted comes along with the Ubuntu ISO, you can use that during live USB. Clonezilla is a separate ISO, that can also clone an HDD/SSD.

In this method, you'll need at least 3 storage devices.

  1. Your main drive, you'll make all the settings in this one
  2. Your live USB, you'll use this one to clone the first drive to the third
  3. Your backup drive, you'll clone everything into this drive. You'll need to keep this offline. THIS HAS TO BE EQUAL TO OR LARGER THAN THE FIRST DRIVE

Steps

  1. Install Ubuntu to the first drive, make necessary additions and set it to your desire
  2. Turn off your system, now boot from the second drive, attach your third drive
  3. Open Gparted/Clonezilla and clone every partition (in the same order) from the first drive to the third. (you can resize these partitions, but it's much likely, that this will corrupt your partitions)
  4. Once the cloning is done, eject your third drive and keep it somewhere safe.

With the clone in the third drive, you can re-clone it from your third drive to your first drive and restart with the configurations you've saved.


Gunzip Method

With this method, you'll compress your main drive into an .img.gz file. This will be easier to store thanks to the compression.

In this method, you'll need at least 3 storage devices.

  1. Your main drive, you'll make all the settings in this one
  2. Your live USB, you'll be using this to create an image to your third drive. This can be any Linux distro, the only requirements are gunzip, dd, and necessary packages to read the file systems
  3. Your backup drive, you'll store the image in this device. Since this method compresses the disk, this can be smaller than the first drive. The resulting file size is dependent on the storage used. (I've compressed 128 GB disk into 14 GB file)

Steps

  1. Install Ubuntu to the first drive, make necessary additions and set it to your desire
  2. Turn off your system, now boot from the second drive
  3. Determine your main drive's letter(/dev/sdX, X being the letter you've determined), you can use Gnome disks(gnome-disk-utility), lsblk, ...
  4. Attach your third drive, determine where it is mounted.
  5. Run sudo dd if=/dev/sdX conv=syns,noerror bs=64k| gunzip -c > /path/to/third/drive/YOUR_BACKUP_NAME.img.gz
  6. Once the cloning is done, eject your third drive and store the file somewhere safe.

The reinstallation

  1. Boot from the second drive(live USB), attach a third drive containing the image file
  2. Determine your main drive's letter
  3. Run (as root), gunzip -c /path/to/backup/YOUR_BACKUP_NAME.img.gz | dd of=/dev/sdX bs=64k.

Gunzip + Ventoy Method

This method is similar to the second method, but utilizing Ventoy's persistent live USB's to eliminate the need of a third drive.

You'll need at least 2 storage devices

  1. Your main drive, you'll make all the settings in this one
  2. Your live USB + temporary storage, you'll clone with this, and store in this drive. Since this will store quite a bit, I recommend at least 64 GB for this one.

Steps

  1. Install Ubuntu to the first drive, make necessary additions and set it to your desire
  2. Create a ventoy disk and set persistence storage for your desired Linux distro, (I won't get into the details of this, follow the documents on the ventoy's site)
  3. Boot from your ventoy drive into live USB with persistent storage. Determine where your persistent storage is mounted.
  4. Run sudo dd if=/dev/sdX conv=syns,noerror bs=64k| gunzip -c > /path/to/third/drive/YOUR_BACKUP_NAME.img.gz
  5. Once the cloning is done, turn off your computer and store the file somewhere safe.

The reinstallation

  1. Boot from the second drive(live USB) with persistent storage
  2. Determine your main drive's letter
  3. Run (as root), gunzip -c /path/to/backup/YOUR_BACKUP_NAME.img.gz | dd of=/dev/sdX bs=64k.

Conclusion

All these methods will take at least an hour depending on your setup, drive speeds and used storage. You can replicate the gunzip method with a second computer, but I've assumed you have only one computer + sata/nvme to usb 3.0 adapters are usually slower than using it in the computer.