Installing Gentoo/Linux AMD64 on my notebook
Wednesday, 11. June 2008, 03:00:00
This post isn't supposed to be a "How to install Gentoo on a laptop". If this is what you want, please read the Gentoo handbook. This post just tries to document what I've done and things that have worked and have failed, with some nice small tips alongside.
The Live-CDs issue
Since this notebook has Core 2 Duo, I'm going to install a 64-bit Gentoo/Linux system. It is called amd64 on Gentoo, even for non-AMD processors. The first thing I need is a 64-bit live-CD. It does not need to be a Gentoo live-CD, any 64-bit Linux will work.
At first I tried Ubuntu 7.04 (Feisty Fawn) live-CD that I already had. Well, it didn't boot. After some time at that splash Ubuntu logo, it gave me an error and dropped me a busybox shell that didn't work very well. Ok, this version has been released on 2007-04-19, about 14 months old. Maybe it's too old for this desktop, or maybe the CD is defective (I doubt, but I haven't tested this).
Then, I tried the 2007.0 amd64 Gentoo live-CD, which is the latest "stable" by now. It booted fine, I got a proper shell, but it wasn't flawless. The X server could not be started (something GL-related was missing, by looking at X log). Well, I could install without X, I have access to my desktop anyway. However, I can't install without network access.
According to a page I found, the Attansic L1 Gigabit Ethernet Adapter is only supported in Linux kernel versions >= 2.6.21. The 2007.0 Gentoo live-CD comes with an older kernel and does not support the card in this notebook.
I guess this is a good time to download the 2008.0-beta2 live-cd. While it is downloading, I might re-partition my hard disk. Well, I did, and I moved (actually, cloned it using ntfsclone) the NTFS Windows Vista partition at least 3 times, and now Windows doesn't want to start and asks me to try booting from Windows installation CD. Hey, I don't have this CD! Vista came pre-installed with this notebook, and all that I have is a recovery DVD from Asus, which will probably just reformat my entire hard disk back to default, which is not what I want. Meh, screw it. I will reinstall Windows later (and will probably choose XP, unless I can't find drivers for it).
The 2008.0-beta2 Gentoo live-CD works fine! It comes with 2.6.24-gentoo-r5 kernel, and it could start X with no issues. And, what's more, it has even detected the correct resolution for my video (1280x800)! I've had so many problems with Ubuntu (both 7.10 Gutsy Gibbon and 8.04 Hardy Heron) not discovering and not remembering the video resolution on other machines (both desktops and laptops). Hey, Ubuntu devs, try learning something from the Gentoo live-CD!
Making the Gentoo Live-CD usable
The Gentoo live-CD has booted, I got network, I got Xfce... But there are some things I need to do before I can use it properly.
Mouse speed
At first, I just noticed that the mouse speed seems to be too fast. I've gone to Xfce mouse settings and decreased it, but it still felt too fast. Then I went to a terminal and tried to set it manually, using xset command. Oops... command not found Hey, Gentoo devs, add this f... fine program to the live-CD!
Disabling touchpad
Then I noticed that I was hitting the touchpad by mistake. I have a very good USB mouse that came with the notebook (thanks, Asus!), so for now I don't want the touchpad. In Windows there was a special key combination that disabled the touchpad by software. In Linux... well, I had absolutely no idea about how to do it. Google has just saved the day again! (actually, the night) I just needed to run synclient TouchPadOff=1. Hey, Gentoo devs, thanks for having this program in the live-CD!
Terminal
Talking about typing commands, I needed to open a terminal. There was something unexpected when I opened it: the background was black, and the text was white! Oh, damn, the first thing I do EVERYWHERE is to set the terminal colors to this, and I was really surprised to find that this terminal has already been pre-configured this way! Hey, Ubuntu devs, this is another lesson you should learn from Gentoo live-CD!
Keyboard NumPad
There is something peculiar about this notebook: it includes a full numeric keypad. This is very nice, specially when I want to type numbers. However, because of this, it does not include some dedicated keys found in all other keyboards: Page Up, Page Down, Home and End. This probably happens because these functions are already available at the numpad, so it wouldn't be necessary to replicate them. Note that Insert and Delete do have their own dedicated keys (even though they are also available at the numpad).
Of course, this seems to be a reasonable choice, and I think there is nothing wrong with it. On the other hand... On Linux the Shift+NumKey combination (when NumLock is off) returns the digit of the key, while on Linux it worked as Shift+<key function>. As an example, Shift+<1/End> gives 1 on Linux, but Shift+End on Windows. (Ctrl+<1/End> works as Ctrl+End on both systems, and Shift+Ctrl+<1/End> does not seem to work on Linux)
Again, there is nothing wrong with this... except that I don't have dedicated Home/End/PageUp/PageDown keys! So, it seems to be impossible to press Shift+<Home/End/PageUp/PageDown> on this keyboard! I think I will need to mess with X keyboard mapping files sometime in future...
VNC viewer
I wanted to have a VNC viewer connected to my desktop computer, so I could use the notebook and the desktop at same time (which is handy, since all my mail, bookmarks, instant message, etc. are still on the desktop). Previously, when I still had windows at this notebook, I had a VNC session opened all the time. But... Gentoo live-CD does not appear to have any VNC viewer.
Time to search the web for any VNC viewer binary for Linux... Hum... nothing? Let me try TightVNC... Binaries for Windows, RPM binary for Fedora, Java binaries, and sources for all of these. No luck. Maybe I can compile it... There seems to be gcc at the live-CD, so it might work. How do I compile it? Hum, I must run xmkmf, followed by make world... What? command not found?! Ok, there is no xmkmf at the live-CD...
Maybe I can find a binary at RealVNC? Well, there is a binary tarball, let me try it... unpacking... running... ./vncviewer: error while loading shared libraries: libSM.so.6: cannot open shared object file: No such file or directory Damn it! Is it so difficult to distribute a damn static tarball?
Maybe I can try the Java binary? Or the Java pplet version? No, I can't, there is no JRE here... Hey, Gentoo devs, could you please add a f... fine VNC viewer to the live-CD? Well, a VNC viewer, a VNC server, a remote desktop client, and a frontend for all of this. It would have saved me a lot of trouble and a lot of work.
Let's emerge... inside the live-CD?
Since I can't compile by myself and I can't find a damn binary, maybe I could run emerge inside the live-cd? (sidenote: this was the real motivation behind this blog entry, since it will probably include some hacks to make it work)
Let me try... emerge --info shows me that the portage directory is /usr/portage, but this directory only has two symlinks: eclass and profiles. Well, I think I need a copy of the portage tree. Fortunately, I have one 2 meters away from here: on my desktop! And what's more, my desktop already has it configured for NFS sharing!
mkdir /mnt/portage /mnt/distfiles mount 10.0.0.1:/gentoo/portage /mnt/portage -t nfs mount 10.0.0.1:/gentoo/distfiles /mnt/distfiles -t nfs echo 'PORTDIR=/mnt/portage' >> /etc/make.conf echo 'DISTDIR=/mnt/distfiles' >> /etc/make.conf
Let me try to emerge... Hum, nice, it appears to be worki... OSError: [Errno 30] Read-only file system: '/var/db/.pkg.portage_lockfile'
Damn, /var/db is just a symlink to /usr/livecd/db. BTW, /usr is also a symlink to /mnt/livecd/usr. Why the hell Gentoo devs haven't configured the live-CD filesystem as unionfs, like SystemRescueCD has done?
Let me see what can I do... net-misc/tightvnc requires me to install 5 packages as dependencies, while net-misc/vnc can be installed directly, with no other dependency! I gotta try that!
emerge -av vnc... Compiling... Installing... That error about /var/db... Ok, that's fine. I knew it wouldn't install anyway. Actually, it wouldn't merge, but it installs fine inside an "image" directory, which basically contains all files that the package installs. So, I might be able to access the compiled binary from there, or copy it to somewhere else...
IMG=/var/tmp/portage/net-misc/vnc-4.1.2-r4/image export LD_LIBRARY_PATH=$IMG/usr/lib64:$LD_LIBRARY_PATH $IMG/usr/bin/vncviewer
And it works!
And then the hardware fails
Not more than one hour after I finally got the VNC client working, the hardware on my desktop fails... Some programs that were trying to access the disk got frozen, while others continued to run normally. The kernel was still up, routing packets and so on. The network and cpu monitors (small dockapps) were still working, as well as the VNC server and the window manager. I switched to text terminal that displays syslog output and I found the cause: /dev/hda was failing. And the root filesystem was contained... guess where? Yep, at /dev/hda. This explains why many programs froze, and why no other program could be started anymore. Nevertheless, many programs continued to work. Damn, Linux rocks!
Well, let me stop everything I was doing for... *sigh* a few hours. I need to open this desktop to replace the IDE flat cable, that should be the problem... Closing the case, booting... What? Some weird errors? The screen goes blank? Let me unplug this drive to check if the problem persists... Booting... A long beep followed by 3 short beeps... After looking at the web I think it can be memory or video. Ok, removing all 3 memory cards, removing the AGP video card, putting all of them back to the place... Booting... Well, now at least it appears to be working.
Let me test the hardware for a (long) while... (thanks to the amazing UBCD) Seagate tools finds no problem... Now memtest86+ is running... Well, 768MB on a Pentium III 803.4MHz takes about one hour and a half to test. And after that I will run fsck on harddisks, which means even more waiting time...
Enough time to document here one of my opinions: I HATE HARDWARE. Hardware fails too often, and in weird and unreproducible ways. Hardware is unreliable. The main cause of system reboots and system failures is hardware. Damn, hardware... If it was not you, software would not exist...
On the next morning...
(I don't know if it is in the next morning or on the next morning)
Many boring hours later, my desktop was up again. I could finally copy /etc/make.conf, /etc/portage/package.* and my portage overlay to the not-yet-chrooted filesystem.
Then I went to bed to sleep for a while, as I was tired. When I come back, I see the output on my ssh terminal saying that the desktop was running on batteries and then later it had to shutdown. Oh, dear, everything is happening to me! (later I discovered the problem was a fire at the street lamppost in front of my new apartment!)
Initial emerges
With my desktop up again, NFS-shared distfiles directory is mounted again, it is time to start emerging things inside the new chrooted system. First of all: emerge -av eix screen vim gentoolkit genlop htop strace
Damn, Core 2 Duo T5550 with 3GB of RAM is so damn faster than my Pentium III 800MHz desktop! The app-editors/vim compile time has decreased from around 6 minutes on the desktop to about 1 minute at this laptop! Wow!
After the first reboot
Configure something here and there, emerge other things, compile the kernel, install grub... Ok, now it is time for the first reboot! And... it works! It works really well.
I have ethernet, I also have wi-fi! No need for NdisWrapper! The built-in driver from Linux kernel, plus a firmware downloaded from Intel site, and the wi-fi works!
Of course, I haven't tested too much yet. All I can say is that most of the things appear to work well. I've got no sound yet, I need to configure power-saving features (like CPU frequency scaling), I need to test and configure the MMC/SD/MS card reader... So many small things, but overall it works! And it is fast!
And that's all for this post. See you other time.
Update: This machine is unbelievably fast! x11-libs/qt-3.3.8 used to take around 1h and 1h20min to compile on my desktop. Right now, at the laptop, it has been compiled in 13min 30s!
Useful links