Skip to content

Instantly share code, notes, and snippets.

@petarnikolovski
Last active August 10, 2024 13:04
Show Gist options
  • Save petarnikolovski/ab8f9fd8c339df392206adcfb999adb6 to your computer and use it in GitHub Desktop.
Save petarnikolovski/ab8f9fd8c339df392206adcfb999adb6 to your computer and use it in GitHub Desktop.
Update host ubuntu from a live CD
#!/bin/bash
# Run with `sudo`
MOUNTED_DISK=$1
umount ${MOUNTED_DISK}/run
umount ${MOUNTED_DISK}/sys
umount ${MOUNTED_DISK}/dev/pts
umount ${MOUNTED_DISK}/dev
umount ${MOUNTED_DISK}/proc
umount ${MOUNTED_DISK}
#!/bin/bash
wget https://gist.githubusercontent.com/petarnikolovski/ab8f9fd8c339df392206adcfb999adb6/raw/26f2e9c4f043c8d2ef5c06c21498a4c4c49b5fd6/provision.sh
chmod +x provision.sh
wget https://gist.githubusercontent.com/petarnikolovski/ab8f9fd8c339df392206adcfb999adb6/raw/34e61693d0fb7cd9da9bc81d22bef49b2d848913/deprovision.sh
chmod +x deprovision.sh

Paste this into command line to install the scripts

wget https://gist.githubusercontent.com/petarnikolovski/ab8f9fd8c339df392206adcfb999adb6/raw/cacee00c2c433e8fb3b2055432587400773de2fc/download.sh
chmod +x download.sh
./download.sh
#!/bin/bash
# References:
# https://serverfault.com/questions/857474/install-package-via-apt-from-a-live-cd-to-the-real-system
# https://unix.stackexchange.com/questions/112346/is-it-possible-to-install-a-linux-desktop-environment-from-a-live-cd
# https://askubuntu.com/questions/976894/install-package-to-ubuntu-16-04-installation-while-booted-into-live-cd
# Run with `sudo`
# I assume the disk is already mounted, if not, update the script
MOUNTED_DISK=$1
mount -t proc none ${MOUNTED_DISK}/proc
mount --bind /dev ${MOUNTED_DISK}/dev
mount --bind /dev/pts ${MOUNTED_DISK}/dev/pts
mount --bind /sys ${MOUNTED_DISK}/sys
mount --bind /run ${MOUNTED_DISK}/run
cp /etc/resolv.conf ${MOUNTED_DISK}/etc/resolv.conf
# After this, you can install programs as you wish
chroot ${MOUNTED_DISK} /bin/bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment