1. Partitioning a 32 GB usb stick
GPT partition table with 2 primary partitions, feel free to adapt the partition sizes to your needs:
- first partition fat32 labelled
EFIBOOT
, around 9 GiB- second partition ext2 labelled
casper-rw
, around 19 GiBgparted screeshots:
Note you can format the persistent partition to ext4, I chose ext2 for better speed and less overhead over ext4.
Exit gparted.
2. Grub installation
A Grub menu maintains a list of available iso images for booting with different boot options.
To mount the usb fat32 partition on the necessary mount point left click the
EFIBOOT
device label side pane of file manager. Then run below command from a terminal to install grub efi on the usb stick:
Code: Select all
sudo grub-install --target=x86_64-efi --efi-directory=/media/$USER/EFIBOOT --bootloader-id=loader --boot-directory=/media/$USER/EFIBOOT/boot --no-nvram --no-extra-removable --no-uefi-secure-boot
3. rEFInd installation
rEFInd boot manager screen will show up at startup. rEFInd can detect any OS available for booting on an uefi computer. rEFInd will also chain to the grub menu that lists available iso images for booting.
Note rEFInd is installed on your live usb, no changes are made to your computer boot setup.
Create folder
EFI/boot
:
Code: Select all
mkdir /media/$USER/EFIBOOT/EFI/boot
Get latest
refind-bin
zip file from https://sourceforge.net/projects/refind/files/Current version 0.11.4 link http://sourceforge.net/projects/refind/ ... p/download
Extract zip archive and enter folder path
refind-bin-0.11.4/refind
Copy below files and folders to usb folder
EFI/boot
:
Code: Select all
drivers_x64
icons
refind_x64.efi
refind.conf-sample
refind_x64.efi
to bootx64.efi
and
refind.conf-sample
to refind.conf
4. grub.cfg configuration file
Live usb tree (partial):
Code: Select all
.
├── boot
│ └── grub
│ ├── fonts
│ ├── grub.cfg
│ ├── grubenv
│ ├── locale
│ ├── themes
│ └── x86_64-efi
├── EFI
│ ├── boot
│ │ ├── bootx64.efi
│ │ ├── drivers_x64
│ │ ├── icons
│ │ └── refind.conf
│ └── loader
│ └── grubx64.efi
└── isoimages
└── linuxmint-19-cinnamon-64bit-v2.iso
isoimages
at the top of the filesystem tree and copy to that directory your Linux Mint iso image.Create
grub.cfg
configuration file in folder boot/grub
that will maintain the list of available iso images for booting and your customized boot options. Some grub parameters are somehow cryptic, iso images from different origins may need different parameters to boot properly but that's outside of the scope of this tutorial. Each entry in the menu is manually added and maintained.To begin with use my configuration file as a template, here for Linux Mint 19 Cinnamon iso image:
- first menu entry "Linux Mint 19 Cinnamon live" will boot LM live as usual
- second entry "Linux Mint 19 Cinnamon persistent" will boot LM iso image using usb casper-rw partition for persistence. Notice specific grub parameter
persistent
- third entry "Linux Mint 19 Cinnamon ram persistent" also uses persistence plus loads the live squashfs file system into ram. Notice specific grub parameters
toram persistent
If you want to configure the same iso image then just copy paste the following contents to
grub.cfg
:
Code: Select all
insmod all_video
loadfont unicode
set gfxmode=auto
insmod gfxterm
terminal_output gfxterm
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
menuentry "Linux Mint 19 Cinnamon live" {
search --set -f "/isoimages/linuxmint-19-cinnamon-64bit-v2.iso"
loopback loop "/isoimages/linuxmint-19-cinnamon-64bit-v2.iso"
linux (loop)/casper/vmlinuz file=/cdrom/preseed/linuxmint.seed boot=casper iso-scan/filename=/isoimages/linuxmint-19-cinnamon-64bit-v2.iso quiet splash --
initrd (loop)/casper/initrd.lz
}
menuentry "Linux Mint 19 Cinnamon persistent" {
search --set -f "/isoimages/linuxmint-19-cinnamon-64bit-v2.iso"
loopback loop "/isoimages/linuxmint-19-cinnamon-64bit-v2.iso"
linux (loop)/casper/vmlinuz file=/cdrom/preseed/linuxmint.seed boot=casper iso-scan/filename=/isoimages/linuxmint-19-cinnamon-64bit-v2.iso quiet splash persistent --
initrd (loop)/casper/initrd.lz
}
menuentry "Linux Mint 19 Cinnamon ram persistent" {
search --set -f "/isoimages/linuxmint-19-cinnamon-64bit-v2.iso"
loopback loop "/isoimages/linuxmint-19-cinnamon-64bit-v2.iso"
linux (loop)/casper/vmlinuz file=/cdrom/preseed/linuxmint.seed boot=casper iso-scan/filename=/isoimages/linuxmint-19-cinnamon-64bit-v2.iso quiet splash toram persistent --
initrd (loop)/casper/initrd.lz
}
First boot
Here a dual boot Linux Mint / Windows computer, note by default Linux Mint uses an Ubuntu identifier for EFI, hence the Ubuntu icon. Screenshot revamped and cropped for the purpose of this tutorial, actual display in your case may differ slightly:
Notes:
- from rEFInd startup screen select the Linux Tux icon harboring a usb stick to chain to the grub menu.
- only associate the persistent partition with a single iso image of your choice. Don't try to setup menu entries with persistence for different iso images.
- once LM Cinnamon running in persistent mode disable Nemo feature "Automatically mount removeable media when inserted and on startup" in Nemo Preferences > Behavior
- rEFInd home page for further references at http://www.rodsbooks.com/refind/index.html
5. Optional: make live usb bootable in Legacy mode
Before proceeding with grub installation in legacy mode, if unsure determine the device id of your usb stick, below command returned
/dev/sdc
in my case:
Code: Select all
echo /dev/$(lsblk -r -o name,label | grep EFIBOOT$ | cut -d'1' -f1)
<DEVICE>
in below command with the device id of your usb stick:
Code: Select all
sudo sgdisk -n9:34:2047 -t9:ef02 <DEVICE>
Grub installation: replace
<DEVICE>
in below command with the correct device id of your usb stick:
Code: Select all
sudo grub-install --target=i386-pc --boot-directory=/media/$USER/EFIBOOT/boot --root-directory=/media/$USER/EFIBOOT --skip-fs-probe <DEVICE>
Edit :
- 29/8/2018, legacy boot update.
- 16/8/2018, make live usb bootable in legacy mode.
- 13/8/2018, first boot screenshot added, thanks to fabien85.