Tag Archives: Ubuntu

Install Grub on GPT

I came across a problem with grub being broken recently on a system running Ubuntu 16.04. This happened after the grub2 package got upgraded. This post will explain how I solved the problem. If you have similar issues, please do not just copy and paste the commands and execute on your machine. First read on, and try to understand it.

Usually, when this happened in the past, we just need to chroot into the system and reinstall grub. On Ubuntu, assuming you’ve chrooted into the system, and the boot disk is /dev/sda, this could be done by running:

# grub-install /dev/sda

This works because /dev/sda was partitioned using MBR. So why didn’t this method work anymore with my current machine?

Well, it’s because the main hard drive was formatted using GPT.

# parted /dev/sda print
Model: ATA Samsung SSD 850 (scsi)
Disk /dev/sda: 250GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number  Start   End    Size   File system  Name  Flags
 1      1049kB  538MB  537MB  ext4
 2      538MB   250GB  250GB

In my case of GPT, because there is no boot partition, grub can’t be installed. Here’s the messages when I tried to install grub:

# grub-install /dev/sda
Installing for i386-pc platform.
grub-install: warning: this GPT partition label contains no BIOS Boot Partition; embedding won't be possible.
grub-install: warning: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their use is discouraged..
grub-install: error: will not proceed with blocklists.

Fortunately, the space of the legacy MBR is still reserved in the GPT specification for limited backward compatibility(1). The grub-install command has just the right option to force install into that MRB space.

# grub-install --force /dev/sda
Installing for i386-pc platform.
grub-install: warning: this GPT partition label contains no BIOS Boot Partition; embedding won't be possible.
grub-install: warning: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their use is discouraged..
Installation finished. No error reported.

Notice the “Installed finished. No error reported.” message.

We can also view the first 512 byte sectors on /dev/sda:

# xxd -l 512 /dev/sda
00000000: eb63 9000 0000 0000 0000 0000 0000 0000  .c..............
00000010: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000020: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000030: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000040: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000050: 0000 0000 0000 0000 0000 0080 481c 0600  ............H...
00000060: 0000 0000 fffa 9090 f6c2 8074 05f6 c270  ...........t...p
00000070: 7402 b280 ea79 7c00 0031 c08e d88e d0bc  t....y|..1......
00000080: 0020 fba0 647c 3cff 7402 88c2 52bb 1704  . ..d|<.t...R...
00000090: f607 0374 06be 887d e817 01be 057c b441  ...t...}.....|.A
000000a0: bbaa 55cd 135a 5272 3d81 fb55 aa75 3783  ..U..ZRr=..U.u7.
000000b0: e101 7432 31c0 8944 0440 8844 ff89 4402  ..t21..D.@.D..D.
000000c0: c704 1000 668b 1e5c 7c66 895c 0866 8b1e  ....f..\|f.\.f..
000000d0: 607c 6689 5c0c c744 0600 70b4 42cd 1372  `|f.\..D..p.B..r
000000e0: 05bb 0070 eb76 b408 cd13 730d 5a84 d20f  ...p.v....s.Z...
000000f0: 83d0 00be 937d e982 0066 0fb6 c688 64ff  .....}...f....d.
00000100: 4066 8944 040f b6d1 c1e2 0288 e888 f440  @f.D...........@
00000110: 8944 080f b6c2 c0e8 0266 8904 66a1 607c  .D.......f..f.`|
00000120: 6609 c075 4e66 a15c 7c66 31d2 66f7 3488  f..uNf.\|f1.f.4.
00000130: d131 d266 f774 043b 4408 7d37 fec1 88c5  .1.f.t.;D.}7....
00000140: 30c0 c1e8 0208 c188 d05a 88c6 bb00 708e  0........Z....p.
00000150: c331 dbb8 0102 cd13 721e 8cc3 601e b900  .1......r...`...
00000160: 018e db31 f6bf 0080 8ec6 fcf3 a51f 61ff  ...1..........a.
00000170: 265a 7cbe 8e7d eb03 be9d 7de8 3400 bea2  &Z|..}....}.4...
00000180: 7de8 2e00 cd18 ebfe 4752 5542 2000 4765  }.......GRUB .Ge
00000190: 6f6d 0048 6172 6420 4469 736b 0052 6561  om.Hard Disk.Rea
000001a0: 6400 2045 7272 6f72 0d0a 00bb 0100 b40e  d. Error........
000001b0: cd10 ac3c 0075 f4c3 0000 0000 0000 0000  ...<.u..........
000001c0: 0100 eefe ffff 0100 0000 6f59 1c1d 0000  ..........oY....
000001d0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000001e0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000001f0: 0000 0000 0000 0000 0000 0000 0000 55aa  ..............U.

Ref:

(1) https://en.wikipedia.org/wiki/GUID_Partition_Table

Docker with OverlayFS on Ubuntu 15.10

As of today, the default storage for Docker on (K)Ubuntu 15.10 is AUFS. I want to switch it to OverlayFS. Personally, I’m still new to Docker, but I did hear that OverlayFS is better than AUFS. You can read more about OverlayFS here.

Anyway, the purpose of this post is how to switch OverlayFS and avoid head-scratching.

On Ubuntu 15.10 (wily), one can start/stop services either using Upstart or systemd. Since I want to get more accustomed to using systemd, I’ve been trying to use it anywhere possible. For example, here’s the command to start docker:

$ sudo systemctl start docker

To verify what storage driver used:

$ docker info 
Containers: 0
Images: 0
Server Version: 1.9.1
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 0
 Dirperm1 Supported: true
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 4.2.0-19-generic
Operating System: Ubuntu 15.10
CPUs: 4
Total Memory: 7.663 GiB
Name: f9470m

Okay, let’s begin to change the storage driver from AUFS to OverlayFS.

Lots of tutorials online including this one and this one, suggest to provide an option in /etc/default/docker.

DOCKER_OPTS="-s overlay"

or

DOCKER_OPTS="--storage-driver=overlay"

Unfortunately, it didn’t work for me. But when I started docker using upstart command as the following:

$ sudo service docker start

the storage driver has changed to “overlay” correctly!

$ docker info | grep -i driver
WARNING: No swap limit support
Storage Driver: overlay

It took me awhile to figure out that the option provided to /etc/default/docker is only for Upstart.

Well, now I at least know which direction; or questions I should ask Google. Docker has an article explaining how to control docker with systemd. With that, I was able to adapt it to pass an option to systemd docker.service to use OverlayFS.

Here’s how I did it.

First, I ensure that docker is not running.

$ sudo systemctl stop docker

If docker was started with Upstart use ($ sudo service docker stop instead.)

In my case, since I just started running Docker on this machine, I didn’t have any images or useful files. So I took an extra step to remove old AUFS files. You may need to think twice before running the following command. You might lose your important data!

If you’re unsure, don’t run it. You’ve been warned!

$ sudo rm /var/lib/docker -rf

Then create a directory, if not yet exist, /etc/systemd/system/docker.service.d. Create a file, call it whatever you like. I named it overlay.conf with the content:

[Service]
ExecStart=
ExecStart=/usr/bin/docker daemon -H fd:// --storage-driver overlay

Now, start docker service with systemd again:

$ sudo systemctl start docker

We can verify it by running ‘docker info’:

$ docker info
Containers: 0
Images: 0
Server Version: 1.9.1
Storage Driver: overlay
 Backing Filesystem: extfs
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 4.2.0-19-generic
Operating System: Ubuntu 15.10
CPUs: 4
Total Memory: 7.663 GiB
Name: f9470m

It’s working! Oh, if you’re wondering why I can just run docker command without prefix with sudo; it’s because my user account is docker group.

Happy dockering!

ERROR: could not insert ‘nvidia_352’: Unknown symbol in module, or unknown parameter (see dmesg)

This is my third time having problem installing Nvidia drivers on Ubuntu (14.04). What’s worse is that I could not remember how I fixed them last time.

Hope this blog post will prevent me from pulling my hair out for the 4th time.

So, I installed Nvidia driver as usual:

# apt-get install nvidia_352

After it’s finished, I tried to load the module:

# modprobe nvidia
modprobe: ERROR: could not insert 'nvidia_352': Unknown symbol in module, or unknown parameter (see dmesg)

Well, it turned out that I need to also install another linux-image package: linux-image-extra-3.13.0-70-generic. If you try to install this package on your machine, ensure that you match the version of the kernel too; i.e. 3.13.0-70 in my case.

# apt-get install linux-image-extra-3.13.0-70-generic 
# modprobe nividia
# lsmod | grep nvidia
nvidia               8642880  33 
drm                   303102  2 nvidia

Thanks to people in this link: https://devtalk.nvidia.com/default/topic/547588/error-installing-nvidia-drivers-on-x86_64-amazon-ec2-gpu-cluster-t20-gpu-/

Installing Code Composer Studio 6 on Ubuntu 14.10 (64-bit)

As of today, Code Composer Studio (ccs) 6 is only available for 32-bit Linux platform.  The good news is that it can be installed on a 64-bit version of Ubuntu and Fedora.

ccs6

In this blog post, I’m going to show a few issues I came across and how to fix them on Ubuntu 14.10 64-bit.

Issue 1:

After the installation, when I ran the ccs, it produces some warning and error messages then quit.

...
java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
    /home/kenno/apps/ti/ccsv6/eclipse/configuration/org.eclipse.osgi/bundles/244/1/.cp/libswt-pi-gtk-4333.so: libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory
    no swt-pi-gtk in java.library.path
    /home/kenno/.swt/lib/linux/x86/libswt-pi-gtk-4333.so: libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory
    Can't load library: /home/kenno/.swt/lib/linux/x86/libswt-pi-gtk.so

The fix [1]:

$ sudo apt-get install libgtk2.0-0:i386

Issue 2:

Now that ccs can be launched, but there are still some warnings.

ccstudio:23614): Gtk-WARNING **: Unable to locate theme engine in module_path: "pixmap",
Gtk-Message: Failed to load module "canberra-gtk-module"

The fix:

$ sudo apt-get install libcanberra-gtk-module:i386

Issue 3:

Here is another warning, which we can get rid of.

(ccstudio:28693): Gtk-WARNING **: Unable to locate theme engine in module_path: "pixmap",

The fix [2]:

$ sudo apt-get install gtk2-engines-pixbuf:i386

Issue 4:

This one is similar to the issue #3.


(ccstudio:28917): Gtk-WARNING **: Unable to locate theme engine in module_path: "murrine",

The fix:

$ sudo apt-get install gtk2-engines-murrine:i386

Issue 5:

This one is something to do with the App Center which only shows a blank page. According to the information found in reference [3], the internal web browser, chromium, could not launch because of missing libudev.so.0.

The fix:

 
$ sudo apt-get install libudev1:i386
$ sudo ln -s /lib/i386-linux-gnu/libudev.so.1 /usr/lib/libudev.so.0

Note that you must use libudev.so.1 provided by the 32 bit package.

References:

  1. http://askubuntu.com/questions/356605/ubuntu-13-10-64-bit-machinarium-error-while-loading-shared-libraries-libgtk-x1
  2. http://askubuntu.com/questions/66356/gdk-gtk-warnings-and-errors-from-the-command-line
  3. http://tools1105.rssing.com/chan-14792965/all_p238.html

Gtk-Message: Failed to load module “overlay-scrollbar”

On Ubuntu distro, if you see the error message in console as the following

Gtk-Message: Failed to load module "overlay-scrollbar"

whenever you run a Gnome-based applications, chances are you had ‘overlay-scrollbar’ package previously installed but now removed. However, the configuration file which came with that package remained on your system.

We can verify this with this command:

$ dpkg -l overlay-scrollbar
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                         Version             Architecture        Description
+++-============================-===================-===================-================
rc  overlay-scrollbar            0.2.16+r359+14.04.2 all                 Scrollbar overlay

rc : remove but config file still presents.

On my Ubuntu desktop, this config file resides at /etc/X11/Xsession.d/81overlay-scrollbar.

To correct this problem, we can purge ‘overlay-scrollbar’ package with this command:

# apt-get purge overlay-scrollbar

You would need to log out and log back in of your current X session (KDE, or Gnome) for the change to take effect.