Announcement

Collapse
No announcement yet.

Dual-booting Kubuntu on a Windows machine

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Dual-booting Kubuntu on a Windows machine

    Because it's a common scenario, I am going to document a step-by-step process for setting up a Windows machine to dual-boot Kubuntu. Specifics of this walkthrough are:
    • A Lenovo ThinkPad X1 with Intel HD 3000 graphics
    • Booting in UEFI mode only -- no BIOS compatibility
    • Secure Boot is disabled in the firmware settings
    • A completely blank hard drive
    • No pre-existing UEFI NVRAM variables for prior operating system boot loaders
    • Windows 8.1 installed first, followed by Kubuntu 14.04 Trusty Tahir

    Because I think it's an interesting procedure, I will add subsequent posts to this thread as I complete the various steps.



    NOTE. For the purposes of documenting epxected results, I've intentionally begun this procedure with a completely clean machine. I wanted to examine how Windows configures partitions and the UEFI when it had nothing else to contend with on the machine. I suspect most readers of this thread will want to configure dual-boot on a machine that already has Windows installed; in such a case, some of the foreboding-looking steps here are unnecessary. You should begin your work with Part 3. Necessary Windows configuration procedures, documented in post #4 in this thread.
    Last edited by SteveRiley; Aug 14, 2014, 11:29 PM.

    #2
    Part 1. Creating a bootable Windows USB drive

    I have downloaded the Windows 8.1 ISO from Microsoft TechNet using my subscription. The ISO contains a UDF filesystem. The following steps create a bootable USB that will properly boot a UEFI machine into UEFI mode for subsequent install. It will not boot a BIOS machine or a UEFI machine in BIOS compatibility mode.

    1. Mount the ISO:
    Code:
    sudo mount -t udf -o loop,ro,unhide /path/to/file.iso /mnt
    2. Insert the USB drive.

    3. Run fdisk and specify the device name of the USB drive; for example:
    Code:
    sudo fdisk /dev/sdc
    4. Delete any existing partition table and create a new one.

    5. Create a new partition of at least 4.5 GB. Mark it bootable and set its type to 7 (HPFS/NTFS/ExFAT).

    6. Write changes and exit fdisk.

    7. Create a FAT-32 file system in the new partition; for example:
    Code:
    sudo mkfs.vfat -F 32 /dev/sdc1
    8. Mount this partition to an existing subdirectory; for example:
    Code:
    sudo mount /dev/sdc1 /media/usbstick
    9. Copy all of the files from the mounted ISO into this directory:
    Code:
    sudo cp -rv /mnt/* /media/usbstick
    10. Sync the file systems just to be sure:
    Code:
    sudo sync
    11. Unmount both items previously mounted:
    Code:
    sudo umount /media/usbstick
    sudo umount /mnt
    Last edited by SteveRiley; Aug 14, 2014, 11:28 PM.

    Comment


      #3
      Part 2. Installing Windows

      1. Insert the USB drive. Start the computer, interrupt the boot sequence, and boot from the USB drive.

      2. The windows installer will start. When prompted, enter the 25-character license key. Accept the license terms (without reading, of course -- does anyone?). Choose Custom install. Remove all existing partitions so that all you see is "Drive 0 Unallocated Space." Don't create any partitions; let the installer do its default stuff.

      3. Wait. Wait some more. Go have a gin tonic. Have another one. Have a third -- no one will notice!

      4. Eventually, the installer reboots the system and then spends some time "getting ready."

      5. One more reboot, and it's time to finish the usual post-install stuff -- system name, network connection, etc. I will be customizing the settings to send minimal information to Microsoft.

      6. To avoid automatically signing into an account when Windows boots:
      • Click Create a new account underneath "Don't have an account?" on the "Sign in to your Microosft account" screen.
      • Click Sign in without a Microsoft account on the "Create a Microsoft account" screen.
      • Enter a local user name and password on the "Your account" screen.

      7. Windows installation is now complete, and the desktop will appear. There's a semi-Start button in Windows 8.1!

      Partition and volume information follows.
      Code:
      C:\Windows\system32> [b]diskpart[/b]
      Microsoft DiskPart version 6.3.9600
      On computer: X1
      
      DISKPART> [b]select disk 0[/b]
      
      Disk 0 is now the selected disk.
      
      DISKPART> [b]list partition[/b]
      
        Partition ###  Type              Size     Offset
        -------------  ----------------  -------  -------
        Partition 1    Recovery           300 MB  1024 MB
        Partition 2    System              99 MB   301 MB
        Partition 3    Reserved           128 MB   400 MB
        Partition 4    Primary            148 GB   528 MB
      
      DISKPART> [b]list volume[/b]
      
        Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
        ----------  ---  -----------  -----  ----------  -------  ---------  --------
        Volume 0     C                NTFS   Partition    148 GB  Healthy    Boot
        Volume 1         Recovery     NTFS   Partition    300 MB  Healthy    Hidden
        Volume 2                      FAT32  Partition     99 MB  Healthy    System

      Interpreting the above. Partitions are numbered in the order they're physically allocated on the disk. Volumes are not.
      • Partition 1 corresponds to Volume 1. It is visible in the Disk Management utilty but doesn't have a drive letter. It contains the Windows Recovery Environment -- to repair or reinstall the operating system without installation media.
      • Partition 2 corresponds to Volume 2. It is visible in the Disk Management utility but doesn't have a drive letter. It's the EFI system partition required for booting any UFEI-based machine into UEFI mode. As of now, it contains only the Windows boot loader.
      • Partition 3 does not contain a normal file system volume. It is not visible in the Disk Management utility. It's used to boot the system in an emergency; if you want to rebuild the system, that process will use files from partition 1.
      • Partition 4 corresponds to Volume 0. It is visibile in the Disk Management utility. It is the traditional NTFS-formatted C: drive.


      Examining the EFI partition contents. Contents of the Windows EFI system partition are as follows. (Language subdirectories and fonts are omitted. Also, I'm mounting the EFI partition on drive letter Z:.)
      Code:
      C:\Windows\system32> [b]mountvol z: /s[/b]
      
      C:\Windows\system32> [b]tree z: /f /a[/b]
      Folder PATH listing
      Volume serial number is 00000011 B4C3:517B
      Z:\
      \---EFI
          +---Microsoft
          |   \---Boot
          |       |   BCD
          |       |   boot.stl
          |       |   bootmgfw.efi
          |       |   bootmgr.efi
          |       |   memtest.efi
          |       |   
          |       +---{...snip language subdirectories...}
          |       |       
          |       +---Fonts
          |       |       {...snip font files...}
          |       |       
          |       \---Resources
          |           |   bootres.dll
          |           |   
          |           \---{...snip language subdirectories...}
          |                   
          \---Boot
                  bootx64.efi
      My X1 has a rudimentary EFI boot manager in the firmware, which I can activate by pressing F12 early during startup. Only two options are available currently:
      • Windows Boot Manager
      • ATA HDD0: INTEL SSDSA2M160G2GC

      The first points to \EFI\Microsoft\Boot\bootmgfw.efi. The second appears because \EFI\Boot\bootx64.efi is present; the UEFI standard will default to a so-named boot loader automatically if no other boot loaders are present on the system. In a default Windows install, this file is the same as bootmgfw.efi.
      Last edited by SteveRiley; Aug 14, 2014, 11:29 PM.

      Comment


        #4
        Part 3. Necessary Windows configuration procedures

        For the sake of completeness, I am running Windows Update enough times to ensure the system has all relevant drivers and patches. After this, it's necessary to fix two things to make Windows and Linux happier together.


        Disable fast startup. This feature makes dual boot nearly impossible to use effectively, because it's a form of hibernation. It needs to be disabled.

        1. Go to Control Panel -> Power Options.

        2. Click Choose what the power buttons do, then click Change settings that are currently unavailable.

        3. In the "Shutdown settings" section, deselect Turn on fast startup. Click Save changes.


        Fix the contentious clock. Windows wants to set the hardware clock to whatever your local time is, while Linux wants to use Coordinated Universal Time. A registry key can change this behavior, and has been reported to be buggy -- however, I'm not aware of any problems. But in Windows 8 and above, the system's time service will write the local time to the hardware clock regardless of the registry setting. You should disable this.

        1. Your clock is probably not correct now. So click the clock and set the correct local time for your time zone.

        2. Apply the registry setting for using UTC in the hardware clock.
        1. Press Win+R and run regedit.
        2. Navigate to
          Code:
          HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation
        3. Create a 32-bit DWORD called RealTimeIsUniversal and set the value to 1.

        3. Disable the time service.
        1. Open an elevated command prompt: Press Win, type command, right-click the resulting Command Prompt item, and chose Run as administrator. Click Yes in the consent dialog.
        2. To stop the service from running at boot, enter the following. Yes, you need the space after start=.
          Code:
          sc config w32time start= disabled
        3. Enter exit to, well, exit the command prompt.

        4. Reboot the computer into your firmware settings menu. Set the clock to the current UTC. Reboot once more. Windows will display your local time and no longer mess with the hardware clock.
        Last edited by SteveRiley; Aug 14, 2014, 11:29 PM.

        Comment


          #5
          Part 4. Installing Kubuntu

          Despite my preferences for not using Ubiquity (the graphical installer) and for replacing GRUB with rEFInd, I will not do that here. Instead, I'll attempt a vanilla install. If it shows any signs of not working, I will revert to my preferred methods. Starting now...!

          Well, the guided installer proposes shrinking my NTFS partition and creating space for "Kubuntu (auto)." Grr. Why not tell me what "auto" means? Will I end up with a single EXT4 partition? Or an EXT4 partition plus a swap partition? Dunno, grr. I will accept this choice to see what happens.



          The installation finished. Upon boot, GRUB presents the following options:
          • Ubuntu
          • Advanced options for Ubuntu
          • Windows Boot Manager (on /dev/sda2)

          GRUB tells us that the Windows Boot Manager is on /dev/sda2 because that's the system's EFI partition. The "Advanced" choice returns another menu containing the Linux kernels that GRUB knows about. So I will select the first option. Kubuntu starts as one would expect. Time for some exploring.


          Install tools. PastebinIt to easily capture outputs, view them in a web browser on my T520 (upon which I'm typing this), and copy/paste to the forum. Tree for useful directory displays.
          Code:
          steve@x1:~$ [B]sudo apt-get install pastebinit tree[/B]

          Examine the UEFI NVRAM variables. Note that Ubiquity and GRUB are doing what they should: an entry for Ubuntu is added (Boot0014) and it is set as the first item in BootOrder.
          Code:
          steve@x1:~$: [B]sudo efibootmgr -v[/B]
          BootCurrent: 0014
          Timeout: 0 seconds
          BootOrder: 0014,0013,0006,0007,000A,0009,000C,0008,000D
          Boot0000  Setup	
          Boot0001  Boot Menu	
          Boot0002  Diagnostic Splash Screen	
          Boot0003  Startup Interrupt Menu	
          Boot0004  ME Configuration Menu	
          Boot0005  Rescue and Recovery	
          Boot0006* USB CD	030a2400d23878bc820f604d8316c068ee79d25b86701296aa5a7848b66cd49dd3ba6a55
          Boot0007* USB FDD	030a2400d23878bc820f604d8316c068ee79d25b6ff015a28830b543a8b8641009461e49
          Boot0008* ATA HDD2	030a2500d23878bc820f604d8316c068ee79d25b91af625956449f41a7b91f4f892ab0f602
          Boot0009* ATA HDD0	030a2500d23878bc820f604d8316c068ee79d25b91af625956449f41a7b91f4f892ab0f600
          Boot000A* USB HDD	030a2400d23878bc820f604d8316c068ee79d25b33e821aaaf33bc4789bd419f88c50803
          Boot000B* PCI LAN	030a2400d23878bc820f604d8316c068ee79d25b78a84aaf2b2afc4ea79cf5cc8f3d3803
          Boot000C* ATAPI CD1	030a2500d23878bc820f604d8316c068ee79d25baea2090adfde214e8b3a5e471856a35403
          Boot000D* ATA HDD3	030a2500d23878bc820f604d8316c068ee79d25b91af625956449f41a7b91f4f892ab0f603
          Boot000E* IDER BOOT CDROM	ACPI(a0341d0,0)PCI(16,2)ATAPI(0,1,0)
          Boot000F* IDER BOOT Floppy	ACPI(a0341d0,0)PCI(16,2)ATAPI(0,0,0)
          Boot0010* ATA HDD	030a2400d23878bc820f604d8316c068ee79d25b91af625956449f41a7b91f4f892ab0f6
          Boot0011* ATAPI CD:	030a2400d23878bc820f604d8316c068ee79d25baea2090adfde214e8b3a5e471856a354
          Boot0012* PCI LAN	030a2400d23878bc820f604d8316c068ee79d25b78a84aaf2b2afc4ea79cf5cc8f3d3803
          Boot0013* Windows Boot Manager	HD(2,96800,31800,23013f90-a8a2-4f70-969f-21ee2e529d94)File(\EFI\Microsoft\Boot\bootmgfw.efi)WINDOWS.........x...B.C.D.O.B.J.E.C.T.=.{.9.d.e.a.8.6.2.c.-.5.c.d.d.-.4.e.7.0.-.a.c.c.1.-.f.3.2.b.3.4.4.d.4.7.9.5.}...3................
          Boot0014* ubuntu	HD(2,96800,31800,23013f90-a8a2-4f70-969f-21ee2e529d94)File(\EFI\ubuntu\shimx64.efi)

          Examine the EFI partition contents. Again, language and font files are snipped. Note the additional directory for Kubuntu (called ubuntu); it contains the shim loader for Secure Boot and the boot loader for GRUB. The shim boot loader automatically chainloads the operating system's "normal" boot loader. And even though I've disabled Secure Boot on my system, the installer still plumbs it into the UEFI NVRAM and onto the drive in case I decide to enable Secure Boot later.
          Code:
          steve@x1:~$ [B]tree -R --dirsfirst /boot/efi[/B]
          /boot/efi
          └── EFI
              ├── Boot
              │   └── bootx64.efi
              ├── Microsoft
              │   └── Boot
              │       ├── {...snip language subdirectories...}
              │       ├── {...snip font files...}
              │       ├── Resources
              │       │   ├── {...snip language subdirectories...}
              │       │   └── bootres.dll
              │       ├── BCD
              │       ├── BCD.LOG
              │       ├── BCD.LOG1
              │       ├── BCD.LOG2
              │       ├── bootmgfw.efi
              │       ├── bootmgr.efi
              │       ├── BOOTSTAT.DAT
              │       ├── boot.stl
              │       └── memtest.efi
              └── ubuntu
                  ├── grub.cfg
                  ├── grubx64.efi
                  ├── MokManager.efi
                  └── shimx64.efi
          
          44 directories, 128 files

          Examine the partition layout and filesystems. Ubiquity shrank my NTFS partition to 82 GB, placed an 8 GB partition at the end of the drive (likely because my system has 8 GB RAM -- when swap = RAM, you can hibernate), and used the remaining intervening space for a single EXT4 partition. That's actually a quite logical approach.
          Code:
          steve@x1:~$ [b]sudo gdisk -l /dev/sda[/b]
          GPT fdisk (gdisk) version 0.8.8
          
          Partition table scan:
            MBR: protective
            BSD: not present
            APM: not present
            GPT: present
          
          Found valid GPT with protective MBR; using GPT.
          Disk /dev/sda: 312581808 sectors, 149.1 GiB
          Logical sector size: 512 bytes
          Disk identifier (GUID): B487C870-98B4-46B5-B40D-4EEBE8DAA78B
          Partition table holds up to 128 entries
          First usable sector is 34, last usable sector is 312581774
          Partitions will be aligned on 2048-sector boundaries
          Total free space is 4277 sectors (2.1 MiB)
          
          Number  Start (sector)    End (sector)  Size       Code  Name
             1            2048          616447   300.0 MiB   2700  Basic data partition
             2          616448          819199   99.0 MiB    EF00  EFI system partition
             3          819200         1081343   128.0 MiB   0C01  Microsoft reserved part
             4         1081344       172987831   82.0 GiB    0700  Basic data partition
             5       172988416       296044543   58.7 GiB    8300  
             6       296044544       312580095   7.9 GiB     8200  
          
          
          steve@x1:~$ [B]sudo parted -l /dev/sda[/B]
          Model: ATA INTEL SSDSA2M160 (scsi)
          Disk /dev/sda: 160GB
          Sector size (logical/physical): 512B/512B
          Partition Table: gpt
          
          Number  Start   End     Size    File system     Name                          Flags
           1      1049kB  316MB   315MB   ntfs            Basic data partition          hidden, diag
           2      316MB   419MB   104MB   fat32           EFI system partition          boot
           3      419MB   554MB   134MB                   Microsoft reserved partition  msftres
           4      554MB   88.6GB  88.0GB  ntfs            Basic data partition          msftdata
           5      88.6GB  152GB   63.0GB  ext4
           6      152GB   160GB   8466MB  linux-swap(v1)



          Well, that was reasonably uneventful -- everything just worked. Either the goofiness in GRUB and Ubiquity have been fixed, or the scenario is on the simple side. I'm inclined to think the latter -- after all, this is not an OEM installation of Windows, which usually adds a wrinkle or two, and I'm not dealing with a zillion partitions like many of you fine folk here seem to be in love with. But it's good to see that my results were positive.
          Last edited by SteveRiley; Aug 14, 2014, 11:30 PM.

          Comment


            #6
            Part 5. Verifying that Windows still works

            What happens when I select "Windows Boot Manager" in GRUB's menu? Let's find out!

            Windows works exactly as expected. Whew. Let's at least see what Windows thinks about these new partitions.
            Code:
            C:\Windows\system32> [B]diskpart[/B]
            Microsoft DiskPart version 6.3.9600
            On computer: X1
            
            DISKPART> [B]select disk 0[/B]
            
            Disk 0 is now the selected disk.
            
            DISKPART> [B]list partition[/B]
            
              Partition ###  Type              Size     Offset
              -------------  ----------------  -------  -------
              Partition 1    Recovery           300 MB  1024 MB
              Partition 2    System              99 MB   301 MB
              Partition 3    Reserved           128 MB   400 MB
              Partition 4    Primary             81 GB   528 MB
              Partition 5    Unknown             58 GB    82 GB
              Partition 6    Unknown           8074 MB   141 GB
            
            DISKPART> [B]list volume[/B]
            
              Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
              ----------  ---  -----------  -----  ----------  -------  ---------  --------
              Volume 0     C                NTFS   Partition    148 GB  Healthy    Boot
              Volume 1         Recovery     NTFS   Partition    300 MB  Healthy    Hidden
              Volume 2                      FAT32  Partition     99 MB  Healthy    System
            We can see the smaller NTFS partition; it's indicated as "primary," which is unfortunate because there's no such thing as "primary" or "extended" on GPT disks -- there are simply partitions without any modifier. Perhaps "regular" would have been better, because distinguishing the specialized recovery partitions is useful.

            We can see the EXT4 and swap partitions appear as "unknown" and have no corresponding volume or file system recognized by Windows, as expected. And both appear in the Disk Management utility, but of course Windows really can't make any sense of them.



            I am going to stop here for now. I hope this is useful for everyone. I will likely return at some point and document my preferred method: using a separate partitioning tool before installing Kubuntu, and then replacing GRUB with rEFInd after the installation finishes. I believe this scenario is likely to be more applicable to complicated setups.
            Last edited by SteveRiley; Aug 14, 2014, 11:30 PM.

            Comment


              #7
              A fantastically detailed write up, once Google gets a hold of it links might show up in lots of places.
              But as you say, you did a custom Windows install.

              Comment


                #8
                Originally posted by Teunis View Post
                A fantastically detailed write up, once Google gets a hold of it links might show up in lots of places.
                But as you say, you did a custom Windows install.
                Thank you.

                I tried to keep the Windows side as vanilla as possible. One possible variation would be to start with a clean Windows 7 install, upgrade to 8, then again to 8.1. This will leave a few extra partitions littering the drive, which should help tease out any possible problems remaining in Ubiquity and/or GRUB.

                Comment


                  #9
                  Perfect timing for this. I'm likely going to pick up a new laptop for work later this year. It comes with Win7 and a free 8.1 upgrade so after all that is done I'll be adding Kubuntu along side.

                  Please Read Me

                  Comment


                    #10
                    Steve Riley ... value in terms of Gold: $3 Million US. In terms of Windows+Linux knowledge: priceless!
                    "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
                    – John F. Kennedy, February 26, 1962.

                    Comment


                      #11
                      Hmm, the places where I buy computers mention Win7pro plus a free downgrade to Win8.1

                      Comment


                        #12
                        Steve, regarding step 3, fix the contentious clock, is there a way to reverse this process? It seems that the latest upgrade to windows 8.1 has corrected this issue. On my new Lenovo t540p when I did the clock in accordance with the above procedure, it set my clock 7 hours ahead (clock was showing the correct time before fixing.)
                        Please advise!
                        Thanks!

                        Comment


                          #13
                          @marco07 -- let's test something. Please follow these steps and report the results of each:

                          1. Cold-boot the machine into Kubuntu. Check the time. Is it correct for your time zone?
                          2. Warm-reboot the machine and enter the firmware settings. Is the time UTC or local?
                          3. Warm-reboot the machine into Windows. Check the time and the time zone. Are both correct?
                          4. Warm-reboot the machine and enter the firmware settings. Is the time the same as it was in step 2, or did it change?

                          Comment


                            #14
                            Originally posted by SteveRiley View Post
                            @marco07 -- let's test something. Please follow these steps and report the results of each:

                            1. Cold-boot the machine into Kubuntu. Check the time. Is it correct for your time zone?
                            I cannot cold boot into Kubuntu. A cold boot take me straight into windows. However, time is set correctly in Kubuntu to local time (Central USA). I checked it by a warm boot.

                            Originally posted by SteveRiley View Post
                            2. Warm-reboot the machine and enter the firmware settings. Is the time UTC or local?
                            Local.

                            Originally posted by SteveRiley View Post
                            3. Warm-reboot the machine into Windows. Check the time and the time zone. Are both correct?
                            Yes!

                            Originally posted by SteveRiley View Post
                            4. Warm-reboot the machine and enter the firmware settings. Is the time the same as it was in step 2, or did it change?
                            Same as step 2, local.

                            Also going into Kubuntu thru a restart from Windows by holding down the shift key shows time set as local the same as in windows & firmware settings.
                            Steve, it seems time is set correctly as local in my system. Right now the only problem I have is that I have to go into Kubuntu thru the Windows, i. e. a cold boot goes straight into Window. There is no boot manager like grub to select which OS to boot.
                            Last edited by Snowhog; Mar 07, 2015, 02:34 PM.

                            Comment


                              #15
                              Can a computer be built, where the Operating System only has to consider and deal with the unique aspects of a single motherboard, video card, sound card, optical drive, USB manufacturer. CD maker, DVD maker, RAM manufacturer, HDD maker, SSD maker, keyboard maker, mouse maker, cooling system and processor manufacturer?

                              I am wondering what kind of efficiency and stability could be created in a computer that only had to deal with the specific attributes of a single, specific component required to compute data. Steve's presentation caused me to have that thought.

                              If such a thing could be done, after the manner that Steve installed the custom Window Operating System, wouldn't the speed and efficiency of the computer become 1000 or so times faster, more efficient, more stable, longer lasting, less power consuming, less costly If so, you can ad 6 more zeros to Steve's monitory worth and come closer to his technical worth. Add patience, kindness and humility, and you have the making of a pretty good company and product. Like who could compete without following the leader.

                              The same with programs, packages and applications. One company's process for a specific purpose, not multi-purposed at all made for the unique need of a single user. Find the PGQ that makes the best of each component, the PGQ's that write the best application for each and every end use, and the search in each provider for the patience, kindness, and humility that makes for strength.

                              Let all these individuals spend their life and times making the best even better, and only the scraps will remain, those competing with eachother for market share, those undercutting their competition, those compromising to cut cost and increase profit at the expense of excellence.

                              And lastly take the best of the available operating systems and remove all considerations for all but the best individual component, application, and what a happy thought, human value. What country or company or even individual would settle for anything less. A kind of 'Facebook' absent greed, lust, theft and noseyness.

                              Steve, you are amazing, so are the rest of you, always helping the faceless needy.

                              Comment

                              Working...
                              X