headerImage2

How to Load Linux via ISO from your hard drive

Instead of burning a CD or using a USB flash stick you can install most Linux distribution from a hard disk. All you need is a small (about 2 GB) extra partition somewhere.

This method uses GRUB2 but I believe GRUB will also work with different syntax (not shown here).

You should edit the GRUB2 configruation rather than editing /boot/grub/grub.cfg. The configuration files are at /etc/grub.d/ and the file you want to edit is 40_custom.

There will probably be nothing in that file to begin with other than the first five lines below. Add the following lines after the header that was there. The items within {} should be the location and name of the iso file.

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.

menuentry "{name of distribution}" {
 loopback loop (hd1,msdos5)/{location where the iso resides}/{iso file name}.iso
 linux (loop)/casper/vmlinuz file=/cdrom/preseed/mint.seed boot=casper initrd=/casper/initrd.lz iso-scan/filename={location of the iso file and fill name of the file} noeject noprompt splash --
 initrd (loop)/casper/initrd.lz
}

The first five lines are what is usually in the file to start. Add the other five lines and then edit them to reflect your environment. You will need to edit the lines that start with 'loopback' and 'linux'. On my system I have a seperate partition for my /home directory. This makes it much easier when it comes time to upgrade as my home directory is safe and I can also put my ISO somewhere on that partition.

(hd1,msdos5)/barton/Downloads/{distribution name}.iso

(hd1,msdos5) means the second hard disk in my system (I have two internal hard drives one with 320 GB and one with 500 GB). hd1 is the 500 GB drive which has five partitions. My home directory is on partition five (msdos5). In the /home directory is my home /home/barton/ and the distribution iso is in the /home/barton/Downloads directory.
If your disk is GPT (GUID Partition Table) rather than MSDOS you will need to use (hd1,gpt1) instead. If you run 'sudo parted -l' you will see either 'Partition Table: gpt' or 'Partition Table: msdos'.

The ISO is only about one GB so you really don't need a very big partition. Unfortunatly you do need a partition other than the one where you will install the new OS. If you don't have a seperate partition for /home you can use 'parted' (sudo apt-get install parted) or some other utility to create a little partition, 2 GB is plenty.

The next line which starts with 'linux' only needs the section
iso-scan/filename=/barton/Downloads/{distribution name}.iso
changed to match where your ISO is, which is the same as the line above without the (h1,msdos5) part.

Once you have the new code added to the 40_custom file you need to update the grub.cfg which is probably in your /boot/grub directory. Run 'sudo grub-mkconfig --output=filename' or you can just do 'sudo grub-mkconfig >filename' as without the option the output goes to stdout. I would create a file somewhere other than /boot/grub so I could look at the output first and make sure it is OK.

Once you think the output is OK you can move it to the location of grub.cfg (usually at /boot/grub). You might want to make a backup of the original file (or not, up to you).

Now it is time to reboot your system.

Oh, you might want to backup anything you don't want to lose before you go any further.
Some things to think about backing up are things in /etc that you have customized, your /var/www, /var/mail and any database files if you have them, and anything else that is on the partition where the new OS is going that you don't want to lose. If your /home directory is on that partition you should probably back it up also.

When you reboot select the new distribution ISO entry which brings up the 'Live CD' from which you can install the new OS.

But, maybe it doesn't work.
You can use the GRUB edit facilities and command line to look to see if you have the drive and partition stuff correct. Using the 'c' option on the first GRUB menue you can look at the drive where you think your ISO is. Type ls (h1,msdos5), for example, and you should see the files and directories. If you type the full path to your ISO you should see it. If not then you got the drive and partition wrong. Use the 'ls' command and find your ISO using other disk and partition values. Remember the 'hd' starts at zero not one, so the first disk drive is 'hd0'. Partitions start at one not zero, so '(hd1,msdos1) means the second disk drive on the system and the first parition ('consistency is the hobgoblin of small minds').

If you still can't get the boot to work reboot your old OS and review everything and maybe do some 'google' searches. This all worked for several distribution changes (Linx Mint, to Ubuntu Mate).

I hope this helps. Any questions please email me.


About This Site

Copyright © 2024 Barton L. Phillips
New Bern, North Carolina
Counter Reset: June 13, 2023
161
Last Modified: Dec 30, 2023 13:07