Showing posts with label dual-boot. Show all posts
Showing posts with label dual-boot. Show all posts

Tuesday, September 20, 2016

Basic version control with Git and GitHub in RStudio in both Windows and Ubuntu

I don't remember why, but a few months ago I decided I finally had to try out this "version control" thing.  I love it SO MUCH.  Github and git can be a bit confusing initially, especially as I had the added layers of making it work with RStudio and on two different operating systems, but now that I've got it going it's great.

I started and installed git with this tutorial for starting with RStudio and git/github on Windows.  To understand how push and pull work (as this confused me), I read through several pages.  I started with this graphic of the workflow.  That one ignores RStudio and is just about git and github.  This essay has great illustrations and more details (code to use in the shell/terminal in RStudio).  Finally this one is github/git only (no RStudio) but I still found it helpful to read about push/pull/branching in yet another way.

Next problem was that when I opened up my project on Ubuntu, git said all lines in files were modified when I had not actually changed all lines.  This turned out to be an issue between line endings in Windows and linux type systems, and this would hide any actual changes if I had just made a few, so just committing every time was not a good option.  I decided to go with adding a gitattributes file in each repository (so all users will get the same line endings regardless of who I share with).  I added a gitattributes file (I combined general settings and the R settings available here) into the main project directory.  For a directory that I had already used a lot (so lots of files with the wrong line endings) I followed these steps for the per-repository settings, including opening a shell in RStudio to input their code for refreshing my repository.  (I backed up on a separate hard drive first in case I totally messed something up.)  At first this didn't work, because I have a dual-boot situation, not using the files in two separate computers, according to this top answer.  I ran the two lines of code in the top answer's update and that fixed it.
$ git config core.eol lf
$ git config core.autocrlf input

I now copy the custom attributes file into any new R repository I have, run those two lines, and haven't had any problems going between operating systems now.  Keep in mind this is where I have two different operating systems accessing the SAME FILES on the SAME drive/partition.  If I understand correctly the gitattributes file should work fine without the extra lines if you have different computers, but I have not yet tested this.

Finally, when I tried pushing in RStudio to github, I kept getting two errors:
error: unable to read askpass response from 'rpostback-askpass'
fatal: could not read Username for 'https://github.com': No such device or address

As I had already done the git config steps to add my github username and github email address, I looked up the error and found that I needed to create a private/public key pair because RStudio has issues authenticating apparently.  I followed the top answer's links, which resulted in my changing the url in the .config file and then generating and linking an SSH key.  I did this on both Ubuntu and Windows following the same instructions, resulting in two new key pairs (one for Ubuntu, one for Windows).

2016/11/04 edit: I got the askpass response error again in a new repository, but on the same computer that already had the SSH keys.  In this case I only changed the url in the .config file and then it worked swimmingly.  I've also had consistent success with line endings using the custom .gitattributes file followed by the two git config commands above.

Tuesday, July 19, 2016

Dual-boot Ubuntu 16.04 with Windows 7, then upgrading to Windows 10

I have a small Lenovo (ThinkPad X100e) running 32-bit Windows 7 Home edition.  I wantd to add dual-boot, then upgrade to Windows 10 to test that it won't erase my Ubuntu partition.

I first tried just running a bootable Ubuntu 16.04 LTS (long term stable) USB, and it got me into Ubuntu install, but when I got to the partitioning step the computer said okay, then shut down, and it never seemed to install.  I suspected I might need to partition first.  I pre-emptively went ahead on shrinking the Windows partition before repartitioning, following these steps as in my previous post just adjusting steps by looking in Windows 7 places for the settings.   System protection was already off and I skipped CHKDSK because Windows ran it on its own after my failed original Ubuntu automatic repartitioning attempts.  My computer also insisted on rebooting between steps 4 and 5.  Disk cleanup (step 5) took less than 20 minutes. Disk shrinking was maybe less than an hour.

I also realized during the Windows shrinking that I was trying to install 64-bit Ubuntu (the main file that downloads) onto a 32-bit computer.  I downloaded 32-bit from a mirror (there didn't seem to be an easy link on the main Ubuntu site, had to look around for it in their site) and made a new bootable USB.  I tried again.  At the partitioning step, I got a scary looking message about whether I wanted to continue with automatic partitioning (it said it will change and format some things).  I answered continue, and then I went on with set up.  That worked and I now have Ubuntu 16.04 LTS dual booting with Windows 7.

This went a lot faster than with my last dual-boot setup.  I think this was because I had Windows 7, an older laptop, and a bit more experience, and probably mostly because I cared less about whether I ruined my Windows set up. This older computer also didn't have weird boot settings that the newer one did (secure boot), nor did it have Windows 8 hibernation and fast shutdown/startup to worry about.  I also did not want to set up a shared data partition on this laptop so that did not take up any time.  So I did less prep, and it still turned out okay.  Your results may vary.

Now, the Windows 10 upgrade over the dual-boot system.  I ended up not having enough space on my Windows partition because I had some duplicate users and all their data.  I uninstalled a few large programs that I didn't use any more and then removed the two duplicate users and their data (be careful with this!  I was very sure I did not need those user profiles).  After following the various on-screen prompts, I eventually got a message that I had to log into my administrator account.  I did so, waited for the download again, and then the Windows 10 upgrade just... failed, every time, even though I was booting back into Windows 7 and not Ubuntu.  With the error code, I found that I should be rebooting into the system recovery partition.  I did that and sure enough, it worked!  The install crashed once because my laptop overheated, but that's my laptop's problem.  I set it on an air vent in the house and the AC kept it cool enough to restore Windows 7 (Windows did this on its own).  I then started the Windows 10 upgrade again and it finished the install.  I missed a few reboots and it booted into Ubuntu, but in those instances I just rebooted and watched to select the Windows system recovery partition and it resumed where it had left off.  Windows 10 did not erase my programs or apps, so I am pleased with how this went and might even try it on my main working computer now.

Thursday, July 16, 2015

Moving default folders such as Pictures and Documents, etc. to the new partition

So I have set up my computer to dual boot into Ubuntu and Windows 8.1.  Then I partitioned my hard drive so I could have a shared data partition between Ubuntu and Windows.  Now, I want to change the default folders on both operating systems (like My Documents and My Pictures on Windows) to be on this new partition so I can use files from both places easily.  It was pretty easy and took about 15 minutes in Windows 8.1 despite my having delayed doing this for several days because surely it'd be hard. It appears to be essentially the same in Windows 7 if you have that.  I had three user accounts that I all directed to the same folders.  Otherwise it would have just been a few minutes.  I didn't redirect the desktop as I think this allows me to have different things saved on each one, and I only save temporary files on the desktop.  There was one conflict where I had the same file in each download folder, and Windows asked me what to do about it (replace, add, etc.) so I think if you try this after you have a lot of files it would still work.  I did this when my computer was essentially empty.


Okay, how to do this in Ubuntu?  It appears Windows always mounts the drive so it's visible, but in Ubuntu it doesn't and you have to configure it manually.  Here is a file showing all the commands and responses I got.

Next, how do I change the folders?  That first link I provided wanted me to make some sort of links, but this changing of a configuration file seems more permanent and unlikely to confuse programs like LibreOffice.  I couldn't find the  .config folder though and it was hidden.  Ctrl+H did the trick. I changed the file from $home/Downloads to media/Data/Downloads first to test it.  It didn't show up at first, but this older tutorial says I need to either log off and on again, or kill and restart Nautilus first.  My computer needed rebooting for some updates anyway, so I tried that first.  It worked!

I wondered if Ubuntu would politely accommodate the files from both the original default folder and the new folder like Windows did, so I put two documents in the default: one that had a duplicate and one that did not.  Then I went back to the configuration file and changed everything except the desktop.  Templates and Public did not have folders in Windows, so I added those to the data partition in case they are important for Ubuntu (I don't know yet).  This time I tried the killall nautilus in the terminal and it worked (much faster than rebooting or logging on and off).  Ubuntu did not move the files over, which makes sense since it wasn't particularly automated.  So if you already have a bunch of files, you'll need to move them manually.

I next noticed that there are two sets of links to documents, downloads, music, pictures, etc. in the files browser.  The top set (about the Data, Windows8_OS, and Computer partitions) go to the newly set folders.  The bottom set goes to the old /home ones.  I deleted the folders from /home, but then those lower links just gave an error for a missing directory.  I discovered you can right click on them and remove them.  No more confusion or errors.  I then tried saving something from LibreOffice to see where it goes as default.  It goes to /home/Claire which would have been annoying anyway I think.  I opened LibreOffice Writer and went to Options>LibreOffice>Paths and edited where "My Documents" is.  I tried installing another program afterwards (DigiKam for photo management) and it automatically went to my new Pictures folder.  Success!

I only have one Ubuntu user account right now so I just did this once.  I assume it'll work okay if I create another account, but so far I'm just using one account.

Thursday, July 09, 2015

Setting up partitioning on my dualboot laptop

Now that I have my shiny new laptop successfully dual booting, I want to access the same files from both operating systems.  I see on the side menu thing (start menu?  task bar?) a "Windows8_OS" icon.  When I click this, it "mounts" the partition with Windows 8.1 so I can nose around in the files.  I had two screenshots from my dual boot adventures previously, so I went to those files and copied one and edited it.  Now I will reboot and go into Windows and see if it worked.  Yes!

I want a separate data partition though and inexplicably Windows 8.1 had 400+ GB in spite of using only about 35 GB currently.  I went to Adminstrative Tools>Disk Cleanup.  I selected all the files it gave me and told it to clean up system files as well (the button with the adminstrator shield on it).   Disk cleanup continued.  It took around 5-10 minutes and then brought up the window again with more selections for cleanup.  When I said okay, it asked if I wanted to permanently delete these files.  Yes, I do want to delete them.  Thanks.  It took at least 20 minutes.  Then I defragmented again.  This didn't get rid of the extra space.

Some googling let me know that Windows apparently stores some critical files at the middle/end of its original partition.  I followed these instructions to move the files into a smaller region.  It worked without a hitch.  I left about 70 GB for Windows 8.1.  Unfortunately, since I did my "unallocations" at two different times (once to make space for Ubuntu and now to solve the problem of why Windows wanted 400 GB), they are not combined.  The unallocated portions were separate.  It appeared the easiest way to combine them would be with the linux-based disk management GParted. 

I rebooted into Ubuntu and installed (using the application manager) and then opened up GParted.  It looks like I need to move the Ubuntu partitions around.  I did "swapoff" for the linux-swap partition, then moved it as described on the GParted site.  I just did one first to make sure it worked.  I rebooted twice into Windows and then once into Ubuntu to confirm everything was happy (the site suggests just doing Windows twice but I figured it was important to see if Ubuntu was happy since this was the linux swap partition I just moved).

Apparently I then needed a LiveCD version of GParted (can be done with USB too but CD seemed easier and it fit on the old CDs I have).  It was a bit over 200 MB so it took a while to download on my connection.  I burned this bootable CD on the lowest speed with "Verify disk after burning" checked.  I then reinserted the CD and shut down my laptop and turned it on again.  It didn't boot from the CD so I went to system settings, it took me through the Lenovo screen again, where I pressed F12 to choose the boot device.  I picked the third one, which had CD0 and DVDRAM in the name so I figured that was the CD.

I left it to sit a bit too long on default once GParted live had loaded and it started doing things.  Then the keymap screen came up as described. For the next few questions it asked me, I picked all defaults as suggested by the GParted help and then was at step 6.  I moved the remaining two linux partitions (/ and /home).  While I was there I right-clicked on the linux-swap file system and labeled it "Linuxswap".  After those changes were applied, I took the now-continuous and contiguous unallocated space and created a new partition which I labeled Data.

Once this was all done I rebooted into both operating systems to confirm I could see the files.  I ran into a bit of trouble with Windows not being able to read the Ubuntu screenshot, because it contained a colon.  I renamed the file back in Ubuntu and could see it fine in Windows then.

Finally, I needed to reset the changes I made from the initial instructions on reducing the size of the Windows partition.  The memory dump change wouldn't go without changing the paging file settings first.  It was still giving that error after I changed the paging file, so I did the other things (except for hibernation, which I have tried to turn off everywhere anyways).

I could have saved myself all this trouble by shrinking the Windows partition more appropriately BEFORE I installed Ubuntu.  Then I'd only have had to create the new partition from the one piece of unallocated space instead of moving things around.  Oh well, I learned how to use GParted!  Next up I'll figure out how to redirect all the default directories (My Documents, My Pictures, etc.) to the new partition and how to do the equivalent in Ubuntu.

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.