Fixing Ubuntu Boot Loader with Boot-Repair

As I am slowly adapting to the Linux world there are still occasions when I need to boot into the Windows partition of my hard drive to perform a task that I have yet to get working in Linux. Yesterday was one of those times and upon rebooting my computer today to go back into Ubuntu the boot loader was bypassed and Windows was directly loaded without any option to select which operating system to boot.

After a brief moment of staring blankly into the screen I recalled many resources online stating that when setting up a dual-boot with Windows 8 or 8.1 you need to disable fast startup in Windows and secure boot in UEFI. Fast startup is a feature whereby Windows saves some information to a file during shutdown, such as a registry cache or mounted partition state, which allows Windows to boot more quickly. This sounds great but it creates a problem for Ubuntu because the partition information is stored in Windows which prevents Linux from successfully mounting the partitions at startup. UEFI secure boot is a security feature that only allows boot loaders which are signed to the UEFI firmware to boot.

When installing Ubuntu I had read somewhere that secure boot didn’t always have to be disabled, some computers could work around the restriction. In my case, I disabled fast startup but not secure boot and everything worked fine. Well, until today, as I could no longer boot into Ubuntu. To alleviate this issue I needed to disable secure boot as well as fix my Ubuntu boot loader, GRUB.

Secure boot needs to be disabled from within UEFI, so upon rebooting my computer I had to hit the esc key to show the menu followed by F10 to load the UEFI configuration. Once the utility was loaded I navigated to the Secure Boot Configuration within the Security section. As you can see below it is from this prompt that you can disable secure boot. I changed Enable to Disable, then accepted the changes and rebooted. However, that was only step one as upon rebooting my computer booted back into Windows without showing any operating system selection options. I still needed to complete step two, which is to fix GRUB.

UEFI Secure Boot Configuration
UEFI Secure Boot Configuration

There is a tool called Boot-Repair which will fix GRUB and restore access to Ubuntu as it was before. This tool is run from within Ubuntu, which obviously I couldn’t boot into, so that meant I needed to boot to the Ubuntu Live CD. Once the Ubuntu live-session loaded I opened a Terminal window and followed the steps listed on the Ubuntu Boot-Repair community site (actual commands bolded below):

ubuntu@ubuntu:~$ sudo add-apt-repository ppa:yannubuntu/boot-repair
 Simple tool to repair frequent boot problems.
Website: https://launchpad.net/boot-repair
 More info: https://launchpad.net/~yannubuntu/+archive/ubuntu/boot-repair
Press [ENTER] to continue or ctrl-c to cancel adding it
gpg: keyring `/tmp/tmpv5oz0cq5/secring.gpg' created
gpg: keyring `/tmp/tmpv5oz0cq5/pubring.gpg' created
gpg: requesting key 60D8DA0B from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpv5oz0cq5/trustdb.gpg: trustdb created
gpg: key 60D8DA0B: public key "Launchpad PPA for YannUbuntu" imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
OK
ubuntu@ubuntu:~$ sudo apt-get update
Ign cdrom://Ubuntu 14.04.1 LTS _Trusty Tahr_ - Release amd64 (20140722.2) trusty InRelease
Ign cdrom://Ubuntu 14.04.1 LTS _Trusty Tahr_ - Release amd64 (20140722.2) trusty/main Translation-en_US
Ign cdrom://Ubuntu 14.04.1 LTS _Trusty Tahr_ - Release amd64 (20140722.2) trusty/main Translation-en
Ign cdrom://Ubuntu 14.04.1 LTS _Trusty Tahr_ - Release amd64 (20140722.2) trusty/restricted Translation-en_US
Ign cdrom://Ubuntu 14.04.1 LTS _Trusty Tahr_ - Release amd64 (20140722.2) trusty/restricted Translation-en
Ign http://archive.ubuntu.com trusty InRelease
Ign http://archive.ubuntu.com trusty-updates InRelease
Hit http://archive.ubuntu.com trusty Release.gpg
Ign http://security.ubuntu.com trusty-security InRelease
Ign http://ppa.launchpad.net trusty InRelease
Get:1 http://archive.ubuntu.com trusty-updates Release.gpg [933 B]
Hit http://archive.ubuntu.com trusty Release
Get:2 http://archive.ubuntu.com trusty-updates Release [62.0 kB]
Get:3 http://security.ubuntu.com trusty-security Release.gpg [933 B]
Get:4 http://ppa.launchpad.net trusty Release.gpg [316 B]
Get:5 http://security.ubuntu.com trusty-security Release [62.0 kB]
Get:6 http://ppa.launchpad.net trusty Release [15.1 kB]
Hit http://archive.ubuntu.com trusty/main amd64 Packages
Hit http://archive.ubuntu.com trusty/restricted amd64 Packages
Hit http://archive.ubuntu.com trusty/main Translation-en
Get:7 http://ppa.launchpad.net trusty/main amd64 Packages [1,970 B]
Hit http://archive.ubuntu.com trusty/restricted Translation-en
Get:8 http://archive.ubuntu.com trusty-updates/main amd64 Packages [441 kB]
Get:9 http://ppa.launchpad.net trusty/main Translation-en [2,123 B]
Get:10 http://security.ubuntu.com trusty-security/main amd64 Packages [214 kB]
Get:11 http://security.ubuntu.com trusty-security/restricted amd64 Packages [8,875 B]
Get:12 http://security.ubuntu.com trusty-security/main Translation-en [109 kB]
Get:13 http://security.ubuntu.com trusty-security/restricted Translation-en [2,266 B]
Get:14 http://archive.ubuntu.com trusty-updates/restricted amd64 Packages [8,875 B]
Get:15 http://archive.ubuntu.com trusty-updates/main Translation-en [210 kB]
Get:16 http://archive.ubuntu.com trusty-updates/restricted Translation-en [2,266 B]
Ign http://archive.ubuntu.com trusty/main Translation-en_US
Ign http://archive.ubuntu.com trusty/restricted Translation-en_US
Fetched 1,141 kB in 3s (296 kB/s)
Reading package lists... Done
ubuntu@ubuntu:~$ sudo apt-get install -y boot-repair && boot-repair
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
boot-sav boot-sav-extra efibootmgr gawk glade2script libsigsegv2 pastebinit
Suggested packages:
mbr mdadm clean-ubiquity boot-info os-uninstaller gawk-doc
Recommended packages:
gksu
The following NEW packages will be installed:
boot-repair boot-sav boot-sav-extra efibootmgr gawk glade2script libsigsegv2
pastebinit
0 upgraded, 8 newly installed, 0 to remove and 338 not upgraded.
Need to get 1,401 kB/1,429 kB of archives.
After this operation, 5,370 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/ trusty/main libsigsegv2 amd64 2.10-2 [15.0 kB]
Get:2 http://archive.ubuntu.com/ubuntu/ trusty/main gawk amd64 1:4.0.1+dfsg-2.1ubuntu2 [781 kB]
Get:3 http://ppa.launchpad.net/yannubuntu/boot-repair/ubuntu/ trusty/main glade2script all 3.2.2~ppa47~saucy [42.3 kB]
Get:4 http://ppa.launchpad.net/yannubuntu/boot-repair/ubuntu/ trusty/main boot-sav all 4ppa33 [392 kB]
Get:5 http://archive.ubuntu.com/ubuntu/ trusty/main pastebinit all 1.4-3 [14.9 kB]
Get:6 http://ppa.launchpad.net/yannubuntu/boot-repair/ubuntu/ trusty/main boot-repair all 4ppa33 [11.6 kB]
Get:7 http://ppa.launchpad.net/yannubuntu/boot-repair/ubuntu/ trusty/main boot-sav-extra all 4ppa33 [143 kB]
Fetched 1,401 kB in 7s (189 kB/s)
Selecting previously unselected package libsigsegv2:amd64.
(Reading database ... 169556 files and directories currently installed.)
Preparing to unpack .../libsigsegv2_2.10-2_amd64.deb ...
Unpacking libsigsegv2:amd64 (2.10-2) ...
Setting up libsigsegv2:amd64 (2.10-2) ...
Processing triggers for libc-bin (2.19-0ubuntu6) ...
Selecting previously unselected package gawk.
(Reading database ... 169564 files and directories currently installed.)
Preparing to unpack .../gawk_1%3a4.0.1+dfsg-2.1ubuntu2_amd64.deb ...
Unpacking gawk (1:4.0.1+dfsg-2.1ubuntu2) ...
Selecting previously unselected package glade2script.
Preparing to unpack .../glade2script_3.2.2~ppa47~saucy_all.deb ...
Unpacking glade2script (3.2.2~ppa47~saucy) ...
Selecting previously unselected package boot-sav.
Preparing to unpack .../boot-sav_4ppa33_all.deb ...
Unpacking boot-sav (4ppa33) ...
Selecting previously unselected package boot-repair.
Preparing to unpack .../boot-repair_4ppa33_all.deb ...
Unpacking boot-repair (4ppa33) ...
Selecting previously unselected package boot-sav-extra.
Preparing to unpack .../boot-sav-extra_4ppa33_all.deb ...
Unpacking boot-sav-extra (4ppa33) ...
Selecting previously unselected package efibootmgr.
Preparing to unpack .../efibootmgr_0.5.4-7ubuntu1_amd64.deb ...
Unpacking efibootmgr (0.5.4-7ubuntu1) ...
Selecting previously unselected package pastebinit.
Preparing to unpack .../pastebinit_1.4-3_all.deb ...
Unpacking pastebinit (1.4-3) ...
Processing triggers for man-db (2.6.7.1-1) ...
Processing triggers for gnome-menus (3.10.1-0ubuntu2) ...
Processing triggers for desktop-file-utils (0.22-1ubuntu1) ...
Processing triggers for bamfdaemon (0.5.1+14.04.20140409-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for mime-support (3.54ubuntu1) ...
Setting up gawk (1:4.0.1+dfsg-2.1ubuntu2) ...
/usr/share/boot-sav/gui-g2slaunch.sh: line 33: hash: gksudo: not found
/usr/share/boot-sav/gui-g2slaunch.sh: line 35: hash: gksu: not found
ubuntu@ubuntu:~$

Once the Terminal actions have completed the Boot-Repair application will launch. Select the Recommended repair option and the tool will run for a few minutes doing its thing. When it’s completed it will provide a URL that you can paste in the Ubuntu support forums if the problem was not fixed and allow others to see the log file to help with troubleshooting.

Boot-Repair
Boot-Repair

After that just close Boot-Repair, eject the Ubuntu Live CD, and reboot your system. And voila, this time the GRUB menu will be presented and you can select and boot into Ubuntu like usual.

Read More

Spotify in Ubuntu

Those with a keen eye may have noticed Spotify running in the screen shot from my return to Linux post yesterday. As it turns out, installing Spotify in Linux (and I’m sure this may become a more common scenario as I delve deeper into Ubuntu) is not quite as straightforward as it is on Windows or Mac OS X. In fact, on their web site Spotify list Windows and Mac as the only supported platforms. However, all is not lost, as there are a few different ways to get Spotify running in Linux.

The first way is to use the Spotify Web Player, which provides a browser-based interface that allows you to run Spotify in all its glory without installing the application, thus removing any dependency on what operating system is used. All you need to do is navigate to https://play.spotify.com and login to start listening.

If you don’t fancy the web player and want to actually install the application in Linux, Spotify does provide a Spotify for Linux preview build, which basically means they do their best to provide an application for use in Linux but it’s not officially supported so it may be buggy and they’re not responsible if it doesn’t work. That said, I’ve been using it for a little while now and have not had any issues whatsoever. It works as flawlessly as on Windows or Mac. The installation was pretty straightforward, the preview web page has some Terminal instructions which worked a charm – the commands below entered in sequence:

jon@holato:~$ sudo gedit /etc/apt/sources.list

When gedit opens then add the Spotify repository to the file and save:

deb http://repository.spotify.com stable non-free

sources.list (-etc-apt) - gedit
sources.list (-etc-apt) – gedit
jon@holato:~$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 94558F59
jon@holato:~$ sudo apt-get update
jon@holato:~$ sudo apt-get install spotify-client

And that’s it. Spotify will be installed and in no time you’ll be able to launch and run it locally on your Linux desktop.

The final way to get Spotify running under Linux is to use Wine, and I must confess I don’t know much about this method at all however I’d be remiss if I didn’t mention it, but essentially it’s a program that allows applications designed for Windows to run on Unix-based operating systems.

And those are some of the various ways to run Spotify in Linux. Personally I prefer the second approach of installing the preview build but to each their own. The most important thing is that it works, and my dependency on Windows or Mac is reduced as one of my favorite, everyday programs works great in Ubuntu.

Read More

My Return to Linux with Ubuntu 14.04

It’s been seven years and seven major releases of Ubuntu since my last foray into Linux a la Ubuntu 7.10. During that time I’ve been a Mac OS X user at home and a Windows user in the workplace. While I don’t really have a choice when it comes to the workplace, Mac OS X has been really convenient at home as my wife and I have become deeply entrenched in the Apple world of iPhones, iPads, iTunes, iEverything. There was a brief stint in 2012 when I was an Android user for several months but I was eventually wooed back to the iPhone when the shiny, new iPhone 5 was released – I also missed the apps from the App Store (I used some obscure ones at the time related to following Chelsea FC which were not available for Android).

Despite being very much an Apple man for much of the past decade, my inner geek has always quietly persisted under the radar, and recently I’ve been lured back into trying Linux, particularly as I work to grow my son’s interest in science; there are a ton of free apps in the Ubuntu ecosystem which are very exciting. I also want to use this Linux machine as sort of a centralized storage location. One of the problems we faced on our Macbook Pro (which has amazingly lasted 6 years and still going…though not as strongly as it once did) was that the storage was eclipsed years ago and it’s been a constant struggle of backing up and purging data. One of my goals for this Linux machine is to store all of our family photos and videos in a common location which can also be shared over our home network and streamed from. We have Samsung Smart TVs which can directly stream from computers if setup correctly.

I’m currently in some what of a test drive mode. I partitioned a small section of my 2 TB hard drive to experiment with Ubuntu in a dual-boot setup with the Windows 8.1 that came pre-installed for a while and make sure it will meet all of my long term needs. So far so good with Ubuntu though admittedly it has not been all that long yet. I plan to write more posts on my experience with Ubuntu and actions I may need to take to get the system working as I need it to.

Here are some resources I used to help in getting the dual-boot with Windows working properly:

http://itsfoss.com/install-ubuntu-1404-dual-boot-mode-windows-8-81-uefi/

And here is a screen shot of my dual screen Ubuntu desktop:

Ubuntu 14.04 Screenshot from 2015-02-16 21:40:12
Ubuntu 14.04 Screenshot from 2015-02-16 21:40:12

Read More

My First Linux Shell Script

Last week I wrote about my Ubuntu installation. At the end of that post I promised some Linux-related posts in the future, and here is my first one.

In my opinion one of the things about Linux that makes it so powerful is the shell. And as powerful as the shell can be, it becomes even more powerful when you create a shell script to execute a multitude of commands. Nobody wants to type ten commands in a row in order to achieve a desired result. Further, nobody wants to type the same ten commands in a row every single day. Enter the shell script.

My first shell script started out as a bit of experimenting but has evolved into quite a useful utility. The end result is a script that automatically backs up the development area of partybody.com at a specified time each night, stores a copy locally on the server, and emails a copy to the relevant administrators.

Let’s take a look at the code (some values have been changed for security reasons):

1 #!/bin/bash
2
3 # “scriptname” – copies all contents of a directory into time stamped tar.gz file in /path/to/backup/file
4
5 TD=$(date +%T-%d_%m_%Y)
6 FILE=”/home/user/web/cms/backup-$TD.tar.gz”
7 DIR=”/home/user/web/dev/”
8
9 # Create the gzipped archive file
10 tar -zcvf $FILE $DIR
11
12 # Send successful backup notification email
13 DEST=”/web/cms”
14 FILENAME=”backup-$TD.tar.gz”
15
16 echo “Automated backup ran successfully at $TD and created file: $FILENAME in FTP location: $DEST.” | mutt -s “Daily Automated Backup Complete” -a $FILE -c cc_email@yoursite.com to_email@yoursite.com
17

To get an idea of what’s going on here let’s examine this code line-by-line.

Line 1 is simply telling the script to use the BASH shell environment. Certain shell environments allow for different scripting capabilities than other shell environments, so it’s necessary to declare which one you’re using on the first line of your script. Note: BASH is the default for most Linux distributions.

Line 3 is a comment. The # character at the beginning of the line tells the shell to ignore all content on that particular line. In this case we’re just using the comment to identify the name of the script and a description of what it is intending to perform.

Line 5 creates our first variable, TD, and gives it the value of $(date +%T-%d_%m_%Y). In this instance we are accessing the built-in date function of the BASH shell and pulling out some values like time, day, month and year in order to create a time stamp.

Line 6 creates a variable called FILE and gives is the value of the backup file to be created. In other words, we’re specifying the filename we want to create and the location where we want to put it.

Line 7 creates a variable called DIR and gives it the value of the directory that we want to backup.

Line 9 is a comment declaring the action that we want to take next, in this case, creating the actual gzipped file.

Line 10 creates the archive file and gzips it taking the $DIR variable as input and the creating the $FILE variable as output.

Line 12 is another comment declaring the final action the script will take, sending the email to relevant administrators.

Lines 13 and 14 are variables that contain values to include as descriptors in the notification email, and have no effect on the execution of the script.

Line 16 echo’s the notification message into the email as the body content. The program Mutt is used to send the email. It accepts the piped input from echo and we specify a subject using the -s flag, an attachment using the -a flag, and a cc address using the -c flag. All that together sends an email to the “to” and “cc” email addresses with the subject of “Daily Automated Backup Complete” and attachment of the $FILE (”/home/user/web/cms/backup-$TD.tar.gz”) the script created.

And that’s it. Only 16 lines to backup any directory (including sub-directories), store a copy on your server, and email to whomever you wish.

There is still one problem with this script, though. As it stands it must be manually executed in order to run, and who wants to have to ssh into their server every time they want to run a backup. Therefore, we must auto-schedule the script using cron.

Cron is a time-based scheduling service driven by a crontab, a configuration file that specifies shell commands to run periodically on a schedule. Basically, we just need to add a line to this crontab file telling the shell to execute our backup script at a time of our choosing.

In this case, I added the following line to my crontab file to execute the script every day at 3 a.m.:

0 3 * * * /path/to/script/scriptname

Also, one final note, be sure to make your script executable or else it will not run. We can do this by using chmod +x as follows:

chmod +x /path/to/script/scriptname

That’s all for now. You should be able to adapt this code into a backup script of your own. Feel free to ask any questions in the comments section below.

Read More

Ubuntu 7.10 Gutsy Gibbon A Joy Once Installed

Ubuntu LogoTonight I made the switch from Fedora to the latest version of Ubuntu, 7.10, dubbed “Gutsy Gibbon.” I have long been a Fedora user over Ubuntu for the simple fact that the Fedora worked better “out-of-the-iso” in terms of supporting my hardware — an old Sony Vaio VGN-S480P. However, given some recent issues with configuring the wireless adapter, coupled with the fact that I had installed an older version of Ubuntu a few years ago and wireless worked instantly, I decided to give it a go.

I downloaded the Ubuntu ISO and burned the image to a blank CD using Alex Feinman’s ISO Recorder. Everything up until this point worked like a charm and I booted up the Ubuntu Live CD to the desktop.

Older Ubuntu Live CDs had failed to even reach the desktop on this old Vaio, so already I was making much more progress than in the past. Once on the desktop, I was able to connect to my wireless network and I got a warm, fuzzy feeling inside that this would be the one. Then things took a turn south.

After testing the wireless I double-clicked the “Install” icon on the desktop to put Ubuntu on the hard drive for good. Navigating through the on-screen menus and selecting my preferences was no problem, it’s once the actual process started that problems arose.

Without getting into too much detail, basically the install froze during the installation at 5% and wouldn’t budge. To make a long story short, the problem was with the ntfs-3g driver during the ext3 formatting step. After a rather extensive investigation into the Ubuntu support archives and The Google, I discovered a few solutions which somehow, some way fixed the issue. I’m not sure exactly which command got the installer to stop hiccuping and complete the installation, but the two I used were:

killall -9 <ntfs-3g process>

rm -rf *

Maybe I needed only one, maybe both, I have no idea. But I do know that now it works, and I encourage anyone having similar problems to use these commands as a starting point for your research into a fix.

Once I got past that the rest of the install was a breeze. The computer booted up no problem and has been running like an absolute gem for a few hours now.

The GUI Add/Remove Software application is simply awesome, and made getting Flash, MP3 support, and many other items a breeze.

Now that Gutsy Gibbon is up and running you can expect some Linux-related posts in the future, I just wanted to check in with you all and say a few words about my installation troubleshooting experience.

To end with, here is a screen shot of my current Ubuntu desktop:

ubuntu desktop screen shot

Read More

Fedora Core 6 Installation

Part one of my computer work at home is nearly complete. Last week I made the decision to remove Windows Vista from my laptop. I have the full retail version from Microsoft’s Technet, not a beta, but it just simply is not working out. But before I can get rid if it , I have gigabytes of data to backup. Thus my laptop’s weekend was constricted to backing up data (yes I just referenced my laptop in the 3rd person). However, playing around with my laptop got up my interest in playing around with my home desktop computer.

Currently my home PC is a Pentium III 800mhz, with 256 MB of RAM. I know, I know, horrible by today’s standards. However, this was a hand-me-down system from a friend and when I got it the system didn’t even turn on. I had to pop in some memory, a hard drive, and a PCI wireless ethernet device.. For simplicity I installed Windows XP at the time.

Now, working on my laptop got me interested in an old hobby: Linux. Again I originally installed Windows XP for simplicity, because I highly doubted that any flavor of Linux would support my PCI ethernet card out of the box.

I chose Fedora Core 6, a long-time favorite of mine. Many people swear over their children by Ubuntu but personally I’ve always had the best experiences with Fedora. The installation went pretty seamless. There was only one hiccup, where the installer said that the xcdroast package was missing or corrupt but after a few keystrokes of hitting the “retry” button it started working again; a slight issue reading the installation cd most likely. The total process took about an hour and a half I’d guesstimate, which is long for a Linux install, but also remember my horrible PC specs (I also chose to install a bunch of extras, such as French and Polish language support).

When the system was finished doing its thing I booted into Linux and was very delighted with the UI and simplicity of Fedora. It certainly has come a very long way from when I used to use RedHat 7.1. Unfortunately I was right and my PCI ethernet device did not work out of the box, so currently I have no internet access under Linux. After some brief research last night it appears as though I will be able to get it to work as long as I have pciutils and ndiswrapper installed, at which point I should be able to load the windows driver and get it to work.

Once this is setup my computer work will be halfway complete, although I must say this is definitely the more difficult part, as the laptop work consists of inserting a restoration cd and copying and pasting data. I will keep you updated with my progress on getting the wireless to work, and I highly recommend it to anyone looking to venture into Linux.

Read More

Microsoft and Novell to partner on Linux

In a stunning change of position today Microsoft announced that it would allow open-source Linux software to work with Windows. What’s more, Microsoft even claimed that it will provide the support and technology necessary to achieve this end. This marks the company’s second open-source partnership this week, which signals an effort by Microsoft to inform an ever-growing Linux user base that the two platforms can co-exist, particularly in the server market where Linux is most competitive against the Redmond giant. For those who are unfamiliar with Linux, it is open-source software, which means developers are able to share code with one another and anyone may contribute to the project. Most Linux distributions are free, in the dual-sense of no cost and of code without restrictions, with a few commercial Linux companies that make money by offering custom features, maintenance and technical support.

I think this collaboration of Microsoft Windows and SuSe Linux represents a clear victory for the open-source community. For years individuals from Microsoft, particularly top-level executives, have done nothing but bad-mouth Linux, and have made threats to “crush it.” Linux had always lagged behind Windows in the consumer desktop environment, due to its traditionally difficult learning curve. However, certain flavors of Linux such as Suse and Ubuntu have come a long way in making the Linux desktop easier for novice Windows users. In terms of the server market, Linux has long been a competitor to Microsoft, as many large enterprises such as IBM have realized the power and reliability of Linux over Windows in a corporate backend environment. It seems clear that Microsoft is doing this simply as an attempt to prevent further losses in market share. Linux has slowly grown stronger over the years and it seems like the time has finally arrived when Microsoft has got to take it seriously.

Read More