Link to restart from Windows to Ubuntu
I have standard dual-boot system: Ubuntu and Windows. Grub is configured to launch Windows by default.
Is there a way to create some kind of link in Windows, that would:
- restart Windows
- boot into Ubuntu
Solution 1:
You don't need to modify /boot/grub/grub.cfg
like Michal Hagara suggested. This could break Ubuntu if you install a new kernel and doesn't update the e:\home\user\Grubshift\ubuntudefault\grub.cfg
.
All you need to do is to create/copy a file /boot/grub/grubenv
with following content
# GRUB Environment Block
next_entry=2
###########################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################
Where next_entry
is the line of the next grub menu entry which should be started next time (starting from zero). So next_entry=2
would be the 3th line.
Grub will automatically remove the value after boot so next time you'll boot into your default OS again.
This is how grub-reboot
works.
Solution 2:
Here is what I have in mind:
- http://www.ext2fsd.com/ (it should be capable of writing to EXT partition, "mounting" and assigning letter on boot)
- then I would prepare modified GRUB file, where Ubuntu is set as Default OS (this one would be stored on Linux partition too)
- Windows BATCH script (executed by your desired shortcut) which would:
- Backup OLD GRUB (Windows as default)
- copy modified GRUB (default is Ubuntu) over OLD one (Default is Windows)
- Restart PC
- Linux BASH script which would modify and update GRUB on startup (or reboot) to set back Windows as default OS
I can be completely wrong with this approach, but I can't see, why it shouldn't work.
EDIT:
And also there is: http://www.paragon-drivers.com/extfs-windows/ which I have never tried.
PROGRESS
1.Shortcut to restart Windows and boot Ubuntu
OK, down side of this is we will have to modify grub.cfg (/boot/grub/grub.cfg) directly (it is advised against - https://askubuntu.com/a/437341/402801),because there is no way to run update-grub
from Windows... if you can live with that read further.
- As I have mentioned before, install Ext2Fsd, make it auto-mount and assign letter on startup
- I have created my "Backup folder" in
/home/user/Grubshift
with 3 sub directories: backup (for backing up actual /boot/grub/grub.cfg), ubuntudefault (for storing grub.cfg with Ubuntu as default), windowsdefault (you've got the idea)
After installation, Ubuntu is set as default, so copy that grub.cfg
to your desired directory. I've got "Windows as default" config by modifying GRUB via grub-customizer (it's safer in my opinion), after that copy Windows grub.cfg
to your desired directory
After that, open notepad and insert:
copy e:\boot\grub\grub.cfg /y e:\home\user\Grubshift\backup
copy e:\home\user\Grubshift\ubuntudefault\grub.cfg /y e:\boot\grub
shutdown /r /t 0
/y
- option of copy
command, suppresses prompting to confirm you want to overwrite an existing destination file
/r /t 0
- options of shutdown, 1. means reboot, 2. means immediately, without ugly messages popping up
Modify the path accordingly !!!
- Save that file (I've used UTF-8) and change extension to
*.bat
- Create Desktop shortcut for
shift.bat
, right click on shorctur --> properties--> shortcut tab --> Run:minimized (that will get rid of CMD popping up)
I have tried this at least 8 times, setting Windows as default
with grub-customizer
...
I'm not saying it's safe, but HEY!, we are messing with bootloader... that isn't safe
When it's fully working, we can get rid of GRUB menu completely, because it will always boot into right OS...
Solution 3:
Here's how I've set up my configuration:
To sum it up: System reboots default to last active, reboots from windows to linux and vice versa using a simple script.
Set up grub to always boot last selected:
Under linux:
- enter
GRUB_DEFAULT=saved
andGRUB_SAVEDEFAULT=true
in /etc/default/grub - update config using
sudo update-grub
Install Paragons extfs driver
see http://www.paragon-drivers.com/extfs-windows/
Create reboot-scripts:
If /boot/grub/grubenv doesn't exist, create it using the answer from Germar
Batch-file for reboot from windows to linux:
@echo off
"C:\Program Files (x86)\Paragon Software\ExtFS for Windows\extmounter" /mount disk1 L:
:CheckForFile
IF EXIST "L:\boot\grub\grubenv" GOTO FoundIt
GOTO CheckForFile
:FoundIt
sed -i -e '/next_entry/c\next_entry=0' L:/boot/grub/grubenv
"C:\Program Files (x86)\Paragon Software\ExtFS for Windows\extmounter" /umount disk1 L:
echo press enter to reboot
pause
shutdown -r -t 00
- replace
/mount disk1 L:
with something specific to your system. You can find available disks using theextmounter /list
command and the drive letter. Also,L:
must not be already taken. - save it as e.g.
reboot-linux.bat
- you can right-click on bat and select
run as administrator
to execute it
Shell script for reboot from linux to windows:
sudo sed -i -e '/next_entry/c\next_entry=2' /boot/grub/grubenv
sudo reboot
- replace
next_entry=2
with whatever your windows entry is. - save it as e.g.
~/reboot_windows
and mark as executable:chmod +x ~/reboot_windows