4

How can I setup an internal SATA SSD such that it boots an Ubuntu installer ISO image ? This would be much faster than using an USB stick.

The naive approach to dd the image file to a disk partition and then setup grub to chainload this partition does not work. Why not ? Which is the key feature for booting an ISO image that a thumb drive has but an internal drive misses ?

  • Which release of Ubuntu do you intend to install? Please click edit and add that to your question. – K7AAY Mar 11 at 17:51
  • 1
    It probably can be done, but think you are trying do make a lot of work for little gain. An installer ISO is usually only used to try Ubuntu for a limited time to make sure you like it and all hard ware works. Most setups will not even retain changes between boots, so you usually have to start all over again. – crip659 Mar 11 at 18:08
2
  1. Get the uuid of the partition on the disk:

    sudo blkid
    /dev/sda1: UUID="6f2b5b8c-f0af-4d4d-a32b-2481a9e2c5d7" TYPE="ext4" PARTUUID="694a694a-05"
        

  2. Store the ISO in the root of the partition, in this example we will use ubuntu-19.04-desktop-amd64.iso.

  3. Mount the ISO and copy the first menuentry from /boot/grub/grub.cfg, and paste it in /etc/grub.d/40_custom:

    #!/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 "Try Ubuntu without installing" {
        set gfxpayload=keep
        linux   /casper/vmlinuz  file=/cdrom/preseed/ubuntu.seed boot=casper quiet splash ---
        initrd  /casper/initrd
    }
    
  4. Change the following in bold:

    menuentry "Try Ubuntu without installing" {
                                                 # the uuid you got i step 1
        search --no-floppy --fs-uuid --set=root 6f2b5b8c-f0af-4d4d-a32b-2481a9e2c5d7
        set iso_path=/ubuntu-19.04-desktop-amd64.iso
        loopback loop $iso_path
        set gfxpayload=keep
        linux   (loop)/casper/vmlinuz  file=/cdrom/preseed/ubuntu.seed boot=casper quiet splash iso-scan/filename=$iso_path ---
        initrd  (loop)/casper/initrd
    }
    
  5. Update grub:

    sudo update-grub
    

Next time you reboot you will have an entry to boot the ISO.

| improve this answer | |
2

Grub 2.04

Grub 2.04 as found in Ubuntu 19.10 and later, does not chainload ISO files in UEFI mode.

See [Bug 1851311] Re: Grub 2.04 Out of memory error, https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1851311

See posts 17 to 21 for background on workaround.

Procedure to lookmount ISO files on SSD

  • Install Ubuntu to the SSD using mkusb with the usb-pack-efi option. (this replaces grub 2.04 with 2.02).

  • Deleted ISO9660 partition sdx4, and casper-rw partition sdx5, stretch usbdata NTFS partition #1 into it's place.

  • Dropped ISO into iso folder on NTFS partition.

  • Updated grub.cfg on usbboot partition #2 to loopmount the ISO.

  • Boots in BIOS using grub 2.04, Boots in UEFI using grub 2.02~Beta2

Booting an ISO file on SSD and running it in RAM should make a fast setup.

| improve this answer | |
  • Thanks to Sudodus for the usb-pack-efi option. Thanks to Oldfred for reminding me how slow toram boots on mechanical drive. – C.S.Cameron Mar 12 at 1:20
1

RAM is orders of magnitude faster than an SSD.

A relatively fast SSD may achieve real-world write speeds of 456MB/sec.

The theoretical maximum speed of RAM is in its PC number, so a module of PC3-12800 memory can transfer 12,800MB/sec. (roughly 30 times faster than the real world performance of an SSD).

An Ubuntu installer image will run in RAM. You need more RAM than the size of the image. (>2.5GB).

Mkusb will make a USB that has a boot to RAM option, or when booting, you can press shift, then F6 and type a space then toram then enter.

| improve this answer | |
  • 1
    Whether I use SSD, HDD, or flash drive I use a toram parameter. Then entire ISO is in RAM. The advantage of SSD, is that it loads the image faster. But I often have to unmount the isodevice. sudo umount -l -r -f /isodevice – oldfred Mar 11 at 20:13
  • @oldfred: When I need to unmount a drive that is running in RAM, say to make a Full install to it, I just use Disks. I always prefer GUIs so I can see what is happening. – C.S.Cameron Mar 12 at 12:59
  • I booted the Ubuntu 20.04 ISO normally on a USB3 disk and it took over three minutes to run the Disk Check. I then booted the ISO to RAM and it took three seconds to run the disk check. This is a easy experiment anyone can do. – C.S.Cameron Jul 3 at 5:56
0

debootstrap gives this capability but it is a complex process, and generating then installing from a LiveDVD or LiveUSB is far easier and quicker than using debootstrap.

  1. Install debootstrap with sudo update && sudo apt install debootstrap
  2. Use mkfs to make a partition for the new OS sudo mkfs.ext4 /dev/sda1.
  3. If you intend to add Hibernation after installation and do not have a swap partition, make one now.
  4. Mount the destination partition sudo mkdir /mnt/installer && sudo mount /dev/sda1 /mnt/installer
  5. Get the base system packages and install them with sudo debootstrap xxxxxx /mnt/installer - substitute the Ubuntu distro you intend to install for xxxxxx .
  6. Do sudo cp /etc/apt/sources.list /mnt/installer/etc/apt/ to copy files to retain your repositories.
  7. Chroot in
sudo mount --bind /dev /mnt/installer/dev
sudo mount --bind /dev/pts /mnt/installer/dev/pts
sudo mount -t proc proc /mnt/installer/proc
sudo mount -t sysfs sys /mnt/installer/sys
sudo chroot /mnt/installer
  1. Set language and locale to avoid warnings from dpkg:
cp /usr/share/zoneinfo/America/Los Angeles /etc/localtime
echo 'LANG="en_US.UTF-8' >  /etc/default/locale
echo 'LANG="en_US:en:us' >> /etc/default/locale
echo 'America/Los_angeles' > /etc/timezone
locale-gen en_US.UTF-8
dpkg-reconfigure -f non-interactive tzdata
## All this inside chroot! Alter for your language, nation, and locale.
  1. Upgrade the new install. Install your local "language-pack-en-base" with apt-get update && apt-get install language-pack-en-base && apt-get upgrade

  2. If you intend to use Software RAID and/or LVM, install these packages before the kernel: apt install mdadm lvm2

  3. Install GRUB2 and the kernel with apt install grub-pc linux-image

  4. Add a user & set their password, and the root password, with adduser <username> then passwd

  5. Do you want them to belong to sudoers? Then do gpasswd -a <username> sudo

  6. Make fstab; a simple example is echo "/dev/sda1 / ext4 errors=remount-ro 0 1" >> /etc/fstab

More details are available in https://help.ubuntu.com/community/Installation/FromLinux#Debootstrap including the installation of a desktop (which you haven't yet said you wanted).

| improve this answer | |
0

General comment

I notice that the answers are very different. I think it is because we read your question in different ways. Please make things more clear:

  • Either edit your question to make it more specific, so that we understand what you want,
  • or, if one of the answers is targeting exactly what you want, you can accept it and that way let us know (and if you let me know that my answer is not what you want or need, I can delete it to decrease the confusion for other people.)

Your [original] question and my answer

How can I setup an internal SATA SSD such that it boots an Ubuntu installer ISO image ? This would be much faster than using an USB stick.

You can treat a SATA SSD (internal SATA or external eSATA or connected via a USB adapter or box) just like a USB stick, if the tool you are using is allowing it.

And you are right, it is much faster than using a USB stick.

The naive approach to dd the image file to a disk partition and then setup grub to chainload this partition does not work. Why not ? Which is the key feature for booting an ISO image that a thumb drive has but an internal drive misses ?

I have done it with dd. So it works, but if you use the simple cloning method, there will be a terrible waste of drive space.

But there are several methods to create a persistent live drive with a partition for persistence, where you can use the remaining drive space 'behind' the cloned image, or create a dedicated partition table.

I have done it many times and can confirm that it works. I have also created persistent live drives with mkusb, edited the partition table (when booted live-only 'to RAM' from the drive itself) and created an installed system in the drive space made unallocated. (It is even possible to overwrite the live system completely, when you install the system, but if you make a mistake you have to start from the beginning, so I would not recommend it.)

You can also use other methods to boot via grub.

The following links describe methods that work, if you want to setup an internal or external SSD such that it boots an Ubuntu installer ISO image.

help.ubuntu.com/community/mkusb

help.ubuntu.com/community/mkusb/persistent

How is it easier to make a persistent live drive with Ubuntu 19.10? - you can use mkusb-sedd directly for an internal target drive because mkusb-plug needs a removable target drive

Ubuntu on a USB stick - boot in both BIOS and UEFI modes

help.ubuntu.com/community/Grub2/ISOBoot/Examples

help.ubuntu.com/community/Installation/UEFI-and-BIOS/stable-alternative-18.04.1

| improve this answer | |
  • My understanding of this question is that it concerns [Bug 1851311] Re: Grub 2.04 Out of memory error. That was the one where 19.10 started using grub 2.04 which doesn't boot ISOs in UEFI mode. The Op wants to boot ISOs on SSD. – C.S.Cameron Mar 12 at 11:37
  • @C.S.Cameron, You are probably right, but I would like to get an answer about it from the OP. (Anyway, I already upvoted your answers, because I thought that you understood the question correctly.) – sudodus Mar 12 at 11:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.