My new Asus N56V arrived earlier this week, and the first thing I wanted to do was install ArchLinux on it. Being a CUDA programmer by profession I also needed to get it working with the Optimus configuration NVIDIA GPUs have to work with on board Intel Graphics cards.
Being a new arrival in the market it has had some issues. Some due to my unfamiliarity with them (such as grub2 and UEFI) and others such as lack of availability (such as drivers for the ethernet).
Thankfully, the internet has been helpful; Sometimes providing outright solutions, sometimes guiding you in the right direction. Since I had to scour through the web to figure out the many issues facing me, I think putting together this guide (by no means fool proof or comprehensive) should be helpful to those with similar hardware in the future.
Here is the hardware configuration:
|GPU||NVIDIA GT 650M|
I chose to use the Netinstall Image (dated August 2011) because it is quicker to download. It can also automatically download and install the latest packages over the internet. If you have a slow ineternet connection or already have Core Images of archlnux it is best to use the core image.
Preparing the disks
The laptop came with UEFI enabled and the harddisk using GPT as its partitioning table. Why choose this over regular BIOS I am not sure. If your laptop uses UEFI, while you can partition and format the disks from the archlinux live image, it is best if you create the required partition (and format them as ntfs for now) from Windows or any other utility before you proceed with the installation.
Please have the Archlinux Beginners guide open at all times. It is absolutely necessary for beginners and highly recommended for everyone else. For a forgetful person like me it saved my ass more than a few times. This guide about setting up ArchLinux with UEFI is also helpful. I had to change a couple of paths, but we will get to that later.
If you have an UEFI setup, you will need to create a bootable flash drive with an UEFI shell. Have a flash drive (256MB should be more than enough) formatted as FAT32. Download the appropriate shell from here. And rename it as bootx64.efi and place it in /path/to/flashdrive/efi/boot/bootx64.efi
This will be useful for later.
The following command should show you the networking devices that are readily available.
If you can see eth0 and have an ethernet cable, then running dhcpcd should allow you to connect to the internet directly. If you can not see eth0 or want to use wifi, you can set up WPA connections in the following manner.
ip link set wlan0 up wpa_passphrase ssid “passphrase” > /etc/wpa_supplicant.conf wpa_supplicant -B -Dwext -i wlan0 -c /etc/wpa_supplicant.conf iwconfig wlan0 dhcpcd wlan0 ping -c3 www.google.com # Testing the network
You can find the instructions for setting up other kinds of networks over here.
Partitioning the disks
This section is in case you have not created the partitions you want already. If the laptop is using GPT tables, the archlinux installer will not be able to detect free space for you to set up the partitions. You will need to install gptfdisk and create partitions.
pacman -S gptfdisk gdisk # instructions exactly like fdisk # create partitions and write to disk
At this point I needed to reboot the system for the changes to be identified. Painfully I had to set up the wifi again (and everytime after that if you reboot your system and end up in the live session).
Starting the install process
from the prompt run the following
The best thing to do here is to follow the Beginners guide. I will try to provide the options I chose.
You will be asked to select a server to download from if you are using a net install. Choose the server that is closest to you. For those in USA, rit.edu should work well.
When prompted to select repositories and packages, choose what is relavent to you. I chose the following.
Repositories: core-remote extra-remote community-remote
Packages: xorg, xorg-font, gnome, gnome-extra
Packages: boost, boost-libs, emacs, gcc-fortran, libreoffice
If you are using an Optimus setup machine, DO NOT SELECT nvidia or nvidia-utils. You can always install additional packages after archlinux is setup.
Next you will be prompted to prepare the hard disks. Do not wipe the entire disk (unless that is what you intend to do). Select the manual setup and use the layout you want. Now proceed to the installation step where the installer will try to download packages over the network and install them. This will take about 10 – 20 minutes (depending on the machine and the packages selected), so it would be a good time for a coffee break.
At the end of the install process you will be asked to configure your system. The only real things you need to care about are rc.conf and pacman.d/mirrorlist.
Add your machine’s name at the end of HOSTNAME in rc.conf like so:
Edit pacman.d/mirrorlist and uncomment the servers that are nearest to you. I chose rit.edu because their servers seem to be in sync the most.
Next setup your root password, and proceed to finish the setup. You will be asked about the location grub needs to be installed. Choosing /dev/sdX (sdX is where archlinux is installed, for most it is /dev/sda) should finish the setup and you can boot into archlinux.
For those using UEFI however, you will be notified that the procedure failed. This is expected and can be remedied.
Setting up UEFI entry
If you are not using an UEFI machine, please skip over this part. For those of you still here, this is what needs to be done.
Chrooting to archlinux
mount /dev/your_root_partition /mnt/ mount /dev/your_boot_partition /mnt/boot # Only if you have seperate boot partition mount -o bind /dev /mnt/dev mount -t proc /proc /mnt/proc/ mount -t sysfs /sys /mnt/sys/ chroot /mnt bash mkdir /boot/efi mount /dev/your_efi_partition /boot/efi pacman-db-upgrade pacman -Syy
Time to install grub
pacman -S grub2-efi-x86_64 grub-install –directory=/usr/lib/grub/x86_64-efi –target=x86_64-efi –efi-directory=/boot/efi –bootloader-id=Archlinx –boot-directory=/boot –recheck –debug
However it will fail to add an entry to EFI with the following error
Fatal: Couldn’t open either sysfs or procfs directories for accessing EFI variables
Run the following to finish setting up grub 2 before fixing EFI.
grub-mkconfig -o /boot/grub/grub.cfg
The flash drive
This is when you use the flash drive created earlier. Plug it in, reboot, choose to boot from the flash drive. Once you are in the shell, type the following:
bcfg boot add 0 fs0:\efi\Archlinux\grubx64.efi “Arch Linux”
This will create a temporary entry with which you can boot into ArchLinux.
Finishing it off
Reboot machine, choose “Arch Linux” entry from EFI table. You will be logged into Arch Linux. However this is a one time thing and you will need to make it permanent by running the following command
grub-install –directory=/usr/lib/grub/x86_64-efi –target=x86_64-efi –efi-directory=/boot/efi –bootloader-id=Archlinx –boot-directory=/boot –recheck –debug
Reboot and choose “Archlinux” as the boot option and you should be good to go!
Apparently the driver required for this card has not yet been merged into the linux kernel. However the linuxfoundation website explains how to set it up.
Step 1: Download the driver. Unpack it.
Step 2: Install the driver.
./scripts/driver-select alx make sudo make install
Step 3: Reboot. You now have ethernet.
X and Graphics
For those of you unfamiliar with Archlinux, the initial setup is very minimal. It is command line only and you will need to set up the X server and the relavent drivers
pacman -S xf86-video-intel xorg-server xorg-xinit xorg-server-utils
To test X
pacman -S xorg-twm xorg-xclock xterm startx
You should a minimal X come up. Exit it to continue with the rest of the setup.
adduser username pacman -S sudo visudo # Give the user sudo permissions
Installing a desktop manager
This is where the installation steps may not be relavent to most people. I prefer gnome 3 over the other alternatives. You can replace gnome and gdm with their equivalents for the dm of your choice.
Log out as root, login with your user name.
sudo pacman -S dbus gnome gnome-extras networkmanager network-manager-applet sudo rc.d start dbus sudo rc.d start gdm # should bring up the login screen
after logging in,
- edit /etc/rc.conf and add dbus to DEAMONS immediately after syslog-ng
gnome 3.4 uses systemd instead of initscripts for a few things, including time and rc.local
You will need to do the following to set them up.
pamcan -S systemd systemd-arch-tools initscripts-systemd systemctl enable gdm.service systemctl enable NetworkManager.service systemctl enable rc-local.service
Edit /etc/default/grub and add the following just below a similar line
run the following command and reboot
grub-mkconfig -o /boot/grub/grub.cfg
Installing other packages
pacman -S pulseaudio
pacman -S xf86-input-symantics
Edit /etc/pacman.conf. Uncomment multilib repository.
pacman -Syy pacman -S lib32-pulseaudio skype # skype only available for 32 bit
A package manager for third party Arch User Repository (AUR)
Download packer tarball
unpack tarball and cd into the directory
makepkg pacman -S jshon pacman -U packer-*
Installing nvidia driver
Since NVIDIA does not officially support Optimus on linux, the opensource project bumblebee is filling its shoes. You can set this up quite easily if you already installed packer (or other AUR helpers)
packer -S bumblebee bbswitch packer -S nvidia-bumblebee nvidia-utils-bumblebee sudo usermod -a -G bumblebee $USER
edit /etc/rc.conf and add nvidia to end of MODULES and @bumblebeed to end of DAEMONS
For some of you this may be enough. But just to be extra careful, create the following script and name it nvwake
This makes sure the nvidia module is loaded and /dev/nvidia0 and /dev/nvidiactl are created (which are required for those who intend to use CUDA)
#!/bin/bash /sbin/modprobe nvidia if [ "$?" -eq 0 ]; then # Count the number of NVIDIA controllers found. N3D=`lspci | grep -i NVIDIA | grep "3D controller" | wc -l` NVGA=`lspci | grep -i NVIDIA | grep "VGA compatible controller" | wc -l` N=`expr $N3D + $NVGA - 1` for i in `seq 0 $N`; do mknod -m 666 /dev/nvidia$i c 195 $i done mknod -m 666 /dev/nvidiactl c 195 255 else exit 1 fi
Now make it executible and make sure it gets run at startup (by putting it in rc.local)
chmod +x nvwake sudo echo /path/to/nvwake >> /etc/rc.local # make sure it is run at startup
This is the easiest part.
pacman -S cuda-toolkit cuda-sdk # should install opencl-nvidia
You don’t need to do anything special for CUDA programs.
You can test if everything is alright by running the following
sudo make -C /opt/cuda-sdk/C/ -j # why use only one thread? /opt/cuda-sdk/C/bin/linux/release/deviceQuery /opt/cuda-sdk/C/bin/linux/release/deviceQueryDrv
To run any graphics examples you need to use optirun like this:
optirun glxgears optirun glxspheres
They may take some time to load though.
And that is it.
Added some more information about CUDA since it felt a bit abandoned.
If any of you are having trouble, leave a comment or dm me @pavan_ky on twitter.