Linux - Dual boot Windows and Linux

Tags Linux Ubuntu

Issue/Question

  • How do I dual boot linux and windows on my machine?
  • I have windows and want linux also.
  • I have linux and want windows also.

Environment

  • A laptop that is not apple brand.

Resolution

Windows already installed

Things needed before starting:

  • Linux usb
  • Windows PC
  1. Log in to Windows
  2. Launch Disk Management
  3. Shrink the large partition where the Windows operating system is stored enough so that the linux operating system can fit plus extra. (probably the OS (C:) partition) by right-clicking and hitting Shrink Volume
  4. Leave the unallocated space alone.
  5. Log out of windows.
  6. Launch the linux usb to install linux
  7. Choose the unallocated space to install in
  8. Install the linux OS
  9. Unplug the usb and turn on the computer
  10. If Grub appears and shows and entry for linux and windows boot manager you are good to go. If not proceed
  11. Launch into linux
  12. Open a terminal and do sudo os-probe
  13. Then sudo grub-update
  14. This will add the windows boot manager entry to grub.
  15. Restart and the windows option should be there.

Linux already installed

  • Windows install usb
  • Linux live usb
  • Laptop with linux installed.
  1. Boot into the linux live usb
  2. launch gparted by opening a terminal a do sudo -i gparted
  3. Unmount the main partition (the big one) by right clicking and hitting unmount (or something similar)
  4. Right click the partition and hit resize
  5. Move the slider to the left until you have enough space for windows plus extra space
  6. Hit ok
  7. Hit the green check mark to apply
  8. Select the newly appeared unallocated partition and right click and hit new partition
  9. Format as NTFS using the entire unallocated partition
  10. Hit ok
  11. Hit the green check-mark
  12. Shut down the computer
  13. Launch the windows installer
  14. Install
  15. Custom windows install
  16. Select the new partition you would like to install windows on to that we just created (probably the bottom partition)
  17. Install windows
  18. Restart the computer and go in to the system boot menu
  19. Check the boot options. If there is an ubuntu/linux option set that as default/priority
    if not, add a new boot option that points to \EFI\ubuntu\grubx64.efi or something similar. It will be under EFI.
  20. Restart.
  21. If the windows boot manager entry is in grub you are done, if not, continue.
  22. Open a terminal and do sudo os-probe then sudo grub-update
  23. Restart the computer.
  24. There should be a windows boot manager entry now.

Dual-Boot Windows and Linux in AD

Normally Linux PCs are not enrolled in AD and managed in this way, but for Linux labs, and other areas where many many users would be using it (say, anyone in ONID) this would be ideal.

Follow the enrollment step in Linux Standard Build under "Join ONID Domain" once done and after verifying with the 'id' command that it lists your ONID account it will be set to proceed.

If you need to add a Windows half of a dual boot to AD, follow the below naming convention for the latter half of the device.  (Cosine standard)
OSOS# = Dual-boot
OS#OS = VM

Examples of this are STAG060-UNIXPC1 or STAG060-PCUNIX1.  Alternatively, a VM would be STAG060-UNIX1PC if it is enrolled in AD and a Windows 10 Virtual Machine.

If GRUB fails, and Linux/Windows won't boot

  • GRUB will point to existing areas where OS boot entries are located, offering a menu when booting
    • This can be Linux entries, or Linux + Windows, Linux + Mac OS X, etc
  • If something happens to GRUB you may not be able to boot normally since it cannot find valid entries to boot from
  • There's a GUI (Graphical) method and a command line method below:
  1. Boot into a Linux live-boot CD/USB.
  2. Click "Try Linux" (or "Try Ubuntu") option to boot into Linux live-boot environment.
  3.  Add boot-repair to repository:  sudo apt-add-repository ppa:yannubuntu/boot-repair
  4. Update apt repositories and install:  sudo apt-get update && sudo apt-get install -y boot-repair
  5. Run boot-repair:  boot-repair
  6. Avoid advanced options and instead opt for the recommended repair options.  (this covers and fixes most common issues that prevent booting into Windows and Linux.
  7. Follow the prompts, if asked to copy-paste commands into a terminal window, follow the steps given.

 

  1. Live-boot into Linux USB and "Try Ubuntu" (or "Try Linux")
  2. Launch terminal window and run the following commands:  sudo fdisk -l  sudo blkid
    1. This will show entries in terminal window that show device blocks (/dev/sda or /dev/sdb, etc) 
    2. blkid grabs the UUID entry for the partition, which may be needed for following steps.

       
  3. mount the ubuntu partition after making a directory to mount it to.
    1. sudo mkdir /mnt/ubuntu
    2. sudo mount /dev/sdX# /mnt/ubuntu
      1. X is replaced by an alphabetical letter for the partition found in fdisk  (ex.  /dev/sda1)
      2. If your boot partition is separated from OS drive, mount on /mnt/ubuntu/boot instead.
    3. run following command to install GRUB from live-boot USB:  sudo grub-install --boot-directory=/mnt/ubuntu/boot /dev/sdX
  • After performing the above steps (GUI or command-line) you can restart and should see the familiar GRUB menu and be able to boot properly.
    [ source ]

Details

Article ID: 86778
Created
Thu 9/12/19 3:02 PM
Modified
Fri 6/3/22 2:52 PM