Skip to content

Instantly share code, notes, and snippets.

@siddharthdeore
Last active November 30, 2023 10:59
Show Gist options
  • Select an option

  • Save siddharthdeore/6db47cc8ea9ecf56e1c84dd3c8d5efec to your computer and use it in GitHub Desktop.

Select an option

Save siddharthdeore/6db47cc8ea9ecf56e1c84dd3c8d5efec to your computer and use it in GitHub Desktop.
create iso image of ubuntu 20.04

Install Required Packages: Make sure you have the necessary packages installed:

sudo apt update
sudo apt install genisoimage
#!/bin/bash
# Create a temporary directory
mkdir ~/custom_iso
cd ~/custom_iso
# Copy necessary files
cp /etc/apt/sources.list .
cp /etc/fstab .
# ... copy other configuration files ...
# Create a list of installed packages
dpkg --get-selections > installed-software
# Install necessary packages on the custom_iso
sudo xargs -a installed-software apt-get install --reinstall -y
# Create the ISO
sudo mkisofs -o custom.iso -r -J .
#!/bin/bash
# Set the output ISO file name
ISO_FILE="system_image.iso"
# Set the temporary directory
TMP_DIR="/tmp/system_image"
# Create the temporary directory
mkdir -p "$TMP_DIR"
# Create a list of installed packages
dpkg --get-selections > "$TMP_DIR/installed-packages.txt"
# Copy kernel information
uname -a > "$TMP_DIR/kernel_info.txt"
# Copy necessary configuration files (customize as needed)
cp -R /etc "$TMP_DIR/etc"
# Copy home directory (optional, comment if not needed)
cp -R /home "$TMP_DIR/home"
# Create the ISO image
genisoimage -o "$ISO_FILE" -r -J "$TMP_DIR"
# Clean up temporary directory
rm -r "$TMP_DIR"
echo "System image created successfully: $ISO_FILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment