Easiest way is with Grub
It is cumbersome controlling grub
from Windows. A third party application to access Ubuntu from Windows and some hacking is required. However from the top part of this post: How to change the order on my dual booting distros, you can setup grub
to automatically reboot to the last menu option. So when you initially boot with windows, and it wakes up at 2 am to run updates, grub
will reload Windows so it can gracefully finish updates.
When you manually reboot and pick Ubuntu from grub
all your next reboots automatically load Ubuntu. This feature works equally well if you have bugs in the current kernel and want grub
to automatically reboot into an older kernel version you selected.
How to get Grub to repeat last boot selection
This is fairly straight forward. Using sudo
powers edit /etc/default/grub
and change the following:
#GRUB_DEFAULT=0 # Rather than option #1, we'll always default to last boot choice.
GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
The first line you will be commenting out and right below that insert the next two lines.
Save the file and type in the terminal:
sudo update-grub
Ubuntu command line to reboot into Windows
Currently you use something like this:
sudo grub-reboot x # Where x is Windows zero-based grub menu number
sudo reboot now
From this modified Stack Exchange answer you can use the grub default to reboot into Windows. Copy this code into your ~/.bashrc
file:
function reboot-to-windows {
WINDOWS_TITLE=`grep -i "^menuentry 'Windows" /boot/grub/grub.cfg|head -n 1|cut -d"'" -f2`
sudo grub-set-default "$WINDOWS_TITLE"
sudo reboot
}
- Save the
~/.bashrc
file with new reboot-to-windows
function.
- Close your current terminal session.
- Open a new terminal session for changed
~/.bashrc
to be loaded.
- You could type
: ~/.bashrc
to reload it into the existing terminal session but some people recommend against do this.
To reboot into Windows from the command line use:
reboot-to-windows
If Windows automatically restarts when you aren't looking, Windows is rebooted. This allows Windows automatic updates to be processed normally over multiple-reboot cycles Windows sometimes uses.
Best Answer
Part 1 - Creating the installation media
3rd party installation media creation tools like Unetbootin are not creating the USB installation media properly in many cases. A tool to create a correctly working installation media is GNOME Disks, it's available in the repositories of nearly every Linux distribution.
Open Disks - select Restore Disk Image from the menu on the top right.
Choose the ISO file and the USB drive to write it to, then start restoring.
In case you have no access to a Linux operating system and have to do it from within Windows, you can create the installation media with the
diskpart
tool from a running Windows system.Open Command prompt as administrator and execute :
Note : * = number of USB drive | ** = select a free drive letter
Now mount the ISO file and copy the content to the USB disk.
Part 2 - Reinstalling the GRUB boot loader
Boot from the Ubuntu installation media - select the option Try Ubuntu without installing.
Once you are on the Live desktop ... open a terminal and execute the following commands.
Important information concerning the USB boot options :
Choose the USB entry with UEFI in front, in case the systems are installed in EFI mode and
the USB entry without UEFI in front, in case the systems are installed in legacy BIOS mode.
In case your computer has UEFI BIOS execute these commands :
Note :
sdX
= disk |sdXX
= EFI partition |sdXXX
= system partitionIn case your computer has legacy BIOS execute these commands :
Note :
sdX
= disk |sdXX
= system partitionYou can identify disk and partition numbers by using GParted (included in the installation media).
Additional information : Do not forget to disable hibernation and Fast startup in Windows !
Then shutdown the PC completely, do NOT restart - otherwise it will always start Windows.