https://wiki.archlinux.org/api.php?action=feedcontributions&user=Hpo3&feedformat=atomArchWiki - User contributions [en]2024-03-29T13:33:01ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Improve_pacman_performance&diff=90730Improve pacman performance2010-01-02T18:11:12Z<p>Hpo3: without ' -c ' ,aria2c can't resume the previous download, and rename the new file to filename.1</p>
<hr />
<div>[[Category:Package management (English)]][[Category:HOWTOs (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|:Improve_Pacman_Performance}}<br />
{{i18n_entry|Deutsch|Pacman beschleunigen}}<br />
{{i18n_entry|Português|Acelerando Pacman}}<br />
{{i18n_entry|Русский|Ускорение работы Pacman}}<br />
{{i18n_entry|Türkçe|:Pacman optimizasyonu}}<br />
{{i18n_entry|繁体中文|Improve Pacman Performance.幫 Pacman 加速}}<br />
{{i18n_entry|简体中文|:改善Pacman性能 (简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
== Improving database access speeds ==<br />
<br />
Pacman stores all package information in a collection of small files, one for each package. Improving database access speeds reduces the time taken in database-related tasks, e.g. searching packages and resolving package dependencies.<br />
<br />
The safest and easiest method is to run<br />
<br />
# pacman-optimize && sync<br />
<br />
as root. This will attempt to put all the small files together in one (physical) location on the hard disk so that the hard disk head does not have to move so much when accessing all the packages. This method is safe, but is not for-sure. It depends on your filesystem, disk usage and empty space fragmentation.<br />
<br />
=== Further tweaks ===<br />
<br />
'''ody''' has posted [http://bbs.archlinux.org/viewtopic.php?id=20385 a script on the forum] that replaces the current Pacman database with a ''loopback filesystem'' which ensures that all the small files continue to stay together on the hard disk. Several users have reported great improvements, but problems have also been reported so do not do this unless you are an expert user. <br />
<br />
To use ody's script you must have a kernel compiled with loopback filesystem support. The default kernels already have this, so you only need to be concerned with this if you compile your own custom kernel.<br />
<br />
== Improving download speeds ==<br />
<br />
Firstly, if your download speeds have been reduced to a crawl, ensure you are using one of the many [[mirrors]] and not ftp.archlinux.org, which, [http://www.archlinux.org/news/302/ as of March 2007], is now throttled.<br />
<br />
Pacman's speed in downloading packages can be improved by using a different application to download packages instead of Pacman's built-in file downloader.<br />
<br />
In all cases, make sure you have the latest Pacman before doing any modifications.<br />
<br />
# pacman -Sy pacman<br />
<br />
=== Using wget ===<br />
<br />
This is also very handy if you need more powerful proxy settings than pacman's built-in capabilities. <br />
<br />
To use <code>wget</code>, first install it with <code>pacman -S wget</code> and then modify <code>/etc/pacman.conf</code> by adding the following line to the <code>[options]</code> section:<br />
<br />
XferCommand = /usr/bin/wget -c --passive-ftp -c %u<br />
<br />
Instead of putting <code>wget</code> parameters in <code>/etc/pacman.conf</code>, you can also modify the <code>wget</code> configuration file directly (the system-wide file is <code>/etc/wgetrc</code>, per user files are <code>$HOME/.wgetrc</code>).<br />
<br />
=== Using aria2 ===<br />
<br />
According to the aria2 website, aria2 is "a download utility with resuming and segmented downloading. Supports HTTP/HTTPS/FTP/BitTorrent/Metalink." This means that you can make several HTTP/FTP connections to an Arch mirror at the same time, which should result in an increase in download speeds.<br />
<br />
Install it with <code>pacman -S aria2</code> and then edit <code>/etc/pacman.conf</code> by adding the following line to the <code>[option]</code> section:<br />
<br />
XferCommand = /usr/bin/aria2c --no-conf -c -s 2 -m 2 -d / -o %o %u<br />
<br />
Let's run over the options here:<br />
* ''/usr/bin/aria2c'' - the location of the aria2 application<br />
* ''--no-conf'' - do not use a parameterized configuration file if one is available in ~/.aria2 (typically ~/.aria2/aria2.conf)<br />
* ''-s 2'' - use 2 concurrent connections (you can set this higher if you want, but it's not going to do a whole lot)<br />
* ''-m 2'' - make 2 attempts to download the package per mirror<br />
* ''-o %o'' - output to the file pacman specifies<br />
* ''%u'' - download the file pacman specifies<br />
<br />
=== Powerpill ===<br />
'''''[http://xyne.archlinux.ca/info/powerpill Powerpill]''''' is a wrapper for pacman that uses aria2 to download packages. Unlike the other aria2 solutions, powerpill uses '''simultaneous''' downloads for all files and segmented downloads only for larger files, which really makes the most of your bandwidth without wasting time splitting small files unnecessarily. Powerpill is available in the community repo.<br />
<br />
# pacman -S powerpill<br />
<br />
For more info, see the [[Powerpill]] wiki article.<br />
<br />
=== Using airpac ===<br />
<br />
In a nutshell, [http://aur.archlinux.org/packages.php?ID=26118 airpac] is an aria2c wrapper for pacman. Unlike powerpill, which acts as a frontend to pacman, airpac serves as a backend downloader for pacman. On the other hand, however, it behaves similarly to powerpill, as far as downloading is concerned, since both use aria2c to actually download the files. Because it is a backend though, it cannot download multiple packages simultaneously as powerpill can.<br />
<br />
Essentially, airpac is the Python implementation of the pacget script below. However, the main difference lies in the handling of aria2c output. airpac shows only the most relevant info, i.e., the download progress, although it currently doesn't use a progressbar (maybe in the near future). Also, airpac caches the db files so that they won't be downloaded for every <code>pacman -Sy</code>. On the downside, this breaks <code>pacman -Syy</code> since airpac has no way of knowing the options pacman is executed with. As a workaround, however, one can use <code>pacman -Sc</code> to delete the cached files in '''/var/lib/pacman/.airpac'''.<br />
<br />
The configuration file is located in '''/etc/airpac.conf'''. This is actually an aria2c config file. Because of this, the user can directly configure how aria2c is used by airpac without meddling with airpac's code. For more info about the available options, consult the aria2c manpage.<br />
<br />
airpac also uses the ''Server Performance Profile'' feature of aria2c by default. The statistics file is located in '''/var/lib/airpac.stats'''. The default URI selector is ''adaptive''.<br />
<br />
'''Usage in /etc/pacman.conf'''<br />
XferCommand = /usr/bin/airpac %u %o<br />
<br />
=== pacget (aria2) Mirror Script ===<br />
<br />
This script will greatly improve the download speed for broadband users. It uses the servers in /etc/pacman.d/mirrorlist as mirrors in aria2. What happens is that aria2 downloads from multiple servers simultaneously which gives a huge boost in download speed.<br />
<br />
Take note that you have to put 'exec' before /usr/bin/pacget in the XferCommand. This is needed so that when you terminate pacget or aria2 (with process id used by pacget), pacman would also terminate. This would prevent inconvenience because Pacman would not persist downloading a file when you tell it not to.<br />
<br />
WARNING: You may experience some problems if the mirrors used are out-of-sync or are simply not up-to-date. Just use the [[Reflector]] script to generate a list of up-to-date and ''fast'' mirrors. Also, ftp.archlinux.org resolves to two IPs. You may want to choose only one of them and hard code ftp.archlinux.org and the chosen IP address to /etc/hosts.<br />
<br />
'''/usr/bin/pacget'''<br />
<pre><br />
#!/bin/bash<br />
<br />
msg() {<br />
echo ""<br />
echo -e " \033[1;34m->\033[1;0m \033[1;1m${1}\033[1;0m" >&2<br />
}<br />
<br />
error() {<br />
echo -e "\033[1;31m==> ERROR:\033[1;0m \033[1;1m$1\033[1;0m" >&2<br />
}<br />
<br />
CONF=/etc/pacget.conf<br />
STATS=/etc/pacget.stats<br />
ARIA2=$(which aria2c 2> /dev/null)<br />
<br />
# ----- do some checks first -----<br />
if [ ! -x "$ARIA2" ]; then<br />
error "aria2c was not found or isn't executable."<br />
exit 1<br />
fi<br />
<br />
if [ $# -ne 2 ]; then<br />
error "Incorrect number of arguments"<br />
exit 1<br />
fi<br />
<br />
filename=$(basename $1)<br />
server=${1%/$filename}<br />
<br />
# Determine which repo is being used<br />
repo=$(awk -F'/' '$(NF-2)~/^(community|core|extra|testing)$/{print $(NF-2)}' <<< $server)<br />
[ -z $repo ] && repo="custom"<br />
<br />
# For db files, or when using a custom repo (which most likely doesn't have any mirror),<br />
# use only the URL passed by pacman; Otherwise, extract the list of servers (from the include file of the repo) to download from<br />
url=$1<br />
if ! [[ $filename = *.db.tar.gz || $repo = "custom" ]]; then<br />
mirrorlist=$(awk -F' *= *' '$0~"^\\["r"\\]",/Include *= */{l=$2} END{print l}' r=$repo /etc/pacman.conf)<br />
if [ -n mirrorlist ]; then<br />
num_conn=$(grep ^split $CONF | cut -d'=' -f2)<br />
url=$(sed -r '/^Server *= */!d; s/Server *= *//; s/\$repo'"/$repo/; s:$:/$filename:" $mirrorlist | head -n $(($num_conn * 2)))<br />
fi<br />
fi<br />
<br />
msg "Downloading $filename"<br />
cd /var/cache/pacman/pkg/<br />
<br />
touch $STATS<br />
<br />
$ARIA2 --conf-path=$CONF --max-tries=1 --max-file-not-found=5 \<br />
--uri-selector=adaptive --server-stat-if=$STATS --server-stat-of=$STATS \<br />
--allow-overwrite=true --remote-time=true --log-level=error --summary-interval=0 \<br />
$url --out=${filename}.pacget && [ ! -f ${filename}.pacget.aria2 ] && mv ${filename}.pacget $2 && chmod 644 $2<br />
<br />
exit $?<br />
</pre><br />
<br />
'''/etc/pacget.conf'''<br />
<pre><br />
# The log file<br />
log=/var/log/pacget.log<br />
# Number of servers to download from<br />
split=5<br />
# Maximum download speed (0 = unrestricted)<br />
max-download-limit=0<br />
# Minimum download speed (0 = don't care)<br />
lowest-speed-limit=0<br />
# Server timeout period<br />
timeout=5<br />
# Passive FTP or not<br />
ftp-pasv=true<br />
# 'none' or 'prealloc'<br />
file-allocation=none<br />
</pre><br />
<br />
Save this script as /usr/bin/pacget.<br />
chmod 755 /usr/bin/pacget<br />
This makes the script an executable<br />
<br />
In /etc/pacman.conf, in the [options] section, the following needs to be added:<br />
XferCommand = exec /usr/bin/pacget %u %o<br />
<br />
PS: If you use ftp.archlinux.org as the first server listed in your include files (/etc/pacman.d/*), some problems may occur when the mirrors you are using have not yet synced. To make great use of this script, choose a mirror (that syncs in a timely manner) that is more appropriate for you, then put that on top of the server lists. This is to prevent downloading only from ftp.archlinux.org when the mirrors have not yet synced. The rankmirrors python script can be useful in this case.<br />
<br />
=== Using other applications ===<br />
<br />
There are other downloading applications that you can use with Pacman. Here they are, and their associated XferCommand settings:<br />
<br />
* <code>snarf</code>: <code>XferCommand = /usr/bin/snarf -N %u</code><br />
* <code>lftp</code>: <code>XferCommand = /usr/bin/lftp -c pget %u</code><br />
* <code>axel</code>: <code>XferCommand = /usr/bin/axel -n 2 -v -a -o %o %u</code><br />
<br />
== Choosing the fastest mirror ==<br />
When downloading packages pacman uses the mirrors in the order they are in /etc/pacman.d/mirrorlist.The mirror which is at the top of the list by default however may not be the fastest for you.<br />
<br />
=== Choosing a local mirror ===<br />
The simple way is to edit mirrorlist file by placing a local mirror at the top of the list. pacman will then use this mirror for preference.<br />
<br />
Alternativley the pacman.conf file can be edited by placing a local mirror before the line sourcing the mirrorlist file, i.e. where it says "add your preferred servers here". It is safer if you use the same server for each repository.<br />
<br />
=== Using rankmirror ===<br />
<br />
You can use rankmirrors to rank pacman mirrors by their connection and opening speed.<br />
<br />
Backup the original in case any problems come up:<br />
<br />
mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.org<br />
<br />
Then run rankmirrors to test and add the five fastest mirrors:<br />
<br />
rankmirrors -n 5 /etc/pacman.d/mirrorlist.org > /etc/pacman.d/mirrorlist<br />
<br />
See the help for more information.<br />
<br />
rankmirrors -h<br />
<br />
=== After changing mirrors ===<br />
<br />
After changing your mirror it is a good idea to refresh the pacman database. Using two y's forces a download of a fresh copy of the master package list from the server even if they are thought to be up to date.<br />
<br />
# pacman -Syy<br />
<br />
== Sharing packages over your LAN ==<br />
<br />
If you happen to run several Arch boxes on your LAN, you can share packages so that you can greatly decrease your download times. Keep in mind you should not share between different architectures (i.e. i686 and x86_64) or you'll get into troubles.<br />
There are actually 2 ways to achieve this :<br />
<br />
=== The do-it-yourself way ===<br />
<br />
Get your hands dirty: http://wiki.archlinux.org/index.php/Howto_Upgrade_via_Home_Network<br />
<br />
=== The easy way ===<br />
<br />
Install and configure [http://xyne.archlinux.ca/contributions Xyne]'s pkgd: http://xyne.archlinux.ca/info/pkgd<br />
<br />
[http://bbs.archlinux.org/viewtopic.php?id=64391 Related forum thread]</div>Hpo3https://wiki.archlinux.org/index.php?title=VirtualBox_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=68148VirtualBox (简体中文)2009-05-04T01:36:21Z<p>Hpo3: </p>
<hr />
<div>[[Category:模拟器]]<br />
[[Category:HOWTOs (简体中文)]]<br />
[[Category:简体中文]]<br />
<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|:VirtualBox}}<br />
{{i18n_entry|Italiano|:VirtualBox (Italiano)}}<br />
{{i18n_entry|简体中文|:VirtualBox (简体中文)}}<br />
{{i18n_entry|Русский|VirtualBox (Русский)}}<br />
{{i18n_entry|Español|VirtualBox (Español)}}<br />
{{i18n_links_end}}<br />
<br />
== 什么是VirtualBox ==<br />
[http://www.virtualbox.org VirtualBox]是类似于vmware的虚拟机模拟器。它拥有vmware的许多特性,以及许多它自身独有的。最近这个软件发展很快,比如在2.2版本对Linux和Solaris引入OpenGL 3D加速功能。这个软件有很友好的界面(QT或SDL),同时也可以依靠强大的命令行来进行操作。<br />
<br />
=== 版本 ===<br />
VirtualBox有两种版本:VirtualBox-ose和VirtualBox(PUEL)(Personal Use and Evaluation License 个人使用和评估许可协议) <br />
<br />
==== VirtualBox-ose ====<br />
这是VirtualBox的开源版本,可以在community软件仓库找到。它缺少一些功能,比如USB支持和RCP服务器。<br />
<br />
==== VirtualBox (PUEL) ====<br />
这是免费供个人使用的版本,可以在<br />
[http://aur.archlinux.org/packages.php?do_Details=1&ID=9753&O=0&L=0&C=0&K=VirtualBox&SB=n&SO=a&PP=25&do_MyPackages=0&do_Orphans=0&SeB=nd AUR]找到,或者到<br />
[http://www.virtualbox.org/wiki/Downloads VirtualBox官方网站]下载<br />
<br />
附加特性包括:<br />
<br />
*<b>远程显示协议(Remote Display Protocol RDP)服务器</b> <br />
<br />
这一要素在虚拟硬件上提供了一个完整的RDP服务器,用户可以通过任何RDP兼容的客户端来远程连接虚拟机。<br />
<br />
*<b>USB支持</b> <br />
<br />
VirtualBox提供了一个虚拟的USB控制器,支持从USB 1.1、USB 2.0设备到虚拟机的传输。<br />
<br />
*<b>在RDP上使用USB</b> <br />
<br />
这是USB支持和RDP服务器的结合,让用户可以在远程运行的虚拟机上使用USB设备。<br />
<br />
*<b>iSCSI initiator</b> <br />
<br />
VirtualBox包含一个内建的iSCSI initiator,不需要虚拟系统对iSCSI的支持就可以用iSCSI targets作虚拟磁盘。<br />
<br />
== 安装 ==<br />
<br />
现在让我们来安装VirtualBox。我们有两种选择:OSE版本或者PUEL版本。<br />
<br />
=== 安装VirtualBox OSE ===<br />
<br />
安装VirtualBox OSE,你需要在/etc/pacman.conf中打开community软件仓库<br />
<br />
#[community]<br />
# Add your preferred servers here, they will be used first<br />
#Include = /etc/pacman.d/community<br />
<br />
改成:<br />
<br />
[community]<br />
# Add your preferred servers here, they will be used first<br />
Include = /etc/pacman.d/community<br />
<br />
用pacman安装VirtualBox OSE:<br />
<br />
pacman -Sy virtualbox-ose<br />
<br />
(注意:安装程序会生成一个桌面项,位于applications -> system tools -> VirtualBox OSE)<br />
<br />
(注意:依靠这种方法安装的VIrtualBOx不支持x86_64平台,2.0.4版本不是在x86_64位平台编译的,2.10版或许会对64位平台有更好支持)<br />
<br />
这样做会默认安装virtualbox-ose和virtualbox-modules两个包。然后你要加自己到vboxusers组:<br />
<br />
gpasswd -a USERNAME vboxusers<br />
<br />
(注意:为使这一变更生效,你需要注销并重新登陆)<br />
<br />
然后把vboxdrv添加到/etc/rc.conf的modules行,它就会在每次开机时自动加载。如果你想手动加载,用root身份输入:<br />
<br />
modprobe vboxdrv<br />
<br />
'''HowTo:'''<br><br />
[[VirtualBox-HowTo]]<br />
<br />
=== 安装VirtualBox PUEL ===<br />
这很容易,因为piie已经写出了一份很好的pkgbuild,就在[http://aur.archlinux.org/packages.php?ID=9753 AUR: virtualbox_bin]里。<br />
<br />
从[http://aur.archlinux.org/packages.php?ID=9753 AUR: virtualbox_bin]下载tar压缩包,解压缩后运行makepkg然后作为root:<br />
<br />
# pacman -U PACKAGE-NAME.pkg.tar.gz <br />
<br />
(注意: 安装程序会生成一个桌面项,位于applications -> system tools -> Innotek VirtualBox)<br />
<br />
'''但是,还有另外一种方法可以更方便安装virtualbox_bin软件包:'''<br />
<br />
首先,按照下面修改/etc/pacman.conf:<br />
[archlinuxfr]<br />
Server = <nowiki>http://repo.archlinux.fr/i686</nowiki><br />
或者<br />
[archlinuxfr]<br />
Server = <nowiki>http://repo.archlinux.fr/x86_64</nowiki><br />
之后就能用<br />
# pacman -Sy virtualbox_bin<br />
安装Virtualbox_bin<br />
<br />
装完以后把你自己加入到vboxusers用户组:<br />
<br />
gpasswd -a USERNAME vboxusers<br />
<br />
(注意:为使这一变更生效,你需要注销并重新登陆)<br />
<br />
把'''vboxdrv'''加到/etc/rc.conf的MODULES行,如果要手动载入模块,在终端下执行:<br />
# modprobe vboxdrv<br />
<br />
<b>重要:</b><br><br />
由于升级、重编译等原因,每次内核版本发生变化时,你都要用"vbox_build_module"来重新制作virtualbox的内核模块。这一程序可能位于以下任何一个位置:<tt>/sbin</tt>, <tt>/bin</tt>, 或<tt>/usr/bin</tt>,必须用超级用户(superuser)权限来执行它。重新制作以后,别忘了加载它:<tt>modprobe vboxdrv</tt>.<br />
<br />
=== 安装QT库 ===<br />
最新的VirtualBox需要QT4库文件来构建图形界面,如果你需要图形界面,就要保证安装了QT4:<br />
# pacman -S qt<br />
<br />
=== 启动VirtualBox ===<br />
要启动VirtualBox,只需要在终端下执行下面的命令:<br />
$ VirtualBox<br />
<br />
=== 安装VirtualBox 2.1 (另外一种方法) ===<br />
<br />
VirtualBox安装也可以直接从VirtualBox网站上下载安装文件来进行安装。[http://www.virtualbox.org/wiki/Linux_Downloads Linux section]<br />
<br />
确保安装了4.3.0或更高版本的 Qt 和 1.2.7 或者更高版本的SDL :<br />
<br />
# pacman -Sy qt sdl <br />
<br />
从网站上根据自己电脑下载 i386/AMD64 的安装文件。之后在终端进入下载目录执行下面的命令:<br />
<br />
# sh VirtualBox-2.XXXX-Linux_ARCH.run<br />
<br />
软件将会被安装在 /opt/VirtualBox-2.XXX 目录。<br />
<br />
装完以后把你自己加入到vboxusers用户组:<br />
<br />
gpasswd -a USERNAME vboxusers<br />
<br />
(注意:为使这一变更生效,你需要注销并重新登陆)<br />
<br />
把'''vboxdrv'''加到/etc/rc.conf的MODULES行,如果要手动载入模块,在终端下执行:<br />
# modprobe vboxdrv<br />
<br />
== 配置 ==<br />
装好VirtualBox并把自己添加到vboxusers组以后,我们就可以开始配置系统,让VirtualBox的所有功能都可以使用。利用GUI提供的向导创建一个新的虚拟机,点击settings来修改虚拟机的设置。<br />
<br />
=== 客户机与主机间的键盘鼠标设置 ===<br />
在虚拟的主机上点击就可以激活客户机对键盘鼠标的捕捉,需要捕捉只需要按下 "Ctrl-Alt Delete"。<br />
<br />
如果在客户机中无法使用键盘和鼠标,你就需要禁用[[Xorg]]的新的热插拔功能[[Xorg#Input_hotplugging_with_xorg-server_1.5| new hot plugging feature of Xorg 1.5]]。将下面内容加入到/etc/X11/xorg.conf中:<br />
<br />
Section "ServerLayout"<br />
. . .<br />
Option "AutoAddDevices" "False"<br />
. . .<br />
EndSection<br />
<br />
一般来说上面这一段只对Linux客户机在Mac OS X 或者Windows主机上才需要设置,但是在Arch64位主机和Arch64位客户机间也需要这样设置。<br />
<br />
如果在客户机和主机之间,鼠标不能统一,就把下面内容加入到xorg.conf中:<br />
<br />
Section "InputDevice"<br />
Identifier "Mouse0"<br />
Driver "vboxmouse"<br />
Option "Protocol" "auto"<br />
Option "Device" "/dev/input/mice"<br />
Option "ZAxisMapping" "4 5 6 7"<br />
EndSection<br />
<br />
Section "ServerLayout"<br />
Identifier "X.org Configured"<br />
Screen 0 "Screen0" 0 0<br />
InputDevice "Mouse0" "CorePointer"<br />
InputDevice "Keyboard0" "CoreKeyboard"<br />
EndSection<br />
<br />
如果你是用 "X -configure" 生成的 xorg.conf , 配置文件会在InputDevice 区域使用 "mouse" 驱动. 安装完Guest Additions后,将"mouse" 用 "vboxmouse" 取代,然后重启 X 系统 或者重启虚拟机。<br />
<br />
=== 让虚拟系统使用网络 ===<br />
首先让虚拟系统能使用网络。点击network标签。”not attached“选项意味着“虚拟机的网络适配器被拨掉了“或其它类似的错误。<br />
<br />
==== 使用NAT网络 ====<br />
这是使用网络的最简单方法。选择NAT network应该就能用了。第一块网卡的NAT IP地址是10.0.2.0,第二块是10.0.3.0,依此类推。<br />
<br />
==== 使用host interface网络 (设置虚拟机来实现)====<br />
这种方法麻烦一点,但它让你的虚拟机看起来就像是局域网上一台”真正的“电脑。从VirtualBox 2.1.0 开始支持直接从客户机来实现Host interface功能。只需要在[[rc.conf]]中的MODULES中加入 '''vboxnetflt''' 之后在你虚拟机设置中选择''Host Interface Networking''。<br />
<br />
==== 使用host interface网络 (设置Arch实现) ====、<br />
<br />
设置下面的几个文件,然后重启就就好:<br />
<br />
* /etc/conf.d/bridges<br />
* /etc/rc.conf<br />
* /etc/vbox/interfaces<br />
<br />
Ready? Let's go!<br />
<br />
'''/etc/conf.d/bridges:'''<br />
bridge_br0="eth0 vbox0" # Put any interfaces you need.<br />
BRIDGE_INTERFACES=(br0)<br />
<br />
'''/etc/rc.conf:'''<br />
在MODULES中加入bridge模块:<br />
MODULES=( <your other modules> '''bridge''')<br />
<br />
在网络设置部落设置如下:<br />
br0="dhcp" # 这是DHCP的设置部分,如果你是静态网络,按照你自己网络情况设置。<br />
INTERFACES=(eth0 br0)<br />
<br />
之后修改 '''/etc/udev/rules.d/60-vboxdrv.rules''' ,输入:<br />
<br />
KERNEL=="vboxdrv", NAME="vboxdrv", OWNER="root", GROUP="vboxusers", MODE="0660"<br />
<br />
保存退出。<br />
<br />
之后打开终端,输入下面内容:<br />
<br />
# pacman -S bridge-utils uml_utilities<br />
<br />
通过命令建立网桥。<br />
<br />
# brctl addbr br0<br />
<br />
'''/etc/vbox/interfaces'''<br />
<br />
<br />
(你可是设置任意多的接口. Sky is the limit!):<br />
<br />
vbox0 your_user br0 # 请再次确保你的用户是在vboxuser用户组中.<br />
<br />
重启,搞定<br />
<br />
'''''注意:''' 记住在虚拟机中设置好对应的网络.''<br />
<br />
'''''注意:''' 如果遇到什么问题,请确定你安装了bridge-utils 并且载入了 vboxnet''<br />
<br />
==== 使用host interface网络 (通用)==== <br />
<br />
这种方法麻烦一点,但它让你的虚拟机看起来就像是局域网上一台”真正的“电脑。你需要安装bridge-utils <br />
<br />
# pacman -S bridge-utils uml_utilities<br />
<br />
:*** Sp1d3rmxn的补充<br />
:你还要加载TUN模块...在rc.conf中添加tun到MODULES行。如果你不想重新启动,用命令"modprobe tun"来加载它。<br />
<br />
:然后'''必须'''设置好权限,有两种方法:<br />
1、命令是:chmod 666 /dev/net/tun<br />
<br />
2、::*** Dharivs的补充<br />
可以不使用命令,而是利用/etc/udev/rules.d/60-vboxdrv.rules,使它们在开机时设置好: <br />
<pre><br />
KERNEL=="vboxdrv", NAME="vboxdrv", OWNER="root", GROUP="vboxusers", MODE="0660"<br />
KERNEL=="tun", OWNER="root", GROUP="vboxusers", MODE="0660"<br />
</pre><br />
<br />
:现在请按照以下所写的进行<br />
<b>1.</b> 用如下命令创建一个新的网桥:<br />
<br />
brctl addbr br0<br />
<br />
<b>2.</b>如果你不是使用DHCP, 运行ifconfig,记下你正在使用的网络设置(比如eth0),一会儿我们需要把它们复制到网桥。<br />
<br />
(注意: <b>你将会用到这些设置,所以请不要弄丢了!!!!</b>)<br />
<br />
<b>3.</b>把你的网卡转换到"promiscuous"模式,这样它将会接收来自它自己以外MAC地址的以太网数据帧(把下面的eth0换成你自己的网络接口):<br />
<br />
ifconfig eth0 0.0.0.0 promisc <br />
<br />
(注意:此时你会失去eth0的网络连接)<br />
<br />
<b>4.</b>把你的网卡添加到网桥上:<br />
<br />
brctl addif br0 eth0<br />
<br />
<b>5.</b> 把你方才所用的物理网卡的设置添加到网桥。如果你使用DHCP,那么:<br />
<br />
dhcpcd -t 30 -h yourhostname br0 &<br />
<br />
或者,运行ifconfig br0 x.x.x.x netmask x.x.x.x,使用你刚才记下的设置。 <br />
<br />
<b>6.</b>创建一个名为vbox0的固定宿主接口(所有用这种方式创建的宿主接口都必须命名为vbox加数字的形式)并把它添加到以上创建的网桥中,命令:<br />
<br />
VBoxAddIF vbox0 vboxuser br0<br />
<br />
把vboxuser替换成将要使用这个接口的用户的名字。<br />
<br />
(注意:VboxAddIF位于/opt/VirtualBox-VIRTUALBOX的版本号/VBoxAddIF)<br />
<br />
另外,你还可以通过/etc/rc.conf来[http://mychael.gotdns.com/blog/2007/05/31/virtualbox-bridging/ 创建一个桥接的网络连接]。<br />
<br />
<br />
==== 让虚拟机使用无线网络来上网 ====<br />
前面的设置方法对无线网络并不适用. 请使用[http://aur.archlinux.org/packages.php?ID=16356 parprouted]的方法来实现.<br />
<br />
# Install parprouted and iproute<br />
# <code># ln -s /usr/sbin/ip /sbin/ip</code><br />
# Make sure IP fowarding is enabled: <code># sysctl net.ipv4.ip_forward=1</code>, and/or edit /etc/sysctl.conf<br />
# <code># VBoxTunctl -b -u <user></code>, to create the tap device<br />
# <code># ip link set tap0 up; ip addr add 192.168.0.X/24 dev tap0</code>, needs to be a manually set IP on the same network your wireless device is.<br />
# <code># parprouted wlan0 tap0</code><br />
<br />
=== 让虚拟机使用USB ===<br />
(需要PUEL版本)<br />
<br />
首先,要在虚拟机上使用USB,你必须在/etc/fstab里添加一行:<br />
<br />
none /proc/bus/usb usbfs devgid=85,devmode=664 0 0<br />
<br />
其中85是被允许访问USB设备的用户组的id。把它换成你的vboxusers组的id。你可以这样来获取该id:<br />
<br />
grep vboxusers /etc/group<br />
<br />
如果你不介意可能的安全漏洞,就把devmode由664改成666。<br />
<br />
重新挂载/proc/bus/usb:<br />
<br />
mount -o remount /proc/bus/usb/<br />
<br />
重启动Virtualbox,点击虚拟机设置的USB标签,选择你的电脑开机时可用的设备。如果你打算使用刚插上的设备(假设虚拟机是开机状态),在虚拟机的窗口找到devices -> USB Devices -> 然后选择你打算插到虚拟机上的设备。<br />
<br />
=== 安装Guest Additions ===<br />
对于 VirtualBox (OSE) version 1.6.2 =>, 参见:<br><br />
[[VirtualBox-HowTo]]<br />
<br />
Guest Additions提供文件夹共享功能以及更好的显卡驱动(2.1版本以上提供3D加速)和鼠标驱动。你将能无缝运行虚拟机(全屏和窗口运行随窗口自动切换,鼠标自动捕捉到和自动释放掉,还可以打开双向的剪贴板。)<br />
<br />
启动虚拟机之后,到菜单里选择Devices->Install Guest Additions...点击之后VirtualBox会往当前的CD-ROM中加载一个ISO镜像, 看起来就像什么都没有发生一样;)<br />
<br />
然后在虚拟系统中以root身份按照以下步骤(如果虚拟系统是windows的话,会自动弹出窗口提示,按提示运行即可,下面的是针对虚拟机是linux的情况):<br />
<br />
# mount /mnt/cdrom<br />
对于i686(32 bit)系统:<br />
# sh /media/cdrom/VBoxLinuxAdditions-x86.run<br />
对于x86-64(64 bit)系统:<br />
# sh /media/cdrom/VBoxLinuxAdditions-amd64.run<br />
<br />
系统将创建和安装内核模块,安装Xorg驱动并创建初始脚本。很可能会有关于初始脚本、run levels的错误信息,忽略它们即可。你将会在/etc/rc.d中找到rc.vboxadd和 rc.vboxvfs(还有/etc/rc.d/rc.local,这个可以删掉)。若要在启动时加载Guest Additions,只需把它们加入/etc/rc.conf的DAEMONS列,比如:<br />
<br />
DAEMONS=(syslog-ng network netfs crond alsa rc.vboxadd rc.vboxvfs)<br />
<br />
如果不通过这种方式,可以按照下面的方法进行:<br />
<br />
# pacman -S virtualbox-additions<br />
<br />
或者<br />
<br />
# pacman -S virtualbox-ose-additions<br />
<br />
之后你会得到一个ISO文件,将这个文件当作loop设备装载。不过首先要保证载入了loop内核模块:<br />
<br />
# modprobe loop<br />
# mount /usr/lib/virtualbox/additions/VBoxGuestAdditions.iso /media/cdrom -o loop<br />
<br />
之后执行 VBoxLinuxAdditions.run。在将rc.vbox加入到DAEMONS前,检查/etc/rc.local是不是已经有了安装程序添加的用于启动vboxadd的daemons.<br />
<br />
'''注意:'''如果你安装了Xorg,请检查/etc/X11/xorg.conf,看显卡驱动是否为vboxvideo。如果出现找不到鼠标的现象,把鼠标驱动由“mouse”改成“vboxmouse“。<br />
<br />
=== 宿主机与虚拟机间的共享文件夹 ===<br />
对于 VirtualBox (OSE) version 1.6.2 =>, 请参见:<br><br />
[[VirtualBox-HowTo]]<br />
<br />
在虚拟机设置中,找到shared folders标签,添加你想共享的文件夹。<br />
<br />
*注意:要使用这一功能,你需要安装Guest Additions。<br />
<br />
在Windows虚拟系统中,自VirtualBox 1.5.0起,共享文件夹在Windows Explorer中是可见的。打开Windows Explorer到以下位置寻找:<br />
<br />
My Networking Places --> Entire Network --> VirtualBox Shared Folders<br />
<br />
另外,用Windows的命令行,你也可以这样:<br />
<br />
net use x: \\vboxsvr\sharename<br />
<br />
其中vboxsvr是固定的名称,把"x:"换成你想用来共享的盘符,sharename换成在VBoxManage中指定的文件夹名称<br />
<br />
在Linux虚拟系统中,使用如下命令:<br />
<br />
mount -t vboxsf [-o OPTIONS] sharename mountpoint<br />
<br />
把sharename换成在VBoxManage中指定的文件夹名称,mountpoint换成你想挂载到的路径(例如/mnt/share)。如果这个目录不存在,挂载前先创建它。<br />
<br />
除了mount命令提供的标准选项之外,还有如下选项可用:<br />
iocharset CHARSET<br />
设定I/O操作中所用的字符集(默认是utf8),以及<br />
convertcp CHARSET<br />
指定共享文件夹名所用的字符集(默认是utf8)。<br />
<br />
=== 在虚拟机中使用音频 ===<br />
<br />
在虚拟机设置的audio标签中选择对应驱动(alsa,OSS或者PulseAudio)。如果声音和真机出现冲突,可以使用另外的两种驱动(必须真机中已经安装了它们)<br />
<br />
=== 设置虚拟机的内存的显存 ===<br />
<br />
你可以在settings -> general中修改默认值。<br />
<br />
=== 为虚拟机设转置CDROM ===<br />
<br />
你可以在settings -> CD/DVD-ROM中修改默认值。<br />
<br />
勾选“mount cd/dvd drive”并在其后的选项中选择一个。<br />
<br />
''注意:''' 如果检测不到光驱,确保守护程序HAL已经被启动. 可以使用下面的命令来启动:<br />
<br />
# /etc/rc.d/hal start<br />
<br />
=== 重建vboxdrv模块 ===<br />
更新kernel之后,为使VirtualBox继续工作可能需要这样做。以root身份运行如下命令:<br />
<br />
/usr/bin/vbox_build_module</div>Hpo3https://wiki.archlinux.org/index.php?title=ArchWiki_talk:Sandbox&diff=67953ArchWiki talk:Sandbox2009-05-01T02:50:40Z<p>Hpo3: </p>
<hr />
<div>联合联合</div>Hpo3https://wiki.archlinux.org/index.php?title=User_talk:Hpo3&diff=67952User talk:Hpo32009-05-01T02:45:24Z<p>Hpo3: </p>
<hr />
<div>[[Category:HOWTOs (简体中文)]]<br />
<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|Ivman}}<br />
{{i18n_entry|简体中文|Ivman(简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
=介绍=<br />
<br />
这篇文章将向您介绍 Ivman 的安装与配置。Ivman 是通过 HAL/dbus 来管理驱动器的终端软件。Ivman 在你的桌面环境或者视窗软件没有自动挂载的功能时可以帮你挂载驱动器。这篇文章是从 Ivman 俄语文章基础上翻译到英文,再从英文翻译而来。<br />
<br />
=安装=<br />
<br />
Ivman 的安装依赖下面的四个软件:<br />
* udev<br />
* hal<br />
* dbus<br />
* pmount<br />
<br />
按照下面的命令安装 Ivman 的依赖包:<br />
# pacman -Sy udev hal dbus pmount<br />
<br />
Ivman 的安装包需要从 AUR 获得: <br />
[http://aur.archlinux.org/packages.php?ID=18938 这里]<br />
<br />
'''注意:''' ivman 需要安装打了补丁后的版本,因为 ivman 已经停止升级开发,仅仅进行基本维护,可能会由于HAL/dbus的版本升级而导致软件不能正常使用。<br />
<br />
=配置=<br />
在配置 ivman 前首先要确保你在 rc.conf 文件中已经进入了 hal 。如果还没有这么做,编辑 /etc/rc.conf,在守护进程 ( daemons ) 中加入 hal。当然要以root身份修改这个文件。<br />
DAEMONS = (syslog-ng '''hal''' network ...)<br />
<br />
在默认配置中, Ivman会自动挂载 /media 下的所有驱动器,并动态创建和删除所需要的文件夹,所以并没有必要自己创建和删除目录。Ivman 使用 pmount 来挂载驱动器,因而闪存驱动器会被叫做 'usbdisk', 'usbdisk1'等,而光盘会按照光盘的卷标来命名。<br />
<br />
如果驱动器在 fstab 文件中有对应的条目, ivman 会按照文件中参数进行挂载。如果没有对应的条目,ivman 调用 pmount 命令用默认参数挂载驱动器,并将挂载后的驱动器文件夹放在 /media 中。 因此,如果你对挂载的驱动器有特殊的参数要求,那么就必须在 fstab 文件中现加入对应的条目使 ivman 能以你需要的方式加载。<br />
<br />
=启动程序=<br />
<br />
==守护进程 ( Daemon )==<br />
Ivman 可以以守护进程的方式启动,只需要在 /etc/rc.conf 中的 DAEMONS 中加入 ivman :<br />
DAEMONS = (syslog-ng hal '''ivman''' network ...)<br />
<br />
但是在一些系统中,启动后一段时间 ivman 会报错。(从俄语翻译成英语再翻译成中文,中间歧义太大,据英文文章中说他也没弄明白到底怎么回事) 。如果以守护进程的方式启动ivman, 那么 ivman 会让所有的存储对所有人都有读取的权限,对驱动器有所有权的用户组有读/写权限。<br />
<br />
== 手动启动 ==<br />
如果手动启动 ivman ,那么这个驱动器就只对当前的用户有读/写权限,其他用户都不可以读写。<br />
<br />
使用下面的命令手动启动ivman:<br />
# ivman<br />
一种比较有效的方式就是在 X 界面的启动脚本中加入 ivman :<br />
ivman &<br />
numlockx &<br />
exec openbox-session<br />
<br />
( 在部分窗口管理软件中,还需要在 session 文件中也加入ivman,例如 openbox 和 pekwm 等。)<br />
<br />
守护进程和手动启动的 ivman 并不冲突, 如果用户用户没有手动运行 ivman ,那么系统的守护进程会挂载驱动器。如果手动运行了程序,那么驱动器会优先由手动运行的 ivman 挂载。<br />
<br />
= 小贴示与小技巧 =<br />
上面提到的东西已经足够你使你的驱动器正确挂载上了。但是 Ivman 还有一些其他小的功能。 比如其中有一个很有意思的个功能,那就是当驱动器正确连接上电脑时候,给用户一个提示,即驱动器已经正确识别并指出驱动器将在什么位置挂载上。要使用这个功能,就需要手动修改 ivman 在 ~/.ivman 下的配置文件了。这个文件叫做 IvmConfigActions.xml。将下面的内容加入到IvmConfigActions.xml中:<br />
<br />
<ivm:Match name="hal.info.category" value="storage"> <ivm:Match name="hal.info.category" value="storage"> <br />
<ivm:Match name="hal.storage.bus" value="usb"> <ivm:Match name="hal.storage.bus" value="usb"> <br />
<ivm:Option name="exec" value="kdialog -passivepopup 'обнаружен USB-накопитель $hal.info.vendor$ $hal.info.product$ с меткой $hal.partition.label$' 4" /> <br />
<ivm:Option name="exec" value="kdialog -passivepopup'obnaruzhen USB-nakopitel $hal.info.vendor$ $hal.info.product$ labeled $hal.partition.label$' 4" /> <br />
</ivm:Match> </ ivm: Match> <br />
</ivm:Match> </ ivm: Match><br />
<br />
上面这些内容,会让 ivman 在正确挂载 USB 驱动器后通过一个 kdialog 的对话框提示驱动器被正确识别。(你也可以用zenity来实现 GTK 造型的对话框。 )<br />
<br />
= 问题解答 =<br />
我个人在 ivman 配置安装过程中没有遇到任何问题,如果你遇到了,可以尝试 ivman 的调试模式:<br />
# ivman -d<br />
<br />
或者运行<br />
# hal-devices<br />
<br />
来确保驱动器已经被正确识别。</div>Hpo3https://wiki.archlinux.org/index.php?title=User_talk:Hpo3&diff=67951User talk:Hpo32009-05-01T02:40:23Z<p>Hpo3: Created page with 'Category:HOWTOs (简体中文) {{i18n_links_start}} {{i18n_entry|English|Ivman}} {{i18n_entry|简体中文|Ivman}} {{i18n_links_end}} =介绍= 这篇文章将向您介...'</p>
<hr />
<div>[[Category:HOWTOs (简体中文)]]<br />
<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|Ivman}}<br />
{{i18n_entry|简体中文|Ivman}}<br />
{{i18n_links_end}}<br />
<br />
=介绍=<br />
<br />
这篇文章将向您介绍 Ivman 的安装与配置。Ivman 是通过 HAL/dbus 来管理驱动器的终端软件。Ivman 在你的桌面环境或者视窗软件没有自动挂载的功能时可以帮你挂载驱动器。这篇文章是从 Ivman 俄语文章基础上翻译到英文,再从英文翻译而来。<br />
<br />
=安装=<br />
<br />
Ivman 的安装依赖下面的四个软件:<br />
* udev<br />
* hal<br />
* dbus<br />
* pmount<br />
<br />
按照下面的命令安装 Ivman 的依赖包:<br />
# pacman -Sy udev hal dbus pmount<br />
<br />
Ivman 的安装包需要从 AUR 获得: <br />
[http://aur.archlinux.org/packages.php?ID=18938 这里]<br />
<br />
'''注意:''' ivman 需要安装打了补丁后的版本,因为 ivman 已经停止升级开发,仅仅进行基本维护,可能会由于HAL/dbus的版本升级而导致软件不能正常使用。<br />
<br />
=配置=<br />
在配置 ivman 前首先要确保你在 rc.conf 文件中已经进入了 hal 。如果还没有这么做,编辑 /etc/rc.conf,在守护进程 ( daemons ) 中加入 hal。当然要以root身份修改这个文件。<br />
DAEMONS = (syslog-ng '''hal''' network ...)<br />
<br />
在默认配置中, Ivman会自动挂载 /media 下的所有驱动器,并动态创建和删除所需要的文件夹,所以并没有必要自己创建和删除目录。Ivman 使用 pmount 来挂载驱动器,因而闪存驱动器会被叫做 'usbdisk', 'usbdisk1'等,而光盘会按照光盘的卷标来命名。<br />
<br />
如果驱动器在 fstab 文件中有对应的条目, ivman 会按照文件中参数进行挂载。如果没有对应的条目,ivman 调用 pmount 命令用默认参数挂载驱动器,并将挂载后的驱动器文件夹放在 /media 中。 因此,如果你对挂载的驱动器有特殊的参数要求,那么就必须在 fstab 文件中现加入对应的条目使 ivman 能以你需要的方式加载。<br />
<br />
=启动程序=<br />
<br />
==守护进程 ( Daemon )==<br />
Ivman 可以以守护进程的方式启动,只需要在 /etc/rc.conf 中的 DAEMONS 中加入 ivman :<br />
DAEMONS = (syslog-ng hal '''ivman''' network ...)<br />
<br />
但是在一些系统中,启动后一段时间 ivman 会报错。(从俄语翻译成英语再翻译成中文,中间歧义太大,据英文文章中说他也没弄明白到底怎么回事) 。如果以守护进程的方式启动ivman, 那么 ivman 会让所有的存储对所有人都有读取的权限,对驱动器有所有权的用户组有读/写权限。<br />
<br />
== 手动启动 ==<br />
如果手动启动 ivman ,那么这个驱动器就只对当前的用户有读/写权限,其他用户都不可以读写。<br />
<br />
使用下面的命令手动启动ivman:<br />
# ivman<br />
一种比较有效的方式就是在 X 界面的启动脚本中加入 ivman :<br />
ivman &<br />
numlockx &<br />
exec openbox-session<br />
<br />
( 在部分窗口管理软件中,还需要在 session 文件中也加入ivman,例如 openbox 和 pekwm 等。)<br />
<br />
守护进程和手动启动的 ivman 并不冲突, 如果用户用户没有手动运行 ivman ,那么系统的守护进程会挂载驱动器。如果手动运行了程序,那么驱动器会优先由手动运行的 ivman 挂载。<br />
<br />
= 小贴示与小技巧 =<br />
上面提到的东西已经足够你使你的驱动器正确挂载上了。但是 Ivman 还有一些其他小的功能。 比如其中有一个很有意思的个功能,那就是当驱动器正确连接上电脑时候,给用户一个提示,即驱动器已经正确识别并指出驱动器将在什么位置挂载上。要使用这个功能,就需要手动修改 ivman 在 ~/.ivman 下的配置文件了。这个文件叫做 IvmConfigActions.xml。将下面的内容加入到IvmConfigActions.xml中:<br />
<br />
<ivm:Match name="hal.info.category" value="storage"> <ivm:Match name="hal.info.category" value="storage"> <br />
<ivm:Match name="hal.storage.bus" value="usb"> <ivm:Match name="hal.storage.bus" value="usb"> <br />
<ivm:Option name="exec" value="kdialog -passivepopup 'обнаружен USB-накопитель $hal.info.vendor$ $hal.info.product$ с меткой $hal.partition.label$' 4" /> <br />
<ivm:Option name="exec" value="kdialog -passivepopup'obnaruzhen USB-nakopitel $hal.info.vendor$ $hal.info.product$ labeled $hal.partition.label$' 4" /> <br />
</ivm:Match> </ ivm: Match> <br />
</ivm:Match> </ ivm: Match><br />
<br />
上面这些内容,会让 ivman 在正确挂载 USB 驱动器后通过一个 kdialog 的对话框提示驱动器被正确识别。(你也可以用zenity来实现 GTK 造型的对话框。 )<br />
<br />
= 问题解答 =<br />
我个人在 ivman 配置安装过程中没有遇到任何问题,如果你遇到了,可以尝试 ivman 的调试模式:<br />
# ivman -d<br />
<br />
或者运行<br />
# hal-devices<br />
<br />
来确保驱动器已经被正确识别。</div>Hpo3