1. The first step is to use Win2USB to install Windows 10 on external USB and setup UEFI partition and finish Windows driver e.g. Boot Camp driver and for the USB stick successfully.
The necessary software downloads links are in previous post
2. Use IM Magic Partition Resizer (Windows software) to shrink the USB stick Win2USB partition so that it can install Ubuntu iso and persistence data. This partition action can be performed in the booted up Windows USB stick, however, it is more safe to use another Windows machine. Create one FAT32 partition to keep the Ubuntu 18.04 iso file (say 10Gb in case to add more later) in Windows. Another 2 partitions for the Ubuntu ext4 say 50Gb each, which will be done when booting into Ubuntu non-persistence later. After that download the Ubuntu 18.04 desktop image to the new partition that was created, the file ubuntu-18.04.4-desktop-amd64.iso is to be renamed as ubuntu-18.04.4.iso
3. Download and Install grub-2.02-for-windows (not the latest version) in another Windows machine that is not the usb stick which is going to add installation of Ubuntu
4. Assume E drive is the UEFI partition for the USB Stick plugged in. Not the WinToUSB partition that has been installed Windows 10.
5. Install Grub2 for Windows (command reference from https://www.aioboot.com/en/install-grub2-from-windows/) amd Run Command Prompt under Admin
cd C:\Users\%USERNAME%\Downloads\grub-2.02-for-windows\grub-2.02-for-windows
grub-install.exe --boot-directory=E:\ --efi-directory=E: --removable --target=x86_64-efi
6. Create E:\grub\grub.cfg plus menuentry as below
- notepad E:\grub\grub.cfg Select all
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
load_env
fi
if [ "${next_entry}" ] ; then
set default="${next_entry}"
set next_entry=
save_env next_entry
set boot_once=true
else
set default="0"
fi
if [ x"${feature_menuentry_id}" = xy ]; then
menuentry_id_option="--id"
else
menuentry_id_option=""
fi
export menuentry_id_option
if [ "${prev_saved_entry}" ]; then
set saved_entry="${prev_saved_entry}"
save_env saved_entry
set prev_saved_entry=
save_env prev_saved_entry
set boot_once=true
fi
function savedefault {
if [ -z "${boot_once}" ]; then
saved_entry="${chosen}"
save_env saved_entry
fi
}
function load_video {
if [ x$feature_all_video_module = xy ]; then
insmod all_video
else
insmod efi_gop
insmod efi_uga
insmod ieee1275_fb
insmod vbe
insmod vga
insmod video_bochs
insmod video_cirrus
fi
}
if [ x$feature_default_font_path = xy ] ; then
font=unicode
else
font="${prefix}/fonts/unicode.pf2"
fi
#larger font size for Retina Display
#font="${prefix}/fonts/DejaVuSansMono.pf2"
if loadfont $font ; then
#set gfxmode=1024x768x32,1024x768x24,1024x768x16,1024x768,auto
#set gfxpayload=keep
load_video
insmod gfxterm
#insmod png
terminal_output gfxterm
#background_image -m stretch $prefix/themes/splash.png
fi
if [ x$feature_timeout_style = xy ] ; then
set timeout_style=menu
set timeout=15
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
set timeout=15
fi
### END /etc/grub.d/00_header ###
### BEGIN /etc/grub.d/10_linux ###
### END /etc/grub.d/10_linux ###
### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###
### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###
### 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.
### END /etc/grub.d/40_custom ###
### BEGIN /etc/grub.d/41_custom ###
if [ -f ${config_directory}/custom.cfg ]; then
source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###
menuentry "Windows 10 Pro Boot Camp" {
# UEFI - MBR method
# set uuid="0000-XXXX"
# search --fs-uuid --no-floppy --set=root $uuid
# In Linux, you can find UUID by using : sudo blkid /dev/sda?
# (hd0,1) means /dev/sda1 change it to (hd0,2) or (hd0,3) as necessary
# This should be the partition of System Boot Partition
set root=(hd0,1)
chainloader (${root})/EFI/Microsoft/Boot/bootmgfw.efi
}
menuentry "Ubuntu 18.04 persistent" {
set isofile="/ubuntu-18.04.4.iso"
insmod ntfs
# In Linux, you can find UUID by using : sudo blkid /dev/sda?
# set uuid="0000-XXXX"
# search --fs-uuid --no-floppy --set=root $uuid
# loopback loop (${root})${isofile}
# (hd0,3) means /dev/sda3 change it to (hd0,2) or (hd0,4) as necessary
# This should be the partition of the ubuntu ISO
loopback loop (hd0,3)${isofile}
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=${isofile} persistent quiet splash
initrd (loop)/casper/initrd
}
menuentry "Ubuntu 18.04 non-persistent Live Session" {
set isofile="/ubuntu-18.04.4.iso"
insmod ntfs
# In Linux, you can find UUID by using : sudo blkid /dev/sda?
# set uuid="0000-XXXX"
# search --fs-uuid --no-floppy --set=root $uuid
# loopback loop (${root})${isofile}
# (hd0,3) means /dev/sda3 change it to (hd0,2) or (hd0,4) as necessary
# This should be the partition of the ubuntu ISO
loopback loop (hd0,3)${isofile}
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=${isofile} quiet splash
initrd (loop)/casper/initrd
}
menuentry "Restart" {
reboot
}
menuentry "Power Off" {
halt
}
7. Boot into the USB, running on non-persistence and create the partitions for Ubuntu persistence
- shell script Select all
# Running on Ubuntu non-persistence
sudo fdisk -l
#assume /dev/sda is the USB stick
sudo fdisk /dev/sda
# (n) (p) (4) to recreate primary partition 4 for Linux in fdisk
# (n) (5) to recreate logical partition 5 for Linux in fdisk
# (w) to write to partition table and quit fdisk
# Reboot to let partition table effective
8. Boot into the USB again, running on non-persistence and create format the partitions for Ubuntu persistence
- shell script Select all
# Running on Ubuntu non-persistence
# check the disk device and assume the two partitions of Linux are sda4 and sda5
sudo fdisk -l
# format the second partition with label persistence and add persistence.conf
sudo mkfs.ext4 -L persistence /dev/sda4
sudo mkdir -p /media/ubuntu/persistence
sudo mount /dev/sda4 /media/ubuntu/persistence
echo / union | sudo tee /media/ubuntu/persistence/persistence.conf
# format the third partition with label casper-rw
sudo mkfs.ext4 -L casper-rw /dev/sda5
# Reboot to start other configuration and installation
9. Reboot USB stick and choose grub2 menu "Windows 10 Pro Boot Camp" and "Ubuntu 18.04 persistent" for testing and further installations
10. The final USB stick partitions are
/dev/sda1 /media/ubuntu/UUID-XXXX (Windows E Drive FAT32 for EFI Boot and Grub2)
/dev/sda2 /media/ubuntu/WinToUSB (Windows F Drive NTFS primary partition for Windows 10)
/dev/sda3 /isodevice (Windows G Drive FAT32 Extended Partition for iso images)
/dev/sda4 /media/ubuntu/persistence (Linux ext4 primary partition for Ubuntu)
/dev/sda5 /media/ubuntu/casper-rw (Linux ext4 primary partition for Ubuntu)
It should be noted that UEFI MBR can only create maximum 4 primary partitions whereas UEFI GPT has no such limit. If for MBR the last partition /dev/sda5 can be logical in Ubuntu. There is no difference when using logical partition in Ubuntu.
11. For Retina Mac with very tiny size grub menu display, the solution is to create a larger font say 48 dpi for grub menu and enable it in grub.cfg
Please take note that Ubuntu 18.04 started to have better kernel support for MacBook Retina Display, Keyboard and TrackPad.
# Install truetype font in Ubuntu
sudo apt-get install grub2
sudo apt-get install fonts-dejavu and fonts-dejavu-core
# Create font size 48
sudo grub-mkfont -s 48 -o /media/ubuntu/UUID-5637/grub/fonts/DejaVuSansMono.pf2 /usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf
# Edit and uncomment the grub.cfg file for the use of new font DejaVuSansMono.pf2
The converted font DejaVuSansMono.pf2 with font size 48 can also be downloaded here
No comments:
Post a Comment