ArchLinux On Surface Pro

Following is the steps for installing ArchLinux on Surface Pro, from the very beginning.

Prerequisite

First you have to download the iso from http://www.archlinux.org/download, Mine is 2014.06.01.
Also I use a USB-LAN adapter which holds the following information: ASIX Electronics Corp. AX88772B.
A 8G Flash Disk, 80G USB3.0 USB HardDisk. I also use a 4-Port USB2.0 HUB which carries a AC/DC Adapter for using 3 equipemts(FlashDisk/USB Adapter/USB Disk).
Make the bootable flash disk via:

# dd if=/path/to/archlinux.iso of=/dev/sdX bs=1M && sync

After it finished we insert the flash disk into the USB HUB, boot-up the Surface Pro Holding both the Power Key and Volumn - Key. Shortly we will go into the archlinux installtion shell.

Installation Of ArchLinux

These steps are mainly refers to following URL:
https://bbs.archlinuxcn.org/viewtopic.php?id=1037
First start-up the sshd so we can remotely login onto the terminal, thus we could easily copy-paste the commands.

Make partitions on disk

GPT Partition:

cgdisk /dev/sdX

The Partition I made is as following:

# fdisk -l /dev/sdb

Disk /dev/sdb: 74.5 GiB, 80026361856 bytes, 156301488 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: CEFF8C6A-A06A-46DF-9D10-F4C593C32CA0

Device           Start          End   Size Type
/dev/sdb1         2048      1050623   512M EFI System
/dev/sdb2      1050624      5244927     2G Linux swap
/dev/sdb3      5244928    156301454    72G Linux filesystem

Notice we have to make a seperated EFI partition, because surface pro is UEFI enablbed. We also have a 2-Gigabyte swap partition and remains all of the reset as the root partition.
Now make the filesystems on the disk:

# mkfs.ext4 /dev/sdb3
# mkswap /dev/sdb2
# mkfs.vfat -F32 /dev/sdb1 

If you are using SSD, then format the ext4 without journal will greatly extend your SSD lifetime.

But this option is not OK?

# mkfs.ext4 -O "^has_journal" /dev/sd
# mkfs.ext4 /dev/sdb2
# tune2fs -O ^has_journal /dev/sdb2
# tune2fs -o discard /dev/sdb2

Enable the swap partion:

# swapon /dev/sdb2 

Installation Of Basic System

After creating the partition, mount them into the corresponding position:

# mount /dev/sdb3 /mnt
# mkdir -p /mnt/boot/EFI/
# mount /dev/sdb1 /mnt/boot/EFI/

Install the basic system:

pacstrap -i /mnt base

Generate the fstab file:

# genfstab -U -p /mnt >> /mnt/etc/fstab

Examine the generate the fstab:

# file /mnt/etc/fstab 
# cat /mnt/etc/fstab

Now you have the basic system installed the /dev/sdb, next step we will enter the system and configure this newly installed system.

Configure The System

Enter the system via:

# arch-chroot /mnt /bin/bash

Locale:

# vim /etc/locale.gen
# locale-gen

Default Language:

echo LANG=en_US.UTF-8>/etc/locale.conf

Timezone:

# ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

HostName:

# echo SurfacePro>/etc/hostname

Auto-configuring the network at startup:

# systemctl start dhcpcd.service
# systemctl enable dhcpcd.service    

Set the password for root user:

# passwd

Install grub with efi support:

# pacman -S grub efibootmgr
# grub-install --target=x86_64-efi --efi-directory=/boot/EFI --bootloader-id=arch_grub --recheck

Generate the configure files:

# grub-mkconfig -o /boot/grub/grub.cfg

Finish

Return to the installtion environment:

exit

Umount new partion:

# umount -R /mnt

Reboot via shutdown -h now and next time remove the flash-disk, also press power-up and volumn-down key together, this time you will be leading the usb-disk powered system.

ScreenShot:

See following picture:

/images/surfacepro1.jpg

ArchLinux On Surface Pro(1)

System Management

Users and Groups

Install zsh and use zsh as the newly added users’s default SHELL:

# pacman -S zsh
# useradd -m -g root -G audio -s /bin/zsh Trusty

Then we add the newly added user into the sudo group and configure the sudo parameters:

# pacman -S sudo
# visudo
Trusty ALL=(ALL) NOPASSWD: ALL
Defaults env_keep += "LANG LANGUAGE LINGUAS LC_* _XKB_CHARSET http_proxy https_proxy ftp_proxy ftps_proxy"

Now the user is OK, and you can directly use newly added user for login, I suggest you swiftly switch to the newly added user, because using root is not a good idea, it’s not safe.
And we can copy the existing zshrc file from the company machine.

Yaourt

Add following command into /etc/pacman.conf:

[archlinuxfr]
SigLevel = Never
Server = http://repo.archlinux.fr/$arch

Then:

sudo pacman -Syu && sudo pacman -S yaourt

Packages

Install following packages:

# pacman -S chromium firefox xorg xorg-xinit awesome xf86-video-intel xf86-video-ati pidgin thunderbird wget libreoffice gnome-terminal tigervnc xfce4  evince gimp smplayer alsa-utils gvim eclipse git subversion wireshark-gtk tcpdump ddd gdb meld qemu virtualbox wqy-bitmapfont wqy-microhei wqy-microhei-lite wqy-zenhei fcitx fcitx-libpinyin rox gpicview conky fcitx-googlepinyin nodejs cronie ntfs-3g dmenu lm_sensors pm-utils

Configure:

[Trusty@~]$ cat ~/.xinirc 
exec awesome
[Trusty@~]$ cat ~/.vnc/xstartup 
#!/bin/sh

export XKL_XMODMAP_DISABLE=1
exec startxfce4

Configure crontab:

crontab -e
*/4 * * * * sudo fdisk -l /dev/sdb

Configure lm_sensors:

# yes | sensors-detect

Brightness of the screen(Too light!!!! should be darker!!!):

$ sudo echo 1240>/sys/class/brightness/intel_backlight/brightness

Network Configration(Wireless)

The wireless configuration on SurfacePro is quite annoying procedure, so following are the steps for configurating it.

Install NetworkManager:

$ sudo pacman -S networkmanager

Disable the dhcpd.service of systemd, cause the networkmanager will have its own dhcp client for configurating:

$ sudo systemctl --type=service 
$ sudo systemctl disable dhcpcd.service

Now enable and start the NetworkManager.service:

$ sudo systemctl enable NetworkManager.service

Using the applet for configurating the Network Manager:

$ sudo pacman -S network-manager-applet

Call nm-applet via:

$ nm-applet

Configure the wireless connection, the NM will automatically store it so now you could reboot for using the wifi(Make sure you have removed the wired connection).

Auto-Login Awesome

Since awesome will using the terminal by default, while I use synergyc for connecting to the synergys server, this will cause me to using surface pro’s keyboard, so enable auto-login for avoiding this.

Install lightdm via:

$ sudo pacman -S lightdm
$ sudo systemctl enable lightdm.service

Install lightdm-greeter via:

$ sudo pacman -S lightdm-gtk-greeter
$ sudo vim /etc/lightdm/lightdm.conf
greeter-session=lightdm-gtk-greeter

The greeter session could be view under ls -l /usr/share/xgreeters.

Configure the auto-login for awesome:

# vim /etc/lightdm/lightdm.conf

[Seat:*]
pam-service=lightdm
pam-autologin-service=lightdm-autologin
autologin-user=username
autologin-user-timeout=0
session-wrapper=/etc/lightdm/Xsession


# groupadd -r autologin
# gpasswd -a username autologin

Now restart the machine and it will automatically falls into the awesome login session.

fcitx

Always a big problem!!!!!

$ sudo pacman -S fcitx fcitx-googlepinyin fcitx-configtool fcitx-qt4 fcitx-qt5
fcitx-gtk2

in /etc/locale.conf:

# Enable UTF-8 with Australian settings.
LANG="en_US.UTF-8"

# Keep the default sort order (e.g. files starting with a '.'
# should appear at the start of a directory listing.)
LC_COLLATE="C"

# Set the short date to YYYY-MM-DD (test with "date +%c")
LC_TIME="en_US.UTF-8"

Configure it via:

$ vim .xprofile 
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx

Restart the surfacepro, now you could using fcitx along with awesome/lightdm/firefox(need fcitx-gtk2)

On Surface Pro

Yes, two weeks ago I bought a surface pro, following is the steps for me to discover on Surface Pro.

Remote Viewer

Since the remote desktop server is not installed on surface pro, I have to install the remote viewer, I choose TeamViewer, the steps is quite easy. But it requires both side(client and server)both could reach internet.
TeamViewer Download:
http://www.teamviewer.com/zhcn/download/windows.aspx
You can also install teamviewer from the yaourt of ArchLinux.

Upgrade Pidgin For Using Microsoft Lync

Since company has upgrade the IM tools from office communicator into Lync, thus I have to upgrade the pidgin’s plugins for using lynx. Folloing is the tips:

Upgrade SIPE

Sipe is installed via yaourt:

# yaourt -S pidgin-sipe

Configure Pidgin

Edit the existing account via: Edit->Preference->Advanced.
The connection type is auto, the authentication scheme is TLS-DSK.
In the “User Agent”, insert following:

UCCAPI/15.0.4481.1000 OC/15.0.4481.1000

The detailed “User Agent” descriptions could be refered to following links:
http://sourceforge.net/p/sipe/wiki/Frequently%20Asked%20Questions/#connection-refused-with-error-messagewzxhzdk10you-are-currently-not-using-the-recommended-version-of-the-clientwzxhzdk11you-have-been-rejected-by-the-server-httpsportalmicrosoftonlinecomdownloadlyncaspx

Re-enable the account then you can use lync now.

Moving From Working PC to Own USB-Disk Based 6

Kernel

As for i686 only support 4GB at most memory, we have to change the existing memory into a new one. PAE based kernel will support up to 64GB memory, so we upgrade our kernel to this one:

yaourt -S linux-pae

Building will take for a while, two tips is:

  1. Change the building directory from TMPDIR="/tmp" to TMPDIR=/real_file_system, this configuration file is /etc/makepkg.conf.
  2. Add the MAKEFLAGS="-j6", this will speed-up the building procedure.

FCITX

We have to set following variables, in /etc/locale.conf:

# Enable UTF-8 with Australian settings.
LANG="en_US.UTF-8"

# Keep the default sort order (e.g. files starting with a '.'
# should appear at the start of a directory listing.)
LC_COLLATE="C"

# Set the short date to YYYY-MM-DD (test with "date +%c")
LC_TIME="en_US.UTF-8"

Then we install the googlepinyin input method via:

sudo pacman -S fcitx-googlepinyin

Now hit CTRL+SPACE you can call the goolgepinyin out.

Some Other Tools

Install strace for tracing the program:

sudo pacman -S strace

flash-plugins:

sudo pacman -S flashplugin

quazilla, another browser:

sudo pacman -S qupzilla

When writing octopress based blogs, you will face .rvmrc cannot executed, then enable the terminal emulator’s setting, change it as run as login shell.

Some more tips will be added later.