How to Run Any Linux Distribution Directly from Hard Disk in Ubuntu Using Grub Menu

Most of Linux distributions provide ISO files that are designed and built to run in Live Mode directly from a bootable media such as CD /DVD, Flash/USB cards or even directly from a Hard Drive using Linux Grub menu without the need to burn it to a CD/DVD or create a bootable USB.

Run Linux From Hard Disk
Run Linux From Hard Disk

This tutorial will concentrate on presenting a way you can run some Linux ISO distributions directly from your hard disk by editing Ubuntu 20.04 GRUB2 (works on Ubuntu 18.04 or earlier) menu which is the default boot loader in most modern Linux distributions, which provides a faster way of using a Linux Operating System, and also has a great impact on privacy because all your settings and live sessions are not preserved by default.

The distributions presented in this topic are CentOS, Fedora, Kali Linux and Gentoo Live DVD.

Requirements

Ubuntu 20.04 ( or any other Linux distributions with GRUB2 boot loader) installed on your system hard drive.

Step 1: Download Linux Live ISO Files

1. To able boot and run any Linux distribution without installing them to your hard drive, make sure to download the “Live CD/DVD” release of each Linux ISO image.

Step 2: Add ISO Images to GRUB2 Menu

2. After you have downloaded your favorite Linux ISO Live DVD Images, open Ubuntu Nautilus with root privileges using ‘sudo nautilus‘ command from Terminal and create a directory called live in your system root path and move ISO file to this folder.

$ sudo nautilus
Create Directory in Ubuntu Root Location
Create Directory in Ubuntu Root Location
Copy Linux ISO Files to Live Directory
Copy Linux ISO Files to Live Directory

3. To continue further will need to provide Grub2 with our disk partition UUIDUniversally Unique Identifier (the partition where ISO files are located). To get partition UUID run the following blkid command.

$ sudo blkid

For automatically mounted partition or hard disks on system boot run following cat command.

$ sudo cat /etc/fstab   
Get Partition UUID
Get Partition UUID

4. Another method to get your partition UUID is, to open visualize grub.cfg file content located in /boot/grub/ path and search for --fs-uuid a string (in case you don’t have a separated partition for /boot).

Find Partition UUID
Find Partition UUID

5. After you obtained your root partition UUID code move to /etc/grub.d/ directory, open 40_custom file for editing and add the following lines at the bottom of this file.

menuentry 'CentOS 8 Live' --class os --class gnu-linux --class gnu --class os --group group_main {
                set isofile="/live/CentOS-8-x86_64-1905-dvd1.iso"

         insmod ext2
         insmod loopback
         insmod iso9660      
                loopback loop (hd0,msdos1)$isofile      
                search --no-floppy --fs-uuid --set=root 3b87d941-8ee7-4312-98fc-1f26828d62ab                            
                linux (loop)/isolinux/vmlinuz boot=live fromiso=/dev/sda1/$isofile noconfig=sudo username=root hostname=centos
                initrd (loop)/isolinux/initrd.img
}
Add CentOS Boot Kernel Parameters
Add CentOS Boot Kernel Parameters

Here the following directives represents:

  1. set isofile = A variable the holds ISO system path location.
  2. (hd0,msdos1) = First partition from first hard disk (In Linux disks are numbered starting with 0) – the same as /dev/sda1.
  3. –fs-uuid –set=root 59036d99-a9bd-4cfb-80ab-93a8d3a92e77 = First partition from first hard disk UUID code.
  4. linux and initrd = Custom kernel booting parameters – they are different depending on every Linux distribution.

6. After you finish editing the file, update-grub to add the new ISO (in this case CentOS) to your Grub2 menu. To verify it open /boot/grub/grub.cfg and search at the bottom for your ISO entry.

$ sudo update-grub
Update Grub to Add ISO Images
Update Grub to Add ISO Images
Verify Grub Entry
Verify Grub Entry

7. To run CentOS Live ISO, reboot your computer, select CentOS entry from GRUB menu then press Enter key.

Select CentOS from Boot Menu
Select CentOS from Boot Menu
CentOS 8 Booting
CentOS 8 Booting

In the same way, you can add the other Linux Live ISO distribution images to the GRUB2 menu as shown. Again open and edit /etc/grub.d/40_custom grub file and add the following entries.

For Fedora Live DVD

menuentry 'Fedora Live' --class os --class gnu-linux --class gnu --class os --group group_main {
                set isofile="/live/Fedora-Workstation-Live-x86_64-32-1.6.iso"

         insmod ext2
         insmod loopback
         insmod iso9660      
                loopback loop (hd0,msdos1)$isofile      
                search --no-floppy --fs-uuid --set=root 3b87d941-8ee7-4312-98fc-1f26828d62ab                            
                linux (loop)/isolinux/vmlinuz boot=live fromiso=/dev/sda1/$isofile noconfig=sudo username=root hostname=fedora
                initrd (loop)/isolinux/initrd.img
}

For Kali Linux Live DVD

menuentry 'Kali Linux Live' --class os --class gnu-linux --class gnu --class os --group group_main {
                set isofile="/live/kali-linux-2020.2-live-i386.iso"

         insmod ext2
         insmod loopback
         insmod iso9660      
                loopback loop (hd0,msdos1)$isofile      
                search --no-floppy --fs-uuid --set=root 3b87d941-8ee7-4312-98fc-1f26828d62ab                            
                linux (loop)/live/vmlinuz boot=live fromiso=/dev/sda1/$isofile noconfig=sudo username=root hostname=kalilinux
                initrd (loop)/live/initrd.img
}

For Gentoo Live DVD

menuentry 'Gentoo Linux Live' --class os --class gnu-linux --class gnu --class os --group group_main {
                set isofile="/live/livedvd-amd64-multilib-20160704.iso"

         insmod ext2
         insmod loopback
         insmod iso9660      
                loopback loop (hd0,msdos1)$isofile      
                search --no-floppy --fs-uuid --set=root 3b87d941-8ee7-4312-98fc-1f26828d62ab                            
                linux (loop)/live/vmlinuz boot=live fromiso=/dev/sda1/$isofile noconfig=sudo username=root hostname=gentoo
                initrd (loop)/live/initrd.img
}

8. Then update your GRUB menu again, reboot your computer and choose your preferred Linux distribution ISO from the GRUB menu.

$ sudo update-grub

9. If you don’t have enough free space on your root partition, to host other Linux ISO files you can add another hard disk and move all your Linux distribution ISO files there. After you create a partition and add a file system mount it on /mnt path to make it available.

$ sudo mount /dev/sdb1 /mnt

10. Then move all ISO on the new hard disk and grab its UUID using blkid command.

$ sudo blkid
Move ISO Images and Verify UUID
Move ISO Images and Verify UUID
Verify All ISO Images
Verify All ISO Images

11. Again open and edit /etc/grub.d/40_custom grub file and add other Linux Live ISO distribution images to GRUB2 menu using the same procedure but pay attention to every distribution Live Kernel booting parameters which can be inspected by mounting the ISO image using mount -o loop option or consult distribution Wiki pages.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

21 thoughts on “How to Run Any Linux Distribution Directly from Hard Disk in Ubuntu Using Grub Menu”

  1. Does anyone know how to make this iso persistent?

    I used this to boot and works for me.

    menuentry ‘Kali Linux 2014 Live’ –class os –class gnu-linux –class gnu –class os –group group_main {
    set isofile=”/live/kali-linux-1.1.0a-amd64.iso”
    insmod ext2
    insmod loopback
    insmod iso9660
    loopback loop (hd0,msdos2)$isofile
    search –no-floppy –fs-uuid –set=root 07c0e976-866d-49f6-9ac7-018b5b4d9a8a
    linux (loop)/live/vmlinuz boot=live fromiso=/dev/sda2/$isofile noconfig=sudo username=root hostname=kali
    initrd (loop)/live/initrd.img
    }

    Reply
  2. Hey guys,
    Great article!! It works fine for me (Ubuntu Gnome 14.04).
    Only 1 more question, how can I know (or find) the linux and initrd section for other kind of live distros?
    Thanks a lot!

    Reply
  3. hi guys im running ubuntu 14.04 (hd0,gpt7) the thing is when I launch kali there’s an error that pops up

    Begin: Mounting root file system …/init: .: line 224: cant open ‘ /scripts/Live’
    kernel panic – not syncing: attempted to kill init!

    please help me

    Reply
  4. forgot to add my current 40_custom config
    my grub file shows: hd1,msdos5

    menuentry ‘Kali Linux 2014 Live’ –class os –class gnu-linux –class gnu –class os –group group_main {
    set isofile=”/live/kali-linux-1.0.9a-amd64.iso”

    insmod ext2
    insmod loopback
    insmod iso9660
    loopback loop (hd1,msdos5)$isofile
    search –no-floppy –fs-uuid –set=root b86769fa-9af1-4d92-b8f0-dc528f9a0f0f
    linux (loop)/live/vmlinuz boot=live fromiso=/dev/sdb1/$isofile noconfig=sudo username=root hostname=kali
    initrd (loop)/live/initrd.img
    }

    menuentry ‘Backbox Live ISO’ –class os –class gnu-linux –class gnu –class os –group group_main {
    set isofile=”/backbox-4.0-amd64.iso”
    loopback loop (hd1,5)$isofile
    linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile noprompt noeject
    initrd (loop)/casper/initrd.gz
    }

    Reply
  5. hey
    first of all thx for the tutorial, but i do have a problem.
    i did manage to add the kali linux to the grub menu
    but after i pick it it simply restarts my computer and comes back to the grub menu
    and ideas on how to fix?

    Reply

Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.