Friday, August 23, 2013

Gentoo and Atheros QCA8172 Fast Ethernet

I mentioned in previous posts that wired ethernet was not working on my laptop when I booted the Ubuntu Live DVD and SystemRescueCD. It was working after I installed Ubuntu 12.04 LTS, but was not detected by Gentoo.

The hardware:

lspci -k : 02:00.0 Ethernet controller: Qualcomm Atheros QCA8172 Fast Ethernet (rev 10) Subsystem: Lenovo Device 3804
lspci -n : 02:00.0 0200: 1969:10a0 (rev 10)

According to the linuxfoundation website, the driver needed for this hardware is alx. However this driver is not available in the kernel in Gentoo.

For kernel 3.8.13:

1. Download the compat-driver.
2. Extract the file using tar -xjvf compat-drivers-2013-03-04-u.tar.bz2

Note: This is not the latest stable version available now. I just want to document here that this was the driver that I used when I initially installed it on my system running on kernel 3.8.13.

3. Enter the compat-drivers directory. Run:

./scripts/driver-select alx

make

make install

After I have done this, I encountered errors trying to load this module:
modprobe: ERROR: could not insert 'alx': Unknown symbol in module, or unknown parameter (see dmesg)
alx: Unknown symbol mdio_mii_ioctl (err 0) 

In order to resolve this error, I have to compile the module bnx2x in the kernel. (I cannot explain why that will resolve the matter.  I found the fix somewhere in the net. It does work.)

Device drivers >> Network device support >> Ethernet driver support >> Broadcom devices >>   Broadcom NetXtremeII 10Gb support

I compiled it as a module. Just for curiosity sake, I did try one kernel compile without this module. As a result, besides the modprobe error with alx, I also received this message at the end of the kernel compilation:
depmod: WARNING: /lib/modules/3.10.7-gentoo/updates/drivers/net/ethernet/atheros/alx/alx.ko needs unknown symbol mdio_mii_ioctl
After compiling the bnx2x module, the alx module could be loaded and ethernet was finally working.

After upgrading to kernel 3.10.7 I couldn't install the alx driver with the instructions from linuxfoundation anymore. There was an error during compilation: 

So I downloaded the latest compat-drivers file which has now been renamed to backports. The reason I didn't use the latest backport file in the first place was because I didn't know how to install the alx driver with backports. The instruction on the linuxfoundation website to use ./scripts/driver-select alx didn't work anymore. So I had to dig around for solutions. And here we go:

1. Download backports-3.11-rc3-1.tar.bz2
2. Untar using tar -xjvf backports-3.11-rc3-1.tar.bz2
3. Enter the backports directory. 
4. Do as you would when manually compiling a kernel:

Run make menuconfig

As I only needed the alx driver, I only chose that one and unselected the rest of the drivers.

Ethernet driver support >> Atheros device >>  Qualcomm Atheros AR816x/AR817x support (compiled as module)

Save the configuration.

Run make

and then make modules_install as root. 

Load the module modprobe alx and voila! Ethernet is working. 

Note: I still needed to compile bnx2x in the new kernel to prevent the mdio error.



Tuesday, August 20, 2013

Dual-boot Gentoo with Windows 8

Actually it should be triple-boot because I have installed Ubuntu as well. :) This is the guide which I followed.

1. I installed SystemRescueCD on a USB stick.

2. The USB stick was detected by rEFind without any problems. Once the GUI was up, I opened a terminal to create the partitions necessary for Gentoo. 

As recommended by the guide, I used GPT and created a 200MB ext 2 boot partition. After that I created a 2GB swap partition, a 60GB ext4 root partition and the remainder 700GB for my home partition. I'm not sure if the 60GB is enough for the root partition. My previous root partition on the old Compaq was only 15 GB and it was just enough.

3. Once the partitions were created, I started the installation of Gentoo by following the handbook starting from Step 5: Installing the Gentoo Installation Files.

Just like the Ubuntu Live DVD, my wired ethernet also did not work using SystemRescueCD but wireless was functioning.

4. A note on configuring the kernel. According to the WIKI guide, we need to enable the following:

[*] Built-in kernel command line
(root=PARTUUID=92d3d504-9e7e-4c3d-9e56-15e3bd43511b) Built-in kernel command string EXAMPLE USE CORRECT PARTUUID FOUND WITH BLKID
[*] Built-in command line overrides boot loader arguments 

I've discovered that if the kernel is saved to the boot directory which is on a separate partition from the root partition, the above is needed. But the built-in kernel command line is not needed if you don't have a separate boot partition. rEFind will automatically detect the kernel and load it. 

As for the name of the kernel, I did not have to rename the kernel to .efi extension. As long as I used bzImage-something-something, for example bzImage-3.18.3, the kernel was automatically detected by rEFind.

Rebooted the laptop and rEFind detected all the operating systems. 


Here's a screenshot of the rEFind boot manager on startup. The "orange-reddish circlish" icon is Ubuntu. The Tux icon is Gentoo kernel on the separate boot partition and the Gentoo icon is the kernel in the boot directory on the root partition.

Getting Gentoo to work was however not as easy as Ubuntu. Some problems which I encountered:

1. Black screen after booting up Gentoo with rEFind and X server was not working.
2. Wired ethernet still not working.
3. Bluetooth not working.
4. Some of the Lenovo hotkeys were not working.

I'll go through them one by one in the next few posts.

Dual-boot Ubuntu and Windows 8 on UEFI

I managed to install Ubuntu 12.04 LTS (Precise Pangolin) successfully alongside Windows 8.

1. Disable Secure Boot in UEFI (BIOS).

There are two ways to access the Setup Utility:
a. Press the Novo button when the laptop is switched off. OR
b. Switch on the laptop using the normal On/Off button. Press F2 (Meaning press Fn and the F2 button together.)

Go to Security > Secure Boot


2. Install rEFind boot manager. I installed rEFind using Windows. The author of rEFind provides very good documentation on his website and he also gives out advices at the Gentoo and Ubuntu forums.

3. I downloaded Ubuntu 12.04 amd64 desktop version from the Ubuntu website and made a bootable USB stick using LinuxLive USB Creator.

4. Boot up the USB stick and choose "Try Ubuntu without installing". The reason I chose this option was to be able to install Ubuntu later without installing GRUB.

5. Open a terminal and run ubiquity -b or ubiquity --no-bootloader. This will start the installation of Ubuntu with no bootloader.

6. I created a 2GB Linux swap partition and a 90GB ext4 partition for Ubuntu and then let the installer run its course. Wired ethernet aws not detected on Live DVD but the wireless was working.

7. Installation proceeded smoothly and after rebooting I'm pleased to report that everything works on Ubuntu, even the wired ethernet.

Next: To install Gentoo.


Thursday, August 15, 2013

Shrink hard disk partition on Windows 8

The original partitions on my hard disk are as follows:

Please excuse the poor quality of the picture. For some reasons I didn't think of taking a screenshot but used my Galaxy 2 camera instead. So we have here:

1. Recovery Partition (Windows recovery partition)
2. EFI system (This is the boot partition)
3. OEM partition (I read somewhere that this is where Lenovo saves some important data about the laptop when they set it up)
4. Windows 8_OS C drive
5. Lenovo D drive
6. Recovery partition (This is the Lenovo recovery key partition)

 A few original concerns which I had:

1. Win 8 took up so many partition and I thought that with the limit of 4 primary partitions, I may not have enough partitions for Linux.

There was actually nothing to be worried about. The hard disk was partitioned using GUID Partition Table (GPT) which, unlike MBR, can support more than 4 partitions. (128 according to the Wikipedia)

2. I have read many discussions by Lenovo users that altering the partition table will somehow render the Lenovo recovery key useless.

I decided to give it a go anyway because I have backed up my drive using Clonezilla. Anyway, it turned out that resizing the C: drive didn't kill Lenovo Recovery as long as I left the Recovery partition, which is the last one in the picture with 13GB intact. I just resized C: drive and started Lenovo Recovery to backup the new drive and all was well.

On with the resizing:

1. First of all, I deleted D drive which contained all the drivers file needed for the laptop (after copying the files over to C drive).

2. Then I used Disk Management to resize C drive. The first thing that I noticed was that I could only shrink the partition to half of its original size. When I tried to shrink it further, this message came up:

You cannot shrink a volume beyond the point where any unmovable files are located. 

After reading through some workarounds and articles regarding this problem on the net, the solution which worked for me was found on this page. 3 steps:

i. Disable hibernation
ii. Disable paging
iii. Disable system protection (system restore)

I ran Disk Defrag just for good measure and after that I could shrink C drive as much as I wanted. I shrank it down to about 80GB and was left with nearly 900GB of free space. Perfect, as Windows 8 is just going to be an ornamental system on my laptop. :)

Next up: Install Ubuntu

Reinstalling Windows 8 OEM on Lenovo G400s

One of the first things that I did before altering my system on the brand new Lenovo was to install all the updates for Windows 8. After that I rebooted the system and ran Clonezilla to save an image of my hard disk on to a removable drive so that I can restore the laptop to its original state in case I were to mess up anything. Once that was done, the first thing to do was to try and reinstall Win 8. Why? Oh, just for fun to see whether it is doable. I don't see why I must pay for a new license to get Windows 8 DVD for reinstallation (which was what the salesperson told me) when I have already have a proper legal license to use it on my laptop.

I followed the instructions from mydigitallife forum.

1.  Ran "slmgr.vbs /dlv" in Command Prompt and I found that the SKU for my Windows 8 was CoreSingleLanguage. 

For CoreSingleLanguage you need: 
Win 8 RTM CoreSingleLanguage OEM.iso
SHA1: 8C6345E4AE37BD64911F2B2AA243ED604BBBE922

I won't be providing links to the iso. It can be found at the forum or via Google.

2. Burned the ISO on to a DVD and booted up the DVD.

3. Installed Win 8 and followed the instructions on the screen. 

4. Win 8 was installed successfully.

BUT... yes, there is a but. After the installation of Win 8, I was left with an operating system which allowed me to access the hard disk, the programs on it and to use USB drives. Other than that, no other drivers were detected and installed. Yes, no wired and wireless ethernet, no sound, no sdcard, zilch. I downloaded the ethernet driver from Lenovo website with another laptop and managed to get the internet connection going. The moment the internet connection was up, Windows 8 was activated automatically. That was what I wanted to know - whether Win 8 can be activated using the hardcoded key in my laptop. 

So, after that was done, I booted up Clonezilla and restored the hard disk to the image that I saved. It was too much trouble to search for, download and install all the necessary drivers. 

Target 1 of reinstalling Win 8 and getting it activated was achieved. 

Tuesday, August 13, 2013

New Laptop - Lenovo G400s without Touchscreen

My Compaq V3252AU running on Gentoo has finally croaked on 3rd of August 2013 after 6 years, one month and 3 weeks. A record for a Compaq laptop, huh? The salesman at the computer shop was actually astounded that the laptop lasted 6 years. 

I bought a new laptop - a Lenovo G400s without touchscreen. The specs are as followed:

Colour red
Windows 8 Single Core Language preinstalled 
Intel® Core™ i5-3230M (2.60Ghz, 3MB L3 Cache) 
14" HD WLED
1TB HDD 
Integrated Intel graphics together with Nvidia GT720M 2GB
4 GB (1x4096) RAM

This laptop came with no Windows 8 CD and no recovery disk from the laptop manufacturer. The salesman told me that:
1. Reinstalling Windows 8 afresh is impossible as you don't have the Windows 8 OEM CD.
2. Dual-booting this system with Linux is impossible.
3. Repartitioning the HD is impossible as it will mess up the recovery system.
4. If anything happens to your system, the only way to restore it is to press the Lenovo recovery key and restore the backup from there. 

Naturally I was not pleased with his answers at all. But I knew what I was looking for before I went to buy the laptop. So I went ahead with the purchase and started on my project which is to:

2. Backup the hard disk with Clonezilla.

My preferred OS is naturally Gentoo. But it is not the easiest distro to install. Therefore I choose to install Ubuntu first so that I can have a backup Linux distro to fall back on when/if I encounter any problems with the installation of Gentoo.

My following few posts will detail No. 1  to 5.

EDIT 15 March 2014: I have added links to the posts regarding the above list.