1

Disclaimer: I'm a newb and I need step by step guide. Thanks!

I want to first install grub without OS, since it will boot from ISO file off the local network storage. I'm booted into a liveCD (I can't install it since I need a volatile system) I'm already stuck at first stage. I tried grub-install /dev/sda and I get error saying grub-install: error: cannot open directory '/boot/grub/i386-pc': No such file or directory.

So I created and copied all files it grub-install needed and now it says grub-install: error: failed to get canonical path of 'aufs'.

I searched web and figure most answers requires me to use chroot while I have a installed system (can be broken though) I don't have Ubuntu installed to any drive and my goal is to install grub from liveCD to empty drive.

I want to start with an empty boot loader.

How do I do this?

Thanks again in advance.

1

You should not need the full Linux file structure if just booting an ISO. I have installed grub to flash drive with various formats and booted ISO on that same flash drive. Not sure exact grub boot stanza required for network boot.

I had an old USB2 flash drive which I reformated. I first make it gpt, as I prefer that over the now 40 year old MBR partitioning. You can use gparted which I normally do. Select gpt under device, advanced over msdos(MBR) default partitioning before starting. or use parted or gdisk. Note: This totally erases drive. The sdX, is your flash drive.

sudo parted /dev/sdX mklabel gpt

I then used gparted to create on large FAT32 partition. I had to reboot for it to be seen correctly & file browser does not auto mount ESP partitions, so used Disks or manually mount.

Model: Kingston DataTraveler 2.0 (scsi)
Disk /dev/sdc: 1998MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name  Flags
 1      1049kB  1998MB  1996MB  fat32        esp2  msftdata

I then mounted it with disks and then it was in /media/fred:

/dev/sdc1 on /media/fred/FC87-F75C type vfat (rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2)

Then installed grub. My drive was seen as sdc. Was a bit slow as old USB2 flash drive.

sudo grub-install --root-directory=/media/fred/FC87-F75C /dev/sdc

It created structure and the normal /EFI/ubuntu/grub.cfg that is a 3 line configfile to full grub in /boot/grub/grub.cfg. But did not create any /boot/grub/grub.cfg boot file. I normally manually created one to boot local ISO using these references & my older notes. You will have to create a grub.cfg but with path & mount? to network.

ISO boot & link to examples

https://help.ubuntu.com/community/Grub2/ISOBoot

more examples

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

Network grub info I found using google. nfs will not work, but has example for net boot.

Set up nfsroot for GRUB PXE

How to boot linux kernel from network through GRUB2 console?

1
  • sudo parted /dev/sdX mklabel gpt then formatted my device to fat and mounted it sudo grub-install --root-directory=/media/ubuntu/XXXX-XXXX /dev/sdX This worked really well. Thanks! – newbie Jan 26 at 16:14
0

You don't need an installed system. First you have to mount the disk, from now we will use as example sda. As a mountpoint example /media/usr/DISK

In a terminal, use this code:

dirs=(etc bin usr proc sys lib lib64 dev sbin)

for dir in ${dirs[@]}; do
  mkdir /media/usr/DISK/$dir
  sudo mount --bind /$dir /media/usr/DISK/$dir
done

sudo chroot /media/usr/DISK/ grub-install --target=i386-pc --boot-directory=/ /dev/sda

for dir in ${dirs[@]}; do
  sudo umount /media/usr/DISK/$dir
  rm -r /media/usr/DISK/$dir
done

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.