This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo bash << 'ENDSCRIPT' | |
#!/bin/bash | |
set -e | |
clear | |
echo "###############################################" | |
echo "## Ubuntu Cloud Image Deployment" | |
echo "###############################################" | |
echo "" |