Tuesday, June 23, 2015

Switching gears from virtual machine Ubuntu over to dual booting

I still haven't gotten bgc to work, mainly because I haven't made it that far into Ubuntu/Xubuntu/linux.  Running the virtual machine on my old laptop was becoming aggravating because of how slow it was, so I decided to just wait until I got a new computer.  It's a Windows 8.1 Lenovo machine, so before I load it up with all my files and settings I'm going to attempt to get it to dual-boot the pre-installed Windows 8.1 and the very latest version of Ubuntu (15.04).  The current recommended version of Ubuntu is 14.04.2, but apparently that may sometimes conflict with Windows 8.1 still.  I downloaded 15.04, accordingly.

Back up Windows 8.1

Part of the reason I waited until getting a new laptop was that I didn't want to ruin my main working computer if the dual boot install fails.  I typed "Create recovery media" into the search and followed Window's instructions.  Part of this involved my having to go out of the house buy a 32 GB USB drive.  Sigh.

Creating the Ubuntu boot drive

To create a bootable USB (using only a 4 GB USB drive, by the way), I followed ubuntu's directions, including downloading the bootable USB drive creator program pendrivelinux.  I ran the program on my Windows 7 desktop and just followed the instructions.  I checked the format usb drive option.  Once I clicked create, a warning window with the list of changes popped up.

I'm not sure if 7-Zip is required for this (I already had it installed), but the pendrivelinux program brought up a 7-Zip window that began extracting the Ubuntu .iso file.  It's not mentioned anywhere so I assume it works without it, but if not 7-Zip is easy to download and install.

In the guide to installing Ubuntu with Windows 8.1 it mentioned that WUBI (Windows-based Ubuntu Installer) no longer works.  I had no idea what this was.  When my USB stick was done, it had a WUBI file on it, so I was concerned.  I think, from reading this and another article, that WUBI now has only limited functionality and formerly would only run if I try to run the bootable USB from Windows already started.  So it's still there, and assorted askubuntu posts exist about it, but it seems unlikely to jump out and get me.  Also, I left the USB stick in and left for several hours.  When I woke the computer up, Windows Explorer locked up.  I'm not sure if it was confused about the bootable USB, so I shut it down and removed the USB before turning it on again.

It turned out later in installation that my first bootable USB had two errors, so I remade it with UNetbootin.  Not sure if it was the program that did it or luck of the draw.

Partitioning the computer's hard drive

Alright, this is one of the parts that scared me.  First, Ubuntu suggests several procedures to prepare.  Right clicking on C:/ within "This PC" (the new "My Computer") doesn't get tools; "Tools" are a tab you can find once you right-click C and click "properties".  First I optimized/defragmented the drive.  It took maybe 20 minutes or so since it is brand new and I've only been messing with it for a few days.  Then there is error checking.  Mine came up with a message saying no errors have been found (I guess it checks often?) but that I could scan if I wanted.  Scanning only took about as long as it took me to write these few sentences.  It doesn't have the same options as shown on the Ubuntu site (for scan and repair), so I think their instructions are for an older version (most seem to be for Windows 7 and earlier, though they occasionally discuss Windows 8.

Okay, partitioning!  I thought the Windows Disk Management sounded easiest.  Their instructions are also a little out of date there.  I went to "Control Panel">"System and Security">"Administrative Tools">"Computer Management" (the instructions say "Disk Management", so it's a bit different).  In the left hand panel you can go to "Storage">"Disk Management".  It said I didn't have access to this on [COMPUTERNAME].  Hmm, maybe access from the admin account.  I logged out of my user account and into admin.  No protests this time.
Here's what it looked like.

So, now what?  I followed these steps and allowed 30 GB for my Ubuntu partition.  Twenty GB was recommended by Ubuntu but I added a bit more for installing other programs (suggested by the partitioning guide link).  Very quickly after pressing "Shrink", 29.30 GB became unallocated.  I restarted twice as one of those guides pointed out it needs to reconsider its space after changing the allocation.  I had a brief moment of panic as I tried to under my usual user password before realizing I was logging into admin and really, how would repartitioning lose my password while rebooting normally.  Anyway.  Then after reading more I found I should use Ubuntu to create the shared partition later, so I shrunk the Windows volume again (to the default allowed number) and rebooted twice.  It was unclear to me why I couldn't shrink the Windows volume beyond about 450 GB when only about 30 GB are currently being used.  The Disk Management told me to use the defrag application log.  Wasn't sure what to do there, so instead went to defragment again (under "Defragment and Optimize Drives").  That didn't change anything so that's a problem for a different day, if it is even a problem.  Edited to add: I should have shrunk down the partition at this step following this procedure, because it ended up adding another hour or three of work to move two unallocated partitions together.

Making sure hybrid shutdown/fast start is disabled

I noticed this when reading about partitioning.  Apparently Windows 8.1's automatic "shut down" is really a weird hibernation if "fast startup" is enabled (which is the default).  If the files are still in use by Windows 8.1's snapshot that is created, anything you mess with in Ubuntu will get corrupted and disappear.  It was fairly easy to turn this off, both at the power button settings and power plans.  Essentially this takes you through all the power options in Control Panel > Hardware and Sound > Power Options.  Make sure hibernating is never allowed under any of the advanced settings.  I found that it would hibernate if the battery was critically low as well, so I set it to shut down as well.

Installing Ubuntu

I think I'm finally ready now.  There are various guides that talk about problems with Secure Boot, UEFI, and other things I'm not really sure what they do.  However, this guide (which seems to do well on the askubuntu site) suggests that many issues are for older installs of Ubuntu.  This is a shiny new Lenovo as well, and it comes pre-installed with Ubuntu in some regions, so I decided I should just go ahead and try it now.  I shut down my machine and put in the bootable USB.  Here goes nothing!

The Lenovo splash screen comes up first.  To interrupt startup, press Enter.  I waited to see what would happen.  Oh.  Nothing.  Back to Windows login.  I restarted.  Nope.  Restarted again and pressed Enter at the prompt.  Uh.  Somehow that didn't work.  Probably should have pressed it longer.  Shut down again.  Hmm.

This makes me think I somehow still have fast start up enabled.  I press shift while shutting down.  Nope.  This is not where I expected to run into trouble.  I then tried F1, which is not what the Lenovo boot screen tells me to do.  I disabled Quick Boot under the Startup tab (the other option, which is now selected, is "Diagnostics").  I couldn't find an Intel Smart Response option.  So I shut down and started again.  Still doesn't boot from the USB.  I went to F12 during startup this time.  I selected the USB HDD option (it also listed the name of my USB, SanDisk Cruzer or whatever it's called).  I then got a GNU GRUB menu.

I selected check disk for defects first.  Now a prettier Ubuntu screen sits there checking a list of files.  Hmm.  Errors were found in two files.  I decided to remake the USB drive with the other recommended program.   No errors were found.  Reboot again, the selected "Install Ubuntu" from the GNU Grub menu.  (I recall a few sites saying it wouldn't boot UEFI, which is the new thing as opposed to Legacy/BIOS mode but mine seems to have turned out okay; I checked at the end).

Followed the assorted instructions, connected to wifi, and had it download updates while installing and install the third-party MP3 software.

The screen for "How to install Ubuntu..." alongside, erase Windows, or something else.  From googling, it was unclear to me if "Alongside" would work since I had already shrunk my Windows partition.  Selecting "Something else" brought up a very complicated table of what exists on my computer already.  Google time.  I followed these instructions (did not do the optional ones) to make three new partitions (swap, /, and /home) out of the unallocated large space (about 450 GB).  I left quite a bit of unallocated space because I didn't see an option to create a NTFS file system and the internet tells me gparted will let me do that once I have Ubuntu installed.  Once I press "Install Now" Ubuntu asks if I want to write these changes to disk.  Go back is default, but it looks okay so I say continue.

Things seem to go on.  It asks where I am, what keyboard to use, and for a username, computer name, and password.  I made sure the computer name was the same as what Windows calls it, but no idea if that matters.  Now it installs!  I'm doomed!  Time to go check on my bored helper.
Nobody ever does anything fun with her.

Optional while you wait: trim dog's toenails, sweep floor, take out trash, organize field work schedule for next day, cut and sample blueberry muffin cake.  I actually only made it through clip dog toenails, sweep part of the floor, and take out the trash before it was done and requested a restart.

It brought me to the GNU GRUB menu again.  I guess I still have it set to boot off the USB.  I just selected the top option, which was Ubuntu.  I logged in, looked around a bit, and shut down.  I removed the USB.  Now I get the Lenovo start screen.  It takes me to the GNU GRUB again.  Let's see if I can find Windows.  Windows Boot Manager is the third option.  I select it and get a scary error, which disappears quickly.  It can't find some file.  After a moment it goes back to the GNU GRUB.  I tell it to go to system settings and it goes through the Lenovo splash screen.  I press F12.  In the boot menu now, ubuntu is first followed by Windows Boot Manager and assorted other options.  PCI LAN is the selected option.  I select Windows Boot Manager.  The computer thinks... and it works!  I'm back in Windows 8.1.  I go have a look in Disk Management and things are wild now.

I shut down from Windows.  Upon startup, without pressing anything, it takes me to the BIOS.  I didn't do anything as I couldn't figure out what to do.  So I read some more, and then remembered a lot of sites said to disable secure boot.  So back to the BIOS.  Disabled secure boot.  Then the ubuntu GRUB menu was up again.  This time pressing Windows Boot Manager did not give an error!  One line said it was booting unsecurely, and then I am at the Windows login screen.  SCORE.  Oddly, it has changed the time and claims it is six hours later than it is.  I changed the time back.  I switched users to test all three out.  So far okay.  Shutting it down again.  "Booting in insecure mode".  I get the GRUB again, and click Ubuntu.  It runs some file checks.  No idea why.  I restart from Ubuntu instead of shutting down to see if that's how I can get the GRUB menu again.  Yup.  I waited too long though so it just automatically selects Ubuntu.  The screen does a really weird flicker when I am shutting down or restarting, shifting things from side to side rapidly.  This time on restart I pick Windows Boot Manager, and sure enough, there's the candy-colored stripes that now show on Windows.  I think I did it!  The time is correct in both operating systems now.

I also wanted to double-check that I did a UEFI install (and not the legacy BIOS) because both operating systems are supposed to have the same booting.  I clicked on the Files icon in the menu bar (I guess that's what it's called), then "Computer", and then navigated to sys/firmware/efi as described here.  The folder exists (with stuff in it, no less), so I seem to have done that correctly.

What now?
Good question.  Mostly, eat dinner.  This whole dual-booting procedure took me about four or five hours (troubleshooting included), but longer if you count several days of reading up on the procedures.  Next, I should probably read up on things one does in Ubuntu.  Software updates seem a good first step, although I think at least some should have installed during setup because I selected that option.  I just typed "update" into the search box and ran the first icon (a swirly A) which was Ubuntu's "Software Updater".  It found some updates for me.  Thanks, updater!  I looked at settings and it let me know that it would check for updates daily, including security fixes.  The second icon "Software and Updates" actually also took me to the settings menu from the Software Updater.

I guess the next things I should do are find out what type of user account I should have (I seem to be an administrator) and if they mean the same things as in Windows, create a shared partition for all my data and files, understand the security (anti-virus and firewall) a bit more, and then figure out how to install the scientific packages I need.

No comments:

Post a Comment

Comments and suggestions welcome.