Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rainly/4362d84889fcbffd82e2956a966622c4 to your computer and use it in GitHub Desktop.
Save rainly/4362d84889fcbffd82e2956a966622c4 to your computer and use it in GitHub Desktop.
boot ubuntu iso directly from hard disk with grub
#boot into exist linux in /dev/sda1
#download iso file into for example: /home/malcolm/Downloads/lubuntu-18.04-desktop-amd64.iso
#sudo subl /boot/grub/grub.cfg:
menuentry 'Lubuntu 18.04 ISO' {
set isofile='/home/malcolm/Downloads/lubuntu-18.04-desktop-amd64.iso'
loopback loop (hd0,1)$isofile
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile noprompt noeject
initrd (loop)/casper/initrd.lz
}
#sudo reboot
#boot menu appear, choose "Lubuntu 18.04 ISO", boot into ISO
#sudo umount -l /isodevice
#click "Install Lubuntu 18.04" icon to install Lubuntu into /dev/sda2
#choose install grub into /dev/sda2(don't install into /dev/sda), but it will fail silently, we should manually do it in the next 2 lines
#mkdir /mnt/sda2 && mount /dev/sda2 /mnt/sda2 && mount --bind /dev /mnt/sda2/dev && mount --bind /proc /mnt/sda2/proc
#sudo chroot /mnt/sda2 && sudo grub-install --force /dev/sda2
#use "fdisk /dev/sda" and "a" "1", "a" "2" to toggle boot flag, and verify it with "p"
#to fix MBR ruined by grub: testdisk, no log, Proceed, Intel, MBR Code, y, OK, Quit, Quit
#sudo reboot
#now boot into Lubuntu in /dev/sda2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment