Skip to content

Instantly share code, notes, and snippets.

View MartinCKH's full-sized avatar
🌴
On vacation

Cheng Ka Ho MartinCKH

🌴
On vacation
View GitHub Profile
@MartinCKH
MartinCKH / grok.sh
Last active October 14, 2025 11:54
grok generate script
#!/bin/bash
# deploy-image.sh: Fixed Ubuntu 22.04 Cloud Image Deployment Script
# FIXED:
# - Run as root (add sudo checks/installs).
# - Install missing tools (cloud-guest-utils for growpart).
# - Convert QCOW2 to temp raw file first, then dd to /dev/sda (avoids qemu-img host_device permission issues).
# - Added checks for mounts/unmounts.
# - Target: /dev/sda (DANGEROUS - typically live boot disk; ensure ISO boot and sda is empty VM disk).
# Run with: sudo bash deploy-image.sh
@MartinCKH
MartinCKH / update.sh
Created October 14, 2025 04:26
update.sh
sudo bash << 'ENDSCRIPT'
set -e
echo "###############################################"
echo "## Ubuntu Cloud Image Deployment"
echo "###############################################"
echo ""
echo "[1/6] Fixing repository configuration..."
sed -i '/cdrom/d' /etc/apt/sources.list
sudo bash << 'ENDSCRIPT'
set -e
echo "=== Converting and writing image ==="
# Download if not already present
if [ ! -f /tmp/ubuntu.img ]; then
wget -O /tmp/ubuntu.img \
https://cloud-images.ubuntu.com/minimal/releases/jammy/release/ubuntu-22.04-minimal-cloudimg-amd64.img
fi
sudo bash << 'ENDSCRIPT'
set -e
TARGET="/dev/sda"
echo "=== Downloading Ubuntu Cloud Image ==="
wget -q --show-progress -O /tmp/ubuntu.img \
https://cloud-images.ubuntu.com/minimal/releases/jammy/release/ubuntu-22.04-minimal-cloudimg-amd64.img
echo ""
@MartinCKH
MartinCKH / install.sh
Last active October 14, 2025 03:48
install2 script
sudo bash << 'ENDSCRIPT'
set -e
TARGET="/dev/sda"
echo "=== Downloading Ubuntu Cloud Image ==="
wget -q --show-progress -O /tmp/ubuntu.img \
https://cloud-images.ubuntu.com/minimal/releases/jammy/release/ubuntu-22.04-minimal-cloudimg-amd64.img
echo ""
sudo bash << 'ENDSCRIPT'
#!/bin/bash
set -e
clear
echo "###############################################"
echo "## Ubuntu Cloud Image Deployment"
echo "###############################################"
echo ""