Reinstalling Ubuntu 16 Xenial from within Linux
I have rented a KVM-based VPS from a provider and wanted to reinstall the templated Ubuntu 14.04 install that can with it. This is how I did it.
I basically remove the 4GB swap drive (/dev/vda2) and write the mini.iso on top of it. Then I tell the grub2 bootloader to boot using the partition, and then I reboot the machine. Enjoy!
# swapoff /dev/vda2
# sudo sed -i '/ swap / s/^/#/' /etc/fstab
# fdisk /dev/vda
( alternatively use the easier 'cfdisk /dev/vda')
press ‘d’ for delete
press ‘2’ for partition 2
press n for new partition
press p for primary
press 2
just fill in the defaults
press ‘w’ to write
This may display:
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
$ wget -O ubuntu.iso http://archive.ubuntu.com/ubuntu/dists/xenial-updates/main/installer-amd64/current/images/netboot/mini.iso
Alternative: Minimize wait and do it faster:
$ apt-get install -y axel && axel -a -n 10 http://archive.ubuntu.com/ubuntu/dists/xenial-updates/main/installer-amd64/current/images/netboot/mini.iso
$ dd if=mini.iso of=/dev/vda3 bs=4MB;sync
cat <<EOF > /etc/grub.d/06_custom
#!/bin/sh
exec tail -n +3 \$0
menuentry "ISO" {
set root=(hd0,3)
set gfxpayload=keep
linux /linux -- quiet
initrd /initrd.gz
}
EOF
$ chmod a+x /etc/grub.d/06_custom
$ update-grub && reboot
After installation if the terminal does not show, then try and press CTRL+ALT+F1 (together with FN on a Mac)
Comments
Post a Comment