我的ArchLinux安装与配置[deprecated]

原贴 的基础上继续更新。

一、从windows 6.0+以硬盘方式安装:

下载343.5M的安装镜像 archlinux-2009.08-core-x86_64.iso 和最新版的grub4dos

解压 grldr 和 grldr.mbr 这两个文件到C:\目录下,

用 easybcd 软件或 bcdedit 工具添加 grub 启动项:

管理员身份运行CMD.exe
> bcdedit /create /d “Grub4DOS” /application bootsector
得到一个guid项{xxx}值
接着运行下面的命令,将下面命令里面的{GUID}替换为上面得到的那个字符串,
> bcdedit /set {GUID} device partition=C:
> bcdedit /set {GUID} path \grldr.mbr
> bcdedit /displayorder {GUID} /addlast

重启进入"Grub4DOS",用以下命令直接加载ISO镜像文件,假设它位于C盘根目录:

grub> map --mem (hd0,0)/archlinux-2009.08-core-x86_64.iso (0xff)
grub> map --hook
grub> chainloader (0xff)
grub> boot

如果想删除GRUB4DOS启动项,运行 > bcdedit /delete {GUID}


-------------------------------------------------------------------------------------------

  

二、接下来的安装过程看WIKI照做。

ADSL 拨号: pppd

/etc/rc.conf 中 LOCALE="en_US.UTF-8"    HARDWARECLOCK=localtime

/etc/local.gen 中反注释 zh_CN. 开头的四行

/etc/pacman.conf 末尾加入yaourt 的源: (替代品:Bauerbill,是支持AUR和ABS的 powerpill) 

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

/etc/pacman.d/mirrorlist 添加

Server=http://mirror.bjtu.edu.cn/archlinux/$repo/os/$arch
Server = ftp://fs.fudan.edu.cn/mirror/archlinux/$repo/os/$arch
Server=ftp://mirror.lzu.edu.cn/archlinux/$repo/os/$arch
Server = http://ftp.sjtu.edu.cn/pub/mirror2/www.archlinux.org/$repo/os/$arch
Server =http://mirrors.sohu.com/archlinux/$repo/os/$arch
Server =http://mirrors.163.com/archlinux/$repo/os/$arch
Server =http://mirror.lupaworld.com/archlinux/$repo/os/$arch

Server=ftp://oss.ustc.edu.cn/archlinux/$repo/os/$arch

Server =http://oss6.ustc.edu.cn/archlinux/$repo/os/$arch
Server = ftp://ftp.estpak.ee/pub/archlinux/$repo/os/$arch
Server = ftp://ftp.heanet.ie/mirrors/ftp.archlinux.org/$repo/os/$arch
Server = ftp://ftp.nluug.nl/pub/metalab/distributions/archlinux/$repo/os/$arch
Server = http://ftp.belnet.be/mirror/archlinux.org/$repo/os/$arch

选一个最快的即可。

# useradd -m -s /bin/bash 用户名

# passwd 用户名

# visudo            在 root ALL=(ALL) ALL 的下一行添加 用户名 ALL=(ALL) ALL

# pacman -Sy pacman

# pacman -Syu

# pacman -S sudo dbus hal ntfs-3g alsa-utils alsa-oss xorg xf86-input-evdev laptop-mode-tools lxde iproute2 abs tilda wicd xfce4-notifyd base-devel
xf86-video-intel aria2 unrar unzip p7zip yaourt conky firefox gpm motion gamin qbittorrent mldonkey gimp

# gpasswd -a 用户名 optical [storage audio]

# alsaconf

$ sudo alsactl store
这将创建'/etc/asound.state'文件,用来保存alsamixer的设置。每次升级内核后把 $ sudo alsaconf 这条命令运行一下,否则开机时会出现 Restoring Alsa Levels …… [FAIL]

开机启动的服务项加入 /etc/rc.conf 文件中的 DAEMONS=( …… ) 中。

DAEMONS=(@syslog-ng hal !network !netfs @crond powernowd wicd alsa gpm)

wicd 与 network、network-manager 等服务不能共存,前面加感叹号表示不自动启动这项服务。

$ sudo sysctl -w vm.swappiness=10                  

     调整系统对SWAP分区的使用,swappiness=0的时候表示最大限度使用物理内存,然后才是swap空间,swappiness=100的 时候表示积极的使用swap分区,并且把内存上的数据及时移到swap空间。默认值是60,我没有交换分区,所以把这个值改小点。

但是这只是临时性的修改,在你重启系统后会恢复默认的60。所以还要做一步:
在 /etc/sysctl.conf 这个文档的最后加上一行: vm.swappiness=10

  笔记本CPU节能模式管理: powernowd

  控制台鼠标:gpm

 让系统启动后直接登录进入X: # vi /etc/inittab

把默认运行级别 id:3:initdefault: 改为 id:5:initdefault:

登录和启动X的命令为:

x:5:once:/bin/su 用户名 -l -c "/bin/bash --login -c startx > /dev/null 2>&1"

~/.xinitrc 的内容:

#!/bin/sh

export LANG=zh_CN.utf-8
#export LC_CTYPE=zh_CN.utf-8
export XMODIFIERS="@im=fcitx"
export XIM="fcitx"
export XIM_PROGRAM="fcitx"
export GTK_IM_MODULE=xim
export QT_IM_MODULE=xim
killall -9 fcitx
fcitx > /dev/null 2>&1
exec ck-launch-session startlxde

lxde 的回收站目录: ~/.local/share/Trash/

-------------------------------------------------------------------------------------------

三、

 1. 桌面点右键 - Desktop Settings - Advanced - 把默认使用的虚拟终端改成了tilda, tilda没有切换字符编码的菜单项,需要临时更换终端字符编码的话用:$ luit -encoding GB18030   (也可以在后面加一个程序名)。

将 .desktop 文件(其中Type=Application ,Terminal=True)放在桌面上双击没反应。原因是 Exec= 后面使用了sudo,导致命令无法执行。解决办法: $ sudo pacman -S gksu   并把快捷方式中的 Exec= sudo {命令 } 改为 Exec= gksu {命令}

如果命令比较复杂,就把快捷方式用一个脚本替代,同样可以达到双击使之后台运行的效果。例如:

#!/bin/bash
gksu /路径/ExecProgram >/tmp/execerror 2>&1 &

输出信息和错误信息都被重定向到execerror 这个文件,不过只有后台的程序中止运行时才会写入文件中。

 2. openbox 的右键菜单。      WIKI 中说 $ cp /etc/xdg/openbox/menu.xml ~/.config/openbox/  后对文件内容进行增删。事实上我这样做后对菜单的设置毫无效果,原因在于 ~/.config/openbox/lxde-rc.xml 中并没有把 ~/.config/openbox/menu.xml 作为菜单的配置文件。而是:

  ……


 /usr/share/lxde/openbox/menu.xml
……

 如果要添加更多的项目,最好把上面的内容改为 ~/.config/openbox/menu.xml 后用 obmenu 这个可视化工具,可以方便直观地编辑菜单项。  如果直接编辑menu.xml的内容,只要参考/etc/xdg/openbox/menu.xml 和/usr/share/lxde/openbox/menu.xml 的格式即可。最后,在桌面上点右键 --> “reload config files” 生效。

 3. 如果开机加载模块和启动服务时出现 [FAIL] 一闪而过来不及细看,则将 /etc/issue 第一行的清屏符号去掉重启,进入tty1 即可查看之前闪过的启动信息。如果错误信息出现得比较靠前,在控制台下又无法回滚信息,则必须在开机过程中按 Ctrl+s 锁定屏幕,Ctrl+Q 解除锁定。

另外修改 /etc/issue 文件,可以用彩色字符(用ANSI控制码实现)自定义终端欢迎信息。下面是我的:

^[[H^[[2J
^[[31mWelcome to ^[[34mArch Linux \r \m ^[[35m(\l) on ^[[1;33m\n
^[[32m\t \d

注意: 第一行的作用是清屏。^[[ 的输入方法是vim中Insert模式下先Ctrl+v,再按Esc键,再输入一个 [ 。

^[ 是ANSI控制码的起始符,在terminal中按 Insert 和 Esc 键输入。

 

 4. man xset

 X 默认包含省电和屏保的设置,用命令 $ xset q 可见下面两块,意即十分钟无动作则启动屏幕保护并待机。

 Screen Saver:
  prefer blanking:  yes    allow exposures:  yes
  timeout:  600    cycle:  600

 DPMS (Energy Star):
  Standby: 600    Suspend: 600    Off: 600
  DPMS is Enabled

 

  如果要关闭DPMS电源管理,并且想延长调用屏保(没有安装 xscreensaver 则会黑屏)前的等待时间,将 xset s 1500 7200 -dpms  添加进 ~/.xinitrc 即可。
 

-------------------------------------------------------------------------------------------

四、 lnmp平台搭建。( PHP5 + MySQL5 + nginx + php-fpm + eaccelerator + zend optimizer + suhosin + cacti )

可将AUR中php-fpm 的 PKGBUILD修改后用于安装(源码打补丁方式)。

仓库里有的扩展可以直接安装,就不用自己编译了。

$ sudo pacman -Ss php
   ……

http://wiki.archlinux.org/index.php/Nginx

http://blog.s135.com/nginx_php_v5

http://aur.archlinux.org/packages.php?ID=17067      

php-fpm (FastCGI Process Manager) 将被整合进 php core 5.4

-------------------------------------------------------------------------------------------

五、IPV6 隧道连接。 参见wiki

需要安装 iproute2 包。

 1. 使用 eth0 时执行下面的脚本:

#!/bin/bash

localp=$(ip -4 addr show dev eth0 | sed -n -e 's/.*inet \(.*\)\/.*/\1/p')
remotep="202.120.58.150"
# 202.114.1.186           hust                 2001:250:4000:8fff:200:5efe     
# 202.115.39.98           scu                  2001:250:2003:2009:0:5efe
# 59.66.4.50                 thu                    2001:da8:200:900e:200:5efe
# 202.120.58.150         sjtu                   2001:da8:8000:d010:200:5efe

# 202.112.26.254            2001:da8:8000:3:200:5efe
prefix="2001:da8:8000:d010:200:5efe"
device="sit1"

sudo ip tunnel add $device mode sit remote $remotep local $localp
sudo ifconfig $device up
sudo ifconfig $device add $prefix:$localp/64
# ip -6 route add ::/0 via $prefix:$remotep
sudo ip route add ::/0 via 2001:da8:8000:d010::1 metric 1

  2. 使用宽带(ppp0)时执行 $ sudo /etc/rc.d/6in4-tunnel start

 脚本内容为:

ipv6
#!/bin/bash

### begin user configuration

##############################################
#                                            #
#  Stop this script before you reconfigure!  #
#                                            #
##############################################

# if_name     - interface name that is to be created for the 6in4 link
if_name=6in4

# server_ipv4 - ipv4 address of the server that is providing the 6in4 tunnel
server_ipv4=202.120.58.150

# client_ipv4 - ipv4 address of the client that is receiving the 6in4 tunnel
client_ipv4=$(ip -4 addr show dev ppp0 | sed --'s/.*inet \(.*\)\/.*/\1/p' | cut -" " -f1)

# client_ipv6 - ipv6 address of the client 6in4 tunnel endpoint
client_ipv6=2001:da8:8000:d010:200:5efe
prefix=$(echo $client_ipv6 | cut -":" -f-4)

# link_mtu    - set the mtu for the 6in4 link
link_mtu=1480

# tunnel_ttl  - set the ttl for the 6in4 tunnel
tunnel_ttl=64

### end user configuration

daemon_name=6in4-tunnel

. /etc/rc.conf
. /etc/rc.d/functions

case "$1" in
  start)
    stat_busy "Starting $daemon_name daemon"

    ifconfig $if_name &>/dev/null
    
if [ $? -eq 0 ]; then
      stat_busy "Interface $if_name already exists"
      stat_fail
      
exit 1
    fi

    ip tunnel add $if_name mode sit remote $server_ipv4 local $client_ipv4 ttl $tunnel_ttl
    ip link set $if_name up mtu $link_mtu
    ip addr add $client_ipv6:$client_ipv4/64 dev $if_name
    ip route add ::/0 via $prefix::1

    add_daemon $daemon_name
    stat_done
    ;;

  stop)
    stat_busy "Stopping $daemon_name daemon"

    ifconfig $if_name &>/dev/null
    
if [ $? -ne 0 ]; then
      stat_busy "Interface $if_name does not exist"
      stat_fail
      
exit 1
    fi

    ip link set $if_name down
    ip tunnel del $if_name

    rm_daemon $daemon_name
    stat_done
    ;;

  
*)
    
echo "usage: $0 {start|stop}"
esac
exit 0

ifconfig 看IPV6地址是否正确,访问 http://6rank.edu.cn 查看测试结果。 也可以在 url 第一层末尾加 .sixxs.org 检测。

-------------------------------------------------------------------------------------------

六、

 1. 解决 wine 的中文乱码。

REGEDIT4

[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\FontLink]
"FontLinkControl"=dword:00004000
"FontLinkDefaultChar"=dword:00003000

[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\FontLink\SystemLink]
"Lucida Sans Unicode"=hex(7):4d,53,47,4f,54,48,49,43,2e,54,54,43,00,4d,53,55,49,00,47,6f,74,68,69,63,00,00
"Microsoft Sans Serif"=hex(7):53,69,6d,53,75,6e,2e,54,54,43,00,53,69,6d,53,75,6e,00,00
"SimSun"=hex(7):67,75,6c,69,6d,2e,74,74,63,00,67,75,6c,69,6d,00,00
"Tahoma"=hex(7):53,69,6d,53,75,6e,2e,54,54,43,00,53,69,6d,53,75,6e,00,00

[HKEY_CURRENT_USER\Software\Wine\X11 Driver]
"ClientSideAntiAliasWithCore"="Y"
"ClientSideAntiAliasWithRender"="Y"
"ClientSideWithRender"="Y"

[HKEY_CURRENT_USER\Control Panel\Desktop]
"FontSmoothing"="2"
"FontSmoothingType"=dword:00000002
"FontSmoothingGamma"=dword:00000578
"FontSmoothingOrientation"=dword:00000001

保存为 winefontsmoothing.reg 然后 $ regedit winefontsmoothing.reg

选几种常用字体(如宋体、雅黑、tahoma)软链接到 ~/.fonts/ 和 ~/.wine/drive_c/windows/Fonts/

$ sudo mkfontscale
$ sudo mkfontdir
$ sudo fc-cache -fv

 2. wine Warcraft III

     需要 $ sudo pacman -S mpg123 。当我以默认的全屏模式启动程序时可能会失败,报错要求插入光盘,原因不明。可以试试用窗口模式运行:

  $ wine "/mnt/DATA/Applications/WarcraftIII/Frozen Throne.exe" -opengl -window 

   如果窗口模式也出错,再换用全屏模式,多试几次,总有一种方法可以启动。( `ハ′)

-------------------------------------------------------------------------------------------

七、openbox 和 pacmanfm 的定制:

 1. 有时需要对某个应用程序或某个特定窗口设置相应的行为或属性(per-application settings)。首先获取此窗口的 WM_CLASS 和 WM_WINDOW_ROLE 等 windows property,然后在 ~/.config/openbox/lxde-rc.xml 里模仿示例添加 <application> </application> 规则。

 $ xprop | grep "WM_WINDOW_ROLE\|WM_CLASS" && echo "WM_CLASS(STRING) = \"NAME\", \"CLASS\""

运行上面命令后鼠标指针变成十字,就可以选取要自定义的应用程序窗口了。

  

 2. 自定义图标。将下载或自制的图标放在 ~/.icons/ ,软链接到特定目录。

pcmanfm 模仿vista的文件夹图标,我把它换掉了。只用改一种分辨率的图标,如我使用oxygen图标主题,大多数地方用48x48大小的 图标,就应该在/usr/share/icons/oxygen/48x48/ 下的对应目录进行操作,我换下了apps/accessories-archiver.png ,添加了 mimetypes/application-x-chm.png。另外,新安装软件的图标位于/usr/share/pixmaps/ ,大多是128x128的,我换了 pcmanfm.png。

  3. 更换鼠标指针图标主题。

打开文件 .config/lxsession/LXDE/desktop.conf   在[GTK]部分添加:
sGtk/CursorThemeName=鼠标主题名称

如果不想把图标目录复制到 /usr/share/icons 的话,就放到 ~/.icons/ 下然后

 $ sudo ln -s ~/.icons/鼠标主题名称 /usr/share/icons/鼠标主题名称

 4. lxpanel 面板元件中的 “电池电量显示” 。

  卸下笔记本电池后登录进 X 发现 lxpanel 一直在闪烁,加载不上。在虚拟终端里敲命令输出“段错误”。把面板元件依次排查后发现是“电池电量显示” 这个弱智元件引起的。在 .config/lxpanel/LXDE/panels/bottom [或panel] 文件中删除 “batt” 所在的那一块 Plugin 即可。

 5. 关于 conky 配置以及用 feh 在进入 X 时加载壁纸,详见这里

-------------------------------------------------------------------------------------------

八、 用 fbinst + grub4dos 灌了个启动U盘,拿它引导 ArchLinux 时碰到了障碍(我没有把Linux的grub 装到MBR,而是装在一个ext2 分区,挂载到 /boot )。grub4dos 把U盘认作 (hd0),把硬盘认作 (hd1)。尽管我预先做了磁盘映射:

map (hd0) (hd1)
map (hd1) (hd0)
map --hook
find --set-root --ignore-floppies --ignore-cd /grub/menu.lst && configfile /grub/menu.lst

也进入 ArchLinux 那蓝色的启动菜单了,但是启动后立刻停止在 “Probing EDD ... (edd=off to disable)”,并失去了响应,只能拔电源。

后来了解到 grub4dos 支持在 menu.lst 中使用UUID。这样的话前三行的磁盘映射命令就没必要了,只需把 Archlinux 的boot分区下 /grub/menu.lst 中的 root (hd0,X) 改成 uuid XXXXXXXXX 即可。硬盘分区的UUID 可以通过 $ ls -l /dev/disk/by-uuid/ 查看。
 

原文地址:https://www.cnblogs.com/shankun/p/my_Archlinux_installation_and_configurations.html