Advertisement
v1ral_ITS

booting directly from iso and install

Jul 20th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.03 KB | None | 0 0
  1.  I found this looking around on the net.
  2.  
  3. Grub2 is capable of directly booting ISO images for many Linux distros if the entries have been properly defined in the Grub2 configuration files.
  4.  
  5. The ISO image must be placed on a separate partition that does not have an operating system installed on it. For the sake of simplicity, we would place it inside a new directory under /boot (assuming it is on a separate partition).
  6.  
  7.     Create the new directory and copy your ISO image:
  8.  
  9.     sudo mkdir /boot/iso
  10.     sudo cp ~/Desktop/name.iso /boot/iso
  11.  
  12.     Where ~/Desktop/name.iso is the location and name of your ISO image assuming that the image is located at your desktop.
  13.  
  14.     Add the Grub2 entry:
  15.  
  16.     The entry for the ISO image needs to be added to /etc/grub.d/40_custom file. Edit the file by:
  17.  
  18.     gksudo gedit /etc/grub.d/40_custom
  19.  
  20.     And replace the text in that file with this one:
  21.  
  22.     #!/bin/sh
  23.     echo "Adding 40_custom." >&2
  24.     exec tail -n +4 $0
  25.     # This file provides an easy way to add custom menu entries.  Simply type the
  26.     # menu entries you want to add after this comment.  Be careful not to change
  27.     # the 'exec tail' line above.
  28.  
  29.     menuentry "Kubuntu ISO" {
  30.             set isofile="/boot/iso/kubuntu-12.04.iso"
  31.             loopback loop (hd0,8)$isofile
  32.             linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile noprompt noeject
  33.             initrd (loop)/casper/initrd.lz
  34.     }
  35.  
  36.     Where is:
  37.         Kubuntu ISO = The name you want to display in the Grub menu.
  38.         boot/iso/kubuntu-12.04.iso = The location and name of your ISO image.
  39.         (hd0,8) = The partition which contains the ISO image.
  40.         note: the tail -n +4 means simply "which line grub starts to read the configuration from as is". the 4th line in this example is the first comment line, which is fine.
  41.  
  42.     Grub reads the partitions in a different way than Ubuntu does. 'hd0' means first HDD which is read as sda by Ubuntu, and 8 is the partition which is the same as for Ubuntu. So in other words, (hd0,8) means 'sda8'.
  43.  
  44.     To find out your partition, run this command in a Terminal:
  45.  
  46.     sudo fdisk -l
  47.  
  48.     Suppose your image is contained in the sda1 partition, you'd change (hd0,8) in the above line to (hd0,1) and if the image is in the sdb1 partition, you'd change (hd0,8) to (hd1,1).
  49.  
  50.     Save and close this file and now run this command:
  51.  
  52.     sudo update-grub
  53.  
  54.     Reboot and choose the new ISO entry from Grub menu this time. Hopefully, it will boot successfully to the desktop.
  55.  
  56.     Now, if you want to perform an installation from the same ISO, you'd need to unmount the ISO image first as it is mounted from a partition on your HDD (probably you've got a single HDD and want to install Ubuntu to the same HDD) and the installer needs to unmount any mounted partitions before it can make any changes.
  57.  
  58.     So, from the Live CD environment, go to a Terminal and run:
  59.  
  60.     sudo umount -l /isodevice
  61.  
  62. That's all. Now you can double-click the 'Install' icon at the desktop and proceed with the installation.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement