0

I downloaded the latest LTS release of Ubuntu 18.04. I currently do not have any spare USB or CD/DVD. So, I just want to install or upgrade my current system from that ISO without making any bootable device. Is it possible? If yes, then please tell me the whole process!

mr oogway
  • 1
  • 4
  • 1
    Your solution requires knowledge of your system. If you have a spare HDD in it, you can dd the iso to the hdd/sdd so as to use it in place of a usb/dvd (not install drive though). If you don't want to use the whole drive, you can use a partition on a drive (ie. part of a hdd/sdd). If you already have grub, you can add entries to your existing grub to boot the ISO, then select the 'iso' and install from there (this requires the least work & fix-up afterwards). I'd still recommend using a usb/dvd (back one up somewhere, use it, then restore data to it, or just go to a store & buy another) – guiverc May 06 '18 at 11:33
  • 1
    You can install to the same drive you boot the Live installer system from, as long as you boot toram. I will try to write up a procedure later today. – C.S.Cameron May 06 '18 at 15:58
  • You could boot the ISO with grub using loopback feature. I'll an answer later – solsTiCe May 06 '18 at 18:23
  • 1
    It is risky to upgrade, so you should backup and/or create a test system before you do it on your main operating system. See this link, which creates a system, that you can use for testing alongside your main system, Bash script to clone Ubuntu to new partition for testing 18.04 LTS upgrade – sudodus May 06 '18 at 19:32
  • I usually do an upgrade using Software and Updates for LTS versions. This is simple, preserves /home and updates the installed programs. I've had good luck with this method. and you don't need an external drive, or an ISO. Some people prefer a fresh install. – C.S.Cameron May 07 '18 at 01:24

2 Answers2

1

Backup! everything will be overwritten.

Copy Ubuntu 18.04 ISO to HDD root, (/).

Edit grub.cfg changing 40_custom as shown:

    ### BEGIN /etc/grub.d/40_custom ###
    # 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 "ubuntu-18.04-desktop-amd64" {
            loopback loop (hd0,2)/ubuntu-18.04-desktop-amd64.iso
            linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/ubuntu-18.04-desktop-amd64.iso splash toram -- 
            initrd (loop)/casper/initrd.lz
    }
    ### END /etc/grub.d/40_custom ###

Install Ubuntu as normal, but you only get one chance.

C.S.Cameron
  • 19,519
0

So using the loopback feature of GRUB, one can boot an iso installed on a partition of you HDD.

  1. Copy the ubuntu ISO to one spare partition. By spare, I mean, one partition that you will not overwrite when installing ubuntu. For example, your NTFS windows partition.

  2. Add an entry in grub configuration for the iso. To do that edit /etc/grub/40_custom and add something like

    insmod search_fs_uuid
    insmod ntfs
    search --no-floppy --set=isopart --fs-uuid XXXXXXXXXXXXX
    
    menuentry '[loopback]ubuntu-18.04-desktop-amd64' {
        set isofile='/Grub/ISO/ubuntu-18.04-desktop-amd64.iso'
        loopback loop ($isopart)$isofile
        linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofile locale=en_US.UTF-8
        initrd (loop)/casper/initrd.lz
    }
    

    This needs a little explanation

    This will search for your partition by filesystem uuid. So you need to know the uuid of your fs partition. You can use the output of blkid for that. Look for UUID not PARTUUID. So replace XXXXXXXXXX with the uuid of your fs.

    If your partition is not NTFS then you need to insmod the module for your fs like ext4.

    The isofile variable is relative to the root of your partition, not the root of your current system. For example I have /media/me/Windows10/Grub/ISO/ubuntu-18.04-desktop-amd64.iso, as the ISO, so I use /Grub/ISO/ubuntu-18.04-desktop-amd64.iso as the isofile

  3. Run sudo update-grub

  4. Reboot and, in Grub menu, choose the loopback entry. Then do the installation as if booted from USB or DVD.

solsTiCe
  • 9,231
  • What if you do not have a spare partition? Even with a spare partition, if something goes wrong with the install the old install including grub will be gone the same as with my answer. – C.S.Cameron May 07 '18 at 00:01
  • But if I make a separate partition, my data will get effected! – mr oogway May 09 '18 at 04:49
  • You can resize a partition without affecting data in the alongside partition. Use a gparted Live UB – solsTiCe May 09 '18 at 10:56