1

I often run into situations where I need to run a live distro in order to do something (say resize the main boot partition). The normal process for this would be to find a usb drive I'm not using for something else, create a live usb from it, then boot to it. The issue is often times in the "find a usb I'm not using for something else". I was think recently and was wondering if maybe there's a way to boot a live distro without the usb. I know you can use the toram kernal option to run entirely in the RAM. This makes me wonder if it would be possible to use some GRUB magic to boot the system directly from RAM without needing use a usb.

Ava
  • 771
  • 1
    When the USB boots with the toram option it's running entirely from the RAM, so from the point of view of performance the user doesn't know that the live USB is running from a USB. It's as if the USB device disappeared from a performance point of view. I prefer the USB if it's running entirely in RAM because the USB device doesn't effect performance and more importantly it's portable. – karel Sep 27 '19 at 02:22
  • 2
    There is nothing in your RAM when you boot so you can't boot directly from RAM. You could boot from an iso-image stored on your disk. – mook765 Sep 27 '19 at 02:45
  • 1
    ... and you can combine the advice of the previous two comments: boot from grub into an iso file stored in your internal drive and use the boot option toram so that it will run in RAM and it should be possible to unmount all partitions on the hard disk drive (and for example modify or repair the file system of your installed system). – sudodus Sep 27 '19 at 06:00
  • I tested and could not unmount the partition where the iso file is located. So it should be stored in a separate partition as described with more details in my answer. – sudodus Sep 27 '19 at 06:43

1 Answers1

1

I have a menuentry in my /etc/grub.d/40_custom file that I activate via sudo update-grub to boot into a Lubuntu 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 "Lubuntu 18.04.1 Desktop iso" {
            set isofile="/lubuntu-18.04.1-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
}

This works as expected, but even when I pushed it into RAM with the boot option toram (at the end of the 'linux' line), it would not let me unmount the partition, where the iso file is stored, mounted at /isodevice.

I store the iso file in the root partition of my installed system, so it means that I cannot modify or repair it with tools that only work, when the target partition is unmounted.

  • It is possible to store the iso file in a separate partition, that is not used by the installed operating system. That way you can use the live system booted from the iso file to edit the partition(s) of your installed operating system.

    So modify (hd0,1) in

                loopback loop (hd0,1)$isofile
    

    to point to that separate partition.

  • If there is a swap partition in the internal drive and you want to edit it, you must swap it off

    sudo swapoff /dev/sdxn
    

where x is the device letter and n is the partition number

sudodus
  • 46,324
  • 5
  • 88
  • 152