Booting a live system without a USB stick

For some maintenance tasks you need a linux live system. For example when you or some updates broke your system or you want to resize the partitions of your hard disk.

The common way is to download a live system, searching for your lost USB stick for 30 minutes, flashing the system onto the stick and then you can finally start to work on your system. It is the same processes every time and I really don’t like repetitive work. So I was looking for a better solution.

It turns out that GRUB is able to boot a simple ISO image from your local hard disk. I am using Arch Linux to configure my GRUB but it should work similarly with other distributions.

At first you have to download an ISO image. (e.g. Arch Linux, but every other distribution should also work.)
You have to save it to a location that is accessible by GRUB. As most parts of my hard disk are encrypted I have chosen to increase my unencrypted /boot partition and saved the ISO image to /boot/iso/arch.iso.

Of course GRUB needs to know about this image. One way is to define an additional menu entry in /etc/grub.d/50_arch_live. You have to adjust the imgdevpath to your partition with the ISO image and isofile and to the path of the ISO image inside of the partition. /dev/sda1 is my boot partition and /iso/arch.iso is the image in /boot/iso/arch.iso.

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 'Arch Linux Live' {                   
        set imgdevpath="/dev/sda1"              
        set isofile='/iso/arch.iso'             
        loopback loop (hd0,1)$isofile           
        linux (loop)/arch/boot/x86_64/vmlinuz archisodevice=/dev/loop0 img_dev=$imgdevpath img_loop=$isofile
        initrd (loop)/arch/boot/x86_64/archiso.img                                              

Now you only have to rebuild the GRUB configuration:

$ grub-mkconfig -o /boot/grub/grub.cfg 
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-linux
Found initrd image(s) in /boot: intel-ucode.img initramfs-linux.img
Found fallback initrd image(s) in /boot: intel-ucode.img initramfs-linux-fallback.img

After the next reboot you should have an additional menu entry in GRUB that boots the live system.

Über Max Rosin

Fotograf, Informatikstudent und Blogger. Mehr zu mir, gibt es hier
Dieser Beitrag wurde unter Tech abgelegt und mit , , , verschlagwortet. Setze ein Lesezeichen auf den Permalink.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.