https://wiki.archlinux.org/api.php?action=feedcontributions&user=Apoulos&feedformat=atomArchWiki - User contributions [en]2024-03-29T15:30:45ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=KMSCON&diff=799043KMSCON2024-02-01T14:25:52Z<p>Apoulos: fix formatting of automatic login</p>
<hr />
<div>[[Category:Terminal emulators]]<br />
[[ja:KMSCON]]<br />
[[zh-hans:KMSCON]]<br />
{{Related articles start}}<br />
{{Related|KMS}}<br />
{{Related|systemd}}<br />
{{Related articles end}}<br />
<br />
From the project's [https://cgit.freedesktop.org/~dvdhrm/kmscon/tree/README git repository]:<br />
<br />
:Kmscon is a simple terminal emulator based on linux [[kernel mode setting]]. It is an attempt to replace the in-kernel VT implementation with a userspace console.<br />
<br />
== Features ==<br />
<br />
Kmscon can function as a drop-in replacement for the in-kernel linux-console. Features include:<br />
<br />
* Full vt220 to vt510 implementation.<br />
* Full internationalization support:<br />
** Kmscon supports printing full Unicode glyphs, including the CJK ones.<br />
** Kmscon provides internationalized keyboard handling through libxkbcommon, thus allowing it to use the full range of keyboard layouts supported in X keyboard.<br />
* Hardware accelerated rendering.<br />
* [https://www.freedesktop.org/wiki/Software/systemd/multiseat/ Multi-seat] capability.<br />
<br />
{{Note|In order to be able to log into a kmscon console as root, you have to disable the {{ic|pam_securetty}} module by removing or commenting out the corresponding line in {{ic|/etc/pam.d/login}}. }}<br />
<br />
== Installation ==<br />
<br />
Despite its name, [[KMS]] is not a hard requirement for kmscon. Kmscon supports the following video backends: drm3d (Linux DRM hardware-rendering backend), drm2d (Linux DRM software-rendering backend), [[wikipedia:Linux framebuffer|superseded]] fbdev (Linux fbdev video backend). Make sure one of them is available on your system.<br />
<br />
Install the {{AUR|kmscon}} package or the {{AUR|kmscon-git}} package for a development version. Alternatively, install {{AUR|kmscon-patched-git}}. The patched version, along with its patched dependency ({{AUR|libtsm-patched-git}}), includes fixes and improvements.<br />
<br />
Normally, there is a special systemd configuration for tty1. To be conservative, you can continue to run the traditional agetty on tty1 and only run kmscon on all the other virtual terminals. Or you can run kmscon on both tty1 and the other VTs.<br />
<br />
To enable kmscon on tty1, [[disable]] {{ic|getty@tty1.service}} and [[enable]] {{ic|kmsconvt@tty1.service}}.<br />
<br />
To enable kmscon on all virtual terminals, run:<br />
<br />
{{bc|<br />
# ln -s /usr/lib/systemd/system/kmsconvt\@.service /etc/systemd/system/autovt\@.service<br />
}}<br />
<br />
This will make {{pkg|systemd}} start kmscon instead of agetty on each VT. More precisely, this will make ''systemd-logind'' use {{ic|kmsconvt@.service}} instead of {{ic|getty@.service}} for new VTs. Additionally, all other systemd units that use {{ic|getty@.service}} will not be affected by this change.<br />
<br />
If ''kmscon'' cannot start for whatever reason, this unit will cause {{ic|getty@.service}} to be started instead. Furthermore, if no VTs are available, this unit will not start anything.<br />
<br />
{{Warning|If you have replaced agetty on all terminals, take care to ensure ''kmscon'' presents you with a prompt before rebooting your machine, otherwise you may have to recover through a live CD.}}<br />
<br />
== CJK support ==<br />
<br />
Kmscon supports rendering CJK characters through the default font engine {{pkg|pango}}. However, {{pkg|fontconfig}} has to be ''globally'' configured to map the monospace font alias to proper CJK fonts. For Chinese users, the following template is provided and proved to result in satisfactory Chinese characters rendering:<br />
<br />
{{hc|/etc/fonts/conf.d/99-kmscon.conf|<nowiki><br />
<?xml version="1.0"?><br />
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"><br />
<fontconfig><br />
<match><br />
<test name="family"><string>monospace</string></test><br />
<edit name="family" mode="prepend" binding="strong"><br />
<string>DejaVu Sans Mono</string><br />
<string>WenQuanYi Micro Hei Mono</string><br />
</edit><br />
</match><br />
</fontconfig><br />
</nowiki>}}<br />
<br />
Alternatively, we can add the following line to {{ic|/etc/kmscon/kmscon.conf}} for globally configuring kmscon using the fonts:<br />
<br />
{{hc|/etc/kmscon/kmscon.conf|<nowiki><br />
font-name=DejaVu Sans Mono, WenQuanYi Micro Hei Mono<br />
font-size=14<br />
</nowiki>}}<br />
<br />
See {{man|1|kmscon|url=}}.<br />
<br />
You need to have {{Pkg|ttf-dejavu}} and {{Pkg|wqy-microhei}}, both available from the official repositories, installed.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Problems with switching between Xorg and kmscon ===<br />
<br />
You may want to add {{ic|hwaccel}} to {{ic|/etc/kmscon/kmscon.conf}} if you have problems with switching between [[Xorg]] and kmscon. The file and folder are not part of the package and therefore have to be created manually. Another possibility would be [[Systemd#Editing provided units|editing the systemd service file]].<br />
<br />
=== No audio control ===<br />
<br />
As version 7, if you cannot control the audio, add your user to the {{ic|audio}} [[user group]]. Be aware of the [[Alsa#Installation|shortcomings]] of this choice.<br />
<br />
=== Vim does not clear terminal output ===<br />
<br />
Vim might open without clearing the terminal output, it is still possible to edit the file but the text will not be visible until it is changed. As a workaround, try setting the [[environment variable]] {{ic|1=TERM=vt220}}. Alternatively, another vim-like editor like {{Pkg|vi}} or [[Neovim]] might work.<br />
<br />
{{Note|Color support is not available if {{ic|TERM}} is set to {{ic|vt220}}.}}<br />
<br />
=== Automatic login ===<br />
<br />
It is possible to login as user ''username'' automatically without asking for password by adding this to {{ic|/etc/kmscon/kmscon.conf}}<br />
<br />
{{hc|/etc/kmscon/kmscon.conf|2= <br />
# Example: Login as user "''username''" without asking for password<br />
login=/bin/login -p -f ''username''<br />
}}<br />
<br />
Or as user ''root'':<br />
<br />
{{hc|/etc/kmscon/kmscon.conf|2=<br />
# Example: Login as root in a bash shell without asking for password<br />
login=/bin/bash --login<br />
}}<br />
<br />
=== HiDPI support ===<br />
<br />
You can change font size on the fly with {{ic|Ctrl++}}, {{ic|1=Ctrl+Shift+=}}, {{ic|Ctrl+-}} shortcuts. Also you can set 'font-dpi' and 'font-size' in {{ic|/etc/kmscon/kmscon.conf}} e.g. 'font-dpi=288' 288 is 96 * 3 that is 300% scaling. 96 is default.</div>Apouloshttps://wiki.archlinux.org/index.php?title=KMSCON&diff=799042KMSCON2024-02-01T14:07:43Z<p>Apoulos: changed examples for automatic login</p>
<hr />
<div>[[Category:Terminal emulators]]<br />
[[ja:KMSCON]]<br />
[[zh-hans:KMSCON]]<br />
{{Related articles start}}<br />
{{Related|KMS}}<br />
{{Related|systemd}}<br />
{{Related articles end}}<br />
<br />
From the project's [https://cgit.freedesktop.org/~dvdhrm/kmscon/tree/README git repository]:<br />
<br />
:Kmscon is a simple terminal emulator based on linux [[kernel mode setting]]. It is an attempt to replace the in-kernel VT implementation with a userspace console.<br />
<br />
== Features ==<br />
<br />
Kmscon can function as a drop-in replacement for the in-kernel linux-console. Features include:<br />
<br />
* Full vt220 to vt510 implementation.<br />
* Full internationalization support:<br />
** Kmscon supports printing full Unicode glyphs, including the CJK ones.<br />
** Kmscon provides internationalized keyboard handling through libxkbcommon, thus allowing it to use the full range of keyboard layouts supported in X keyboard.<br />
* Hardware accelerated rendering.<br />
* [https://www.freedesktop.org/wiki/Software/systemd/multiseat/ Multi-seat] capability.<br />
<br />
{{Note|In order to be able to log into a kmscon console as root, you have to disable the {{ic|pam_securetty}} module by removing or commenting out the corresponding line in {{ic|/etc/pam.d/login}}. }}<br />
<br />
== Installation ==<br />
<br />
Despite its name, [[KMS]] is not a hard requirement for kmscon. Kmscon supports the following video backends: drm3d (Linux DRM hardware-rendering backend), drm2d (Linux DRM software-rendering backend), [[wikipedia:Linux framebuffer|superseded]] fbdev (Linux fbdev video backend). Make sure one of them is available on your system.<br />
<br />
Install the {{AUR|kmscon}} package or the {{AUR|kmscon-git}} package for a development version. Alternatively, install {{AUR|kmscon-patched-git}}. The patched version, along with its patched dependency ({{AUR|libtsm-patched-git}}), includes fixes and improvements.<br />
<br />
Normally, there is a special systemd configuration for tty1. To be conservative, you can continue to run the traditional agetty on tty1 and only run kmscon on all the other virtual terminals. Or you can run kmscon on both tty1 and the other VTs.<br />
<br />
To enable kmscon on tty1, [[disable]] {{ic|getty@tty1.service}} and [[enable]] {{ic|kmsconvt@tty1.service}}.<br />
<br />
To enable kmscon on all virtual terminals, run:<br />
<br />
{{bc|<br />
# ln -s /usr/lib/systemd/system/kmsconvt\@.service /etc/systemd/system/autovt\@.service<br />
}}<br />
<br />
This will make {{pkg|systemd}} start kmscon instead of agetty on each VT. More precisely, this will make ''systemd-logind'' use {{ic|kmsconvt@.service}} instead of {{ic|getty@.service}} for new VTs. Additionally, all other systemd units that use {{ic|getty@.service}} will not be affected by this change.<br />
<br />
If ''kmscon'' cannot start for whatever reason, this unit will cause {{ic|getty@.service}} to be started instead. Furthermore, if no VTs are available, this unit will not start anything.<br />
<br />
{{Warning|If you have replaced agetty on all terminals, take care to ensure ''kmscon'' presents you with a prompt before rebooting your machine, otherwise you may have to recover through a live CD.}}<br />
<br />
== CJK support ==<br />
<br />
Kmscon supports rendering CJK characters through the default font engine {{pkg|pango}}. However, {{pkg|fontconfig}} has to be ''globally'' configured to map the monospace font alias to proper CJK fonts. For Chinese users, the following template is provided and proved to result in satisfactory Chinese characters rendering:<br />
<br />
{{hc|/etc/fonts/conf.d/99-kmscon.conf|<nowiki><br />
<?xml version="1.0"?><br />
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"><br />
<fontconfig><br />
<match><br />
<test name="family"><string>monospace</string></test><br />
<edit name="family" mode="prepend" binding="strong"><br />
<string>DejaVu Sans Mono</string><br />
<string>WenQuanYi Micro Hei Mono</string><br />
</edit><br />
</match><br />
</fontconfig><br />
</nowiki>}}<br />
<br />
Alternatively, we can add the following line to {{ic|/etc/kmscon/kmscon.conf}} for globally configuring kmscon using the fonts:<br />
<br />
{{hc|/etc/kmscon/kmscon.conf|<nowiki><br />
font-name=DejaVu Sans Mono, WenQuanYi Micro Hei Mono<br />
font-size=14<br />
</nowiki>}}<br />
<br />
See {{man|1|kmscon|url=}}.<br />
<br />
You need to have {{Pkg|ttf-dejavu}} and {{Pkg|wqy-microhei}}, both available from the official repositories, installed.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Problems with switching between Xorg and kmscon ===<br />
<br />
You may want to add {{ic|hwaccel}} to {{ic|/etc/kmscon/kmscon.conf}} if you have problems with switching between [[Xorg]] and kmscon. The file and folder are not part of the package and therefore have to be created manually. Another possibility would be [[Systemd#Editing provided units|editing the systemd service file]].<br />
<br />
=== No audio control ===<br />
<br />
As version 7, if you cannot control the audio, add your user to the {{ic|audio}} [[user group]]. Be aware of the [[Alsa#Installation|shortcomings]] of this choice.<br />
<br />
=== Vim does not clear terminal output ===<br />
<br />
Vim might open without clearing the terminal output, it is still possible to edit the file but the text will not be visible until it is changed. As a workaround, try setting the [[environment variable]] {{ic|1=TERM=vt220}}. Alternatively, another vim-like editor like {{Pkg|vi}} or [[Neovim]] might work.<br />
<br />
{{Note|Color support is not available if {{ic|TERM}} is set to {{ic|vt220}}.}}<br />
<br />
=== Automatic login ===<br />
<br />
It is possible to login a user automatically without asking for password by adding this to {{ic|/etc/kmscon/kmscon.conf}}<br />
<br />
# Modify this command to do what you need<br />
<br />
# Example: Login as root in a bash shell without asking for password<br />
login=/bin/bash --login<br />
<br />
# Example: Login as user `<your_username>` without asking for password<br />
login=/bin/login -p -f <your_username><br />
<br />
=== HiDPI support ===<br />
<br />
You can change font size on the fly with {{ic|Ctrl++}}, {{ic|1=Ctrl+Shift+=}}, {{ic|Ctrl+-}} shortcuts. Also you can set 'font-dpi' and 'font-size' in {{ic|/etc/kmscon/kmscon.conf}} e.g. 'font-dpi=288' 288 is 96 * 3 that is 300% scaling. 96 is default.</div>Apouloshttps://wiki.archlinux.org/index.php?title=Easy-RSA&diff=765858Easy-RSA2023-01-30T23:45:19Z<p>Apoulos: misspelled directory name in configuration script</p>
<hr />
<div>[[Category:Virtual Private Network]]<br />
[[ja:Easy-RSA]]<br />
The first step when setting up [[OpenVPN]] is to create a [[Wikipedia:Public key infrastructure|Public Key Infrastructure (PKI)]]. In summary, this consists of:<br />
<br />
* A public master [[Wikipedia:Certificate Authority|Certificate Authority (CA)]] certificate and a private key.<br />
* A separate public certificate and private key pair for each server.<br />
* A separate public certificate and private key pair for each client.<br />
<br />
One can think of the key-based authentication in terms similar to that of how [[SSH keys]] work with the added layer of a signing authority (the CA). OpenVPN relies on a bidirectional authentication strategy, so the client must authenticate the server's certificate and in parallel, the server must authenticate the client's certificate. This is accomplished by the 3rd party's signature (the CA) on both the client and server certificates. Once this is established, further checks are performed before the authentication is complete. For more details, see [https://www.secure-computing.net/openvpn/howto.php#pki secure-computing's guide].<br />
<br />
{{Note|<br />
* The process outlined below requires users to securely transfer private key files to/from machines. For the purposes of this guide, using scp is shown, but readers may employ alternative methods as well. Since the Arch default is to deny the root user over ssh, using scp requires transferring ownership of the files to be exported to a non-root user called ''archie'' throughout the guide.<br />
* Avoid generating keys on devices without a good entropy source. See [https://community.openvpn.net/openvpn/wiki/GettingStartedwithOVPN#Configuringencryption]. Sometimes, [[Random number generation#Alternatives|cryptographically secure pseudorandom number generators]] can be used.<br />
}}<br />
<br />
== Certificate Authority (CA) ==<br />
<br />
For security purposes, it is recommended that the CA machine be separate from the machine running OpenVPN.<br />
<br />
On the '''CA machine''', install {{Pkg|easy-rsa}}, initialize a new PKI and generate a CA keypair that will be used to sign certificates:<br />
<br />
# cd /root<br />
# export EASYRSA=/etc/easy-rsa<br />
# easyrsa init-pki<br />
# easyrsa build-ca<br />
<br />
Starting from OpenVPN 2.4, one can also use elliptic curves for TLS connections (e.g. tls-cipher TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384). Elliptic curve cryptography provides more security and eliminates the need for a Diffie-Hellman parameters file. See [https://forums.openvpn.net/viewtopic.php?f=4&t=23227] and [https://www.maths.tcd.ie/~fionn/misc/ec_vpn.php].<br />
<br />
Append the following lines to {{ic|/etc/easy-rsa/vars}}:<br />
<br />
{{hc|/etc/easy-rsa/vars|<br />
set_var EASYRSA_DIGEST "sha512" # Default sha256<br />
set_var EASYRSA_NS_SUPPORT "yes" # for Netscape compatibility, deprecated<br />
}}<br />
<br />
For elliptic curve:<br />
<br />
{{hc|/etc/easy-rsa/vars|<br />
set_var EASYRSA_ALGO ec<br />
set_var EASYRSA_CURVE secp521r1<br />
}}<br />
<br />
or for [[Wikipedia:Twisted_Edwards_curve|Twisted Edwards curve]]:<br />
<br />
{{hc|/etc/easy-rsa/vars|<br />
set_var EASYRSA_ALGO ed<br />
set_var EASYRSA_CURVE ed25519<br />
}}<br />
<br />
Now set up PKI and generate a CA certificate:<br />
<br />
# cd /root<br />
# export EASYRSA=/etc/easy-rsa<br />
# export EASYRSA_VARS_FILE=/etc/easy-rsa/vars<br />
# easyrsa init-pki<br />
# easyrsa build-ca<br />
<br />
== OpenVPN server files ==<br />
<br />
A functional OpenVPN server requires the following:<br />
<br />
# The CA's public certificate<br />
# The Diffie-Hellman (DH) parameters file (required by TLS mode when not using TLS with elliptic curves).<br />
# The server key pair (a public certificate and a private key).<br />
# The Hash-based Message Authentication Code (HMAC) key.<br />
<br />
Upon completing the steps outlined in this article, users will have generated the following files on the server:<br />
<br />
# {{ic|/etc/openvpn/server/ca.crt}}<br />
# {{ic|/etc/openvpn/server/dh.pem}} (not when using TLS with elliptic curves)<br />
# {{ic|/etc/openvpn/server/servername.crt}} and {{ic|/etc/openvpn/server/servername.key}}<br />
# {{ic|/etc/openvpn/server/ta.key}}<br />
<br />
=== CA public certificate ===<br />
<br />
The CA public certificate {{ic|/etc/easy-rsa/pki/ca.crt}} generated in the previous step needs to be copied over to the machine that will be running OpenVPN.<br />
<br />
On the '''CA machine''':<br />
<br />
# scp /etc/easy-rsa/pki/ca.crt archie@hostname-of-openvpn-server:/tmp/ca.crt<br />
<br />
On the '''OpenVPN server machine''':<br />
<br />
# mv /tmp/ca.crt /etc/openvpn/server/<br />
# chown root:openvpn /etc/openvpn/server/ca.crt<br />
<br />
=== Server certificate and private key ===<br />
<br />
On the '''OpenVPN server machine''', install {{Pkg|easy-rsa}} and generate a key pair for the server:<br />
<br />
# cd /etc/easy-rsa<br />
# easyrsa init-pki<br />
# easyrsa gen-req servername nopass<br />
# cp /etc/easy-rsa/pki/private/servername.key /etc/openvpn/server/<br />
<br />
This will create two files:<br />
<br />
* {{ic|/etc/easy-rsa/pki/reqs/servername.req}}<br />
* {{ic|/etc/easy-rsa/pki/private/servername.key}}<br />
<br />
=== Diffie-Hellman (DH) parameters file ===<br />
<br />
{{Note|If you are using TLS with elliptic curves, skip this step.}}<br />
<br />
On the '''OpenVPN server machine''', create the initial dh.pem file:<br />
<br />
# openssl dhparam -out /etc/openvpn/server/dh.pem 2048<br />
<br />
{{Note|Although values higher than 2048 (4096 for example) may be used, they take considerably more time to generate and offer little benefit in security but advisable to have the DH prime number length to match the length of the RSA key. See [https://community.openvpn.net/openvpn/wiki/GettingStartedwithOVPN#Configuringencryption].}}<br />
<br />
=== Hash-based Message Authentication Code (HMAC) key ===<br />
<br />
On the '''OpenVPN server machine''', create the HMAC key:<br />
<br />
# openvpn --genkey secret /etc/openvpn/server/ta.key<br />
<br />
If elliptic curve is used, the HMAC key is generated with the following command:<br />
# openvpn --genkey tls-auth /etc/openvpn/server/ta.key<br />
<br />
This will be used to add an additional HMAC signature to all SSL/TLS handshake packets. In addition any UDP packet not having the correct HMAC signature will be immediately dropped, protecting against:<br />
<br />
* Portscanning.<br />
* DOS attacks on the OpenVPN UDP port.<br />
* SSL/TLS handshake initiations from unauthorized machines.<br />
* Any eventual buffer overflow vulnerabilities in the SSL/TLS implementation.<br />
<br />
== OpenVPN client files ==<br />
<br />
=== Client certificate and private key ===<br />
<br />
Any machine can generate client files provided that {{Pkg|easy-rsa}} is installed.<br />
<br />
If the pki is not initialized, do so via:<br />
<br />
# cd /etc/easy-rsa<br />
# easyrsa init-pki<br />
<br />
{{Note|1=As seen in [[#Certificate Authority (CA)|Certificate Authority]] section, it is possible to use Elliptic curve instead of RSA for client certificate too by defining EC configuration in {{ic|/etc/easy-rsa/vars}} and then exporting it.<br />
<br />
# export EASYRSA=$(pwd)<br />
# export EASYRSA_VARS_FILE=/etc/easy-rsa/vars<br />
<br />
Else it is possible not to use the [https://github.com/OpenVPN/easy-rsa/blob/master/doc/EasyRSA-Advanced.md#environmental-variables-reference Environmental Variables] and use the corresponding options instead, eg.<br />
<br />
# easyrsa --use-algo=ec --curve=secp521r1 --digest=sha512 init-pki<br />
<nowiki/>}}<br />
<br />
Generate the client key and certificate:<br />
<br />
# cd /etc/easy-rsa<br />
# easyrsa gen-req client1 nopass<br />
<br />
This will create two files:<br />
<br />
* {{ic|/etc/easy-rsa/pki/reqs/client1.req}}<br />
* {{ic|/etc/easy-rsa/pki/private/client1.key}}<br />
<br />
The gen-req set can be repeated as many times as needed for additional clients.<br />
<br />
== Sign the certificates and pass them back to the server and clients ==<br />
<br />
=== Obtain and sign the certificates on the CA ===<br />
<br />
The server and client(s) certificates need to be signed by the CA then transferred back to the OpenVPN server/client(s).<br />
<br />
On the '''OpenVPN server''' (or the box used to generate the certificate/key pairs):<br />
<br />
# cp /etc/easy-rsa/pki/reqs/*.req /tmp<br />
# chown archie /tmp/*.req<br />
<br />
Securely transfer the files to the CA machine for signing:<br />
<br />
$ scp /tmp/*.req archie@hostname-of-CA:/tmp<br />
<br />
On the '''CA machine''', import and sign the certificate requests:<br />
<br />
# cd /etc/easy-rsa<br />
# easyrsa import-req /tmp/servername.req servername<br />
# easyrsa import-req /tmp/client1.req client1<br />
# easyrsa sign-req server servername<br />
# easyrsa sign-req client client1<br />
<br />
This will create the following signed certificates which can be transferred back to their respective machines:<br />
<br />
* {{ic|/etc/easy-rsa/pki/issued/servername.crt}}<br />
* {{ic|/etc/easy-rsa/pki/issued/client1.crt}}<br />
<br />
The leftover .req files can be safely deleted:<br />
<br />
# rm -f /tmp/*.req<br />
<br />
=== Pass the signed certificates back to the server and client(s) ===<br />
<br />
On the '''CA machine''', copy the signed certificates and transfer them to the server/client(s):<br />
<br />
# cp /etc/easy-rsa/pki/issued/*.crt /tmp<br />
# chown archie /tmp/*.crt<br />
$ scp /tmp/*.crt archie@hostname-of-openvpn_server:/tmp<br />
<br />
On the '''OpenVPN server''', move the certificates in place and reassign ownership.<br />
For the server:<br />
<br />
# mv /tmp/servername.crt /etc/openvpn/server/<br />
# chown root:openvpn /etc/openvpn/server/servername.crt<br />
<br />
For the client:<br />
<br />
# mv /tmp/clientname.crt /etc/openvpn/client/<br />
# chown root:openvpn /etc/openvpn/client/clientname.crt<br />
<br />
That is it. To generate the client profile. See: [[OpenVPN#ovpngen]].<br />
<br />
== Revoking certificates and alerting the OpenVPN server ==<br />
<br />
=== Revoke a certificate ===<br />
<br />
Over time, it may become necessary to revoke a certificate thus denying access to the affected user(s). This example revokes the "client1" certificate.<br />
<br />
On the '''CA machine''':<br />
<br />
# cd /etc/easy-rsa<br />
# easyrsa revoke client1<br />
# easyrsa gen-crl<br />
<br />
This will produce the CRL file {{ic|/etc/easy-rsa/pki/crl.pem}} that needs to be transferred to the OpenVPN server and made active there.<br />
<br />
=== Alert the OpenVPN server ===<br />
<br />
On the '''CA machine''':<br />
<br />
# cp /etc/easy-rsa/pki/crl.pem /tmp<br />
# chown archie /tmp/crl.pem<br />
<br />
On the '''OpenVPN machine''', copy {{ic|crl.pem}} and inform the server to read it:<br />
<br />
# mv /tmp/crl.pem /etc/openvpn/server/<br />
# chown root:openvpn /etc/openvpn/server/crl.pem<br />
<br />
Edit {{ic|/etc/openvpn/server/server.conf}} uncommenting the crl-verify directive, then [[restart]] openvpn-server@server.service to re-read it:<br />
<br />
{{hc|/etc/openvpn/server/server.conf|<br />
.<br />
crl-verify /etc/openvpn/server/crl.pem<br />
.<br />
}}<br />
<br />
== Abbreviated example specifically for containerized Openvpn ==<br />
<br />
This section is specifically for users wanting to run Openvpn in a Linux container ([[LXC]]). The code below is designed to be pasted into a root shell; the standard hash has been omitted to allow for easy copy/paste operations. It is recommended to have two different shell windows open, one for the host and one for the container.<br />
<br />
{{Note|<br />
* It is assumed that the CA machine is the host and the server machine is the container.<br />
* Both the host and container need to have both {{Pkg|openvpn}} and {{Pkg|easy-rsa}} installed.<br />
* The container needs to be running.<br />
* Define the name of the container in the CONTAINERNAME variable below.<br />
}}<br />
<br />
On the host:<br />
<br />
CONTAINERNAME=foo<br />
/etc/easy-rsa<br />
easyrsa init-pki && easyrsa build-ca<br />
cp /etc/easy-rsa/pki/ca.crt /var/lib/lxc/$CONTAINERNAME/rootfs/etc/openvpn/server/<br />
<br />
{{Note|One may substitute other names in the 2nd line of this code (the for loop). At a minimum, one needs to generate a key for the server and for at least 1 client. The generic words "server" and "client" are shown, but in reality, these can by any words such as the hostname of the container or the name of the intended user. As well, one can add additional words to the for loop if more than 2 keys are needed. If that is the case, just be sure to add corresponding lines to the subsequent steps for each of them.}}<br />
<br />
In the container:<br />
<br />
cd /etc/easy-rsa && easyrsa init-pki<br />
for i in server client; do easyrsa gen-req $i nopass; done<br />
cp /etc/easy-rsa/pki/private/server.key /etc/openvpn/server/<br />
openssl dhparam -out /etc/openvpn/server/dh.pem 2048<br />
openvpn --genkey secret /etc/openvpn/server/ta.key<br />
<br />
Back on the host:<br />
<br />
easyrsa import-req /var/lib/lxc/$CONTAINERNAME/rootfs/etc/easy-rsa/pki/reqs/junk.req junk<br />
easyrsa import-req /var/lib/lxc/$CONTAINERNAME/rootfs/etc/easy-rsa/pki/reqs/client.req client<br />
easyrsa sign-req client client<br />
easyrsa sign-req server server<br />
mkdir /var/lib/lxc/$CONTAINERNAME/rootfs/etc/easy-rsa/pki/issued/<br />
mkdir /var/lib/lxc/$CONTAINERNAME/rootfs/etc/easy-rsa/pki/signed/<br />
cp /etc/easy-rsa/pki/issued/*.crt /var/lib/lxc/$CONTAINERNAME/rootfs/etc/easy-rsa/pki/issued/<br />
<br />
That will provide the needed files to make an OpenVPN compatible tunnel profile for the client, and the needed server key files for the server. To generate a client profile, refer to [[OpenVPN#ovpngen]].<br />
<br />
== See also ==<br />
<br />
* [https://github.com/OpenVPN/easy-rsa/blob/master/README.quickstart.md README.quickstart].<br />
* [https://github.com/OpenVPN/easy-rsa/blob/master/doc/EasyRSA-Advanced.md EASYRSA-Advanced].</div>Apouloshttps://wiki.archlinux.org/index.php?title=Talk:LIRC&diff=276168Talk:LIRC2013-09-20T20:48:11Z<p>Apoulos: removed my old comment.</p>
<hr />
<div>* should try if editing /etc/rc.d/lircd with "lircd --device=/dev/ttyS1 --driver=creative -p 0666" is a better solution instead of compiling lirc module for ttyS1<br />
<br />
* It would probably be better to treat the remote as a HID with devinput than to force 'lirc' mode in /sys/class/rc. [[User:TheCycoONE|TheCycoONE]] 20:18, 26 May 2011 (EDT)</div>Apouloshttps://wiki.archlinux.org/index.php?title=Kodi&diff=276163Kodi2013-09-20T20:01:28Z<p>Apoulos: 99-lirc.rules didn't work for me. Added note to follow LIRC wiki tmpfiles.d method to set the remote to the lirc protocol.</p>
<hr />
<div>[[Category:Player]]<br />
XBMC (formerly "Xbox Media Center") is a free, [http://www.gnu.org/copyleft/gpl.html open source (GPL)] multimedia player that originally ran on the first-generation [[Wikipedia:Microsoft Xbox|XBox]], (not the newer Xbox 360), and now runs on computers running Linux, Mac OS X, Windows, and iOS. XBMC can be used to play/view the most popular video, audio, and picture formats, and many more lesser-known formats, including: <br />
<br />
* Video - DVD-Video, VCD/SVCD, MPEG-1/2/4, DivX, XviD, Matroska <br />
* Audio - MP3, AAC. <br />
* Picture - JPG, GIF, PNG. <br />
<br />
These can all be played directly from a CD/DVD, or from the hard-drive. XBMC can also play multimedia from a computer over a local network (LAN), or play media streams directly from the Internet. For more information, see the [http://wiki.xbmc.org/index.php?title=XBMC_FAQ XBMC FAQ].<br />
<br />
As of version 12, it can also be used to play and record live TV using a tuner, a backend server and a PVR plugin; more information about this can be found on the [http://wiki.xbmc.org/?title=PVR XBMC wiki].<br />
<br />
== Installation ==<br />
<br />
{{Note|These instructions assume you have a working X installation. If you have not done this yet, please consult [[Beginners_Guide#Graphical_User_Interface]].}}<br />
<br />
[[pacman|Install]] {{Pkg|xbmc}} from the [[official repositories]].<br />
If you plan to use the pvr extensions of xbmc you will need to install {{Pkg|xbmc-pvr-addons}}.<br />
<br />
== Configuration ==<br />
<br />
=== Autostarting at boot ===<br />
<br />
To use XBMC on HTPC you may want to start XBMC automatically on boot. Since version 11.0-11 '''xbmc''' package includes the xbmc group, user, and service file necessary to do this.<br />
<br />
To make XBMC start at system boot you should simply enable the service:<br />
<br />
# systemctl enable xbmc<br />
<br />
=== Enabling shutdown, restart, hibernate and suspend ===<br />
<br />
Since version 12 XBMC supports power management via systemd logind daemon. To enable it you should have {{Pkg|polkit}}, {{Pkg|upower}} and {{Pkg|udisks}} installed on your system.<br />
<br />
In case XBMC is started using the systemd service, the session might not get initialzed properly and therefore polkit may not allow the shutdown or reboot of the system. If this happens, adding the following rule file will allow users in the ''power'' and ''storage'' group to shutdown, restart, hibernate and suspend computer.<br />
<br />
{{hc|/etc/polkit-1/rules.d/10-xbmc.rules|2=<br />
polkit.addRule(function(action, subject) {<br />
if(action.id.match("org.freedesktop.login1.") && subject.isInGroup("power")) {<br />
return polkit.Result.YES;<br />
}<br />
});<br />
<br />
polkit.addRule(function(action, subject) {<br />
if (action.id.indexOf("org.freedesktop.udisks") == 0 && subject.isInGroup("storage")) {<br />
return polkit.Result.YES;<br />
}<br />
});<br />
}}<br />
<br />
=== Using a remote controller ===<br />
<br />
As XBMC is geared toward being a remote-controlled media center, if your computer has an IR receiver, you will probably want to set up a remote using [[LIRC]]. Once you are sure your remote is working properly (tested with {{ic|$ irw}}), add '''lircd''' to your [[Daemons#Starting_on_Boot|DAEMONS Array]] and you'll be ready to create an Lircmap.xml file for it.<br />
<br />
Using your favorite text editor, you'll need to go in and create an [[Wikipedia:XML|XML]] file at {{ic|~/.xbmc/userdata/Lircmap.xml}} (note the capital 'L'). Lircmap.xml format is as follows: <br />
<br />
{{bc|1=<lircmap><br />
<remote device="devicename"><br />
<XBMC_button>LIRC_button</XBMC_button><br />
...<br />
</remote><br />
</lircmap>}}<br />
<br />
* '''Device Name''' is whatever LIRC calls your remote. This is set using the '''Name''' directive in lircd.conf and can be viewed by running {{ic|$ irw}} and pressing a few buttons on the remote. IRW will report the name of the button pressed and the name of the remote will appear on the end of the line.<br />
<br />
* '''XBMC_button''' is the name of the button as defined in [http://wiki.xbmc.org/index.php?title=Keymap.xml keymap.xml].<br />
<br />
* '''LIRC_button''' is the name as defined in {{ic|lircd.conf}}. If you automatically generated your lircd.conf using {{ic|# irrecord}}, these are the names you selected for your button then. Refer back to [[LIRC]] for more information.<br />
<br />
* You may want to check out the very thorough [http://wiki.xbmc.org/index.php?title=Lircmap.xml Lircmap.xml] page over at the [http://wiki.xbmc.org/index.php?title=Main_Page XBMC Wiki] for more help and information on this subject.<br />
<br />
==== MCE remote with Lirc and Systemd ====<br />
<br />
Install {{Pkg|lirc-utils}} and link the mce config:<br />
<br />
# ln -s /usr/share/lirc/mceusb/lircd.conf.mceusb /etc/lirc/lircd.conf<br />
<br />
Then, make sure the remote is using the lirc protocol:<br />
$ cat /sys/class/rc/rc0/protocols<br />
If not, issue:<br />
# echo lirc > /sys/class/rc/rc0/protocols<br />
<br />
A udev rule can be added to make lirc the default. A write rule doesn't seem to work, so a simple RUN command can be executed instead.<br />
<br />
{{hc|/etc/udev/rules.d/99-lirc.rules|2=<br />
KERNEL=="rc*", SUBSYSTEM=="rc", ATTR{protocols}=="*lirc*", RUN+="/bin/sh -c 'echo lirc > $sys$devpath/protocols'"}}<br />
<br />
{{Note|If this doesn't work, follow the suggestion to use tmpfiles.d as specified in the [https://wiki.archlinux.org/index.php/LIRC#Kernel_module_change LIRC wiki] to set the remote to the lirc protocol at boot time.}}<br />
<br />
Next, specify the lirc device. This varies with kernel version. As of 3.6.1 {{ic|/dev/lirc0}} should work with the default driver.<br />
<br />
{{hc|/etc/conf.d/lircd.conf|2=<br />
#<br />
# Parameters for lirc daemon<br />
#<br />
<br />
LIRC_DEVICE="/dev/lirc0"<br />
LIRC_DRIVER="default"<br />
LIRC_EXTRAOPTS=""<br />
LIRC_CONFIGFILE=""}}<br />
<br />
The default service file for lirc ignores this conf file. So we need to create a custom one.<br />
<br />
{{hc|/etc/systemd/system/lirc.service|2=<br />
[Unit]<br />
Description=Linux Infrared Remote Control<br />
<br />
[Service]<br />
EnvironmentFile=/etc/conf.d/lircd.conf<br />
ExecStartPre=/usr/bin/ln -sf /run/lirc/lircd /dev/lircd<br />
ExecStartPre=/usr/bin/ln -sf /dev/lirc0 /dev/lirc<br />
ExecStart=/usr/sbin/lircd --pidfile=/run/lirc/lircd.pid --device=${LIRC_DEVICE} --driver=${LIRC_DRIVER}<br />
Type=forking<br />
PIDFile=/run/lirc/lircd.pid<br />
<br />
[Install]<br />
WantedBy=multi-user.target}}<br />
<br />
Finally, enable and start the lirc service:<br />
<br />
# systemctl enable lirc<br />
# systemctl start lirc<br />
<br />
This should give a fully working mce remote.<br />
<br />
=== Fullscreen mode stretches XBMC across multiple displays ===<br />
<br />
If you have got a multi-monitor setup and don't want XBMC to stretch across all screens, you can restrict the fullscreen mode to one display, by setting the environment variable SDL_VIDEO_FULLSCREEN_HEAD to the number of the desired target display. For example if you want XBMC to show up on display 0 you can add the following line to your [[Bashrc]]:<br />
<br />
SDL_VIDEO_FULLSCREEN_HEAD=0<br />
<br />
{{Note|Mouse cursor will be held inside screen with XBMC.}}<br />
<br />
=== Slowing down CD/DVD drive speed ===<br />
<br />
The {{ic|eject}} program from the {{ic|util-linux}} package does a nice job for this, but its setting is cleared as soon as the media is changed.<br />
<br />
This udev-rule reduces the speed permanently:<br />
<br />
{{hc|/etc/udev/rules.d/dvd-speed.rules|2=<br />
KERNEL=="sr0", ACTION=="change", ENV{DISK_MEDIA_CHANGE}=="1", RUN+="/usr/bin/eject -x 2 /dev/sr0"<br />
}}<br />
<br />
Replace {{ic|sr0}} with the device name of your optical drive. Replace {{ic|-x 2}} with {{ic|-x 4}} if you prefer 4x-speed instead of 2x-speed.<br />
<br />
After creating the file, reload the udev rules with<br />
# udevadm control --reload<br />
<br />
== See also ==<br />
<br />
* [http://wiki.xbmc.org/index.php?title=Main_Page XBMC Wiki] - Excellent resource with much information about Arch Linux specifically</div>Apouloshttps://wiki.archlinux.org/index.php?title=System_backup&diff=275695System backup2013-09-15T16:56:09Z<p>Apoulos: Include "see also" for Scheuref's snapshot rsync backup scripts</p>
<hr />
<div>[[Category:System recovery]]<br />
[[cs:Full System Backup with rsync]]<br />
{{Article summary start}}<br />
{{Article summary text|Instructions on backing up the root tree, creating a bootable copy of your system, or for transferring your system to a new drive or partition.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Backup Programs}}<br />
{{Article summary wiki|rsync}}<br />
{{Article summary end}}<br />
<br />
This article is about using [[rsync]] to transfer a copy of your "/" tree, excluding a few select folders. This approach is considered to be better than [[disk cloning]] with {{ic|dd}} since it allows for a different size, partition table and filesystem to be used, and better than copying with {{ic|cp -a}} as well, because it allows greater control over file permissions, attributes, Access Control Lists (ACLs) and extended attributes. [http://www.bestbits.at/acl/about.html]<br />
<br />
Either method will work even while the system is running. Since it's going to take a while, you may freely browse the web during this time. Worst case scenario you won't get the same opened tabs when you restore the backup (or boot from it) because they weren't saved. Not a big deal.<br />
<br />
== With a single command ==<br />
<br />
As root, run:<br />
<br />
# rsync -aAXv /* /path/to/backup/folder --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found}<br />
For information on why these folders were excluded, read the next section.<br />
<br />
{{Note|If you are heavy user of '''hardlinks''', you might consider using additionally '''{{ic|-H}}''' {{ic|rsync}}'s option, which by default is turned off as memory expensive during rsync run, but nowadays it should be no problem on most of modern machines. There are a lot of hard links below the /usr folder which save disk space.}}<br />
<br />
{{Note|If you plan on backing up your system somewhere other than {{ic|/mnt}} or {{ic|/media}}, don't forget to add it to the list, to avoid an infinite loop. Also, if there are any bind mounts in the system they should be excluded as well, as not to copy the bind mounted contents twice. The example below is a good place to start and excludes all the necessary directories that are typically common to all users of Arch Linux. Your system may have additional areas which you may also want to exclude. Use the {{ic|mount}} command to list system mounts for additional insight on what to exclude.}}<br />
<br />
{{Note|You may want to add rsync's '''{{ic|--delete}}''' option if you are running this multiple times to the same backup folder}}<br />
<br />
== Using a script ==<br />
<br />
Same as in the above method, the system files are transferred in archive mode, ensuring that symbolic links, devices, permissions and ownerships, among other file attributes are preserved, while excluding files that match the patterns from the {{ic|--exclude}} string. On top of that, it shows at the end how much time it took, and it also writes a blank file stating when the backup was created. To learn more about what this script does, read {{ic|man rsync}} and {{ic|man date}}.<br />
<br />
{{Note|Again, if you plan on backing up your system somewhere other than {{ic|/mnt}} or {{ic|/media}}, don't forget to add it to the list, to avoid an infinite loop.}}<br />
<br />
{{Note|You may want to add rsync's '''{{ic|--delete}}''' option if you are running this multiple times to the same backup folder}}<br />
<br />
{{hc|$ cd ~/Scripts<br />
$ nano backup.sh|<nowiki><br />
#!/bin/sh<br />
<br />
if [ $# -lt 1 ]; then <br />
echo "No destination defined. Usage: $0 destination" >&2<br />
exit 1<br />
elif [ $# -gt 1 ]; then<br />
echo "Too many arguments. Usage: $0 destination" >&2<br />
exit 1<br />
elif [ ! -d "$1" ]; then<br />
echo "Invalid path: $1" >&2<br />
exit 1<br />
elif [ ! -w "$1" ]; then<br />
echo "Directory not writable: $1" >&2<br />
exit 1<br />
fi<br />
<br />
case "$1" in<br />
"/mnt") ;;<br />
"/mnt/"*) ;;<br />
"/media") ;;<br />
"/media/"*) ;;<br />
*) echo "Destination not allowed." >&2 <br />
exit 1 <br />
;;<br />
esac<br />
<br />
START=$(date +%s)<br />
rsync -aAXv /* $1 --exclude /dev/* --exclude /proc/* --exclude /sys/* --exclude /tmp/* --exclude /run/* --exclude /mnt/* --exclude /media/* --exclude /lost+found --exclude /var/lib/pacman/sync/*<br />
FINISH=$(date +%s)<br />
echo "total time: $(( ($FINISH-$START) / 60 )) minutes, $(( ($FINISH-$START) % 60 )) seconds"<br />
<br />
touch $1/"Backup from $(date '+%A, %d %B %Y, %T')"</nowiki>}}<br />
<br />
$ chmod +x backup.sh<br />
<br />
{{Note|The contents of {{ic|/dev}}, {{ic|/proc}}, {{ic|/sys}}, {{ic|/tmp}}, {{ic|/run}} were excluded because they are populated at boot (while the folders themselves are ''not'' created), {{ic|/lost+found}} is filesystem-specific. For Arch Linux, {{ic|/var/lib/pacman/sync/*}} can also be excluded. This can save a lot of time on every backup since the directory contains many small files that tend to change quite often. These are description files for every package from the repositories and can be re-generated with {{ic|pacman -Syu}}. Additionally, you may also want to skip {{ic|/home/*/.thumbnails/*}}, {{ic|/home/*/.mozilla/firefox/*.default/Cache/*}} and {{ic|/home/*/.cache/chromium/*}}.}}<br />
<br />
Backing up is easy.<br />
<br />
While the system is running, open up a terminal and run (as root):<br />
<br />
# /home/user/Scripts/backup.sh /some/destination<br />
(replace user with username since you created the directory as user in the user's home directory)<br />
<br />
You can also replace both {{ic|$1}} instances from the script with the actual destination path, move it to one of the folders from {{ic|echo $PATH}}, and then simply run (as root):<br />
<br />
# backup.sh<br />
<br />
== Boot requirements ==<br />
<br />
Having a bootable backup can be useful in case the filesystem becomes corrupt or if an update breaks the system. The backup can also be used as a test bed for updates, with the [testing] repo enabled, etc. If you transferred the system to a different partition or drive and you want to boot it, the process is as simple as updating the backup's {{ic|/etc/fstab}} and your bootloader's configuration file.<br />
<br />
=== Update the fstab ===<br />
<br />
Without rebooting, edit the backup's [[fstab]] to reflect the changes:<br />
{{hc|# nano /path/to/backup/etc/fstab|2=<br />
tmpfs /tmp tmpfs nodev,nosuid 0 0<br />
<br />
<font color=#888888><i>/dev/sda1 /boot ext2 defaults 0 2<br />
/dev/sda5 none swap defaults 0 0<br />
/dev/sda6 / ext4 defaults 0 1<br />
/dev/sda7 /home ext4 defaults 0 2</i></font>}}<br />
<br />
Because rsync has performed a recursive copy of the ''entire'' root filesystem, all of the {{ic|sda}} mountpoints are problematic and booting the backup will fail. In this example, all of the offending entries are replaced with a single one:<br />
<br />
{{hc|# nano /path/to/backup/etc/fstab|<br />
tmpfs /tmp tmpfs nodev,nosuid 0 0<br />
<br />
/dev/'''sdb1''' / ext4 defaults 0 1}}<br />
<br />
Remember to use the proper device name and filesystem type.<br />
<br />
=== Update the bootloader's configuration file ===<br />
<br />
This section assumes that you backed up the system to another drive or partition, that your current bootloader is working fine, and that you want to boot from the backup as well.<br />
<br />
For [[Syslinux]], all you need to do is duplicate the current entry, except pointing to a different drive or partition:<br />
<br />
{{Tip|Instead of editing {{ic|syslinux.cfg}}, you can also temporarily edit the menu during boot. When the menu shows up, press the {{ic|Tab}} key and change the relevant entries. Partitions are counted from one, drives are counted from zero.}}<br />
<br />
# nano /boot/syslinux/syslinux.cfg<br />
<br />
For [[GRUB]], it's recommended that you automatically re-generate the {{ic|grub.cfg}} file:<br />
<br />
# pacman -S os-prober<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
== See also ==<br />
<br />
# [http://blog.pointsoftware.ch/index.php/howto-local-and-remote-snapshot-backup-using-rsync-with-hard-links/ Howto – local and remote snapshot backup using rsync with hard links] Includes file deduplication with hard-links, MD5 integrity signature, 'chattr' protection, filter rules, disk quota, retention policy with exponential distribution (backups rotation while saving more recent backups than older)</div>Apouloshttps://wiki.archlinux.org/index.php?title=System_backup&diff=275694System backup2013-09-15T16:18:14Z<p>Apoulos: Include /usr as a reason to use hardlinks -H.</p>
<hr />
<div>[[Category:System recovery]]<br />
[[cs:Full System Backup with rsync]]<br />
{{Article summary start}}<br />
{{Article summary text|Instructions on backing up the root tree, creating a bootable copy of your system, or for transferring your system to a new drive or partition.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Backup Programs}}<br />
{{Article summary wiki|rsync}}<br />
{{Article summary end}}<br />
<br />
This article is about using [[rsync]] to transfer a copy of your "/" tree, excluding a few select folders. This approach is considered to be better than [[disk cloning]] with {{ic|dd}} since it allows for a different size, partition table and filesystem to be used, and better than copying with {{ic|cp -a}} as well, because it allows greater control over file permissions, attributes, Access Control Lists (ACLs) and extended attributes. [http://www.bestbits.at/acl/about.html]<br />
<br />
Either method will work even while the system is running. Since it's going to take a while, you may freely browse the web during this time. Worst case scenario you won't get the same opened tabs when you restore the backup (or boot from it) because they weren't saved. Not a big deal.<br />
<br />
== With a single command ==<br />
<br />
As root, run:<br />
<br />
# rsync -aAXv /* /path/to/backup/folder --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found}<br />
For information on why these folders were excluded, read the next section.<br />
<br />
{{Note|If you are heavy user of '''hardlinks''', you might consider using additionally '''{{ic|-H}}''' {{ic|rsync}}'s option, which by default is turned off as memory expensive during rsync run, but nowadays it should be no problem on most of modern machines. There are a lot of hard links below the /usr folder which save disk space.}}<br />
<br />
{{Note|If you plan on backing up your system somewhere other than {{ic|/mnt}} or {{ic|/media}}, don't forget to add it to the list, to avoid an infinite loop. Also, if there are any bind mounts in the system they should be excluded as well, as not to copy the bind mounted contents twice. The example below is a good place to start and excludes all the necessary directories that are typically common to all users of Arch Linux. Your system may have additional areas which you may also want to exclude. Use the {{ic|mount}} command to list system mounts for additional insight on what to exclude.}}<br />
<br />
{{Note|You may want to add rsync's '''{{ic|--delete}}''' option if you are running this multiple times to the same backup folder}}<br />
<br />
== Using a script ==<br />
<br />
Same as in the above method, the system files are transferred in archive mode, ensuring that symbolic links, devices, permissions and ownerships, among other file attributes are preserved, while excluding files that match the patterns from the {{ic|--exclude}} string. On top of that, it shows at the end how much time it took, and it also writes a blank file stating when the backup was created. To learn more about what this script does, read {{ic|man rsync}} and {{ic|man date}}.<br />
<br />
{{Note|Again, if you plan on backing up your system somewhere other than {{ic|/mnt}} or {{ic|/media}}, don't forget to add it to the list, to avoid an infinite loop.}}<br />
<br />
{{Note|You may want to add rsync's '''{{ic|--delete}}''' option if you are running this multiple times to the same backup folder}}<br />
<br />
{{hc|$ cd ~/Scripts<br />
$ nano backup.sh|<nowiki><br />
#!/bin/sh<br />
<br />
if [ $# -lt 1 ]; then <br />
echo "No destination defined. Usage: $0 destination" >&2<br />
exit 1<br />
elif [ $# -gt 1 ]; then<br />
echo "Too many arguments. Usage: $0 destination" >&2<br />
exit 1<br />
elif [ ! -d "$1" ]; then<br />
echo "Invalid path: $1" >&2<br />
exit 1<br />
elif [ ! -w "$1" ]; then<br />
echo "Directory not writable: $1" >&2<br />
exit 1<br />
fi<br />
<br />
case "$1" in<br />
"/mnt") ;;<br />
"/mnt/"*) ;;<br />
"/media") ;;<br />
"/media/"*) ;;<br />
*) echo "Destination not allowed." >&2 <br />
exit 1 <br />
;;<br />
esac<br />
<br />
START=$(date +%s)<br />
rsync -aAXv /* $1 --exclude /dev/* --exclude /proc/* --exclude /sys/* --exclude /tmp/* --exclude /run/* --exclude /mnt/* --exclude /media/* --exclude /lost+found --exclude /var/lib/pacman/sync/*<br />
FINISH=$(date +%s)<br />
echo "total time: $(( ($FINISH-$START) / 60 )) minutes, $(( ($FINISH-$START) % 60 )) seconds"<br />
<br />
touch $1/"Backup from $(date '+%A, %d %B %Y, %T')"</nowiki>}}<br />
<br />
$ chmod +x backup.sh<br />
<br />
{{Note|The contents of {{ic|/dev}}, {{ic|/proc}}, {{ic|/sys}}, {{ic|/tmp}}, {{ic|/run}} were excluded because they are populated at boot (while the folders themselves are ''not'' created), {{ic|/lost+found}} is filesystem-specific. For Arch Linux, {{ic|/var/lib/pacman/sync/*}} can also be excluded. This can save a lot of time on every backup since the directory contains many small files that tend to change quite often. These are description files for every package from the repositories and can be re-generated with {{ic|pacman -Syu}}. Additionally, you may also want to skip {{ic|/home/*/.thumbnails/*}}, {{ic|/home/*/.mozilla/firefox/*.default/Cache/*}} and {{ic|/home/*/.cache/chromium/*}}.}}<br />
<br />
Backing up is easy.<br />
<br />
While the system is running, open up a terminal and run (as root):<br />
<br />
# /home/user/Scripts/backup.sh /some/destination<br />
(replace user with username since you created the directory as user in the user's home directory)<br />
<br />
You can also replace both {{ic|$1}} instances from the script with the actual destination path, move it to one of the folders from {{ic|echo $PATH}}, and then simply run (as root):<br />
<br />
# backup.sh<br />
<br />
== Boot requirements ==<br />
<br />
Having a bootable backup can be useful in case the filesystem becomes corrupt or if an update breaks the system. The backup can also be used as a test bed for updates, with the [testing] repo enabled, etc. If you transferred the system to a different partition or drive and you want to boot it, the process is as simple as updating the backup's {{ic|/etc/fstab}} and your bootloader's configuration file.<br />
<br />
=== Update the fstab ===<br />
<br />
Without rebooting, edit the backup's [[fstab]] to reflect the changes:<br />
{{hc|# nano /path/to/backup/etc/fstab|2=<br />
tmpfs /tmp tmpfs nodev,nosuid 0 0<br />
<br />
<font color=#888888><i>/dev/sda1 /boot ext2 defaults 0 2<br />
/dev/sda5 none swap defaults 0 0<br />
/dev/sda6 / ext4 defaults 0 1<br />
/dev/sda7 /home ext4 defaults 0 2</i></font>}}<br />
<br />
Because rsync has performed a recursive copy of the ''entire'' root filesystem, all of the {{ic|sda}} mountpoints are problematic and booting the backup will fail. In this example, all of the offending entries are replaced with a single one:<br />
<br />
{{hc|# nano /path/to/backup/etc/fstab|<br />
tmpfs /tmp tmpfs nodev,nosuid 0 0<br />
<br />
/dev/'''sdb1''' / ext4 defaults 0 1}}<br />
<br />
Remember to use the proper device name and filesystem type.<br />
<br />
=== Update the bootloader's configuration file ===<br />
<br />
This section assumes that you backed up the system to another drive or partition, that your current bootloader is working fine, and that you want to boot from the backup as well.<br />
<br />
For [[Syslinux]], all you need to do is duplicate the current entry, except pointing to a different drive or partition:<br />
<br />
{{Tip|Instead of editing {{ic|syslinux.cfg}}, you can also temporarily edit the menu during boot. When the menu shows up, press the {{ic|Tab}} key and change the relevant entries. Partitions are counted from one, drives are counted from zero.}}<br />
<br />
# nano /boot/syslinux/syslinux.cfg<br />
<br />
For [[GRUB]], it's recommended that you automatically re-generate the {{ic|grub.cfg}} file:<br />
<br />
# pacman -S os-prober<br />
# grub-mkconfig -o /boot/grub/grub.cfg</div>Apouloshttps://wiki.archlinux.org/index.php?title=System_backup&diff=275693System backup2013-09-15T16:14:58Z<p>Apoulos: need leading / in rsync excludes. Without leading /, for example, media/* will not include /home/user/media/*</p>
<hr />
<div>[[Category:System recovery]]<br />
[[cs:Full System Backup with rsync]]<br />
{{Article summary start}}<br />
{{Article summary text|Instructions on backing up the root tree, creating a bootable copy of your system, or for transferring your system to a new drive or partition.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Backup Programs}}<br />
{{Article summary wiki|rsync}}<br />
{{Article summary end}}<br />
<br />
This article is about using [[rsync]] to transfer a copy of your "/" tree, excluding a few select folders. This approach is considered to be better than [[disk cloning]] with {{ic|dd}} since it allows for a different size, partition table and filesystem to be used, and better than copying with {{ic|cp -a}} as well, because it allows greater control over file permissions, attributes, Access Control Lists (ACLs) and extended attributes. [http://www.bestbits.at/acl/about.html]<br />
<br />
Either method will work even while the system is running. Since it's going to take a while, you may freely browse the web during this time. Worst case scenario you won't get the same opened tabs when you restore the backup (or boot from it) because they weren't saved. Not a big deal.<br />
<br />
== With a single command ==<br />
<br />
As root, run:<br />
<br />
# rsync -aAXv /* /path/to/backup/folder --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found}<br />
For information on why these folders were excluded, read the next section.<br />
<br />
{{Note|If you are heavy user of '''hardlinks''', you might consider using additionally '''{{ic|-H}}''' {{ic|rsync}}'s option, which by default is turned off as memory expensive during rsync run, but nowadays it should be no problem on most of modern machines.}}<br />
<br />
{{Note|If you plan on backing up your system somewhere other than {{ic|/mnt}} or {{ic|/media}}, don't forget to add it to the list, to avoid an infinite loop. Also, if there are any bind mounts in the system they should be excluded as well, as not to copy the bind mounted contents twice. The example below is a good place to start and excludes all the necessary directories that are typically common to all users of Arch Linux. Your system may have additional areas which you may also want to exclude. Use the {{ic|mount}} command to list system mounts for additional insight on what to exclude.}}<br />
<br />
{{Note|You may want to add rsync's '''{{ic|--delete}}''' option if you are running this multiple times to the same backup folder}}<br />
<br />
== Using a script ==<br />
<br />
Same as in the above method, the system files are transferred in archive mode, ensuring that symbolic links, devices, permissions and ownerships, among other file attributes are preserved, while excluding files that match the patterns from the {{ic|--exclude}} string. On top of that, it shows at the end how much time it took, and it also writes a blank file stating when the backup was created. To learn more about what this script does, read {{ic|man rsync}} and {{ic|man date}}.<br />
<br />
{{Note|Again, if you plan on backing up your system somewhere other than {{ic|/mnt}} or {{ic|/media}}, don't forget to add it to the list, to avoid an infinite loop.}}<br />
<br />
{{Note|You may want to add rsync's '''{{ic|--delete}}''' option if you are running this multiple times to the same backup folder}}<br />
<br />
{{hc|$ cd ~/Scripts<br />
$ nano backup.sh|<nowiki><br />
#!/bin/sh<br />
<br />
if [ $# -lt 1 ]; then <br />
echo "No destination defined. Usage: $0 destination" >&2<br />
exit 1<br />
elif [ $# -gt 1 ]; then<br />
echo "Too many arguments. Usage: $0 destination" >&2<br />
exit 1<br />
elif [ ! -d "$1" ]; then<br />
echo "Invalid path: $1" >&2<br />
exit 1<br />
elif [ ! -w "$1" ]; then<br />
echo "Directory not writable: $1" >&2<br />
exit 1<br />
fi<br />
<br />
case "$1" in<br />
"/mnt") ;;<br />
"/mnt/"*) ;;<br />
"/media") ;;<br />
"/media/"*) ;;<br />
*) echo "Destination not allowed." >&2 <br />
exit 1 <br />
;;<br />
esac<br />
<br />
START=$(date +%s)<br />
rsync -aAXv /* $1 --exclude /dev/* --exclude /proc/* --exclude /sys/* --exclude /tmp/* --exclude /run/* --exclude /mnt/* --exclude /media/* --exclude /lost+found --exclude /var/lib/pacman/sync/*<br />
FINISH=$(date +%s)<br />
echo "total time: $(( ($FINISH-$START) / 60 )) minutes, $(( ($FINISH-$START) % 60 )) seconds"<br />
<br />
touch $1/"Backup from $(date '+%A, %d %B %Y, %T')"</nowiki>}}<br />
<br />
$ chmod +x backup.sh<br />
<br />
{{Note|The contents of {{ic|/dev}}, {{ic|/proc}}, {{ic|/sys}}, {{ic|/tmp}}, {{ic|/run}} were excluded because they are populated at boot (while the folders themselves are ''not'' created), {{ic|/lost+found}} is filesystem-specific. For Arch Linux, {{ic|/var/lib/pacman/sync/*}} can also be excluded. This can save a lot of time on every backup since the directory contains many small files that tend to change quite often. These are description files for every package from the repositories and can be re-generated with {{ic|pacman -Syu}}. Additionally, you may also want to skip {{ic|/home/*/.thumbnails/*}}, {{ic|/home/*/.mozilla/firefox/*.default/Cache/*}} and {{ic|/home/*/.cache/chromium/*}}.}}<br />
<br />
Backing up is easy.<br />
<br />
While the system is running, open up a terminal and run (as root):<br />
<br />
# /home/user/Scripts/backup.sh /some/destination<br />
(replace user with username since you created the directory as user in the user's home directory)<br />
<br />
You can also replace both {{ic|$1}} instances from the script with the actual destination path, move it to one of the folders from {{ic|echo $PATH}}, and then simply run (as root):<br />
<br />
# backup.sh<br />
<br />
== Boot requirements ==<br />
<br />
Having a bootable backup can be useful in case the filesystem becomes corrupt or if an update breaks the system. The backup can also be used as a test bed for updates, with the [testing] repo enabled, etc. If you transferred the system to a different partition or drive and you want to boot it, the process is as simple as updating the backup's {{ic|/etc/fstab}} and your bootloader's configuration file.<br />
<br />
=== Update the fstab ===<br />
<br />
Without rebooting, edit the backup's [[fstab]] to reflect the changes:<br />
{{hc|# nano /path/to/backup/etc/fstab|2=<br />
tmpfs /tmp tmpfs nodev,nosuid 0 0<br />
<br />
<font color=#888888><i>/dev/sda1 /boot ext2 defaults 0 2<br />
/dev/sda5 none swap defaults 0 0<br />
/dev/sda6 / ext4 defaults 0 1<br />
/dev/sda7 /home ext4 defaults 0 2</i></font>}}<br />
<br />
Because rsync has performed a recursive copy of the ''entire'' root filesystem, all of the {{ic|sda}} mountpoints are problematic and booting the backup will fail. In this example, all of the offending entries are replaced with a single one:<br />
<br />
{{hc|# nano /path/to/backup/etc/fstab|<br />
tmpfs /tmp tmpfs nodev,nosuid 0 0<br />
<br />
/dev/'''sdb1''' / ext4 defaults 0 1}}<br />
<br />
Remember to use the proper device name and filesystem type.<br />
<br />
=== Update the bootloader's configuration file ===<br />
<br />
This section assumes that you backed up the system to another drive or partition, that your current bootloader is working fine, and that you want to boot from the backup as well.<br />
<br />
For [[Syslinux]], all you need to do is duplicate the current entry, except pointing to a different drive or partition:<br />
<br />
{{Tip|Instead of editing {{ic|syslinux.cfg}}, you can also temporarily edit the menu during boot. When the menu shows up, press the {{ic|Tab}} key and change the relevant entries. Partitions are counted from one, drives are counted from zero.}}<br />
<br />
# nano /boot/syslinux/syslinux.cfg<br />
<br />
For [[GRUB]], it's recommended that you automatically re-generate the {{ic|grub.cfg}} file:<br />
<br />
# pacman -S os-prober<br />
# grub-mkconfig -o /boot/grub/grub.cfg</div>Apouloshttps://wiki.archlinux.org/index.php?title=System_backup&diff=275545System backup2013-09-14T20:56:40Z<p>Apoulos: Make sure destination is in /media or /mnt for script.</p>
<hr />
<div>[[Category:System recovery]]<br />
[[cs:Full System Backup with rsync]]<br />
{{Article summary start}}<br />
{{Article summary text|Instructions on backing up the root tree, creating a bootable copy of your system, or for transferring your system to a new drive or partition.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Backup Programs}}<br />
{{Article summary wiki|rsync}}<br />
{{Article summary end}}<br />
<br />
This article is about using [[rsync]] to transfer a copy of your "/" tree, excluding a few select folders. This approach is considered to be better than [[disk cloning]] with {{ic|dd}} since it allows for a different size, partition table and filesystem to be used, and better than copying with {{ic|cp -a}} as well, because it allows greater control over file permissions, attributes, Access Control Lists (ACLs) and extended attributes. [http://www.bestbits.at/acl/about.html]<br />
<br />
Either method will work even while the system is running. Since it's going to take a while, you may freely browse the web during this time. Worst case scenario you won't get the same opened tabs when you restore the backup (or boot from it) because they weren't saved. Not a big deal.<br />
<br />
== With a single command ==<br />
<br />
As root, run:<br />
<br />
# rsync -aAXv /* /path/to/backup/folder --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found}<br />
For information on why these folders were excluded, read the next section.<br />
<br />
{{Note|If you are heavy user of '''hardlinks''', you might consider using additionally '''{{ic|-H}}''' {{ic|rsync}}'s option, which by default is turned off as memory expensive during rsync run, but nowadays it should be no problem on most of modern machines.}}<br />
<br />
{{Note|If you plan on backing up your system somewhere other than {{ic|/mnt}} or {{ic|/media}}, don't forget to add it to the list, to avoid an infinite loop. Also, if there are any bind mounts in the system they should be excluded as well, as not to copy the bind mounted contents twice. The example below is a good place to start and excludes all the necessary directories that are typically common to all users of Arch Linux. Your system may have additional areas which you may also want to exclude. Use the {{ic|mount}} command to list system mounts for additional insight on what to exclude.}}<br />
<br />
{{Note|You may want to add rsync's '''{{ic|--delete}}''' option if you are running this multiple times to the same backup folder}}<br />
<br />
== Using a script ==<br />
<br />
Same as in the above method, the system files are transferred in archive mode, ensuring that symbolic links, devices, permissions and ownerships, among other file attributes are preserved, while excluding files that match the patterns from the {{ic|--exclude}} string. On top of that, it shows at the end how much time it took, and it also writes a blank file stating when the backup was created. To learn more about what this script does, read {{ic|man rsync}} and {{ic|man date}}.<br />
<br />
{{Note|Again, if you plan on backing up your system somewhere other than {{ic|/mnt}} or {{ic|/media}}, don't forget to add it to the list, to avoid an infinite loop.}}<br />
<br />
{{Note|You may want to add rsync's '''{{ic|--delete}}''' option if you are running this multiple times to the same backup folder}}<br />
<br />
{{hc|$ cd ~/Scripts<br />
$ nano backup.sh|<nowiki><br />
#!/bin/sh<br />
<br />
if [ $# -lt 1 ]; then <br />
echo "No destination defined. Usage: $0 destination" >&2<br />
exit 1<br />
elif [ $# -gt 1 ]; then<br />
echo "Too many arguments. Usage: $0 destination" >&2<br />
exit 1<br />
elif [ ! -d "$1" ]; then<br />
echo "Invalid path: $1" >&2<br />
exit 1<br />
elif [ ! -w "$1" ]; then<br />
echo "Directory not writable: $1" >&2<br />
exit 1<br />
fi<br />
<br />
case "$1" in<br />
"/mnt") ;;<br />
"/mnt/"*) ;;<br />
"/media") ;;<br />
"/media/"*) ;;<br />
*) echo "Destination not allowed." >&2 <br />
exit 1 <br />
;;<br />
esac<br />
<br />
START=$(date +%s)<br />
rsync -aAXv /* $1 --exclude dev/* --exclude proc/* --exclude sys/* --exclude tmp/* --exclude run/* --exclude mnt/* --exclude media/* --exclude lost+found --exclude var/lib/pacman/sync/*<br />
FINISH=$(date +%s)<br />
echo "total time: $(( ($FINISH-$START) / 60 )) minutes, $(( ($FINISH-$START) % 60 )) seconds"<br />
<br />
touch $1/"Backup from $(date '+%A, %d %B %Y, %T')"</nowiki>}}<br />
<br />
$ chmod +x backup.sh<br />
<br />
{{Note|The contents of {{ic|/dev}}, {{ic|/proc}}, {{ic|/sys}}, {{ic|/tmp}}, {{ic|/run}} were excluded because they are populated at boot (while the folders themselves are ''not'' created), {{ic|/lost+found}} is filesystem-specific. For Arch Linux, {{ic|/var/lib/pacman/sync/*}} can also be excluded. This can save a lot of time on every backup since the directory contains many small files that tend to change quite often. These are description files for every package from the repositories and can be re-generated with {{ic|pacman -Syu}}. Additionally, you may also want to skip {{ic|/home/*/.thumbnails/*}}, {{ic|/home/*/.mozilla/firefox/*.default/Cache/*}} and {{ic|/home/*/.cache/chromium/*}}.}}<br />
<br />
Backing up is easy.<br />
<br />
While the system is running, open up a terminal and run (as root):<br />
<br />
# /home/user/Scripts/backup.sh /some/destination<br />
(replace user with username since you created the directory as user in the user's home directory)<br />
<br />
You can also replace both {{ic|$1}} instances from the script with the actual destination path, move it to one of the folders from {{ic|echo $PATH}}, and then simply run (as root):<br />
<br />
# backup.sh<br />
<br />
== Boot requirements ==<br />
<br />
Having a bootable backup can be useful in case the filesystem becomes corrupt or if an update breaks the system. The backup can also be used as a test bed for updates, with the [testing] repo enabled, etc. If you transferred the system to a different partition or drive and you want to boot it, the process is as simple as updating the backup's {{ic|/etc/fstab}} and your bootloader's configuration file.<br />
<br />
=== Update the fstab ===<br />
<br />
Without rebooting, edit the backup's [[fstab]] to reflect the changes:<br />
{{hc|# nano /path/to/backup/etc/fstab|2=<br />
tmpfs /tmp tmpfs nodev,nosuid 0 0<br />
<br />
<font color=#888888><i>/dev/sda1 /boot ext2 defaults 0 2<br />
/dev/sda5 none swap defaults 0 0<br />
/dev/sda6 / ext4 defaults 0 1<br />
/dev/sda7 /home ext4 defaults 0 2</i></font>}}<br />
<br />
Because rsync has performed a recursive copy of the ''entire'' root filesystem, all of the {{ic|sda}} mountpoints are problematic and booting the backup will fail. In this example, all of the offending entries are replaced with a single one:<br />
<br />
{{hc|# nano /path/to/backup/etc/fstab|<br />
tmpfs /tmp tmpfs nodev,nosuid 0 0<br />
<br />
/dev/'''sdb1''' / ext4 defaults 0 1}}<br />
<br />
Remember to use the proper device name and filesystem type.<br />
<br />
=== Update the bootloader's configuration file ===<br />
<br />
This section assumes that you backed up the system to another drive or partition, that your current bootloader is working fine, and that you want to boot from the backup as well.<br />
<br />
For [[Syslinux]], all you need to do is duplicate the current entry, except pointing to a different drive or partition:<br />
<br />
{{Tip|Instead of editing {{ic|syslinux.cfg}}, you can also temporarily edit the menu during boot. When the menu shows up, press the {{ic|Tab}} key and change the relevant entries. Partitions are counted from one, drives are counted from zero.}}<br />
<br />
# nano /boot/syslinux/syslinux.cfg<br />
<br />
For [[GRUB]], it's recommended that you automatically re-generate the {{ic|grub.cfg}} file:<br />
<br />
# pacman -S os-prober<br />
# grub-mkconfig -o /boot/grub/grub.cfg</div>Apouloshttps://wiki.archlinux.org/index.php?title=System_backup&diff=275403System backup2013-09-13T22:50:04Z<p>Apoulos: added sanity checks for parameter of script. make sure directory exists and is writable.</p>
<hr />
<div>[[Category:System recovery]]<br />
[[cs:Full System Backup with rsync]]<br />
{{Article summary start}}<br />
{{Article summary text|Instructions on backing up the root tree, creating a bootable copy of your system, or for transferring your system to a new drive or partition.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Backup Programs}}<br />
{{Article summary wiki|rsync}}<br />
{{Article summary end}}<br />
<br />
This article is about using [[rsync]] to transfer a copy of your "/" tree, excluding a few select folders. This approach is considered to be better than [[disk cloning]] with {{ic|dd}} since it allows for a different size, partition table and filesystem to be used, and better than copying with {{ic|cp -a}} as well, because it allows greater control over file permissions, attributes, Access Control Lists (ACLs) and extended attributes. [http://www.bestbits.at/acl/about.html]<br />
<br />
Either method will work even while the system is running. Since it's going to take a while, you may freely browse the web during this time. Worst case scenario you won't get the same opened tabs when you restore the backup (or boot from it) because they weren't saved. Not a big deal.<br />
<br />
== With a single command ==<br />
<br />
As root, run:<br />
<br />
# rsync -aAXv /* /path/to/backup/folder --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found}<br />
For information on why these folders were excluded, read the next section.<br />
<br />
{{Note|If you are heavy user of '''hardlinks''', you might consider using additionally '''{{ic|-H}}''' {{ic|rsync}}'s option, which by default is turned off as memory expensive during rsync run, but nowadays it should be no problem on most of modern machines.}}<br />
<br />
{{Note|If you plan on backing up your system somewhere other than {{ic|/mnt}} or {{ic|/media}}, don't forget to add it to the list, to avoid an infinite loop. Also, if there are any bind mounts in the system they should be excluded as well, as not to copy the bind mounted contents twice. The example below is a good place to start and excludes all the necessary directories that are typically common to all users of Arch Linux. Your system may have additional areas which you may also want to exclude. Use the {{ic|mount}} command to list system mounts for additional insight on what to exclude.}}<br />
<br />
{{Note|You may want to add rsync's '''{{ic|--delete}}''' option if you are running this multiple times to the same backup folder}}<br />
<br />
== Using a script ==<br />
<br />
Same as in the above method, the system files are transferred in archive mode, ensuring that symbolic links, devices, permissions and ownerships, among other file attributes are preserved, while excluding files that match the patterns from the {{ic|--exclude}} string. On top of that, it shows at the end how much time it took, and it also writes a blank file stating when the backup was created. To learn more about what this script does, read {{ic|man rsync}} and {{ic|man date}}.<br />
<br />
{{Note|Again, if you plan on backing up your system somewhere other than {{ic|/mnt}} or {{ic|/media}}, don't forget to add it to the list, to avoid an infinite loop.}}<br />
<br />
{{Note|You may want to add rsync's '''{{ic|--delete}}''' option if you are running this multiple times to the same backup folder}}<br />
<br />
{{hc|$ cd ~/Scripts<br />
$ nano backup.sh|<nowiki><br />
#!/bin/sh<br />
<br />
if [ $# -lt 1 ]; then <br />
echo "No destination defined. Usage: $0 destination" >&2<br />
exit 1<br />
elif [ $# -gt 1 ]; then<br />
echo "Too many arguments. Usage: $0 destination" >&2<br />
exit 1<br />
elif [ ! -d "$1" ]; then<br />
echo "Invalid path: $1" >&2<br />
exit 1<br />
elif [ ! -w "$1" ]; then<br />
echo "Directory not writable: $1" >&2<br />
exit 1<br />
fi<br />
<br />
START=$(date +%s)<br />
rsync -aAXv /* $1 --exclude dev/* --exclude proc/* --exclude sys/* --exclude tmp/* --exclude run/* --exclude mnt/* --exclude media/* --exclude lost+found --exclude var/lib/pacman/sync/*<br />
FINISH=$(date +%s)<br />
echo "total time: $(( ($FINISH-$START) / 60 )) minutes, $(( ($FINISH-$START) % 60 )) seconds"<br />
<br />
touch $1/"Backup from $(date '+%A, %d %B %Y, %T')"</nowiki>}}<br />
<br />
$ chmod +x backup.sh<br />
<br />
{{Note|The contents of {{ic|/dev}}, {{ic|/proc}}, {{ic|/sys}}, {{ic|/tmp}}, {{ic|/run}} were excluded because they are populated at boot (while the folders themselves are ''not'' created), {{ic|/lost+found}} is filesystem-specific. For Arch Linux, {{ic|/var/lib/pacman/sync/*}} can also be excluded. This can save a lot of time on every backup since the directory contains many small files that tend to change quite often. These are description files for every package from the repositories and can be re-generated with {{ic|pacman -Syu}}. Additionally, you may also want to skip {{ic|/home/*/.thumbnails/*}}, {{ic|/home/*/.mozilla/firefox/*.default/Cache/*}} and {{ic|/home/*/.cache/chromium/*}}.}}<br />
<br />
Backing up is easy.<br />
<br />
While the system is running, open up a terminal and run (as root):<br />
<br />
# /home/user/Scripts/backup.sh /some/destination<br />
(replace user with username since you created the directory as user in the user's home directory)<br />
<br />
You can also replace both {{ic|$1}} instances from the script with the actual destination path, move it to one of the folders from {{ic|echo $PATH}}, and then simply run (as root):<br />
<br />
# backup.sh<br />
<br />
== Boot requirements ==<br />
<br />
Having a bootable backup can be useful in case the filesystem becomes corrupt or if an update breaks the system. The backup can also be used as a test bed for updates, with the [testing] repo enabled, etc. If you transferred the system to a different partition or drive and you want to boot it, the process is as simple as updating the backup's {{ic|/etc/fstab}} and your bootloader's configuration file.<br />
<br />
=== Update the fstab ===<br />
<br />
Without rebooting, edit the backup's [[fstab]] to reflect the changes:<br />
{{hc|# nano /path/to/backup/etc/fstab|2=<br />
tmpfs /tmp tmpfs nodev,nosuid 0 0<br />
<br />
<font color=#888888><i>/dev/sda1 /boot ext2 defaults 0 2<br />
/dev/sda5 none swap defaults 0 0<br />
/dev/sda6 / ext4 defaults 0 1<br />
/dev/sda7 /home ext4 defaults 0 2</i></font>}}<br />
<br />
Because rsync has performed a recursive copy of the ''entire'' root filesystem, all of the {{ic|sda}} mountpoints are problematic and booting the backup will fail. In this example, all of the offending entries are replaced with a single one:<br />
<br />
{{hc|# nano /path/to/backup/etc/fstab|<br />
tmpfs /tmp tmpfs nodev,nosuid 0 0<br />
<br />
/dev/'''sdb1''' / ext4 defaults 0 1}}<br />
<br />
Remember to use the proper device name and filesystem type.<br />
<br />
=== Update the bootloader's configuration file ===<br />
<br />
This section assumes that you backed up the system to another drive or partition, that your current bootloader is working fine, and that you want to boot from the backup as well.<br />
<br />
For [[Syslinux]], all you need to do is duplicate the current entry, except pointing to a different drive or partition:<br />
<br />
{{Tip|Instead of editing {{ic|syslinux.cfg}}, you can also temporarily edit the menu during boot. When the menu shows up, press the {{ic|Tab}} key and change the relevant entries. Partitions are counted from one, drives are counted from zero.}}<br />
<br />
# nano /boot/syslinux/syslinux.cfg<br />
<br />
For [[GRUB]], it's recommended that you automatically re-generate the {{ic|grub.cfg}} file:<br />
<br />
# pacman -S os-prober<br />
# grub-mkconfig -o /boot/grub/grub.cfg</div>Apouloshttps://wiki.archlinux.org/index.php?title=System_backup&diff=275164System backup2013-09-12T15:56:08Z<p>Apoulos: Suggested adding rsync --delete in note if using the script/command multiple times to the same backup destination.</p>
<hr />
<div>[[Category:System recovery]]<br />
[[cs:Full System Backup with rsync]]<br />
{{Article summary start}}<br />
{{Article summary text|Instructions on backing up the root tree, creating a bootable copy of your system, or for transferring your system to a new drive or partition.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Backup Programs}}<br />
{{Article summary wiki|rsync}}<br />
{{Article summary end}}<br />
<br />
This article is about using [[rsync]] to transfer a copy of your "/" tree, excluding a few select folders. This approach is considered to be better than [[disk cloning]] with {{ic|dd}} since it allows for a different size, partition table and filesystem to be used, and better than copying with {{ic|cp -a}} as well, because it allows greater control over file permissions, attributes, Access Control Lists (ACLs) and extended attributes. [http://www.bestbits.at/acl/about.html]<br />
<br />
Either method will work even while the system is running. Since it's going to take a while, you may freely browse the web during this time. Worst case scenario you won't get the same opened tabs when you restore the backup (or boot from it) because they weren't saved. Not a big deal.<br />
<br />
== With a single command ==<br />
<br />
As root, run:<br />
<br />
# rsync -aAXv /* /path/to/backup/folder --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found}<br />
For information on why these folders were excluded, read the next section.<br />
<br />
{{Note|If you are heavy user of '''hardlinks''', you might consider using additionally '''{{ic|-H}}''' {{ic|rsync}}'s option, which by default is turned off as memory expensive during rsync run, but nowadays it should be no problem on most of modern machines.}}<br />
<br />
{{Note|If you plan on backing up your system somewhere other than {{ic|/mnt}} or {{ic|/media}}, don't forget to add it to the list, to avoid an infinite loop. Also, if there are any bind mounts in the system they should be excluded as well, as not to copy the bind mounted contents twice. The example below is a good place to start and excludes all the necessary directories that are typically common to all users of Arch Linux. Your system may have additional areas which you may also want to exclude. Use the {{ic|mount}} command to list system mounts for additional insight on what to exclude.}}<br />
<br />
{{Note|You may want to add rsync's '''{{ic|--delete}}''' option if you are running this multiple times to the same backup folder}}<br />
<br />
== Using a script ==<br />
<br />
Same as in the above method, the system files are transferred in archive mode, ensuring that symbolic links, devices, permissions and ownerships, among other file attributes are preserved, while excluding files that match the patterns from the {{ic|--exclude}} string. On top of that, it shows at the end how much time it took, and it also writes a blank file stating when the backup was created. To learn more about what this script does, read {{ic|man rsync}} and {{ic|man date}}.<br />
<br />
{{Note|Again, if you plan on backing up your system somewhere other than {{ic|/mnt}} or {{ic|/media}}, don't forget to add it to the list, to avoid an infinite loop.}}<br />
<br />
{{Note|You may want to add rsync's '''{{ic|--delete}}''' option if you are running this multiple times to the same backup folder}}<br />
<br />
{{hc|$ cd ~/Scripts<br />
$ nano backup.sh|<nowiki><br />
#!/bin/sh<br />
<br />
if [ $# -lt 1 ]; then <br />
echo "No destination defined. Usage: $0 destination" >&2<br />
exit 1<br />
elif [ $# -gt 1 ]; then<br />
echo "Too many arguments. Usage: $0 destination" >&2<br />
exit 1<br />
fi<br />
<br />
START=$(date +%s)<br />
rsync -aAXv /* $1 --exclude dev/* --exclude proc/* --exclude sys/* --exclude tmp/* --exclude run/* --exclude mnt/* --exclude media/* --exclude lost+found --exclude var/lib/pacman/sync/*<br />
FINISH=$(date +%s)<br />
echo "total time: $(( ($FINISH-$START) / 60 )) minutes, $(( ($FINISH-$START) % 60 )) seconds"<br />
<br />
touch $1/"Backup from $(date '+%A, %d %B %Y, %T')"</nowiki>}}<br />
<br />
$ chmod +x backup.sh<br />
<br />
{{Note|The contents of {{ic|/dev}}, {{ic|/proc}}, {{ic|/sys}}, {{ic|/tmp}}, {{ic|/run}} were excluded because they are populated at boot (while the folders themselves are ''not'' created), {{ic|/lost+found}} is filesystem-specific. For Arch Linux, {{ic|/var/lib/pacman/sync/*}} can also be excluded. This can save a lot of time on every backup since the directory contains many small files that tend to change quite often. These are description files for every package from the repositories and can be re-generated with {{ic|pacman -Syu}}. Additionally, you may also want to skip {{ic|/home/*/.thumbnails/*}}, {{ic|/home/*/.mozilla/firefox/*.default/Cache/*}} and {{ic|/home/*/.cache/chromium/*}}.}}<br />
<br />
Backing up is easy.<br />
<br />
While the system is running, open up a terminal and run (as root):<br />
<br />
# /home/user/Scripts/backup.sh /some/destination<br />
(replace user with username since you created the directory as user in the user's home directory)<br />
<br />
You can also replace both {{ic|$1}} instances from the script with the actual destination path, move it to one of the folders from {{ic|echo $PATH}}, and then simply run (as root):<br />
<br />
# backup.sh<br />
<br />
== Boot requirements ==<br />
<br />
Having a bootable backup can be useful in case the filesystem becomes corrupt or if an update breaks the system. The backup can also be used as a test bed for updates, with the [testing] repo enabled, etc. If you transferred the system to a different partition or drive and you want to boot it, the process is as simple as updating the backup's {{ic|/etc/fstab}} and your bootloader's configuration file.<br />
<br />
=== Update the fstab ===<br />
<br />
Without rebooting, edit the backup's [[fstab]] to reflect the changes:<br />
{{hc|# nano /path/to/backup/etc/fstab|2=<br />
tmpfs /tmp tmpfs nodev,nosuid 0 0<br />
<br />
<font color=#888888><i>/dev/sda1 /boot ext2 defaults 0 2<br />
/dev/sda5 none swap defaults 0 0<br />
/dev/sda6 / ext4 defaults 0 1<br />
/dev/sda7 /home ext4 defaults 0 2</i></font>}}<br />
<br />
Because rsync has performed a recursive copy of the ''entire'' root filesystem, all of the {{ic|sda}} mountpoints are problematic and booting the backup will fail. In this example, all of the offending entries are replaced with a single one:<br />
<br />
{{hc|# nano /path/to/backup/etc/fstab|<br />
tmpfs /tmp tmpfs nodev,nosuid 0 0<br />
<br />
/dev/'''sdb1''' / ext4 defaults 0 1}}<br />
<br />
Remember to use the proper device name and filesystem type.<br />
<br />
=== Update the bootloader's configuration file ===<br />
<br />
This section assumes that you backed up the system to another drive or partition, that your current bootloader is working fine, and that you want to boot from the backup as well.<br />
<br />
For [[Syslinux]], all you need to do is duplicate the current entry, except pointing to a different drive or partition:<br />
<br />
{{Tip|Instead of editing {{ic|syslinux.cfg}}, you can also temporarily edit the menu during boot. When the menu shows up, press the {{ic|Tab}} key and change the relevant entries. Partitions are counted from one, drives are counted from zero.}}<br />
<br />
# nano /boot/syslinux/syslinux.cfg<br />
<br />
For [[GRUB]], it's recommended that you automatically re-generate the {{ic|grub.cfg}} file:<br />
<br />
# pacman -S os-prober<br />
# grub-mkconfig -o /boot/grub/grub.cfg</div>Apouloshttps://wiki.archlinux.org/index.php?title=BackupPC&diff=274553BackupPC2013-09-06T19:40:17Z<p>Apoulos: </p>
<hr />
<div>[[Category:System recovery]]<br />
'''BackupPC''' is a high-performance, enterprise-grade system for backing up Unix, Linux, WinXX, and MacOSX PCs, desktops and laptops to a server's disk. BackupPC is highly configurable and easy to install and maintain.<br />
<br />
Given the ever decreasing cost of disks and raid systems, it is now practical and cost effective to backup a large number of machines onto a server's local disk or network storage. For some sites this might be the complete backup solution. For other sites additional permanent archives could be created by periodically backing up the server to tape.<br />
<br />
== Installation ==<br />
<br />
[[pacman|Install]] {{Pkg|backuppc}} from the [[official repositories]].<br />
Install {{Pkg|rsync}} and {{Pkg|perl-file-rsyncp}} if you want to use [[rsync]] as a transport.<br />
<br />
=== Start BackupPC ===<br />
<br />
Start '''backuppc''' [[systemd]] [[daemon]] and, if you wish to have running at boot time enable it.<br />
<br />
== Apache Configuration ==<br />
<br />
BackupPC has a web interface that allows you to easily control it. You can access it using Apache and mod_perl but other webservers like {{Pkg|lighttpd}} works too. <br />
Install {{Pkg|apache}} and {{Pkg|mod_perl}} from the official repositories.<br />
<br />
=== Edit Apache configuration ===<br />
<br />
Edit the Apache configuration file to load mod_perl, tell Apache to run as user backuppc and to include {{ic|/etc/httpd/conf/extra/backuppc.conf}}:<br />
{{hc|/etc/httpd/conf/httpd.conf|<br />
LoadModule perl_module modules/mod_perl.so<br />
User backuppc<br />
Group backuppc<br />
Include conf/extra/backuppc.conf<br />
}}<br />
<br />
Edit {{ic|/etc/backuppc/config.pl}}. Set administrator name:<br />
$Conf{CgiAdminUsers} = 'admin'; <br />
Next, we need to add a users file and set the admin password:<br />
# htpasswd -c /etc/backuppc/backuppc.users admin<br />
<br />
The BackupPC-Webfrontend is initially configured, that you can only access it from the localhost. If you want to access it from all machines in your network, you have to edit {{ic|/etc/httpd/conf/extra/backuppc.conf}}.<br />
Edit the line<br />
allow from 127.0.0.1<br />
to<br />
allow from 127.0.0.1 192.168.0<br />
where you have to replace 192.168.0 to your corresponding IP-Adresses you want to gain access from.<br />
Then just start Apache service.<br />
<br />
== Alternative lighttpd Configuration ==<br />
<br />
{{hc|/etc/lighttpd/lighttpd.conf|<nowiki><br />
server.port = 81<br />
server.username = "backuppc"<br />
server.groupname = "backuppc"<br />
server.document-root = "/srv/http"<br />
server.errorlog = "/var/log/lighttpd/error.log"<br />
dir-listing.activate = "enable"<br />
index-file.names = ( "index.html", "index.php", "index.cgi" )<br />
mimetype.assign = ( ".html" => "text/html", ".txt" => "text/plain", ".jpg" => "image/jpeg", ".png" => "image/png", "" => "application/octet-stream" )<br />
<br />
server.modules = ("mod_alias", "mod_cgi", "mod_auth", "mod_access" )<br />
<br />
alias.url = ( "/BackupPC_Admin" => "/usr/share/backuppc/cgi-bin/BackupPC_Admin" )<br />
alias.url += ( "/backuppc" => "/usr/share/backuppc/html" )<br />
<br />
cgi.assign += ( ".cgi" => "/usr/bin/perl" )<br />
cgi.assign += ( "BackupPC_Admin" => "/usr/bin/perl" )<br />
<br />
auth.backend = "plain"<br />
auth.backend.plain.userfile = "/etc/lighttpd/passwd"<br />
auth.require = ( "/BackupPC_Admin" => ( "method" => "basic", "realm" => "BackupPC", "require" => "user=admin" ) )<br />
</nowiki>}}<br />
<br />
{{hc|/etc/lighttpd/passwd|<nowiki><br />
admin:yourpasswordgoeshere<br />
</nowiki>}}<br />
<br />
== Accessing the admin page ==<br />
<br />
Browse to http://localhost/BackupPC_Admin respectively http://YOUR_BACKUPPC_SERVER_IP/BackupPC_Admin.<br />
<br />
== The webserver user and the suid problem ==<br />
<br />
The current setup of backuppc, the webserver needs to run as backuppc user and this can be a problem on many setups where the webserver is used for other sites. In the past one could suid a perl script, but it was blocked globally due security problems several years ago. To workaround that, perl-suid was used, but again blocked due the same problem more recently, scripts can't be run securely with suid bit. Still there is another way, this time using a simple binary program that is suid as a launcher, that will run the backuppc perl scripts already with the correct user. This isolates the perl script from the enviorment and its considered safe.<br />
<br />
To setup the backuppc to run on this mode you need to replace the original backuppc cgi with the below C code compiled program and move the backuppc cgi to another place. <br />
<br />
Save the C code to a file named wrapper.c (please update the cgi path if needed) and compile it with:<br />
<br />
$ gcc -o BackupPC_Admin wrapper.c<br />
<br />
The wrapper C code:<br />
<br />
#include <unistd.h><br />
#define REAL_PATH "/usr/share/backuppc/lib/real-BackupPC_Admin.cgi"<br />
int main(ac, av)<br />
char **av;<br />
{<br />
execv(REAL_PATH, av);<br />
return 0;<br />
}<br />
<br />
move the real cgi {{ic|/usr/share/backuppc/cgi-bin/BackupPC_Admin}} to the lib directory {{ic|/usr/share/backuppc/lib/real-BackupPC_Admin.cgi}} , place the new binary {{ic|BackupPC_Admin}} in the cgi-bin directory and chown the binary cgi to {{ic|backuppc:http}} and set the suid bit:<br />
<br />
chown backuppc:http /usr/share/backuppc/cgi-bin/BackupPC_Admin<br />
chmod 4750 /usr/share/backuppc/cgi-bin/BackupPC_Admin.<br />
<br />
keep your web server with its usual user and backup should now be able to run correctly<br />
<br />
== See also ==<br />
<br />
* [http://backuppc.sourceforge.net/index.html BackupPC Home page]<br />
* [http://backuppc.sourceforge.net/faq/BackupPC.html BackupPC documentation]</div>Apouloshttps://wiki.archlinux.org/index.php?title=CyberPower_UPS&diff=274436CyberPower UPS2013-09-05T16:20:06Z<p>Apoulos: </p>
<hr />
<div>[[Category:Power management]]<br />
This document describes how to install the CyberPower UPS daemon. The main advantage of using a CyberPower UPS is that it is cheap and it can communicate with your Linux box through either a RS-232 or USB serial connection. In the event of a prolonged power outage, should the CyberPower UPS lose most of its battery capacity, it can tell the Linux box to perform a safe shutdown.<br />
<br />
== Installation ==<br />
<br />
Install powerpanel from [[AUR]].<br />
<br />
== Configuration ==<br />
<br />
Edit {{ic|/etc/pwrstatd.conf}}<br />
<br />
Email notifications can be accomplished by editing {{ic|/etc/powerpanel/pwrstatd-powerfail.sh}} and {{ic|/etc/powerpanel/pwrstatd-lowbatt.sh}}<br />
{{Warning|Make sure the path to the email script at the bottom of these scripts is correct. It should be {{ic|/etc/powerpanel/pwrstatd-email.sh}}}}<br />
<br />
== Running ==<br />
<br />
Start and enable the service<br />
{{bc|<br />
# systemctl start pwrstatd<br />
# systemctl enable pwrstatd<br />
}}<br />
<br />
Then run <br />
{{ic|# pwrstat -status}}<br />
<br />
You should get something like this:<br />
{{bc|<br />
<br />
The UPS information shows as following:<br />
<br />
Properties:<br />
Model Name................... Value 1500E<br />
Firmware Number.............. BFF7104#7N5<br />
Rating Voltage............... 230 V<br />
Rating Power................. 900 Watt<br />
<br />
Current UPS status:<br />
State........................ Normal<br />
Power Supply by.............. Utility Power<br />
Utility Voltage.............. 230 V<br />
Output Voltage............... 230 V<br />
Battery Capacity............. 100 %<br />
Remaining Runtime............ 61 min.<br />
Load......................... 126 Watt(14 %)<br />
Line Interaction............. None<br />
Test Result.................. Unknown<br />
Last Power Event............. None<br />
<br />
}}</div>Apouloshttps://wiki.archlinux.org/index.php?title=Dynamic_Kernel_Module_Support&diff=267121Dynamic Kernel Module Support2013-07-20T00:24:35Z<p>Apoulos: </p>
<hr />
<div>[[Category:Kernel]]<br />
[[Wikipedia:Dynamic_Kernel_Module_Support|Dynamic Kernel Module Support]] allows one to compile and install kernel modules without recompiling the entire kernel.<br />
<br />
== Installation ==<br />
<br />
Install package {{pkg|dkms}} in the [[Official Repositories]].<br />
<br />
After installing the DKMS, you still need to install a DKMS package such as<br />
{{AUR|nvidia-dkms}}, otherwise having DKMS installed is just wasting your<br />
disk space.<br />
<br />
== Configuration ==<br />
<br />
To get modules rebuilt automatically after a kernel upgrade, enable the<br />
{{ic|dkms}} service. This service will build DKMS modules if they were not<br />
already available and then exit. For systemd:<br />
{{bc|# systemctl enable dkms.service}}<br />
<br />
Sometimes, a program depends on the module. If that program is started before<br />
the DKMS module is built, you often need to reboot (or restart that program).<br />
An example are the proprietary graphics drivers such as nvidia and catalyst.<br />
<br />
== Usage ==<br />
If you have just upgraded your kernel and want to avoid a reboot, you can<br />
trigger a rebuild for all modules by executing {{ic|dkms autoinstall -k NEW_KERNEL_VERSION}} as<br />
root. This will build and install DKMS modules for all available kernel<br />
versions if they have not been built before.<br />
<br />
Forcing a build of a specific module for a specific kernel version is also<br />
possible, for example:<br />
{{bc|# dkms install -m nvidia -v 304.51 -k 3.6.2-1-ARCH}}<br />
Hint: use tab completion to get the module and kernel version.<br />
<br />
==Guidelines==<br />
Here are some guidelines to follow.<br />
<br />
===Package name===<br />
DKMS packages are named by appending {{ic|-dkms}} to their non-DKMS counterpart (or the module name if no counterpart can be found).<br />
<br />
===Where should source go?===<br />
DKMS by default uses ''/usr/src/'', but [namcap] complains that is a non-standard directory. (Even though the FHS reference namcap uses states that ''/usr/src'' is "optional".<br />
One could place the source in ''/opt/<package>'' and then sym-link it (which is what some non-DKMS packages do.)<br />
<br />
Sources should go into ''/usr/src/<package>-<package version>'' which is<br />
the default directory that DKMS commands use. ''<package>'' is the "true package<br />
name" (which is usually the PKGBUILD $_pkgname variable, which is the $pkgname<br />
minus the "dkms-" prefix).<br />
''<package version>'' refers to the ''PACKAGE_VERSION'' field in dkms.conf.<br />
By convention, PKGBUILDs ''$pkgver'' should have the same value.<br />
<br />
===Where should patches be applied?===<br />
One could patch the source either in the PKGBUILD or through DKMS.<br />
Since non-DKMS packages patch from the PKGBUILD, and to keep the DKMS PKGBUILD as close to the non-DKMS version, I am patching in the PKGBUILD.<br />
<br />
===Should the .install file attempt to modprobe/rmmod the module?===<br />
No, it should not. Consider a module that crashes when loaded. That could halt a<br />
pacman upgrade or installation which has more severe consequences.<br />
<br />
Loading/ removing modules is a task for the user.<br />
<br />
===How to create .install / dkms.conf files?===<br />
Try to avoid updating things like version numbers in multiple files. <br />
Try to avoid cluttering up PKGBUILDs/.install files with DKMS-specific stuff. (This keeps them closer to the non-DKMS files).<br />
<br />
I've just started using a simple bash script to create the ''dkms.conf'' file and to replace text in an ''install.template'' file. This leads to much cleaner and easier to understand files.<br />
<br />
You should ''not'' run {{ic|depmod}} in your .install script, this is done automatically by {{ic|dkms install}}. Running {{ic|dkms install}} depends on {{ic|dkms build}} which depends on {{ic|dkms add}} and are executed automatically. Thus, you only need to put the sources in {{ic|/usr/src/MODULE-VERSION}} and run {{ic|dkms install}} in your .install script.<br />
<br />
Example for a module put in {{ic|/usr/src/MODULE-VERSION}} (substitute {{ic|MODULE}} and {{ic|PACKAGE_NAME}} accordingly):<br />
{{bc|<nowiki>post_install() {<br />
dkms install -m MODULE -v ${1%%-*}<br />
}<br />
pre_upgrade() {<br />
local curver=${2%%-*}<br />
# $2 is unset due to a bug. See, https://bugs.archlinux.org/task/32278<br />
# Query current version using pacman as fallback<br />
[ -n "$curver" ] || curver=$(pacman -Q PACKAGE_NAME | cut -d' ' -f2)<br />
pre_remove $curver<br />
}<br />
post_upgrade() {<br />
post_install ${1%%-*}<br />
}<br />
pre_remove() {<br />
dkms remove -m MODULE -v ${1%%-*} --all<br />
}</nowiki>}}<br />
<br />
===DKMS breaks the ABS===<br />
Sort of, yes. The problem is that the resulting modules don't belong to the package, so pacman can't track or report on them.<br />
<br />
I don't think that's a show-stopper, but it probably puts DKMS out on the fringe a bit.<br />
There is some talk about pacman adding similar support through pacman hooks. [https://wiki.archlinux.org/index.php/User:Allan/Pacman_Hooks].<br />
I think you could "fake" the ownership, by installing the module as normal (or even a "dummy" file) and just letting DKMS overwrite it.<br />
<br />
===namcap issues===<br />
As mentioned earlier, namcap complains if you put source in ''/usr/src''.<br />
Also, namcap can not detect that dkms is a dependency. (I guess maybe it's not technically a dependency, but...)<br />
<br />
Basically, take the dependencies of the non-DKMS version, add 'dkms' and remove 'linux-headers' (since dkms optdepends on that)<br />
<br />
==See Also==<br />
*[http://linux.dell.com/dkms/manpage.html Dell's DKMS man page] Official site.<br />
*[http://manpages.ubuntu.com/manpages/karmic/man8/dkms.8.html Ubuntu's DKMS man page] (Documents some officially un-documented bits.)<br />
*[http://www.linuxjournal.com/article/6896 Exploring Dynamic Kernel Module Support]</div>Apouloshttps://wiki.archlinux.org/index.php?title=GRUB&diff=266658GRUB2013-07-16T20:39:23Z<p>Apoulos: </p>
<hr />
<div>[[Category:Boot loaders]]<br />
[[ar:GRUB]]<br />
[[cs:GRUB2]]<br />
[[de:GRUB]]<br />
[[es:GRUB]]<br />
[[fr:GRUB2]]<br />
[[id:GRUB2]]<br />
[[it:GRUB2]]<br />
[[ru:GRUB2]]<br />
[[tr:GRUB2]]<br />
[[zh-CN:GRUB2]]<br />
[[zh-TW:GRUB2]]<br />
{{Article summary start}}<br />
{{Article summary text|Covers various aspects of version 2 of the GRand Unified Bootloader (GRUB).}}<br />
{{Article summary heading|Overview}}<br />
{{Article summary text|{{Boot process overview}}}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|BURG}} - BURG is a brand-new boot loader based on GRUB v2. It can be built on a wider range of OS, and has a highly configurable menu system which works in both text and graphic mode. <br />
{{Article summary wiki|GRUB Legacy}} - previous Version, now obsolete.<br />
{{Article summary heading|Resources}}<br />
{{Article summary wiki|GRUB EFI Examples}}<br />
{{Article summary link|GNU GRUB - GNU Project|https://www.gnu.org/software/grub/}}<br />
{{Article summary end}}<br />
<br />
[https://www.gnu.org/software/grub/ GRUB] - not to be confused with [[GRUB Legacy]] - is the next generation of the GRand Unified Bootloader. GRUB is derived from [http://www.nongnu.org/pupa/ PUPA] which was a research project to develop the next generation of what is now GRUB Legacy. GRUB has been rewritten from scratch to clean up everything and provide modularity and portability [https://www.gnu.org/software/grub/grub-faq.html#q1].<br />
<br />
In brief, the ''bootloader'' is the first software program that runs when a computer starts. It is responsible for loading and transferring control to the Linux kernel. The kernel, in turn, initializes the rest of the operating system.<br />
<br />
== Preface ==<br />
<br />
* The name ''GRUB'' officially refers to version ''2'' of the software, see [https://www.gnu.org/software/grub/]. If you are looking for the article on the legacy version, see [[GRUB Legacy]].<br />
* GRUB supports [[Btrfs]] as root (without a separate {{ic|/boot}} filesystem) compressed with either zlib or LZO<br />
<br />
=== Notes for current GRUB Legacy users ===<br />
<br />
* Upgrading from [[GRUB Legacy]] to GRUB is much the same as freshly installing GRUB, which is covered [[#Installation|below]]<br />
* There are differences in the commands of GRUB Legacy and GRUB. Familiarize yourself with [https://www.gnu.org/software/grub/manual/grub.html#Commands GRUB commands] before proceeding (e.g. "find" has been replaced with "search")<br />
* GRUB is now ''modular'' and no longer requires "stage 1.5". As a result, the bootloader itself is limited -- modules are loaded from the hard drive as needed to expand functionality (e.g. for [[LVM]] or RAID support)<br />
* Device naming has changed between GRUB Legacy and GRUB. Partitions are numbered from 1 instead of 0 while drives are still numbered from 0, and prefixed with partition-table type. For example, {{ic|/dev/sda1}} would be referred to as {{ic|(hd0,msdos1)}} (for MBR) or {{ic|(hd0,gpt1)}} (for GPT)<br />
* If you use systemd without systemd-sysvcompat, and have had {{ic|<nowiki>init=/usr/lib/systemd/systemd</nowiki>}} in your old grub menu.lst, the automatically generated grub.cfg file might not carry over this kernel parameter (giving you "ERROT: Root device mounted successfully, but /sbin/init does not exist" on boot). If so, edit the Arch Linux entry that grub shows you, add {{ic|<nowiki>init=/usr/lib/systemd/systemd</nowiki>}} to the kernel parameters, and then [[Grub#Additional_arguments|make it permanent]].<br />
* GRUB is noticably bigger than GRUB legacy (occupies ~13 MB in /boot). If you are booting from a separate /boot partition, and this partition is smaller than 32 MB, you will run into disk space issues, and pacman will refuse to install new kernels. If you don't want to re-partition your system, switch to [[Syslinux]] instead, which is smaller (occupies ~1.5 MB in /boot).<br />
<br />
==== Backup important data ====<br />
<br />
Although a GRUB installation should run smoothly, it is strongly recommended to keep the GRUB Legacy files before upgrading to GRUB v2.<br />
<br />
# mv /boot/grub /boot/grub-legacy<br />
<br />
Backup the MBR which contains the boot code and partition table (Replace {{ic|/dev/sd'''X'''}} with your actual disk path):<br />
<br />
# dd if=/dev/sdX of=/path/to/backup/mbr_backup bs=512 count=1<br />
<br />
Only 446 bytes of the MBR contain boot code, the next 64 contain the partition table. If you do not want to overwrite your partition table when restoring, it is strongly advised to backup only the MBR boot code:<br />
<br />
# dd if=/dev/sdX of=/path/to/backup/bootcode_backup bs=446 count=1<br />
<br />
If unable to install GRUB2 correctly, see [[#Restore GRUB Legacy]].<br />
<br />
=== Preliminary requirements ===<br />
<br />
==== BIOS systems ====<br />
<br />
===== GUID Partition Table (GPT) specific instructions =====<br />
<br />
GRUB in [[GPT|BIOS-GPT]] configuration requires a [http://www.gnu.org/software/grub/manual/html_node/BIOS-installation.html BIOS boot partition] to embed its {{ic|core.img}} in the absence of post-MBR gap in GPT partitioned systems (which is taken over by the GPT Primary Header and Primary Partition table). This partition is used by GRUB only in BIOS-GPT setups. No such partition type exists in case of MBR partitioning (at least not for GRUB). This partition is also not required if the system is UEFI based, as no embedding of bootsectors takes place in that case.<br />
<br />
For a BIOS-GPT configuration, create a 1007 KiB partition at the beginning of the disk using gdisk, cgdisk or GNU Parted with no filesystem. The size of 1007 KiB will allow for the following partition to be correctly alligned at 1024 KiB. If needed, the partition can also be located somewhere else on the disk, but it should be within the first 2 TiB region. Set the partition type to {{ic|ef02}} in (c)gdisk or {{ic|set <BOOT_PART_NUM> bios_grub on}} in GNU Parted.<br />
<br />
{{Note|<br />
* This partition should be created before {{ic|grub-install}} or {{ic|grub-setup}} is run<br />
* gdisk will only allow you to create this partition on the position which will waste the least amount of space (sector 34-2047) if you create it last, after all the other partitions. This is because gdisk will auto-align partitions to 2048-sector boundaries if possible<br />
}}<br />
<br />
===== Master Boot Record (MBR) specific instructions =====<br />
<br />
Usually the post-[[MBR]] gap (after the 512 byte MBR region and before the start of the 1st partition) in many MBR (or msdos disklabel) partitioned systems is 31 KiB when DOS compatibility cylinder alignment issues are satisfied in the partition table. However a post-MBR gap of about 1 to 2 MiB is recommended to provide sufficient room for embedding GRUB's {{ic|core.img}} ({{bug|24103}}). It is advisable to use a partitioner which supports 1 MiB partition alignment to obtain this space as well as satisfy other non-512 byte sector issues (which are unrelated to embedding of {{ic|core.img}}).<br />
<br />
==== UEFI systems ====<br />
<br />
{{Note|It is recommended to read and understand the [[Unified Extensible Firmware Interface|UEFI]], [[GUID Partition Table|GPT]] and [[UEFI Bootloaders]] pages.}}<br />
<br />
===== Create and Mount the UEFI System Partition =====<br />
<br />
Follow [[Unified Extensible Firmware Interface#EFI System Partition]] for instructions on creating a UEFI System Partition. Then mount the UEFI System Partition at {{ic|/boot/efi}}. If you have mounted the UEFI System Partition at some other mountpoint, replace {{ic|/boot/efi}} in the below instructions with that mountpoint:<br />
<br />
# mkdir -p /boot/efi<br />
# mount -t vfat <UEFI_SYSTEM_PARTITION> /boot/efi<br />
<br />
Create a {{ic|/boot/efi/EFI}} directory:<br />
<br />
# mkdir /boot/efi/EFI<br />
<br />
== Installation ==<br />
<br />
=== BIOS systems ===<br />
<br />
GRUB can be [[pacman|installed]] with the {{Pkg|grub}} package from the [[official repositories]]. It will replace {{Pkg|grub-legacy}} , if it is installed.<br />
<br />
{{Note|Simply installing the package won't update the {{ic|/boot/grub/i386-pc/core.img}} file and the GRUB modules in {{ic|/boot/grub/i386-pc}}. You need to update them manually using {{ic|grub-install}} as explained below.}}<br />
<br />
==== Install boot files ====<br />
<br />
There are 3 ways to install GRUB boot files in BIOS booting:<br />
* [[#Install to GPT BIOS boot partition]] (recommended with [[GPT]])<br />
* [[#Install to 440-byte MBR boot code region]] (recommended with [[MBR]])<br />
* [[#Install to partition or partitionless disk]] (not recommended)<br />
* [[#Generate core.img alone]] (safest method, but requires another BIOS bootloader like [[GRUB Legacy]] or [[Syslinux]] to be installed to chainload {{ic|/boot/grub/i386-pc/core.img}})<br />
<br />
{{Note|See http://www.gnu.org/software/grub/manual/html_node/BIOS-installation.html for additional documentation.}}<br />
<br />
===== Install to GPT BIOS boot partition =====<br />
<br />
[[GUID Partition Table]] disks do not have a reserved "boot track". Therefore you must create a BIOS Boot Partition ({{ic|ef02}}) to hold the GRUB core image.<br />
<br />
Using GNU Parted, you can set this using a command such as the following:<br />
<br />
# parted /dev/disk set <partition-number> bios_grub on<br />
<br />
If you are using gdisk, set the partition type to {{ic|ef02}}. With partitioning programs that require setting the GUID directly, it should be {{ic|‘21686148-6449-6e6f-744e656564454649’}} (or, {{ic|[[wikipedia:BIOS_Boot_partition|Hah!IdontNeedEFI]]}}).<br />
<br />
{{Warning|Be very careful which partition you select when marking it as a BIOS Boot Partition. When GRUB finds a BIOS Boot Partition during installation, it will automatically overwrite part of it. Make sure that the partition does not contain any other data.}}<br />
<br />
To setup {{ic|grub}} on a GPT disk, populate the {{ic|/boot/grub}} directory, generate the {{ic|/boot/grub/i386-pc/core.img}} file, and embed it in the BIOS Boot Partition, run:<br />
<br />
# modprobe dm-mod<br />
# grub-install --target=i386-pc --recheck --debug /dev/sda<br />
<br />
where {{ic|/dev/sda}} is the destination of the installation.<br />
<br />
Continue with [[GRUB#Generate config file]] below.<br />
<br />
===== Install to 440-byte MBR boot code region =====<br />
<br />
To setup {{ic|grub}} in the 440-byte Master Boot Record boot code region, populate the {{ic|/boot/grub}} directory, generate the {{ic|/boot/grub/i386-pc/core.img}} file, embed it in the 31 KiB (minimum size - varies depending on partition alignment) post-MBR gap, and generate the configuration file, run:<br />
<br />
# modprobe dm-mod<br />
# grub-install --recheck /dev/sdX<br />
<br />
where {{ic|/dev/sdX}} is the destination of the installation (in this case the MBR of the first SATA disk). If you use [[LVM]] for your {{ic|/boot}}, you can install GRUB on multiple physical disks.<br />
<br />
{{Warning|Make sure to check the {{ic|/boot}} directory if you use the latter. Sometimes the {{ic|boot-directory}} parameter creates another {{ic|/boot}} folder inside of {{ic|/boot}}. A wrong install would look like: {{ic|/boot/boot/grub/}}.}}<br />
<br />
Continue with [[GRUB#Generate config file]] below.<br />
<br />
===== Install to partition or partitionless disk =====<br />
<br />
{{Note|GRUB does not encourage installation to a partition boot sector or a partitionless disk like GRUB Legacy or Syslinux does. This kind of setup is prone to breakage, especially during updates, and is not supported by Arch devs.}}<br />
<br />
To set up grub to a partition boot sector, to a partitionless disk (also called superfloppy) or to a floppy disk, run (using for example {{ic|/dev/sdaX}} as the {{ic|/boot}} partition):<br />
<br />
# modprobe dm-mod <br />
# grub-install --target=i386-pc --recheck --debug --force /dev/sdaX<br />
# chattr -i /boot/grub/i386-pc/core.img<br />
# chattr +i /boot/grub/i386-pc/core.img<br />
<br />
You need to use the {{ic|--force}} option to allow usage of blocklists and should not use {{ic|1=--grub-setup=/bin/true}} (which is similar to simply generating {{ic|core.img}}).<br />
<br />
{{ic|grub-install}} will give out warnings like which should give you the idea of what might go wrong with this approach:<br />
<br />
/sbin/grub-setup: warn: Attempting to install GRUB to a partitionless disk or to a partition. This is a BAD idea.<br />
/sbin/grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. <br />
However, blocklists are UNRELIABLE and their use is discouraged.<br />
<br />
Without {{ic|--force}} you may get the below error and {{ic|grub-setup}} will not setup its boot code in the partition boot sector:<br />
<br />
/sbin/grub-setup: error: will not proceed with blocklists<br />
<br />
With {{ic|--force}} you should get:<br />
<br />
Installation finished. No error reported.<br />
<br />
The reason why {{ic|grub-setup}} does not by default allow this is because in case of partition or a partitionless disk is that {{ic|grub}} relies on embedded blocklists in the partition bootsector to locate the {{ic|/boot/grub/i386-pc/core.img}} file and the prefix dir {{ic|/boot/grub}}. The sector locations of {{ic|core.img}} may change whenever the filesystem in the partition is being altered (files copied, deleted etc.). For more info see https://bugzilla.redhat.com/show_bug.cgi?id=728742 and https://bugzilla.redhat.com/show_bug.cgi?id=730915.<br />
<br />
The workaround for this is to set the immutable flag on {{ic|/boot/grub/i386-pc/core.img}} (using chattr command as mentioned above) so that the sector locations of the {{ic|core.img}} file in the disk is not altered. The immutable flag on {{ic|/boot/grub/i386-pc/core.img}} needs to be set only if {{ic|grub}} is installed to a partition boot sector or a partitionless disk, not in case of installation to MBR or simple generation of {{ic|core.img}} without embedding any bootsector (mentioned above).<br />
<br />
Continue with [[GRUB#Generate config file]] below.<br />
<br />
===== Generate core.img alone =====<br />
<br />
To populate the {{ic|/boot/grub}} directory and generate a {{ic|/boot/grub/i386-pc/core.img}} file '''without''' embedding any {{ic|grub}} bootsector code in the MBR, post-MBR region, or the partition bootsector, add {{ic|1=--grub-setup=/bin/true}} to {{ic|grub-install}}:<br />
<br />
# modprobe dm-mod<br />
# grub-install --target=i386-pc --grub-setup=/bin/true --recheck --debug /dev/sda<br />
<br />
You can then chainload GRUB's {{ic|core.img}} from GRUB Legacy or syslinux as a Linux kernel or a multiboot kernel.<br />
<br />
==== Generate config file ====<br />
<br />
Finally, generate a configuration for GRUB (this is explained in greater detail in the Configuration section):<br />
<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
{{Note|The file path is {{ic|/boot/grub/grub.cfg}}, NOT {{ic|/boot/grub/i386-pc/grub.cfg}}.}}<br />
<br />
If GRUB complains about "no suitable mode found" while booting, go to [[#"No suitable mode found" error]].<br />
<br />
If {{ic|grub-mkconfig}} fails, convert your {{ic|/boot/grub/menu.lst}} file to {{ic|/boot/grub/grub.cfg}} using:<br />
<br />
# grub-menulst2cfg /boot/grub/menu.lst /boot/grub/grub.cfg<br />
<br />
For example:<br />
<br />
{{hc|/boot/grub/menu.lst|<nowiki><br />
default=0<br />
timeout=5<br />
<br />
title Arch Linux Stock Kernel<br />
root (hd0,0)<br />
kernel /vmlinuz-linux root=/dev/sda2 ro<br />
initrd /initramfs-linux.img<br />
<br />
title Arch Linux Stock Kernel Fallback<br />
root (hd0,0)<br />
kernel /vmlinuz-linux root=/dev/sda2 ro<br />
initrd /initramfs-linux-fallback.img<br />
</nowiki>}}<br />
<br />
{{hc|/boot/grub/grub.cfg|<nowiki><br />
set default='0'; if [ x"$default" = xsaved ]; then load_env; set default="$saved_entry"; fi<br />
set timeout=5<br />
<br />
menuentry 'Arch Linux Stock Kernel' {<br />
set root='(hd0,1)'; set legacy_hdbias='0'<br />
legacy_kernel '/vmlinuz-linux' '/vmlinuz-linux' 'root=/dev/sda2' 'ro'<br />
legacy_initrd '/initramfs-linux.img' '/initramfs-linux.img'<br />
<br />
}<br />
<br />
menuentry 'Arch Linux Stock Kernel Fallback' {<br />
set root='(hd0,1)'; set legacy_hdbias='0'<br />
legacy_kernel '/vmlinuz-linux' '/vmlinuz-linux' 'root=/dev/sda2' 'ro'<br />
legacy_initrd '/initramfs-linux-fallback.img' '/initramfs-linux-fallback.img'<br />
}<br />
</nowiki>}}<br />
<br />
If you forgot to create a GRUB {{ic|/boot/grub/grub.cfg}} config file and simply rebooted into GRUB Command Shell, type:<br />
<br />
sh:grub> insmod legacycfg<br />
sh:grub> legacy_configfile ${prefix}/menu.lst<br />
<br />
Boot into Arch and re-create the proper GRUB {{ic|/boot/grub/grub.cfg}} config file.<br />
<br />
{{Note|This option works only in BIOS systems, not in UEFI systems.}}<br />
<br />
==== Multiboot ====<br />
This should work out of the box, but an extra utility needs to be installed: os-prober. Install it, then rerun grub-mkconfig -o /boot/grub/grub.cfg. If this fails, you can try manually adding an entry by following the instructions below.<br />
<br />
===== Microsoft Windows installed in BIOS-MBR mode =====<br />
<br />
{{Note|GRUB supports booting {{ic|bootmgr}} directly and chainload of partition boot sector is no longer required to boot Windows in a BIOS-MBR setup.}}<br />
<br />
{{Warning|It is the '''system partition''' that has {{ic|bootmgr}}, not your "real" Windows partition (usually C:). When showing all UUIDs with blkid, the system partition is the one with {{ic|LABEL&#61;"SYSTEM RESERVED"}} and is only about 100 MB in size (much like the boot partition for Arch). See [[Wikipedia:System partition and boot partition]] for more info.}}<br />
<br />
Throughout this section, it is assumed your Windows partition is /dev/sda1. A different partition will change every instance of hd0,msdos1. First, find the UUID of the NTFS filesystem of the Windows's SYSTEM PARTITION where the {{ic|bootmgr}} and its files reside. For example, if Windows {{ic|bootmgr}} exists at {{ic|/media/SYSTEM_RESERVED/bootmgr}}:<br />
<br />
For Windows Vista/7/8:<br />
<br />
# grub-probe --target=fs_uuid /media/SYSTEM_RESERVED/bootmgr<br />
69B235F6749E84CE<br />
<br />
# grub-probe --target=hints_string /media/SYSTEM_RESERVED/bootmgr<br />
--hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1<br />
<br />
{{Note|For Windows XP, replace {{ic|bootmgr}} with {{ic|NTLDR}} in the above commands. And note that there may not be a separate SYSTEM_RESERVED partition; just probe the file NTLDR on your Windows partition.}}<br />
<br />
Then, add the below code to {{ic|/etc/grub.d/40_custom}} or {{ic|/boot/grub/custom.cfg}} and regenerate {{ic|grub.cfg}} with {{ic|grub-mkconfig}} as explained above to boot Windows (XP, Vista, 7 or 8) installed in BIOS-MBR mode:<br />
<br />
For Windows Vista/7/8:<br />
<br />
menuentry "Microsoft Windows Vista/7/8 BIOS-MBR" {<br />
insmod part_msdos<br />
insmod ntfs<br />
insmod search_fs_uuid<br />
insmod ntldr <br />
search --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 69B235F6749E84CE<br />
ntldr /bootmgr<br />
}<br />
<br />
For Windows XP:<br />
<br />
menuentry "Microsoft Windows XP" {<br />
insmod part_msdos<br />
insmod ntfs<br />
insmod search_fs_uuid<br />
insmod ntldr <br />
search --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 69B235F6749E84CE<br />
ntldr /ntldr<br />
}<br />
<br />
{{ic|/etc/grub.d/40_custom}} can be used as a template to create {{ic|/etc/grub.d/nn_custom}}. Where {{ic|nn}} defines the precendence, indicating the order the script is executed. The order scripts are executed determine the placement in the grub boot menu.<br />
<br />
{{Note|{{ic|nn}} should be greater than 06 to ensure necessary scripts are executed first.}}<br />
<br />
=== UEFI systems ===<br />
<br />
{{Note|It is well known that different motherboard manufactures implement UEFI differently. Users experiencing problems getting Grub/EFI to work properly are encouraged to share detailed steps for hardware-specific cases where UEFI booting does not work as described below. In an effort to keep the parent [[GRUB]] article neat and tidy, see the [[GRUB EFI Examples]] page for these special cases.}}<br />
<br />
First install the {{Pkg|grub}} package and then follow the instructions below.<br />
<br />
{{Note|Simply installing the package will not update the {{ic|core.efi}} file and the GRUB modules in the UEFI System Partition. You need to do this manually using {{ic|grub-install}} as explained below.}}<br />
<br />
==== Install boot files ====<br />
<br />
===== Install to UEFI system partition =====<br />
<br />
{{Note|<br />
* The below commands assume you are using installing GRUB for {{ic|x86_64-efi}} (for {{ic|IA32-efi}} replace {{ic|x86_64}} with {{ic|i386}} in the below commands)<br />
* To do this, you need to boot using UEFI and not the BIOS. If you booted by just copying the ISO file to the USB drive, you will need to follow [[Unified Extensible Firmware Interface#Create UEFI bootable USB from ISO|this guide]] or grub-install will show errors<br />
}}<br />
<br />
The UEFI system partition will need to be mounted at {{ic|/boot/efi/}} for the GRUB install script to detect it:<br />
<br />
# mkdir -p /boot/efi<br />
# mount -t vfat /dev/sdXY /boot/efi<br />
<br />
Install GRUB UEFI application to {{ic|/boot/efi/EFI/arch_grub}} and its modules to {{ic|/boot/grub/x86_64-efi}} (recommended) using:<br />
<br />
# modprobe dm-mod<br />
# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch_grub --recheck --debug<br />
<br />
{{Note|Without {{ic|--target}} or {{ic|--directory}} option, grub-install cannot determine for which firmware GRUB is being installed. In such cases {{ic|grub-install}} will show {{ic|source_dir doesn't exist. Please specify --target or --directory}} message.}}<br />
<br />
If you want to install GRUB modules and {{ic|grub.cfg}} at the directory {{ic|/boot/efi/EFI/grub}} and the {{ic|grubx64.efi}} application at {{ic|/boot/efi/EFI/arch_grub}} (ie. all the GRUB UEFI files inside the UEFISYS partition itself) use:<br />
<br />
# modprobe dm-mod <br />
# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch_grub --boot-directory=/boot/efi/EFI --recheck --debug<br />
<br />
The {{ic|--efi-directory}} option mentions the mountpoint of UEFI SYSTEM PARTITION , {{ic|--bootloader-id}} mentions the name of the directory used to store the {{ic|grubx64.efi}} file and {{ic|--boot-directory}} mentions the directory wherein the actual modules will be installed (and into which {{ic|grub.cfg}} should be created).<br />
<br />
The actual paths are:<br />
<br />
<efi-directory>/<EFI or efi>/<bootloader-id>/grubx64.efi<br />
<br />
<boot-directory>/grub/x86_64-efi/<all modules, grub.efi, core.efi, grub.cfg><br />
<br />
{{Note|the {{ic|--bootloader-id}} option does not change {{ic|<boot-directory>/grub}}, i.e. you cannot install the modules to {{ic|<boot-directory>/<bootloader-id>}}, the path is hard-coded to be {{ic|<boot-directory>/grub}}.}}<br />
<br />
In {{ic|<nowiki>--efi-directory=/boot/efi --boot-directory=/boot/efi/EFI --bootloader-id=grub</nowiki>}}:<br />
<br />
<efi-directory>/<EFI or efi>/<bootloader-id> == <boot-directory>/grub == /boot/efi/EFI/grub<br />
<br />
In {{ic|<nowiki>--efi-directory=/boot/efi --boot-directory=/boot/efi/EFI --bootloader-id=arch_grub</nowiki>}}:<br />
<br />
<efi-directory>/<EFI or efi>/<bootloader-id> == /boot/efi/EFI/arch_grub<br />
<boot-directory>/grub == /boot/efi/EFI/grub<br />
<br />
In {{ic|<nowiki>--efi-directory=/boot/efi --boot-directory=/boot --bootloader-id=arch_grub</nowiki>}}:<br />
<br />
<efi-directory>/<EFI or efi>/<bootloader-id> == /boot/efi/EFI/arch_grub<br />
<boot-directory>/grub == /boot/grub<br />
<br />
In {{ic|<nowiki>--efi-directory=/boot/efi --boot-directory=/boot --bootloader-id=grub</nowiki>}}:<br />
<br />
<efi-directory>/<EFI or efi>/<bootloader-id> == /boot/efi/EFI/grub<br />
<boot-directory>/grub == /boot/grub<br />
<br />
The {{ic|<nowiki><efi-directory>/<EFI or efi>/<bootloader-id>/grubx64.efi</nowiki>}} is an exact copy of {{ic|<nowiki><boot-directory>/grub/x86_64-efi/core.efi</nowiki>}}.<br />
<br />
{{Note|<br />
* In GRUB 2.00, the {{ic|grub-install}} option {{ic|--efi-directory}} replaces {{ic|--root-directory}} and the latter is deprecated<br />
* The options {{ic|--efi-directory}} and {{ic|--bootloader-id}} are specific to GRUB UEFI<br />
}}<br />
<br />
In all the cases the UEFI SYSTEM PARTITION should be mounted for {{ic|grub-install}} to install {{ic|grubx64.efi}} in it, which will be launched by the firmware (using the {{ic|efibootmgr}} created boot entry in non-Mac systems).<br />
<br />
If you notice carefully, there is no <device_path> option (Eg: {{ic|/dev/sda}}) at the end of the {{ic|grub-install}} command unlike the case of setting up GRUB for BIOS systems. Any <device_path> provided will be ignored by the install script as UEFI bootloaders do not use MBR or Partition boot sectors at all.<br />
<br />
You may now be able to UEFI boot your system by creating a {{ic|grub.cfg}} file by following [[#Generate UEFI Config file]] and [[#Create GRUB entry in the firmware boot manager]].<br />
<br />
==== Generate config file ====<br />
<br />
Finally, generate a configuration for GRUB (this is explained in greater detail in the Configuration section):<br />
<br />
# grub-mkconfig -o <boot-directory>/grub/grub.cfg<br />
<br />
{{Note|The file path is {{ic|<boot-directory>/grub/grub.cfg}}, NOT {{ic|<boot-directory>/grub/x86_64-efi/grub.cfg}}.}}<br />
<br />
If you used {{ic|<nowiki>--boot-directory=/boot</nowiki>}}:<br />
<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
If you used {{ic|<nowiki>--boot-directory=/boot/efi/EFI</nowiki>}}:<br />
<br />
# grub-mkconfig -o /boot/efi/EFI/grub/grub.cfg<br />
<br />
This is independent of the value of {{ic|--bootloader-id}} option.<br />
<br />
If GRUB complains about "no suitable mode found" while booting, try [[#"No suitable mode found" error]].<br />
<br />
==== Create GRUB entry in the firmware boot manager ====<br />
<br />
{{ic|grub-install}} automatically tries to create a menu entry in the boot manager. If it doesn't, then see [[Beginners' Guide#GRUB]] for instructions to use {{ic|efibootmgr}} to create a menu entry. However, the problem is likely to be that you haven't booted your CD/USB in UEFI mode, as in [[Unified Extensible Firmware Interface#Create UEFI bootable USB from ISO]].<br />
<br />
==== Create GRUB standalone UEFI application ====<br />
<br />
It is possible to create a {{ic|grubx64_standalone.efi}} application which has all the modules embeddded in a memdisk within the UEFI application, thus removing the need for having a separate directory populated with all the GRUB UEFI modules and other related files. This is done using the {{ic|grub-mkstandalone}} command which is included in {{Pkg|grub}}.<br />
<br />
The easiest way to do this would be with the install command already mentioned before, but specifying the modules to include. For example:<br />
<br />
# grub-mkstandalone --directory="/usr/lib/grub/x86_64-efi/" --format="x86_64-efi" --compression="xz" \<br />
--output="/boot/efi/EFI/arch_grub/grubx64_standalone.efi" <any extra files you want to include><br />
<br />
The {{ic|grubx64_standalone.efi}} file expects {{ic|grub.cfg}} to be within its $prefix which is {{ic|(memdisk)/boot/grub}}. The memdisk is embedded within the EFI app. The {{ic|grub-mkstandlone}} script allow passing files to be included in the memdisk image to be as the arguments to the script (in <any extra files you want to include>).<br />
<br />
If you have the {{ic|grub.cfg}} at {{ic|/home/user/Desktop/grub.cfg}}, then create a temporary {{ic|/home/user/Desktop/boot/grub/}} directory, copy the {{ic|/home/user/Desktop/grub.cfg}} to {{ic|/home/user/Desktop/boot/grub/grub.cfg}}, cd into {{ic|/home/user/Desktop/boot/grub/}} and run:<br />
<br />
# grub-mkstandalone --directory="/usr/lib/grub/x86_64-efi/" --format="x86_64-efi" --compression="xz" \<br />
--output="/boot/efi/EFI/arch_grub/grubx64_standalone.efi" "boot/grub/grub.cfg"<br />
<br />
The reason to {{ic|cd}} into {{ic|/home/user/Desktop/boot/grub/}} and to pass the file path as {{ic|boot/grub/grub.cfg}} (notice the lack of a leading slash - {{ic|boot/}} vs. {{ic|/boot/}} ) is because {{ic|dir1/dir2/file}} is included as {{ic|(memdisk)/dir1/dir2/file}} by the {{ic|grub-mkstandalone}} script. <br />
<br />
If you pass {{ic|/home/user/Desktop/grub.cfg}} the file will be included as {{ic|(memdisk)/home/user/Desktop/grub.cfg}}. If you pass {{ic|/home/user/Desktop/boot/grub/grub.cfg}} the file will be included as {{ic|(memdisk)/home/user/Desktop/boot/grub/grub.cfg}}. That is the reason for {{ic|cd}}'ing into {{ic|/home/user/Desktop/boot/grub/}} and passing {{ic|boot/grub/grub.cfg}}, to include the file as {{ic|(memdisk)/boot/grub/grub.cfg}}, which is what {{ic|grub.efi}} expects the file to be.<br />
<br />
You need to create an UEFI Boot Manager entry for {{ic|/boot/efi/EFI/arch_grub/grubx64_standalone.efi}} using {{ic|efibootmgr}}. Follow [[#Create GRUB entry in the Firmware Boot Manager]].<br />
<br />
==== Multiboot ====<br />
<br />
===== Microsoft Windows installed in UEFI-GPT mode =====<br />
<br />
Find the UUID of the FAT32 filesystem in the UEFI SYSTEM PARTITION where the Windows UEFI Bootloader files reside. For example, if Windows {{ic|bootmgfw.efi}} exists at {{ic|/boot/efi/EFI/Microsoft/Boot/bootmgfw.efi}} (ignore the upper-lower case differences since that is immaterial in FAT filesystem):<br />
<br />
# grub-probe --target=fs_uuid /boot/efi/EFI/Microsoft/Boot/bootmgfw.efi<br />
1ce5-7f28<br />
<br />
# grub-probe --target=hints_string /boot/efi/EFI/Microsoft/Boot/bootmgfw.efi<br />
--hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1<br />
<br />
Then, add this code to {{ic|/etc/grub.d/40_custom}} to chainload Windows x86_64 (Vista SP1+, 7 or 8) installed in UEFI-GPT mode:<br />
<br />
menuentry "Microsoft Windows Vista/7/8 x86_64 UEFI-GPT" {<br />
insmod part_gpt<br />
insmod fat<br />
insmod search_fs_uuid<br />
insmod chain<br />
search --fs-uuid --set=root --hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1 1ce5-7f28<br />
chainloader /efi/Microsoft/Boot/bootmgfw.efi<br />
}<br />
<br />
Afterwards remake {{ic|/boot/grub/grub.cfg}}:<br />
<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
== Configuration ==<br />
<br />
You can also choose to automatically generate or manually edit {{ic|grub.cfg}}.<br />
<br />
{{Note|<br />
* For EFI systems, if GRUB was installed with the {{ic|--boot-directory}} option set, the {{ic|grub.cfg}} file must be placed in the same directory as {{ic|grubx64.efi}}. Otherwise, the {{ic|grub.cfg}} file goes in {{ic|/boot/grub/}}, just like in GRUB BIOS<br />
* [http://members.iinet.net/~herman546/p20/GRUB2%20Configuration%20File%20Commands.html Here] is a quite complete description of how to configure GRUB<br />
}}<br />
<br />
=== Automatically generating using grub-mkconfig ===<br />
<br />
The GRUB {{ic|menu.lst}} equivalent configuration files are {{ic|/etc/default/grub}} and {{ic|/etc/grub.d/*}}. {{ic|grub-mkconfig}} uses these files to generate {{ic|grub.cfg}}. By default the script outputs to stdout. To generate a {{ic|grub.cfg}} file run the command:<br />
<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
{{ic|/etc/grub.d/10_linux}} is set to automatically add menu items for Arch linux that work out of the box, to any generated configuration. Other operating systems may need to be added manually to {{ic|/etc/grub.d/40_custom}} or {{ic|/boot/grub/custom.cfg}}<br />
<br />
==== Additional arguments ====<br />
<br />
To pass custom additional arguments to the Linux image, you can set the {{ic|GRUB_CMDLINE_LINUX}} variable in {{ic|/etc/default/grub}}. <br />
<br />
For example, use {{ic|<nowiki>GRUB_CMDLINE_LINUX="resume=/dev/sdaX"</nowiki>}} where {{ic|sda'''X'''}} is your swap partition to enable resume after hibernation.<br />
<br />
You can also use {{ic|<nowiki>GRUB_CMDLINE_LINUX="resume=/dev/disk/by-uuid/${swap_uuid}"</nowiki>}}, where {{ic|${swap_uuid} }} is the [[Persistent_block_device_naming|UUID]] of your swap partition.<br />
<br />
Multiple entries are separated by spaces within the double quotes. So, for users who want both resume and systemd it would look like this:<br />
{{ic|<nowiki>GRUB_CMDLINE_LINUX="resume=/dev/sdaX init=/usr/lib/systemd/systemd"</nowiki>}}<br />
<br />
See [[Kernel parameters]] for more info.<br />
<br />
=== Manually creating grub.cfg ===<br />
<br />
{{Warning|Editing this file is strongly ''not'' recommended. The file is generated by the {{ic|grub-mkconfig}} command, and it is best to edit your {{ic|/etc/default/grub}} or one of the scripts in the {{ic|/etc/grub.d}} folder.}}<br />
<br />
A basic GRUB config file uses the following options:<br />
* {{ic|(hdX,Y)}} is the partition {{ic|Y}} on disk {{ic|X}}, partition numbers starting at 1, disk numbers starting at 0<br />
* {{ic|1=set default=N}} is the default boot entry that is chosen after timeout for user action<br />
* {{ic|1=set timeout=M}} is the time {{ic|M}} to wait in seconds for a user selection before default is booted<br />
* {{ic|<nowiki>menuentry "title" {entry options}</nowiki>}} is a boot entry titled {{ic|title}}<br />
* {{ic|1=set root=(hdX,Y)}} sets the boot partition, where the kernel and GRUB modules are stored (boot need not be a separate partition, and may simply be a directory under the "root" partition ({{ic|/}})<br />
<br />
An example configuration:<br />
<br />
{{hc|/boot/grub/grub.cfg|<nowiki><br />
# Config file for GRUB - The GNU GRand Unified Bootloader<br />
# /boot/grub/grub.cfg<br />
<br />
# DEVICE NAME CONVERSIONS<br />
#<br />
# Linux Grub<br />
# -------------------------<br />
# /dev/fd0 (fd0)<br />
# /dev/sda (hd0)<br />
# /dev/sdb2 (hd1,2)<br />
# /dev/sda3 (hd0,3)<br />
#<br />
<br />
# Timeout for menu<br />
set timeout=5<br />
<br />
# Set default boot entry as Entry 0<br />
set default=0<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
set root=(hd0,1)<br />
linux /vmlinuz-linux root=/dev/sda3 ro<br />
initrd /initramfs-linux.img<br />
}<br />
<br />
## (1) Windows<br />
#menuentry "Windows" {<br />
# set root=(hd0,3)<br />
# chainloader +1<br />
#}<br />
</nowiki>}}<br />
<br />
=== Dual-booting ===<br />
<br />
{{Note|If you want GRUB to automatically search for other systems, you may wish to install {{Pkg|os-prober}}.}}<br />
<br />
==== Using grub-mkconfig ====<br />
The best way to add other entries is editing the {{ic|/etc/grub.d/40_custom}} or {{ic|/boot/grub/custom.cfg}} . The entries in this file will be automatically added when running {{ic|grub-mkconfig}}.<br />
After adding the new lines, run:<br />
# grub-mkconfig -o /boot/grub/grub.cfg <br />
to generate an updated {{ic|grub.cfg}}.<br />
<br />
===== With GNU/Linux =====<br />
<br />
Assuming that the other distro is on partition {{ic|sda2}}:<br />
<br />
menuentry "Other Linux" {<br />
set root=(hd0,2)<br />
linux /boot/vmlinuz (add other options here as required)<br />
initrd /boot/initrd.img (if the other kernel uses/needs one)<br />
}<br />
<br />
===== With FreeBSD =====<br />
<br />
Requires that FreeBSD is installed on a single partition with UFS. Assuming it is installed on {{ic|sda4}}:<br />
<br />
menuentry "FreeBSD" {<br />
set root=(hd0,4)<br />
chainloader +1<br />
}<br />
<br />
===== With Windows =====<br />
<br />
This assumes that your Windows partition is {{ic|sda3}}. Remember you need to point set root and chainloader to the system reserve partition that windows made when it installed, not the actual partition windows is on. This example works if your system reserve partition is {{ic|sda3}}.<br />
<br />
# (2) Windows XP<br />
menuentry "Windows XP" {<br />
set root="(hd0,3)"<br />
chainloader +1<br />
}<br />
<br />
If the Windows bootloader is on an entirely different hard drive than GRUB, it may be necessary to trick Windows into believing that it is the first hard drive. This was possible with {{ic|drivemap}}. Assuming GRUB is on {{ic|hd0}} and Windows is on {{ic|hd2}}, you need to add the following after {{ic|set root}}:<br />
<br />
drivemap -s hd0 hd2<br />
<br />
==== With Windows via EasyBCD and NeoGRUB ====<br />
<br />
Since EasyBCD's NeoGRUB currently does not understand the GRUB menu format, chainload to it by replacing the contents of your {{ic|C:\NST\menu.lst}} file with lines similar to the following:<br />
<br />
default 0<br />
timeout 1<br />
<br />
title Chainload into GRUB v2<br />
root (hd0,7)<br />
kernel /boot/grub/i386-pc/core.img<br />
<br />
=== Visual configuration ===<br />
<br />
In GRUB it is possible, by default, to change the look of the menu. Make sure to initialize, if not done already, GRUB graphical terminal, gfxterm, with proper video mode, gfxmode, in GRUB. This can be seen in the section [[#"No suitable mode found" error]]. This video mode is passed by GRUB to the linux kernel via 'gfxpayload' so any visual configurations need this mode in order to be in effect.<br />
<br />
==== Setting the framebuffer resolution ====<br />
<br />
GRUB can set the framebuffer for both GRUB itself and the kernel. The old {{ic|1=vga=}} way is deprecated. The preferred method is editing {{ic|/etc/default/grub}} as the following sample:<br />
<br />
GRUB_GFXMODE=1024x768x32<br />
GRUB_GFXPAYLOAD_LINUX=keep<br />
<br />
To generate the changes, run: <br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
The {{ic|gfxpayload}} property will make sure the kernel keeps the resolution.<br />
<br />
{{Note|<br />
* If this example does not work for you try to replace {{ic|1=gfxmode="1024x768x32"}} by {{ic|1=vbemode="0x105"}}. Remember to replace the specified resolution with one suitable for your screen<br />
* To show all the modes you can use {{ic|1=# hwinfo --framebuffer}} (hwinfo is available in [community]), while at GRUB prompt you can use the {{ic|1=vbeinfo}} command<br />
}}<br />
<br />
If this method does not work for you, the deprecated {{ic|1=vga=}} method will still work. Just<br />
add it next to the {{ic|1="GRUB_CMDLINE_LINUX_DEFAULT="}} line in {{ic|/etc/default/grub}}<br />
for eg: {{ic|1="GRUB_CMDLINE_LINUX_DEFAULT="quiet splash vga=792"}} will give you a {{ic|1024x768}} resolution.<br />
<br />
You can choose one of these resolutions: {{ic|640×480}}, {{ic|800×600}}, {{ic|1024×768}}, {{ic|1280×1024}}, {{ic|1600×1200}}, {{ic|1920×1200}}<br />
<br />
==== 915resolution hack ====<br />
<br />
Some times for Intel graphic adapters neither {{ic|1=# hwinfo --framebuffer}} nor {{ic|1=vbeinfo}} will show you the desired resolution. In this case you can use {{ic|915resolution}} hack. This hack will temporarily modify video BIOS and add needed resolution. See [http://915resolution.mango-lang.org/ 915resolution's home page]<br />
<br />
First you need to find a video mode which will be modified later. For that we need the GRUB command shell:<br />
{{hc|sh:grub> 915resolution -l|<br />
Intel 800/900 Series VBIOS Hack : version 0.5.3<br />
[...]<br />
'''Mode 30''' : 640x480, 8 bits/pixel<br />
[...]<br />
}}<br />
Next, we overwrite the {{ic|Mode 30}} with {{ic|1440x900}} resolution:<br />
{{hc|/etc/grub.d/00_header|<br />
[...]<br />
'''915resolution 30 1440 900 # Inserted line'''<br />
set gfxmode&#61;${GRUB_GFXMODE}<br />
[...]<br />
}}<br />
Lastly we need to set {{ic|GRUB_GFXMODE}} as described earlier, regenerate GRUB configuration file and reboot to test changes:<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
# reboot<br />
<br />
==== Background image and bitmap fonts ====<br />
<br />
GRUB comes with support for background images and bitmap fonts in {{ic|pf2}} format. The unifont font is included in the {{Pkg|grub}} package under the filename {{ic|unicode.pf2}}, or, as only ASCII characters under the name {{ic|ascii.pf2}}.<br />
<br />
Image formats supported include tga, png and jpeg, providing the correct modules are loaded. The maximum supported resolution depends on your hardware.<br />
<br />
Make sure you have set up the proper [[#Setting the framebuffer resolution|framebuffer resolution]].<br />
<br />
Edit {{ic|/etc/default/grub}} like this:<br />
GRUB_BACKGROUND="/boot/grub/myimage"<br />
#GRUB_THEME="/path/to/gfxtheme"<br />
GRUB_FONT="/path/to/font.pf2"<br />
<br />
{{Note|If you have installed GRUB on a separate partition, {{ic|/boot/grub/myimage}} becomes {{ic|/grub/myimage}}.}}<br />
<br />
To generate the changes and add the information into {{ic|grub.cfg}}, run: <br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
If adding the splash image was successful, the user will see {{ic|"Found background image..."}} in the terminal as the command is executed. <br />
If this phrase is not seen, the image information was probably not incorporated into the {{ic|grub.cfg}} file.<br />
<br />
If the image is not displayed, check:<br />
* The path and the filename in {{ic|/etc/default/grub}} are correct<br />
* The image is of the proper size and format (tga, png, 8-bit jpg)<br />
* The image was saved in the RGB mode, and is not indexed<br />
* The console mode is not enabled in {{ic|/etc/default/grub}}<br />
* The command {{ic|grub-mkconfig}} must be executed to place the background image information into the {{ic|/boot/grub/grub.cfg}} file<br />
<br />
==== Theme ====<br />
<br />
Here is an example for configuring Starfield theme which was included in GRUB package.<br />
<br />
Edit {{ic|/etc/default/grub}}<br />
GRUB_THEME="/usr/share/grub/themes/starfield/theme.txt"<br />
<br />
Generate the changes:<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
If configuring the theme was successful, you'll see {{ic|Found theme: /usr/share/grub/themes/starfield/theme.txt}} in the terminal.<br />
Your splash image will usually not be displayed when using a theme.<br />
<br />
==== Menu colors ====<br />
<br />
You can set the menu colors in GRUB. The available colors for GRUB can be found in [https://www.gnu.org/software/grub/manual/html_node/Theme-file-format.html the GRUB Manual].<br />
Here is an example:<br />
<br />
Edit {{ic|/etc/default/grub}}:<br />
GRUB_COLOR_NORMAL="light-blue/black"<br />
GRUB_COLOR_HIGHLIGHT="light-cyan/blue"<br />
<br />
Generate the changes:<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
==== Hidden menu ====<br />
<br />
One of the unique features of GRUB is hiding/skipping the menu and showing it by holding {{keypress|Esc}} when needed. You can also adjust whether you want to see the timeout counter.<br />
<br />
Edit {{ic|/etc/default/grub}} as you wish. Here is an example where the comments from the beginning of the two lines have been removed to enable the feature, the timeout has been set to five seconds and to be shown to the user:<br />
GRUB_HIDDEN_TIMEOUT=5<br />
GRUB_HIDDEN_TIMEOUT_QUIET=false<br />
<br />
and run:<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
==== Disable framebuffer ====<br />
<br />
Users who use NVIDIA proprietary driver might wish to disable GRUB's framebuffer as it can cause problems with the binary driver.<br />
<br />
To disable framebuffer, edit {{ic|/etc/default/grub}} and uncomment the following line:<br />
GRUB_TERMINAL_OUTPUT=console<br />
<br />
and run:<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
Another option if you want to keep the framebuffer in GRUB is to revert to text mode just before starting the kernel. To do that modify the variable in {{ic|/etc/default/grub}}:<br />
GRUB_GFXPAYLOAD_LINUX=text<br />
<br />
and rebuild the configuration as before.<br />
<br />
=== Other Options ===<br />
<br />
==== LVM ====<br />
<br />
If you use [[LVM]] for your {{ic|/boot}}, add the following before menuentry lines:<br />
<br />
insmod lvm<br />
<br />
and specify your root in the menuentry as:<br />
<br />
set root=lvm/''lvm_group_name''-''lvm_logical_boot_partition_name''<br />
<br />
Example:<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
insmod lvm<br />
set root=lvm/VolumeGroup-lv_boot<br />
# you can only set following two lines<br />
linux /vmlinuz-linux root=/dev/mapper/VolumeGroup-root ro<br />
initrd /initramfs-linux.img<br />
}<br />
<br />
==== RAID ====<br />
<br />
GRUB provides convenient handling of RAID volumes. You need to add {{ic|insmod mdraid}} which allows you to address the volume natively. For example, {{ic|/dev/md0}} becomes:<br />
set root=(md0)<br />
<br />
whereas a partitioned RAID volume (e.g. {{ic|/dev/md0p1}}) becomes:<br />
set root=(md0,1)<br />
<br />
To install grub when using raid1 as the /boot partition (or using /boot housed on a raid1 root partition), on devices with GPT ef02/'BIOS boot partition', simply run grub-install on both of the drives, such as:<br />
grub-install --recheck --debug /dev/sda && grub-install --recheck --debug /dev/sdb<br />
Where the raid1 array housing /boot is housed on /dev/sda and /dev/sdb.<br />
<br />
==== Persistent block device naming ====<br />
One naming scheme for [[Persistent block device naming]] is the use of globally unique UUIDs to detect partitions instead of the "old" {{ic|/dev/sd*}}. Advantages are covered up in the above linked article. <br />
<br />
Persistent naming via filesystem UUIDs are used by default in GRUB. <br />
<br />
{{Note|The {{ic|/boot/grub.cfg}} file needs regeneration with the new UUID in {{ic|/etc/default/grub}} every time a relevant filesystem is resized or recreated. Remember this when modifying partitions & filesystems with a Live-CD.}}<br />
<br />
Whether to use UUIDs is controlled by an option in {{ic|/etc/default/grub}}:<br />
<br />
# GRUB_DISABLE_LINUX_UUID=true<br />
<br />
Either way, do not forget to generate the changes:<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
==== Using Labels ====<br />
<br />
It is possible to use labels, human-readable strings attached to filesystems, by using the {{ic|--label}} option to {{ic|search}}. First of all, label your existing partition:<br />
# tune2fs -L <LABEL> <PARTITION><br />
<br />
Then, add an entry using labels. An example of this:<br />
<br />
menuentry "Arch Linux, session texte" {<br />
search --label --set=root archroot<br />
linux /boot/vmlinuz-linux root=/dev/disk/by-label/archroot ro<br />
initrd /boot/initramfs-linux.img<br />
}<br />
<br />
==== Recall previous entry ====<br />
<br />
GRUB can remember the last entry you booted from and use this as the default entry to boot from next time. This is useful if you have multiple kernels (i.e., the current Arch one and the LTS kernel as a fallback option) or operating systems. To do this, edit {{ic|/etc/default/grub}} and change the value of {{ic|GRUB_DEFAULT}}:<br />
<br />
GRUB_DEFAULT=saved<br />
<br />
This ensures that GRUB will default to the saved entry. To enable saving the selected entry, add the following line to {{ic|/etc/default/grub}}:<br />
<br />
GRUB_SAVEDEFAULT=true<br />
<br />
{{Note|Manually added menu items, e.g. Windows in {{ic|/etc/grub.d/40_custom}} or {{ic|/boot/grub/custom.cfg}}, will need {{ic|savedefault}} added. Remember to regenerate([[#Generate config file]]) your configuration file.}}<br />
<br />
==== Changing the default menu entry ====<br />
<br />
To change the default selected entry, edit {{ic|/etc/default/grub}} and change the value of {{ic|GRUB_DEFAULT}}:<br />
<br />
Using numbers :<br />
GRUB_DEFAULT=0<br />
Grub identifies entries in generated menu counted from zero. That means 0 for the first entry which is the default value, 1 for the second and so on.<br />
<br />
Or using menu titles :<br />
GRUB_DEFAULT='Arch Linux, with Linux core repo kernel'<br />
<br />
{{Note|Remember to regenerate([[#Generate config file]]) your configuration file.}}<br />
<br />
==== Security ====<br />
<br />
If you want to secure GRUB so it is not possible for anyone to change boot parameters or use the command line, you can add a user/password combination to GRUB's configuration files. To do this, run the command {{ic|grub-mkpasswd-pbkdf2}}. Enter a password and confirm it:<br />
<br />
{{hc|grub-mkpasswd-pbkdf2|<br />
[...]<br />
Your PBKDF2 is grub.pbkdf2.sha512.10000.C8ABD3E93C4DFC83138B0C7A3D719BC650E6234310DA069E6FDB0DD4156313DA3D0D9BFFC2846C21D5A2DDA515114CF6378F8A064C94198D0618E70D23717E82.509BFA8A4217EAD0B33C87432524C0B6B64B34FBAD22D3E6E6874D9B101996C5F98AB1746FE7C7199147ECF4ABD8661C222EEEDB7D14A843261FFF2C07B1269A<br />
}}<br />
Then, add the following to {{ic|/etc/grub.d/00_header}}:<br />
{{hc|/etc/grub.d/00_header|<br />
cat << EOF<br />
<br />
set superusers<nowiki>=</nowiki>"'''username'''"<br />
password_pbkdf2 '''username''' '''<password>'''<br />
<br />
EOF<br />
}}<br />
where {{ic|<password>}} is the string generated by {{ic|grub-mkpasswd_pbkdf2}}.<br />
<br />
Regenerate your configuration file. Your GRUB command line, boot parameters and all boot entries are now protected.<br />
<br />
This can be relaxed and further customized with more users as described in the "Security" part of [https://www.gnu.org/software/grub/manual/grub.html#Security the GRUB manual].<br />
<br />
==== Root encryption ====<br />
<br />
To let GRUB automatically add the kernel parameters for root encryption,<br />
add {{ic|1=cryptdevice=/dev/yourdevice:label}} to {{ic|GRUB_CMDLINE_LINUX}} in {{ic|/etc/default/grub}}.<br />
<br />
{{Tip|If you're upgrading from a working GRUB Legacy configuration, check {{ic|/boot/grub/menu.lst.pacsave}} for the correct device/label to add. Look for them after the text {{ic|kernel /vmlinuz-linux}}.}}<br />
<br />
Example with root mapped to {{ic|/dev/mapper/root}}:<br />
<br />
GRUB_CMDLINE_LINUX="cryptdevice=/dev/sda2:root"<br />
<br />
Also, disable the usage of UUIDs for the rootfs:<br />
<br />
GRUB_DISABLE_LINUX_UUID=true<br />
<br />
Regenerate the configuration.<br />
<br />
==== Boot non-default entry only once ====<br />
<br />
The command {{ic|grub-reboot}} is very helpful to boot another entry than the default only once. GRUB loads the entry passed in the first command line argument, when the system is rebooted the next time. Most importantly GRUB returns to loading the default entry for all future booting. Changing the configuration file or selecting an entry in the GRUB menu is not necessary.<br />
{{Note|This requires {{ic|1=GRUB_DEFAULT=saved}} in {{ic|/etc/default/grub}} (and then regenerating {{ic|grub.cfg}}) or, in case of hand-made {{ic|grub.cfg}}, the line {{ic|1=set default="${saved_entry}"}}.}}<br />
<br />
==== Hide GRUB unless the Shift key is held down ====<br />
<br />
In order to achieve the fastest possible boot, instead of having GRUB wait for a timeout, it's possible for GRUB to hide the menu, unless the {{keypress|Shift}} key is held down during GRUB's start-up.<br />
<br />
In order to achieve this, you should add the following line to {{ic|/etc/default/grub}}:<br />
<br />
GRUB_FORCE_HIDDEN_MENU="true"<br />
<br />
And the following file should be created:<br />
<br />
{{hc|/etc/grub.d/31_hold_shift|<br />
<nowiki><br />
#! /bin/sh<br />
set -e<br />
<br />
# grub-mkconfig helper script.<br />
# Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.<br />
#<br />
# GRUB is free software: you can redistribute it and/or modify<br />
# it under the terms of the GNU General Public License as published by<br />
# the Free Software Foundation, either version 3 of the License, or<br />
# (at your option) any later version.<br />
#<br />
# GRUB is distributed in the hope that it will be useful,<br />
# but WITHOUT ANY WARRANTY; without even the implied warranty of<br />
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br />
# GNU General Public License for more details.<br />
#<br />
# You should have received a copy of the GNU General Public License<br />
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.<br />
<br />
prefix="/usr"<br />
exec_prefix="${prefix}"<br />
datarootdir="${prefix}/share"<br />
<br />
export TEXTDOMAIN=grub<br />
export TEXTDOMAINDIR="${datarootdir}/locale"<br />
<br />
. "${datarootdir}/grub/grub-mkconfig_lib"<br />
<br />
found_other_os=<br />
<br />
make_timeout () {<br />
<br />
if [ "x${GRUB_FORCE_HIDDEN_MENU}" = "xtrue" ] ; then <br />
if [ "x${1}" != "x" ] ; then<br />
if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then<br />
verbose=<br />
else<br />
verbose=" --verbose"<br />
fi<br />
<br />
if [ "x${1}" = "x0" ] ; then<br />
cat <<EOF<br />
if [ "x\${timeout}" != "x-1" ]; then<br />
if keystatus; then<br />
if keystatus --shift; then<br />
set timeout=-1<br />
else<br />
set timeout=0<br />
fi<br />
else<br />
if sleep$verbose --interruptible 3 ; then<br />
set timeout=0<br />
fi<br />
fi<br />
fi<br />
EOF<br />
else<br />
cat << EOF<br />
if [ "x\${timeout}" != "x-1" ]; then<br />
if sleep$verbose --interruptible ${GRUB_HIDDEN_TIMEOUT} ; then<br />
set timeout=0<br />
fi<br />
fi<br />
EOF<br />
fi<br />
fi<br />
fi<br />
}<br />
<br />
adjust_timeout () {<br />
if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then<br />
cat <<EOF<br />
if cmostest $GRUB_BUTTON_CMOS_ADDRESS ; then<br />
EOF<br />
make_timeout "${GRUB_HIDDEN_TIMEOUT_BUTTON}" "${GRUB_TIMEOUT_BUTTON}"<br />
echo else<br />
make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}"<br />
echo fi<br />
else<br />
make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}"<br />
fi<br />
}<br />
<br />
adjust_timeout<br />
<br />
cat <<EOF<br />
if [ "x\${timeout}" != "x-1" ]; then<br />
if keystatus; then<br />
if keystatus --shift; then<br />
set timeout=-1<br />
else<br />
set timeout=0<br />
fi<br />
else<br />
if sleep$verbose --interruptible 3 ; then<br />
set timeout=0<br />
fi<br />
fi<br />
fi<br />
EOF<br />
</nowiki><br />
}}<br />
<br />
=== Booting an ISO directly from GRUB ===<br />
<br />
Edit {{ic|/etc/grub.d/40_custom}} or {{ic|/boot/grub/custom.cfg}} to add an entry for the target ISO. When finished, update the GRUB menu as with the usual {{ic|grub-mkconfig -o /boot/grub/grub.cfg}} (as root).<br />
<br />
==== Arch ISO ====<br />
<br />
{{Note|The following examples assume the ISO is in {{ic|/archives}} on {{ic|hd0,6}}.}}<br />
{{Tip|For thumbdrives, use something like {{ic|(hd1,$partition)}} and either {{ic|/dev/sdb'''Y'''}} for the {{ic|img_dev}} parameter or [[Persistent_block_device_naming|a persistent name]], e.g. {{ic|img_dev&#61;/dev/disk/by-label/CORSAIR}}.}}<br />
<br />
===== x86_64 =====<br />
<br />
menuentry "Archlinux-2013.05.01-dual.iso" --class iso {<br />
set isofile="/archives/archlinux-2013.05.01-dual.iso"<br />
set partition="6"<br />
loopback loop (hd0,$partition)/$isofile<br />
linux (loop)/arch/boot/x86_64/vmlinuz archisolabel=ARCH_201305 img_dev=/dev/sda$partition img_loop=$isofile earlymodules=loop<br />
initrd (loop)/arch/boot/x86_64/archiso.img<br />
}<br />
<br />
===== i686 =====<br />
<br />
menuentry "Archlinux-2013.05.01-dual.iso" --class iso {<br />
set isofile="/archives/archlinux-2013.05.01-dual.iso"<br />
set partition="6"<br />
loopback loop (hd0,$partition)/$isofile<br />
linux (loop)/arch/boot/i686/vmlinuz archisolabel=ARCH_201305 img_dev=/dev/sda$partition img_loop=$isofile earlymodules=loop<br />
initrd (loop)/arch/boot/i686/archiso.img<br />
}<br />
<br />
==== Ubuntu ISO ====<br />
<br />
{{Note|The example assumes that the iso is in {{ic|/archives}} on {{ic|hd0,6}}. Users must adjust the location and hdd/partition in the lines below to match their systems.}}<br />
<br />
menuentry "ubuntu-13.04-desktop-amd64.iso" {<br />
set isofile="/archives/ubuntu-13.04-desktop-amd64.iso"<br />
loopback loop (hd0,6)/$isofile<br />
linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofile quiet noeject noprompt splash --<br />
initrd (loop)/casper/initrd.lz<br />
}<br />
<br />
menuentry "ubuntu-12.04-desktop-amd64.iso" {<br />
set isofile="/archives/ubuntu-12.04-desktop-amd64.iso"<br />
loopback loop (hd0,6)/$isofile<br />
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile quiet noeject noprompt splash --<br />
initrd (loop)/casper/initrd.lz<br />
}<br />
<br />
==== Other ISOs ====<br />
<br />
Other working configurations from [http://askubuntu.com/questions/141940/how-to-boot-live-iso-images link Source].<br />
<br />
== Using the command shell ==<br />
<br />
Since the MBR is too small to store all GRUB modules, only the menu and a few basic commands reside there. The majority of GRUB functionality remains in modules in {{ic|/boot/grub}}, which are inserted as needed. In error conditions (e.g. if the partition layout changes) GRUB may fail to boot. When this happens, a command shell may appear.<br />
<br />
GRUB offers multiple shells/prompts. If there is a problem reading the menu but the bootloader is able to find the disk, you will likely be dropped to the "normal" shell:<br />
sh:grub><br />
<br />
If there is a more serious problem (e.g. GRUB cannot find required files), you may instead be dropped to the "rescue" shell:<br />
grub rescue><br />
<br />
The rescue shell is a restricted subset of the normal shell, offering much less functionality. If dumped to the rescue shell, first try inserting the "normal" module, then starting the "normal" shell:<br />
grub rescue> set prefix=(hdX,Y)/boot/grub<br />
grub rescue> insmod (hdX,Y)/boot/grub/i386-pc/normal.mod<br />
rescue:grub> normal<br />
<br />
=== Pager support ===<br />
<br />
GRUB supports pager for reading commands that provide long output (like the {{ic|help}} command). This works only in normal shell mode and not in rescue mode. To enable pager, in GRUB command shell type:<br />
sh:grub> set pager=1<br />
<br />
== GUI configuration tools ==<br />
<br />
Following package may be installed:<br />
* {{App|grub-customizer|Customize the bootloader (GRUB or BURG)|https://launchpad.net/grub-customizer|{{AUR|grub-customizer}}}}<br />
* {{App|grub2-editor|KDE4 control module for configuring the GRUB bootloader|http://kde-apps.org/content/show.php?content&#61;139643|{{AUR|grub2-editor}}}}<br />
* {{App|kcm-grub2|This Kcm module manages the most common settings of GRUB|http://kde-apps.org/content/show.php?content&#61;137886|{{AUR|kcm-grub2}}}}<br />
* {{App|startupmanager|GUI app for changing the settings of GRUB Legacy, GRUB, Usplash and Splashy|http://sourceforge.net/projects/startup-manager/|{{AUR|startupmanager}}}}<br />
<br />
== parttool for hide/unhide ==<br />
<br />
If you have a Windows 9x paradigm with hidden {{ic|C:\}} disks GRUB can hide/unhide it using {{ic|parttool}}. For example, to boot the third {{ic|C:\}} disk of three Windows 9x installations on the CLI enter the CLI and:<br />
parttool hd0,1 hidden+ boot-<br />
parttool hd0,2 hidden+ boot-<br />
parttool hd0,3 hidden- boot+<br />
set root=hd0,3<br />
chainloader +1<br />
boot<br />
<br />
== Using the rescue console ==<br />
<br />
See [[#Using the command shell]] first. If unable to activate the standard shell, one possible solution is to boot using a live CD or some other rescue disk to correct configuration errors and reinstall GRUB. However, such a boot disk is not always available (nor necessary); the rescue console is surprisingly robust.<br />
<br />
The available commands in GRUB rescue include {{ic|insmod}}, {{ic|ls}}, {{ic|set}}, and {{ic|unset}}. This example uses {{ic|set}} and {{ic|insmod}}. {{ic|set}} modifies variables and {{ic|insmod}} inserts new modules to add functionality.<br />
<br />
Before starting, the user must know the location of their {{ic|/boot}} partition (be it a separate partition, or a subdirectory under their root):<br />
grub rescue> set prefix=(hdX,Y)/boot/grub<br />
<br />
where X is the physical drive number and Y is the partition number.<br />
<br />
To expand console capabilities, insert the {{ic|linux}} module:<br />
grub rescue> insmod (hdX,Y)/boot/grub/linux.mod<br />
<br />
{{Note|With a separate boot partition, omit {{ic|/boot}} from the path, (i.e. type {{ic|1=set prefix=(hdX,Y)/grub}} and {{ic|insmod (hdX,Y)/grub/linux.mod}}).}}<br />
<br />
This introduces the {{ic|linux}} and {{ic|initrd}} commands, which should be familiar (see [[#Configuration]]).<br />
<br />
An example, booting Arch Linux:<br />
set root=(hd0,5)<br />
linux /boot/vmlinuz-linux root=/dev/sda5<br />
initrd /boot/initramfs-linux.img<br />
boot<br />
<br />
With a separate boot partition, again change the lines accordingly:<br />
set root=(hd0,5)<br />
linux /vmlinuz-linux root=/dev/sda6<br />
initrd /initramfs-linux.img<br />
boot<br />
<br />
After successfully booting the Arch Linux installation, users can correct {{ic|grub.cfg}} as needed and then reinstall GRUB.<br />
<br />
To reinstall GRUB and fix the problem completely, changing {{ic|/dev/sda}} if needed. See [[#Bootloader installation]] for details.<br />
<br />
== Combining the use of UUIDs and basic scripting ==<br />
<br />
If you like the idea of using UUIDs to avoid unreliable BIOS mappings or are struggling with GRUB's syntax, here is an example boot menu item that uses UUIDs and a small script to direct GRUB to the proper disk partitions for your system. All you need to do is replace the UUIDs in the sample with the correct UUIDs for your system. The example applies to a system with a boot and root partition. You will obviously need to modify the GRUB configuration if you have additional partitions:<br />
<br />
menuentry "Arch Linux 64" {<br />
# Set the UUIDs for your boot and root partition respectively<br />
set the_boot_uuid=ece0448f-bb08-486d-9864-ac3271bd8d07<br />
set the_root_uuid=c55da16f-e2af-4603-9e0b-03f5f565ec4a<br />
<br />
# (Note: This may be the same as your boot partition)<br />
<br />
# Get the boot/root devices and set them in the root and grub_boot variables<br />
search --fs-uuid $the_root_uuid --set=root<br />
search --fs-uuid $the_boot_uuid --set=grub_boot<br />
<br />
# Check to see if boot and root are equal.<br />
# If they are, then append /boot to $grub_boot (Since $grub_boot is actually the root partition)<br />
if [ $the_boot_uuid == $the_root_uuid ] ; then<br />
set grub_boot=($grub_boot)/boot<br />
else<br />
set grub_boot=($grub_boot)<br />
fi<br />
<br />
# $grub_boot now points to the correct location, so the following will properly find the kernel and initrd<br />
linux $grub_boot/vmlinuz-linux root=/dev/disk/by-uuid/$the_root_uuid ro<br />
initrd $grub_boot/initramfs-linux.img<br />
}<br />
<br />
== Troubleshooting ==<br />
<br />
=== Intel BIOS not booting GPT ===<br />
<br />
Some Intel BIOS's require at least one bootable MBR partition to be present at boot, causing GPT-partitioned boot setups to be unbootable.<br />
<br />
This can be circumvented by using (for instance) fdisk to mark one of the GPT partitions (preferably the 1007 KiB partition you've created for GRUB already) bootable in the MBR. This can be achieved, using fdisk, by the following commands: Start fdisk against the disk you're installing, for instance {{ic|fdisk /dev/sda}}, then press {{keypress|a}} and select the partition you wish to mark as bootable (probably #1) by pressing the corresponding number, finally press {{keypress|w}} to write the changes to the MBR.<br />
<br />
{{Note|The bootable-marking must be done in {{ic|fdisk}} or similar, not in GParted or others, as they will not set the bootable flag in the MBR.}}<br />
<br />
More information is available [http://www.rodsbooks.com/gdisk/bios.html here]<br />
<br />
=== Enable debug messages ===<br />
<br />
Add:<br />
<br />
set pager=1<br />
set debug=all<br />
<br />
to {{ic|grub.cfg}}.<br />
<br />
=== "No suitable mode found" error ===<br />
<br />
If you get this error when booting any menuentry:<br />
<br />
error: no suitable mode found<br />
Booting however<br />
<br />
Then you need to initialize GRUB graphical terminal ({{ic|gfxterm}}) with proper video mode ({{ic|gfxmode}}) in GRUB. This video mode is passed by GRUB to the linux kernel via 'gfxpayload'. In case of UEFI systems, if the GRUB video mode is not initialized, no kernel boot messages will be shown in the terminal (atleast until KMS kicks in).<br />
<br />
Copy {{ic|/usr/share/grub/unicode.pf2}} to ${GRUB_PREFIX_DIR} ({{ic|/boot/grub/}} in case of BIOS and UEFI systems). If GRUB UEFI was installed with {{ic|1=--boot-directory=/boot/efi/EFI}} set, then the directory is {{ic|/boot/efi/EFI/grub/}}:<br />
<br />
# cp /usr/share/grub/unicode.pf2 ${GRUB_PREFIX_DIR}<br />
<br />
If {{ic|/usr/share/grub/unicode.pf2}} does not exist, install {{Pkg|bdf-unifont}}, create the {{ic|unifont.pf2}} file and then copy it to {{ic|${GRUB_PREFIX_DIR<nowiki>}</nowiki>}}:<br />
<br />
# grub-mkfont -o unicode.pf2 /usr/share/fonts/misc/unifont.bdf<br />
<br />
Then, in the {{ic|grub.cfg}} file, add the following lines to enable GRUB to pass the video mode correctly to the kernel, without of which you will only get a black screen (no output) but booting (actually) proceeds successfully without any system hang.<br />
<br />
BIOS systems:<br />
<br />
insmod vbe<br />
<br />
UEFI systems:<br />
<br />
insmod efi_gop<br />
insmod efi_uga<br />
<br />
After that add the following code (common to both BIOS and UEFI):<br />
<br />
insmod font<br />
<br />
if loadfont ${prefix}/fonts/unicode.pf2<br />
then<br />
insmod gfxterm<br />
set gfxmode=auto<br />
set gfxpayload=keep<br />
terminal_output gfxterm<br />
fi<br />
<br />
As you can see for gfxterm (graphical terminal) to function properly, {{ic|unicode.pf2}} font file should exist in {{ic|${GRUB_PREFIX_DIR<nowiki>}</nowiki>}}.<br />
<br />
=== msdos-style error message ===<br />
<br />
grub-setup: warn: This msdos-style partition label has no post-MBR gap; embedding won't be possible!<br />
grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists.<br />
However, blocklists are UNRELIABLE and its use is discouraged.<br />
grub-setup: error: If you really want blocklists, use --force.<br />
<br />
This error may occur when you try installing GRUB in a VMware container. Read more about it [https://bbs.archlinux.org/viewtopic.php?pid=581760#p581760 here]. It happens when the first partition starts just after the MBR (block 63), without the usual space of 1 MiB (2048 blocks) before the first partition. Read [[#Master Boot Record (MBR) specific instructions]]<br />
<br />
=== GRUB UEFI drops to shell ===<br />
<br />
If GRUB loads but drops you into the rescue shell with no errors, it may be because of a missing or misplaced {{ic|grub.cfg}}. This will happen if GRUB UEFI was installed with {{ic|--boot-directory}} and {{ic|grub.cfg}} is missing OR if the partition number of the boot partition changed (which is hard-coded into the {{ic|grubx64.efi}} file).<br />
<br />
=== GRUB UEFI not loaded ===<br />
<br />
An example of a working EFI:<br />
{{hc|# efibootmgr -v|<br />
BootCurrent: 0000<br />
Timeout: 3 seconds<br />
BootOrder: 0000,0001,0002<br />
Boot0000* Grub HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\efi\grub\grub.efi)<br />
Boot0001* Shell HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\EfiShell.efi)<br />
Boot0002* Festplatte BIOS(2,0,00)P0: SAMSUNG HD204UI<br />
}}<br />
<br />
If the screen only goes black for a second and the next boot option is tried afterwards, according to [https://bbs.archlinux.org/viewtopic.php?pid=981560#p981560 this post], moving GRUB to the partition root can help. The boot option has to be deleted and recreated afterwards. The entry for GRUB should look like this then:<br />
Boot0000* Grub HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\grub.efi)<br />
<br />
=== Invalid signature ===<br />
<br />
If trying to boot Windows results in an "invalid signature" error, e.g. after reconfiguring partitions or adding additional hard drives, (re)move GRUB's device configuration and let it reconfigure:<br />
# mv /boot/grub/device.map /boot/grub/device.map-old<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
{{ic|grub-mkconfig}} should now mention all found boot options, including Windows. If it works, remove {{ic|/boot/grub/device.map-old}}.<br />
<br />
=== Boot freezes ===<br />
<br />
If booting gets stuck without any error message after GRUB loading the kernel and the initial ramdisk, try removing the {{ic|add_efi_memmap}} kernel parameter.<br />
<br />
=== Restore GRUB Legacy ===<br />
<br />
* Move GRUB v2 files out of the way:<br />
<br />
# mv /boot/grub /boot/grub.nonfunctional<br />
<br />
* Copy GRUB Legacy back to {{ic|/boot}}:<br />
<br />
# cp -af /boot/grub-legacy /boot/grub<br />
<br />
* Replace MBR and next 62 sectors of sda with backed up copy<br />
<br />
{{Warning|This command also restores the partition table, so be careful of overwriting a modified partition table with the old one. It '''will''' mess up your system.}}<br />
<br />
# dd if=/path/to/backup/first-sectors of=/dev/sdX bs=512 count=1<br />
<br />
A safer way is to restore only the MBR boot code use:<br />
<br />
# dd if=/path/to/backup/mbr-boot-code of=/dev/sdX bs=446 count=1<br />
<br />
=== Arch not found from other OS ===<br />
Some have reported that other distributions have trouble finding Arch Linux automatically with {{ic|os-prober}}. If this problem arises, it has been reported that detection can be improved with the presence of {{ic|/etc/lsb-release}}. This file and updating tool is available with the package {{pkg|lsb-release}} in the [[Official Repositories|official repositories]].<br />
<br />
== References ==<br />
<br />
# Official GRUB Manual - https://www.gnu.org/software/grub/manual/grub.html<br />
# Ubuntu wiki page for GRUB - https://help.ubuntu.com/community/Grub2<br />
# GRUB wiki page describing steps to compile for UEFI systems - https://help.ubuntu.com/community/UEFIBooting<br />
# Wikipedia's page on [[Wikipedia:BIOS Boot partition|BIOS Boot partition]]<br />
<br />
== See also ==<br />
<br />
# [https://github.com/the-ridikulus-rat/My_Shell_Scripts/blob/master/grub/grub_bios.sh A Linux Bash Shell script to compile and install GRUB for BIOS from BZR Source]<br />
# [https://github.com/the-ridikulus-rat/My_Shell_Scripts/blob/master/grub/grub_uefi.sh A Linux Bash Shell script to compile and install GRUB for UEFI from BZR Source]</div>Apouloshttps://wiki.archlinux.org/index.php?title=Avahi&diff=262771Avahi2013-06-14T19:35:14Z<p>Apoulos: </p>
<hr />
<div>[[Category:Networking]]<br />
[[fr:Avahi]]<br />
[http://avahi.org/ Avahi] is a free [[Wikipedia:Zero Configuration Networking|Zero Configuration Networking]] (Zeroconf) implementation, including a system for multicast DNS/DNS-SD service discovery. It allows programs to publish and discover services and hosts running on a local network with no specific configuration. For example you can plug into a network and instantly find printers to print to, files to look at and people to talk to. It is licensed under the GNU Lesser General Public License (LGPL). (Source: [[Wikipedia:Avahi (software)]])<br />
<br />
== Installation ==<br />
[[pacman|Install]] {{Pkg|avahi}} and {{Pkg|nss-mdns}}, available in the [[official repositories]]. <br />
<br />
{{bc|# pacman -S avahi nss-mdns}}<br />
<br />
{{Note|After installing Avahi you will need to restart the {{ic|dbus}} [[daemon]] before you can start {{ic|avahi-daemon}}.}}<br />
<br />
=== Enable Avahi daemon under sysvinit system ===<br />
<br />
<br />
{{Note|{{ic|avahi-daemon}} depends on {{ic|dbus}} [[daemon]], so it should be added after {{ic|dbus}} in the {{ic|DAEMONS}} array in [[rc.conf]] file}}<br />
<br />
=== Enable Avahi daemon under native systemd system === <br />
You can enable Avahi Daemon at startup with the following command:<br />
<br />
{{bc|# systemctl enable avahi-daemon.service}}<br />
<br />
== Using Avahi ==<br />
=== Obtaining IPv4LL IP address ===<br />
By default, if you are getting IP using DHCP, you are using {{Ic|dhcpcd}} package. It can attempt to obtain an IPv4LL address if it failed to get one via DHCP. By default this option is disabled. To enable it, comment noipv4ll string:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
...<br />
#noipv4ll<br />
...}}<br />
<br />
Alternatively, run {{Ic|avahi-autoipd}}, included in {{Ic|avahi}} package:<br />
{{bc|# avahi-autoipd -D}}<br />
<br />
=== Hostname resolution ===<br />
Avahi also allows you to access computers using their hostnames. '''Note:''' you must install {{Ic|nss-mdns}} for this to work, and have the {{Ic|avahi-daemon.service}} enabled and running.<br />
<br />
Suppose you have machines with names maple, fig and oak, all running avahi. Avahi can be set up so that you do not have to manage a {{Ic|/etc/hosts}} file for each computer. Instead you can simply use {{Ic|maple.local}} to access whatever services {{Ic|maple}} has. However by default, .local querying is disabled in Arch Linux. To enable it edit the file {{Ic|/etc/nsswitch.conf}} and change the line:<br />
hosts: files myhostname dns<br />
to:<br />
hosts: files myhostname mdns_minimal [NOTFOUND=return] dns<br />
<br />
The {{Ic|mdns_minimal}} module handles queries for the .local TLD only. In case you have configured Avahi to use a different TLD, you'll also need to add the full {{Ic|mdns}} module at the end. There also are IPv4-only and IPv6-only modules {{Ic|mdns[46](_minimal)}}.<br />
<br />
Avahi includes several utilities which help you discover the services running on a network. For example, run<br />
avahi-browse -alr<br />
to discover services in your network.<br />
<br />
The {{Ic|avahi-discover}} (Avahi Zeroconf Browser) shows the various services on your network. You can also browse SSH and VNC Servers using {{Ic|bssh}} and {{Ic|bvnc}} respectively.<br />
<br />
There's a good list of software with Avahi support at their website: http://avahi.org/wiki/Avah4users<br />
{{Note|{{Ic|avahi-discover}} needs pygtk and python-dbus to be installed.}}<br />
<br />
===File sharing===<br />
<br />
====NFS====<br />
If you have an [[NFS]] share set up, you can use Avahi to be able to automount them in Zeroconf-enabled browsers (such as Konqueror on KDE and Finder on Mac OS X). Create a .service file in /etc/avahi/services with the following:<br />
{{hc|/etc/avahi/services/nfs_Zephyrus_Music.service|<nowiki><br />
<?xml version="1.0" standalone='no'?><br />
<!DOCTYPE service-group SYSTEM "avahi-service.dtd"><br />
<service-group><br />
<name replace-wildcards="yes">NFS Music Share on %h</name><br />
<service><br />
<type>_nfs._tcp</type><br />
<port>2049</port><br />
<txt-record>path=/data/shared/Music</txt-record><br />
</service><br />
</service-group></nowiki>}}<br />
<br />
The port is correct if you have ''insecure'' as an option in your /etc/exports; otherwise, it needs to be changed (note that ''insecure'' is needed for OS X clients). The path is the path to your export, or a subdirectory of it. For some reason the automount functionality has been removed from Leopard, however [http://www.macosxhints.com/article.php?story=20071116042238744 a script is available]. This was based upon [http://ubuntuforums.org/showthread.php?p=4387032#post4387032 this post].<br />
<br />
====Samba====<br />
<br />
{{Note|{{Pkg|samba}} package from extra repository build without an avahi suuport.}}<br />
{{hc|/etc/avahi/services/smb.service|<nowiki><br />
<?xml version="1.0" standalone='no'?><br />
<!DOCTYPE service-group SYSTEM "avahi-service.dtd"><br />
<service-group><br />
<name replace-wildcards="yes">Samba Shares on %h</name><br />
<service><br />
<type>_smb._tcp</type><br />
<port>139</port><br />
</service><br />
</service-group></nowiki>}}<br />
{{Note|If you are trying to connect with OS X Lion the port needs to be 445, not 139.}}<br />
<br />
====GShare====<br />
You can grab {{aur|gshare}} from the [[Arch User Repository]] and have shared files between the LAN, with no configuration, no hours in samba hacking, no nothing - it just works.<br />
<br />
====Vsftpd====<br />
Sourced from [http://ubuntuforums.org/showthread.php?t=218630 ubuntuforums.org].<br />
If you would rather use a regular ftp service, install vsftpd and avahi. Change the settings of vsftpd according to what is shown on the ubuntuforums page or according to your own personal preferences (See 'man vsftpd.conf).<br />
<br />
Create a ftp.service file in /etc/avahi/services and paste in that file<br />
<?xml version="1.0" standalone='no'?><br />
<!DOCTYPE service-group SYSTEM "avahi-service.dtd"><br />
<service-group><br />
<name>FTP file sharing</name><br />
<service><br />
<type>_ftp._tcp</type><br />
<port>21</port><br />
</service><br />
</service-group><br />
When you are done, (re)start avahi-daemon and vsftpd in your /etc/rc.d directory.<br />
/etc/rc.d/avahi-daemon restart<br />
/etc/rc.d/vsftpd restart<br />
<br />
After that you should be able to browse through the ftp server from another computer in your network. The steps shown in this section are created so that the ftp server is 'advertised' by avahi to the local Zeroconf network.<br />
<br />
Unless you are using GNOME or KDE, you might not be able to log in to the ftp server directly through your file manager, and so you will have to use a ftp client pointed to the IP address of the server or the hostname of the machine (as shown in [[Avahi#Hostname_resolution|this section]]).<br />
<br />
====Giver====<br />
[http://code.google.com/p/giver/ Giver] is a mono program that allows simple file-sharing between two desktops when both are running Giver. All you need to do is click and drag the file to the name or picture of the person you wish to send the file to.<br />
<br />
A package is on the [https://aur.archlinux.org/packages.php?ID=17139 AUR].<br />
<br />
Note that this depends on gnome-sharp, which has heavy GNOME dependencies.<br />
<br />
===Link-Local (Bonjour/Zeroconf) chat===<br />
<br />
Avahi can be used for bonjour protocol support under linux. The following chat clients support link-local chat.<br />
<br />
====Gajim====<br />
[http://www.gajim.org Gajim] is a Jabber/XMPP instant messenger client written in PyGTK. In the accounts setup just enable "Local" account.<br />
<br />
====Pidgin====<br />
[http://www.pidgin.im Pidgin] is an instant messaging client that supports quite a few commonly used IM protocols. In addition to these, it supports Bonjour.<br />
<br />
Just select 'Bonjour' as the protocol type when you add an account, and enter a username. The first and last name you enter in the 'Advanced' tab will be what the other person (whom you are chatting with) sees, and 'local alias' under 'User Options' in the 'Basic' tab will be what you see of your own name (you could try putting in something like I, me or myself).<br />
<br />
Once this is done, other Pidgin (iChat) users who are on the local network will see you and be able to chat with you. To implement file-sharing, you just send and receive files like you would do with a regular IM session.<br />
<br />
====Kopete====<br />
[http://kopete.kde.org/ Kopete] is the KDE equivalent of Pidgin. It supports the Bonjour/Link-local XMPP protocol. One need to create an account in Kopete, by simply entering the desired name.<br />
<br />
====Telepathy====<br />
[http://telepathy.freedesktop.org Telpathy] is a communication framework which supports different protocols using plugins. The {{Pkg|telepathy-salut}} plugin provides support for Bonjour/Link-Local XMPP protocol. Empathy is a GNOME front-end to Telepathy. Officially, KDE does not support Telepathy, but work is going on which will eventually replace Kopete. KDE Telepathy is available in extra.<br />
<br />
===Airprint from Mobile Devices===<br />
Avahi along with CUPS also provides the capability to print to just about any printer from airprint compatible mobile devices. In order to enable print capability from your device, simply create an avahi service file for your printer in /etc/avahi/services and restart avahi. An example of a generic services file for an HP-Laserjet printer would be similar to the following with the name, rp, ty, adminurl and note fields changed. Save the file as /etc/avahi/services/youFileName.service:<br />
<?xml version="1.0" standalone='no'?><!--*-nxml-*--><br />
<!DOCTYPE service-group SYSTEM "avahi-service.dtd"><br />
<service-group><br />
<name>yourPrnterName</name><br />
<service><br />
<type>_ipp._tcp</type><br />
<subtype>_universal._sub._ipp._tcp</subtype><br />
<port>631</port><br />
<txt-record>txtver=1</txt-record><br />
<txt-record>qtotal=1</txt-record><br />
<txt-record>rp=printers/yourPrnterName</txt-record><br />
<txt-record>ty=yourPrnterName</txt-record><br />
<txt-record>adminurl=http://198.168.7.15:631/printers/yourPrnterName</txt-record><br />
<txt-record>note=Office Laserjet 4100n</txt-record><br />
<txt-record>priority=0</txt-record><br />
<txt-record>product=virtual Printer</txt-record><br />
<txt-record>printer-state=3</txt-record><br />
<txt-record>printer-type=0x801046</txt-record><br />
<txt-record>Transparent=T</txt-record><br />
<txt-record>Binary=T</txt-record><br />
<txt-record>Fax=F</txt-record><br />
<txt-record>Color=T</txt-record><br />
<txt-record>Duplex=T</txt-record><br />
<txt-record>Staple=F</txt-record><br />
<txt-record>Copies=T</txt-record><br />
<txt-record>Collate=F</txt-record><br />
<txt-record>Punch=F</txt-record><br />
<txt-record>Bind=F</txt-record><br />
<txt-record>Sort=F</txt-record><br />
<txt-record>Scan=F</txt-record><br />
<txt-record>pdl=application/octet-stream,application/pdf,application/postscript,image/jpeg,image/png,image/urf</txt-record><br />
<txt-record>URF=W8,SRGB24,CP1,RS600</txt-record><br />
</service><br />
</service-group><br />
<br />
Alternatively, https://raw.github.com/tjfontaine/airprint-generate/master/airprint-generate.py can be used to generate Avahi service files. It depends on python2 and pycups. The script can be run using: {{bc|# python2 airprint-generate.py -d /etc/avahi/services}}<br />
<br />
=== Firewall ===<br />
<br />
Be sure to open UDP port 5353 if you're using iptables:<br />
# iptables -A INPUT -p udp -m udp --dport 5353 -j ACCEPT<br />
<br />
If you're following the more-than-useful [[Simple Stateful Firewall]] format for your firewall:<br />
# iptables -A UDP -p udp -m udp --dport 5353 -j ACCEPT<br />
<br />
==See also==<br />
* [http://avahi.org/ Avahi] - Official project website<br />
* [http://en.wikipedia.org/wiki/Avahi_%28software%29 Wikipedia entry]<br />
* [http://www.apple.com/support/downloads/bonjourforwindows.html Bonjour for Windows] - Enable Zeroconf on Windows<br />
* http://www.zeroconf.org/</div>Apouloshttps://wiki.archlinux.org/index.php?title=GRUB&diff=262562GRUB2013-06-12T17:49:33Z<p>Apoulos: /* Install to 440-byte MBR boot code region */</p>
<hr />
<div>[[Category:Boot loaders]]<br />
[[ar:GRUB]]<br />
[[cs:GRUB2]]<br />
[[de:GRUB]]<br />
[[es:GRUB2]]<br />
[[fr:GRUB2]]<br />
[[id:GRUB2]]<br />
[[it:GRUB2]]<br />
[[ru:GRUB2]]<br />
[[tr:GRUB2]]<br />
[[zh-CN:GRUB2]]<br />
[[zh-TW:GRUB2]]<br />
{{Article summary start}}<br />
{{Article summary text|Covers various aspects of version 2 of the GRand Unified Bootloader (GRUB).}}<br />
{{Article summary heading|Overview}}<br />
{{Article summary text|{{Boot process overview}}}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|BURG}} - BURG is a brand-new boot loader based on GRUB v2. It can be built on a wider range of OS, and has a highly configurable menu system which works in both text and graphic mode. <br />
{{Article summary wiki|GRUB Legacy}} - previous Version, now obsolete.<br />
{{Article summary heading|Resources}}<br />
{{Article summary wiki|GRUB EFI Examples}}<br />
{{Article summary link|GNU GRUB - GNU Project|https://www.gnu.org/software/grub/}}<br />
{{Article summary end}}<br />
<br />
[https://www.gnu.org/software/grub/ GRUB] - not to be confused with [[GRUB Legacy]] - is the next generation of the GRand Unified Bootloader. GRUB is derived from [http://www.nongnu.org/pupa/ PUPA] which was a research project to develop the next generation of what is now GRUB Legacy. GRUB has been rewritten from scratch to clean up everything and provide modularity and portability [https://www.gnu.org/software/grub/grub-faq.html#q1].<br />
<br />
In brief, the ''bootloader'' is the first software program that runs when a computer starts. It is responsible for loading and transferring control to the Linux kernel. The kernel, in turn, initializes the rest of the operating system.<br />
<br />
== Preface ==<br />
<br />
* The name ''GRUB'' officially refers to version ''2'' of the software, see [https://www.gnu.org/software/grub/]. If you are looking for the article on the legacy version, see [[GRUB Legacy]].<br />
* GRUB supports [[Btrfs]] as root (without a separate {{ic|/boot}} filesystem) compressed with either zlib or LZO<br />
<br />
=== Notes for current GRUB Legacy users ===<br />
<br />
* Upgrading from [[GRUB Legacy]] to GRUB is much the same as freshly installing GRUB, which is covered [[#Installation|below]]<br />
* There are differences in the commands of GRUB Legacy and GRUB. Familiarize yourself with [https://www.gnu.org/software/grub/manual/grub.html#Commands GRUB commands] before proceeding (e.g. "find" has been replaced with "search")<br />
* GRUB is now ''modular'' and no longer requires "stage 1.5". As a result, the bootloader itself is limited -- modules are loaded from the hard drive as needed to expand functionality (e.g. for [[LVM]] or RAID support)<br />
* Device naming has changed between GRUB Legacy and GRUB. Partitions are numbered from 1 instead of 0 while drives are still numbered from 0, and prefixed with partition-table type. For example, {{ic|/dev/sda1}} would be referred to as {{ic|(hd0,msdos1)}} (for MBR) or {{ic|(hd0,gpt1)}} (for GPT)<br />
<br />
==== Backup important data ====<br />
<br />
Although a GRUB installation should run smoothly, it is strongly recommended to keep the GRUB Legacy files before upgrading to GRUB v2.<br />
<br />
# mv /boot/grub /boot/grub-legacy<br />
<br />
Backup the MBR which contains the boot code and partition table (Replace {{ic|/dev/sd'''X'''}} with your actual disk path):<br />
<br />
# dd if=/dev/sdX of=/path/to/backup/mbr_backup bs=512 count=1<br />
<br />
Only 446 bytes of the MBR contain boot code, the next 64 contain the partition table. If you do not want to overwrite your partition table when restoring, it is strongly advised to backup only the MBR boot code:<br />
<br />
# dd if=/dev/sdX of=/path/to/backup/bootcode_backup bs=446 count=1<br />
<br />
If unable to install GRUB2 correctly, see [[#Restore GRUB Legacy]].<br />
<br />
=== Preliminary requirements ===<br />
<br />
==== BIOS systems ====<br />
<br />
===== GUID Partition Table (GPT) specific instructions =====<br />
<br />
GRUB in [[GPT|BIOS-GPT]] configuration requires a [http://www.gnu.org/software/grub/manual/html_node/BIOS-installation.html BIOS boot partition] to embed its {{ic|core.img}} in the absence of post-MBR gap in GPT partitioned systems (which is taken over by the GPT Primary Header and Primary Partition table). This partition is used by GRUB only in BIOS-GPT setups. No such partition type exists in case of MBR partitioning (at least not for GRUB). This partition is also not required if the system is UEFI based, as no embedding of bootsectors takes place in that case.<br />
<br />
For a BIOS-GPT configuration, create a 1007 KiB partition at the beginning of the disk using gdisk, cgdisk or GNU Parted with no filesystem. The size of 1007 KiB will allow for the following partition to be correctly alligned at 1024 KiB. If needed, the partition can also be located somewhere else on the disk, but it should be within the first 2 TiB region. Set the partition type to {{ic|ef02}} in (c)gdisk or {{ic|set <BOOT_PART_NUM> bios_grub on}} in GNU Parted.<br />
<br />
{{Note|<br />
* This partition should be created before {{ic|grub-install}} or {{ic|grub-setup}} is run<br />
* gdisk will only allow you to create this partition on the position which will waste the least amount of space (sector 34-2047) if you create it last, after all the other partitions. This is because gdisk will auto-align partitions to 2048-sector boundaries if possible<br />
}}<br />
<br />
===== Master Boot Record (MBR) specific instructions =====<br />
<br />
Usually the post-[[MBR]] gap (after the 512 byte MBR region and before the start of the 1st partition) in many MBR (or msdos disklabel) partitioned systems is 31 KiB when DOS compatibility cylinder alignment issues are satisfied in the partition table. However a post-MBR gap of about 1 to 2 MiB is recommended to provide sufficient room for embedding GRUB's {{ic|core.img}} ({{bug|24103}}). It is advisable to use a partitioner which supports 1 MiB partition alignment to obtain this space as well as satisfy other non-512 byte sector issues (which are unrelated to embedding of {{ic|core.img}}).<br />
<br />
==== UEFI systems ====<br />
<br />
{{Note|It is recommended to read and understand the [[Unified Extensible Firmware Interface|UEFI]], [[GUID Partition Table|GPT]] and [[UEFI Bootloaders]] pages.}}<br />
<br />
===== Create and Mount the UEFI System Partition =====<br />
<br />
Follow [[Unified Extensible Firmware Interface#EFI System Partition]] for instructions on creating a UEFI System Partition. Then mount the UEFI System Partition at {{ic|/boot/efi}}. If you have mounted the UEFI System Partition at some other mountpoint, replace {{ic|/boot/efi}} in the below instructions with that mountpoint:<br />
<br />
# mkdir -p /boot/efi<br />
# mount -t vfat <UEFI_SYSTEM_PARTITION> /boot/efi<br />
<br />
Create a {{ic|/boot/efi/EFI}} directory:<br />
<br />
# mkdir /boot/efi/EFI<br />
<br />
== Installation ==<br />
<br />
=== BIOS systems ===<br />
<br />
GRUB can be [[pacman|installed]] with the {{Pkg|grub-bios}} package from the [[official repositories]]. It will replace {{Pkg|grub-legacy}} or {{Pkg|grub}}, if it is installed.<br />
<br />
{{Note|Simply installing the package won't update the {{ic|/boot/grub/i386-pc/core.img}} file and the GRUB modules in {{ic|/boot/grub/i386-pc}}. You need to update them manually using {{ic|grub-install}} as explained below.}}<br />
<br />
==== Install boot files ====<br />
<br />
There are 3 ways to install GRUB boot files in BIOS booting:<br />
* [[#Install to GPT BIOS boot partition]] (recommended with [[GPT]])<br />
* [[#Install to 440-byte MBR boot code region]] (recommended with [[MBR]])<br />
* [[#Install to partition or partitionless disk]] (not recommended)<br />
* [[#Generate core.img alone]] (safest method, but requires another BIOS bootloader like [[GRUB Legacy]] or [[Syslinux]] to be installed to chainload {{ic|/boot/grub/i386-pc/core.img}})<br />
<br />
{{Note|See http://www.gnu.org/software/grub/manual/html_node/BIOS-installation.html for additional documentation.}}<br />
<br />
===== Install to GPT BIOS boot partition =====<br />
<br />
[[GUID Partition Table]] disks do not have a reserved "boot track". Therefore you must create a BIOS Boot Partition ({{ic|ef02}}) to hold the GRUB core image.<br />
<br />
Using GNU Parted, you can set this using a command such as the following:<br />
<br />
# parted /dev/disk set <partition-number> bios_grub on<br />
<br />
If you are using gdisk, set the partition type to {{ic|ef02}}. With partitioning programs that require setting the GUID directly, it should be {{ic|‘21686148-6449-6e6f-744e656564454649’}} (or, {{ic|[[wikipedia:BIOS_Boot_partition|Hah!IdontNeedEFI]]}}).<br />
<br />
{{Warning|Be very careful which partition you select when marking it as a BIOS Boot Partition. When GRUB finds a BIOS Boot Partition during installation, it will automatically overwrite part of it. Make sure that the partition does not contain any other data.}}<br />
<br />
To setup {{ic|grub-bios}} on a GPT disk, populate the {{ic|/boot/grub}} directory, generate the {{ic|/boot/grub/i386-pc/core.img}} file, and embed it in the BIOS Boot Partition, run:<br />
<br />
# modprobe dm-mod<br />
# grub-install --target=i386-pc --recheck --debug /dev/sda<br />
# mkdir -p /boot/grub/locale<br />
# cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo<br />
<br />
where {{ic|/dev/sda}} is the destination of the installation.<br />
<br />
Continue with [[GRUB#Generate config file]] below.<br />
<br />
===== Install to 440-byte MBR boot code region =====<br />
<br />
To setup {{ic|grub-bios}} in the 440-byte Master Boot Record boot code region, populate the {{ic|/boot/grub}} directory, generate the {{ic|/boot/grub/i386-pc/core.img}} file, embed it in the 31 KiB (minimum size - varies depending on partition alignment) post-MBR gap, and generate the configuration file, run:<br />
<br />
# modprobe dm-mod<br />
# grub-install --recheck /dev/sdX<br />
<br />
where {{ic|/dev/sdX}} is the destination of the installation (in this case the MBR of the first SATA disk). If you use [[LVM]] for your {{ic|/boot}}, you can install GRUB on multiple physical disks.<br />
<br />
{{Warning|Make sure to check the {{ic|/boot}} directory if you use the latter. Sometimes the {{ic|boot-directory}} parameter creates another {{ic|/boot}} folder inside of {{ic|/boot}}. A wrong install would look like: {{ic|/boot/boot/grub/}}.}}<br />
<br />
Continue with [[GRUB#Generate config file]] below.<br />
<br />
===== Install to partition or partitionless disk =====<br />
<br />
{{Note|grub-bios does not encourage installation to a partition boot sector or a partitionless disk like GRUB Legacy or Syslinux does. This kind of setup is prone to breakage, especially during updates, and is not supported by Arch devs.}}<br />
<br />
To set up grub-bios to a partition boot sector, to a partitionless disk (also called superfloppy) or to a floppy disk, run (using for example {{ic|/dev/sdaX}} as the {{ic|/boot}} partition):<br />
<br />
# modprobe dm-mod <br />
# grub-install --target=i386-pc --recheck --debug --force /dev/sdaX<br />
# chattr -i /boot/grub/i386-pc/core.img<br />
# mkdir -p /boot/grub/locale<br />
# cp /usr/share/locale/en@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo<br />
# chattr +i /boot/grub/i386-pc/core.img<br />
<br />
You need to use the {{ic|--force}} option to allow usage of blocklists and should not use {{ic|1=--grub-setup=/bin/true}} (which is similar to simply generating {{ic|core.img}}).<br />
<br />
{{ic|grub-install}} will give out warnings like which should give you the idea of what might go wrong with this approach:<br />
<br />
/sbin/grub-setup: warn: Attempting to install GRUB to a partitionless disk or to a partition. This is a BAD idea.<br />
/sbin/grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. <br />
However, blocklists are UNRELIABLE and their use is discouraged.<br />
<br />
Without {{ic|--force}} you may get the below error and {{ic|grub-setup}} will not setup its boot code in the partition boot sector:<br />
<br />
/sbin/grub-setup: error: will not proceed with blocklists<br />
<br />
With {{ic|--force}} you should get:<br />
<br />
Installation finished. No error reported.<br />
<br />
The reason why {{ic|grub-setup}} does not by default allow this is because in case of partition or a partitionless disk is that {{ic|grub-bios}} relies on embedded blocklists in the partition bootsector to locate the {{ic|/boot/grub/i386-pc/core.img}} file and the prefix dir {{ic|/boot/grub}}. The sector locations of {{ic|core.img}} may change whenever the filesystem in the partition is being altered (files copied, deleted etc.). For more info see https://bugzilla.redhat.com/show_bug.cgi?id=728742 and https://bugzilla.redhat.com/show_bug.cgi?id=730915.<br />
<br />
The workaround for this is to set the immutable flag on {{ic|/boot/grub/i386-pc/core.img}} (using chattr command as mentioned above) so that the sector locations of the {{ic|core.img}} file in the disk is not altered. The immutable flag on {{ic|/boot/grub/i386-pc/core.img}} needs to be set only if {{ic|grub-bios}} is installed to a partition boot sector or a partitionless disk, not in case of installation to MBR or simple generation of {{ic|core.img}} without embedding any bootsector (mentioned above).<br />
<br />
===== Generate core.img alone =====<br />
<br />
To populate the {{ic|/boot/grub}} directory and generate a {{ic|/boot/grub/i386-pc/core.img}} file '''without''' embedding any {{ic|grub-bios}} bootsector code in the MBR, post-MBR region, or the partition bootsector, add {{ic|1=--grub-setup=/bin/true}} to {{ic|grub-install}}:<br />
<br />
# modprobe dm-mod<br />
# grub-install --target=i386-pc --grub-setup=/bin/true --recheck --debug /dev/sda<br />
# mkdir -p /boot/grub/locale<br />
# cp /usr/share/locale/en@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo<br />
<br />
You can then chainload GRUB's {{ic|core.img}} from GRUB Legacy or syslinux as a Linux kernel or a multiboot kernel.<br />
<br />
==== Generate config file ====<br />
<br />
Finally, generate a configuration for GRUB (this is explained in greater detail in the Configuration section):<br />
<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
{{Note|The file path is {{ic|/boot/grub/grub.cfg}}, NOT {{ic|/boot/grub/i386-pc/grub.cfg}}.}}<br />
<br />
If GRUB complains about "no suitable mode found" while booting, go to [[#"No suitable mode found" error]].<br />
<br />
If {{ic|grub-mkconfig}} fails, convert your {{ic|/boot/grub/menu.lst}} file to {{ic|/boot/grub/grub.cfg}} using:<br />
<br />
# grub-menulst2cfg /boot/grub/menu.lst /boot/grub/grub.cfg<br />
<br />
For example:<br />
<br />
{{hc|/boot/grub/menu.lst|<nowiki><br />
default=0<br />
timeout=5<br />
<br />
title Arch Linux Stock Kernel<br />
root (hd0,0)<br />
kernel /vmlinuz-linux root=/dev/sda2 ro<br />
initrd /initramfs-linux.img<br />
<br />
title Arch Linux Stock Kernel Fallback<br />
root (hd0,0)<br />
kernel /vmlinuz-linux root=/dev/sda2 ro<br />
initrd /initramfs-linux-fallback.img<br />
</nowiki>}}<br />
<br />
{{hc|/boot/grub/grub.cfg|<nowiki><br />
set default='0'; if [ x"$default" = xsaved ]; then load_env; set default="$saved_entry"; fi<br />
set timeout=5<br />
<br />
menuentry 'Arch Linux Stock Kernel' {<br />
set root='(hd0,1)'; set legacy_hdbias='0'<br />
legacy_kernel '/vmlinuz-linux' '/vmlinuz-linux' 'root=/dev/sda2' 'ro'<br />
legacy_initrd '/initramfs-linux.img' '/initramfs-linux.img'<br />
<br />
}<br />
<br />
menuentry 'Arch Linux Stock Kernel Fallback' {<br />
set root='(hd0,1)'; set legacy_hdbias='0'<br />
legacy_kernel '/vmlinuz-linux' '/vmlinuz-linux' 'root=/dev/sda2' 'ro'<br />
legacy_initrd '/initramfs-linux-fallback.img' '/initramfs-linux-fallback.img'<br />
}<br />
</nowiki>}}<br />
<br />
If you forgot to create a GRUB {{ic|/boot/grub/grub.cfg}} config file and simply rebooted into GRUB Command Shell, type:<br />
<br />
sh:grub> insmod legacycfg<br />
sh:grub> legacy_configfile ${prefix}/menu.lst<br />
<br />
Boot into Arch and re-create the proper GRUB {{ic|/boot/grub/grub.cfg}} config file.<br />
<br />
{{Note|This option works only in BIOS systems, not in UEFI systems.}}<br />
<br />
==== Multiboot ====<br />
This should work out of the box, but an extra utility needs to be installed: os-prober. Install it, then rerun grub-mkconfig -o /boot/grub/grub.cfg. If this fails, you can try manually adding an entry by following the instructions below.<br />
<br />
===== Microsoft Windows installed in BIOS-MBR mode =====<br />
<br />
{{Note|GRUB supports booting {{ic|bootmgr}} directly and chainload of partition boot sector is no longer required to boot Windows in a BIOS-MBR setup.}}<br />
<br />
{{Warning|It is the '''system partition''' that has {{ic|bootmgr}}, not your "real" Windows partition (usually C:). When showing all UUIDs with blkid, the system partition is the one with {{ic|LABEL&#61;"SYSTEM RESERVED"}} and is only about 100 MB in size (much like the boot partition for Arch). See [[Wikipedia:System partition and boot partition]] for more info.}}<br />
<br />
Throughout this section, it is assumed your Windows partition is /dev/sda1. A different partition will change every instance of hd0,msdos1. First, find the UUID of the NTFS filesystem of the Windows's SYSTEM PARTITION where the {{ic|bootmgr}} and its files reside. For example, if Windows {{ic|bootmgr}} exists at {{ic|/media/SYSTEM_RESERVED/bootmgr}}:<br />
<br />
For Windows Vista/7/8:<br />
<br />
# grub-probe --target=fs_uuid /media/SYSTEM_RESERVED/bootmgr<br />
69B235F6749E84CE<br />
<br />
# grub-probe --target=hints_string /media/SYSTEM_RESERVED/bootmgr<br />
--hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1<br />
<br />
{{Note|For Windows XP, replace {{ic|bootmgr}} with {{ic|ntldr}} in the above commands.}}<br />
<br />
Then, add the below code to {{ic|/etc/grub.d/40_custom}} or {{ic|/boot/grub/custom.cfg}} and regenerate {{ic|grub.cfg}} with {{ic|grub-mkconfig}} as explained above to boot Windows (XP, Vista, 7 or 8) installed in BIOS-MBR mode:<br />
<br />
For Windows Vista/7/8:<br />
<br />
menuentry "Microsoft Windows Vista/7/8 BIOS-MBR" {<br />
insmod part_msdos<br />
insmod ntfs<br />
insmod search_fs_uuid<br />
insmod ntldr <br />
search --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 69B235F6749E84CE<br />
ntldr /bootmgr<br />
}<br />
<br />
For Windows XP:<br />
<br />
menuentry "Microsoft Windows XP" {<br />
insmod part_msdos<br />
insmod ntfs<br />
insmod search_fs_uuid<br />
insmod ntldr <br />
search --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 69B235F6749E84CE<br />
ntldr /ntldr<br />
}<br />
<br />
{{ic|/etc/grub.d/40_custom}} can be used as a template to create {{ic|/etc/grub.d/nn_custom}}. Where {{ic|nn}} defines the precendence, indicating the order the script is executed. The order scripts are executed determine the placement in the grub boot menu.<br />
<br />
{{Note|{{ic|nn}} should be greater than 06 to ensure necessary scripts are executed first.}}<br />
<br />
=== UEFI systems ===<br />
<br />
{{Note|It is well know that different motherboard manufactures implement UEFI differently. Users experiencing problems getting Grub/EFI to work properly are encouraged to share detailed steps for hardware-specific cases where UEFI booting does not work as described below. In an effort to keep the parent [[GRUB]] article neat and tidy, see the [[GRUB EFI Examples]] page for these special cases.}}<br />
<br />
First [[Unified Extensible Firmware Interface#Detecting UEFI Firmware Arch|detect which UEFI firmware arch]] you have (either x86_64 or i386). Depending on the result, install the appropriate package:<br />
*For 64-bit aka x86_64 UEFI firmware, install {{Pkg|grub-efi-x86_64}}<br />
*For 32-bit aka i386 UEFI firmware, install {{Pkg|grub-efi-i386}}<br />
<br />
{{Note|Simply installing the package will not update the {{ic|core.efi}} file and the GRUB modules in the UEFI System Partition. You need to do this manually using {{ic|grub-install}} as explained below.}}<br />
<br />
==== Install boot files ====<br />
<br />
===== Install to UEFI system partition =====<br />
<br />
{{Note|<br />
* The below commands assume you are using {{ic|grub-efi-x86_64}} (for {{ic|grub-efi-i386}} replace {{ic|x86_64}} with {{ic|i386}} in the below commands)<br />
* To do this, you need to boot using UEFI and not the BIOS. If you booted by just copying the ISO file to the USB drive, you will need to follow [[Unified Extensible Firmware Interface#Create UEFI bootable USB from ISO|this guide]] or grub-install will show errors<br />
}}<br />
<br />
The UEFI system partition will need to be mounted at {{ic|/boot/efi/}} for the GRUB install script to detect it:<br />
<br />
# mkdir -p /boot/efi<br />
# mount -t vfat /dev/sdXY /boot/efi<br />
<br />
Install GRUB UEFI application to {{ic|/boot/efi/EFI/arch_grub}} and its modules to {{ic|/boot/grub/x86_64-efi}} (recommended) using:<br />
<br />
# modprobe dm-mod<br />
# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch_grub --recheck --debug<br />
# mkdir -p /boot/grub/locale<br />
# cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo<br />
<br />
{{Note|Without {{ic|--target}} or {{ic|--directory}} option, grub-install cannot determine for which firmware GRUB is being installed. In such cases {{ic|grub-install}} will show {{ic|source_dir doesn't exist. Please specify --target or --directory}} message.}}<br />
<br />
If you want to install GRUB modules and {{ic|grub.cfg}} at the directory {{ic|/boot/efi/EFI/grub}} and the {{ic|grubx64.efi}} application at {{ic|/boot/efi/EFI/arch_grub}} (ie. all the GRUB UEFI files inside the UEFISYS partition itself) use:<br />
<br />
# modprobe dm-mod <br />
# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch_grub --boot-directory=/boot/efi/EFI --recheck --debug<br />
# mkdir -p /boot/efi/EFI/grub/locale<br />
# cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/efi/EFI/grub/locale/en.mo<br />
<br />
The {{ic|--efi-directory}} option mentions the mountpoint of UEFI SYSTEM PARTITION , {{ic|--bootloader-id}} mentions the name of the directory used to store the {{ic|grubx64.efi}} file and {{ic|--boot-directory}} mentions the directory wherein the actual modules will be installed (and into which {{ic|grub.cfg}} should be created).<br />
<br />
The actual paths are:<br />
<br />
<efi-directory>/<EFI or efi>/<bootloader-id>/grubx64.efi<br />
<br />
<boot-directory>/grub/x86_64-efi/<all modules, grub.efi, core.efi, grub.cfg><br />
<br />
{{Note|the {{ic|--bootloader-id}} option does not change {{ic|<boot-directory>/grub}}, i.e. you cannot install the modules to {{ic|<boot-directory>/<bootloader-id>}}, the path is hard-coded to be {{ic|<boot-directory>/grub}}.}}<br />
<br />
In {{ic|<nowiki>--efi-directory=/boot/efi --boot-directory=/boot/efi/EFI --bootloader-id=grub</nowiki>}}:<br />
<br />
<efi-directory>/<EFI or efi>/<bootloader-id> == <boot-directory>/grub == /boot/efi/EFI/grub<br />
<br />
In {{ic|<nowiki>--efi-directory=/boot/efi --boot-directory=/boot/efi/EFI --bootloader-id=arch_grub</nowiki>}}:<br />
<br />
<efi-directory>/<EFI or efi>/<bootloader-id> == /boot/efi/EFI/arch_grub<br />
<boot-directory>/grub == /boot/efi/EFI/grub<br />
<br />
In {{ic|<nowiki>--efi-directory=/boot/efi --boot-directory=/boot --bootloader-id=arch_grub</nowiki>}}:<br />
<br />
<efi-directory>/<EFI or efi>/<bootloader-id> == /boot/efi/EFI/arch_grub<br />
<boot-directory>/grub == /boot/grub<br />
<br />
In {{ic|<nowiki>--efi-directory=/boot/efi --boot-directory=/boot --bootloader-id=grub</nowiki>}}:<br />
<br />
<efi-directory>/<EFI or efi>/<bootloader-id> == /boot/efi/EFI/grub<br />
<boot-directory>/grub == /boot/grub<br />
<br />
The {{ic|<nowiki><efi-directory>/<EFI or efi>/<bootloader-id>/grubx64.efi</nowiki>}} is an exact copy of {{ic|<nowiki><boot-directory>/grub/x86_64-efi/core.efi</nowiki>}}.<br />
<br />
{{Note|<br />
* In GRUB 2.00, the {{ic|grub-install}} option {{ic|--efi-directory}} replaces {{ic|--root-directory}} and the latter is deprecated<br />
* The options {{ic|--efi-directory}} and {{ic|--bootloader-id}} are specific to GRUB UEFI<br />
}}<br />
<br />
In all the cases the UEFI SYSTEM PARTITION should be mounted for {{ic|grub-install}} to install {{ic|grubx64.efi}} in it, which will be launched by the firmware (using the {{ic|efibootmgr}} created boot entry in non-Mac systems).<br />
<br />
If you notice carefully, there is no <device_path> option (Eg: {{ic|/dev/sda}}) at the end of the {{ic|grub-install}} command unlike the case of setting up GRUB for BIOS systems. Any <device_path> provided will be ignored by the install script as UEFI bootloaders do not use MBR or Partition boot sectors at all.<br />
<br />
You may now be able to UEFI boot your system by creating a {{ic|grub.cfg}} file by following [[#Generate UEFI Config file]] and [[#Create GRUB entry in the Firmware Boot Manager]].<br />
<br />
==== Generate config file ====<br />
<br />
Finally, generate a configuration for GRUB (this is explained in greater detail in the Configuration section):<br />
<br />
# grub-mkconfig -o <boot-directory>/grub/grub.cfg<br />
<br />
{{Note|The file path is {{ic|<boot-directory>/grub/grub.cfg}}, NOT {{ic|<boot-directory>/grub/x86_64-efi/grub.cfg}}.}}<br />
<br />
If you used {{ic|<nowiki>--boot-directory=/boot</nowiki>}}:<br />
<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
If you used {{ic|<nowiki>--boot-directory=/boot/efi/EFI</nowiki>}}:<br />
<br />
# grub-mkconfig -o /boot/efi/EFI/grub/grub.cfg<br />
<br />
This is independent of the value of {{ic|--bootloader-id}} option.<br />
<br />
If GRUB complains about "no suitable mode found" while booting, try [[#"No suitable mode found" error]].<br />
<br />
==== Create GRUB entry in the firmware boot manager ====<br />
<br />
{{ic|grub-install}} automatically tries to create a menu entry in the boot manager. If it doesn't, then see [[Beginners' Guide#GRUB]] for instructions to use {{ic|efibootmgr}} to create a menu entry. However, the problem is likely to be that you haven't booted your CD/USB in UEFI mode, as in [[Unified Extensible Firmware Interface#Create UEFI bootable USB from ISO]].<br />
<br />
==== Create GRUB standalone UEFI application ====<br />
<br />
It is possible to create a {{ic|grubx64_standalone.efi}} application which has all the modules embeddded in a memdisk within the UEFI application, thus removing the need for having a separate directory populated with all the GRUB UEFI modules and other related files. This is done using the {{ic|grub-mkstandalone}} command which is included in {{Pkg|grub-common}}.<br />
<br />
The easiest way to do this would be with the install command already mentioned before, but specifying the modules to include. For example:<br />
<br />
# grub-mkstandalone --directory="/usr/lib/grub/x86_64-efi/" --format="x86_64-efi" --compression="xz" \<br />
--output="/boot/efi/EFI/arch_grub/grubx64_standalone.efi" <any extra files you want to include><br />
<br />
The {{ic|grubx64_standalone.efi}} file expects {{ic|grub.cfg}} to be within its $prefix which is {{ic|(memdisk)/boot/grub}}. The memdisk is embedded within the efi app. The {{ic|grub-mkstandlone}} script allow passing files to be included in the memdisk image to be as the arguments to the script (in <any extra files you want to include>).<br />
<br />
If you have the {{ic|grub.cfg}} at {{ic|/home/user/Desktop/grub.cfg}}, then create a temporary {{ic|/home/user/Desktop/boot/grub/}} directory, copy the {{ic|/home/user/Desktop/grub.cfg}} to {{ic|/home/user/Desktop/boot/grub/grub.cfg}}, cd into {{ic|/home/user/Desktop/boot/grub/}} and run:<br />
<br />
# grub-mkstandalone --directory="/usr/lib/grub/x86_64-efi/" --format="x86_64-efi" --compression="xz" \<br />
--output="/boot/efi/EFI/arch_grub/grubx64_standalone.efi" "boot/grub/grub.cfg"<br />
<br />
The reason to cd into {{ic|/home/user/Desktop/boot/grub/}} and to pass the file path as {{ic|boot/grub/grub.cfg}} (notice the lack of a leading slash - boot/ vs /boot/ ) is because {{ic|dir1/dir2/file}} is included as {{ic|(memdisk)/dir1/dir2/file}} by the {{ic|grub-mkstandalone}} script. <br />
<br />
If you pass {{ic|/home/user/Desktop/grub.cfg}} the file will be included as {{ic|(memdisk)/home/user/Desktop/grub.cfg}}. If you pass {{ic|/home/user/Desktop/boot/grub/grub.cfg}} the file will be included as {{ic|(memdisk)/home/user/Desktop/boot/grub/grub.cfg}}. That is the reason for cd'ing into {{ic|/home/user/Desktop/boot/grub/}} and passing {{ic|boot/grub/grub.cfg}}, to include the file as {{ic|(memdisk)/boot/grub/grub.cfg}}, which is what {{ic|grub.efi}} expects the file to be.<br />
<br />
You need to create an UEFI Boot Manager entry for {{ic|/boot/efi/EFI/arch_grub/grubx64_standalone.efi}} using {{ic|efibootmgr}}. Follow [[#Create GRUB entry in the Firmware Boot Manager]].<br />
<br />
==== Multiboot ====<br />
<br />
===== Microsoft Windows installed in UEFI-GPT mode =====<br />
<br />
Find the UUID of the FAT32 filesystem in the UEFI SYSTEM PARTITION where the Windows UEFI Bootloader files reside. For example, if Windows {{ic|bootmgfw.efi}} exists at {{ic|/boot/efi/EFI/Microsoft/Boot/bootmgfw.efi}} (ignore the upper-lower case differences since that is immaterial in FAT filesystem):<br />
<br />
# grub-probe --target=fs_uuid /boot/efi/EFI/Microsoft/Boot/bootmgfw.efi<br />
1ce5-7f28<br />
<br />
# grub-probe --target=hints_string /boot/efi/EFI/Microsoft/Boot/bootmgfw.efi<br />
--hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1<br />
<br />
Then, add this code to {{ic|/etc/grub.d/40_custom}} to chainload Windows x86_64 (Vista SP1+, 7 or 8) installed in UEFI-GPT mode:<br />
<br />
menuentry "Microsoft Windows Vista/7/8 x86_64 UEFI-GPT" {<br />
insmod part_gpt<br />
insmod fat<br />
insmod search_fs_uuid<br />
insmod chain<br />
search --fs-uuid --set=root --hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1 1ce5-7f28<br />
chainloader /efi/Microsoft/Boot/bootmgfw.efi<br />
}<br />
<br />
Afterwards remake {{ic|/boot/grub/grub.cfg}}:<br />
<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
== Configuration ==<br />
<br />
You can also choose to automatically generate or manually edit {{ic|grub.cfg}}.<br />
<br />
{{Note|<br />
* For EFI systems, if GRUB was installed with the {{ic|--boot-directory}} option set, the {{ic|grub.cfg}} file must be placed in the same directory as {{ic|grubx64.efi}}. Otherwise, the {{ic|grub.cfg}} file goes in {{ic|/boot/grub/}}, just like in GRUB BIOS<br />
* [http://members.iinet.net/~herman546/p20/GRUB2%20Configuration%20File%20Commands.html Here] is a quite complete description of how to configure GRUB<br />
}}<br />
<br />
=== Automatically generating using grub-mkconfig ===<br />
<br />
The GRUB {{ic|menu.lst}} equivalent configuration files are {{ic|/etc/default/grub}} and {{ic|/etc/grub.d/*}}. {{ic|grub-mkconfig}} uses these files to generate {{ic|grub.cfg}}. By default the script outputs to stdout. To generate a {{ic|grub.cfg}} file run the command:<br />
<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
{{ic|/etc/grub.d/10_linux}} is set to automatically add menu items for Arch linux that work out of the box, to any generated configuration. Other operating systems may need to be added manually to {{ic|/etc/grub.d/40_custom}} or {{ic|/boot/grub/custom.cfg}}<br />
<br />
==== Additional arguments ====<br />
<br />
To pass custom additional arguments to the Linux image, you can set the {{ic|GRUB_CMDLINE_LINUX}} variable in {{ic|/etc/default/grub}}. <br />
<br />
For example, use {{ic|<nowiki>GRUB_CMDLINE_LINUX="resume=/dev/sdaX"</nowiki>}} where {{ic|sda'''X'''}} is your swap partition to enable resume after hibernation.<br />
<br />
You can also use {{ic|<nowiki>GRUB_CMDLINE_LINUX="resume=/dev/disk/by-uuid/${swap_uuid}"</nowiki>}}, where {{ic|${swap_uuid} }} is the [[Persistent_block_device_naming|UUID]] of your swap partition.<br />
<br />
Multiple entries are separated by spaces within the double quotes. So, for users who want both resume and systemd it would look like this:<br />
{{ic|<nowiki>GRUB_CMDLINE_LINUX="resume=/dev/sdaX init=/usr/lib/systemd/systemd"</nowiki>}}<br />
<br />
See [[Kernel parameters]] for more info.<br />
<br />
=== Manually creating grub.cfg ===<br />
<br />
{{Warning|Editing this file is strongly ''not'' recommended. The file is generated by the {{ic|grub-mkconfig}} command, and it is best to edit your {{ic|/etc/default/grub}} or one of the scripts in the {{ic|/etc/grub.d}} folder.}}<br />
<br />
A basic GRUB config file uses the following options:<br />
* {{ic|(hdX,Y)}} is the partition {{ic|Y}} on disk {{ic|X}}, partition numbers starting at 1, disk numbers starting at 0<br />
* {{ic|1=set default=N}} is the default boot entry that is chosen after timeout for user action<br />
* {{ic|1=set timeout=M}} is the time {{ic|M}} to wait in seconds for a user selection before default is booted<br />
* {{ic|<nowiki>menuentry "title" {entry options}</nowiki>}} is a boot entry titled {{ic|title}}<br />
* {{ic|1=set root=(hdX,Y)}} sets the boot partition, where the kernel and GRUB modules are stored (boot need not be a separate partition, and may simply be a directory under the "root" partition ({{ic|/}})<br />
<br />
An example configuration:<br />
<br />
{{hc|/boot/grub/grub.cfg|<nowiki><br />
# Config file for GRUB - The GNU GRand Unified Bootloader<br />
# /boot/grub/grub.cfg<br />
<br />
# DEVICE NAME CONVERSIONS<br />
#<br />
# Linux Grub<br />
# -------------------------<br />
# /dev/fd0 (fd0)<br />
# /dev/sda (hd0)<br />
# /dev/sdb2 (hd1,2)<br />
# /dev/sda3 (hd0,3)<br />
#<br />
<br />
# Timeout for menu<br />
set timeout=5<br />
<br />
# Set default boot entry as Entry 0<br />
set default=0<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
set root=(hd0,1)<br />
linux /vmlinuz-linux root=/dev/sda3 ro<br />
initrd /initramfs-linux.img<br />
}<br />
<br />
## (1) Windows<br />
#menuentry "Windows" {<br />
# set root=(hd0,3)<br />
# chainloader +1<br />
#}<br />
</nowiki>}}<br />
<br />
=== Dual-booting ===<br />
<br />
{{Note|If you want GRUB to automatically search for other systems, you may wish to install {{Pkg|os-prober}}.}}<br />
<br />
==== Using grub-mkconfig ====<br />
The best way to add other entries is editing the {{ic|/etc/grub.d/40_custom}} or {{ic|/boot/grub/custom.cfg}} . The entries in this file will be automatically added when running {{ic|grub-mkconfig}}.<br />
After adding the new lines, run:<br />
# grub-mkconfig -o /boot/grub/grub.cfg <br />
to generate an updated {{ic|grub.cfg}}.<br />
<br />
===== With GNU/Linux =====<br />
<br />
Assuming that the other distro is on partition {{ic|sda2}}:<br />
<br />
menuentry "Other Linux" {<br />
set root=(hd0,2)<br />
linux /boot/vmlinuz (add other options here as required)<br />
initrd /boot/initrd.img (if the other kernel uses/needs one)<br />
}<br />
<br />
===== With FreeBSD =====<br />
<br />
Requires that FreeBSD is installed on a single partition with UFS. Assuming it is installed on {{ic|sda4}}:<br />
<br />
menuentry "FreeBSD" {<br />
set root=(hd0,4)<br />
chainloader +1<br />
}<br />
<br />
===== With Windows =====<br />
<br />
This assumes that your Windows partition is {{ic|sda3}}. Remember you need to point set root and chainloader to the system reserve partition that windows made when it installed, not the actual partition windows is on. This example works if your system reserve partition is {{ic|sda3}}.<br />
<br />
# (2) Windows XP<br />
menuentry "Windows XP" {<br />
set root="(hd0,3)"<br />
chainloader +1<br />
}<br />
<br />
If the Windows bootloader is on an entirely different hard drive than GRUB, it may be necessary to trick Windows into believing that it is the first hard drive. This was possible with {{ic|drivemap}}. Assuming GRUB is on {{ic|hd0}} and Windows is on {{ic|hd2}}, you need to add the following after {{ic|set root}}:<br />
<br />
drivemap -s hd0 hd2<br />
<br />
==== With Windows via EasyBCD and NeoGRUB ====<br />
<br />
Since EasyBCD's NeoGRUB currently does not understand the GRUB menu format, chainload to it by replacing the contents of your {{ic|C:\NST\menu.lst}} file with lines similar to the following:<br />
<br />
default 0<br />
timeout 1<br />
<br />
title Chainload into GRUB v2<br />
root (hd0,7)<br />
kernel /boot/grub/i386-pc/core.img<br />
<br />
=== Visual configuration ===<br />
<br />
In GRUB it is possible, by default, to change the look of the menu. Make sure to initialize, if not done already, GRUB graphical terminal, gfxterm, with proper video mode, gfxmode, in GRUB. This can be seen in the section [[#"No suitable mode found" error]]. This video mode is passed by GRUB to the linux kernel via 'gfxpayload' so any visual configurations need this mode in order to be in effect.<br />
<br />
==== Setting the framebuffer resolution ====<br />
<br />
GRUB can set the framebuffer for both GRUB itself and the kernel. The old {{ic|1=vga=}} way is deprecated. The preferred method is editing {{ic|/etc/default/grub}} as the following sample:<br />
<br />
GRUB_GFXMODE=1024x768x32<br />
GRUB_GFXPAYLOAD_LINUX=keep<br />
<br />
To generate the changes, run: <br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
The {{ic|gfxpayload}} property will make sure the kernel keeps the resolution.<br />
<br />
{{Note|<br />
* If this example does not work for you try to replace {{ic|1=gfxmode="1024x768x32"}} by {{ic|1=vbemode="0x105"}}. Remember to replace the specified resolution with one suitable for your screen<br />
* To show all the modes you can use {{ic|1=# hwinfo --framebuffer}} (hwinfo is available in [community]), while at GRUB prompt you can use the {{ic|1=vbeinfo}} command<br />
}}<br />
<br />
If this method does not work for you, the deprecated {{ic|1=vga=}} method will still work. Just<br />
add it next to the {{ic|1="GRUB_CMDLINE_LINUX_DEFAULT="}} line in {{ic|/etc/default/grub}}<br />
for eg: {{ic|1="GRUB_CMDLINE_LINUX_DEFAULT="quiet splash vga=792"}} will give you a {{ic|1024x768}} resolution.<br />
<br />
You can choose one of these resolutions: {{ic|640×480}}, {{ic|800×600}}, {{ic|1024×768}}, {{ic|1280×1024}}, {{ic|1600×1200}}, {{ic|1920×1200}}<br />
<br />
==== 915resolution hack ====<br />
<br />
Some times for Intel graphic adapters neither {{ic|1=# hwinfo --framebuffer}} nor {{ic|1=vbeinfo}} will show you the desired resolution. In this case you can use {{ic|915resolution}} hack. This hack will temporarily modify video BIOS and add needed resolution. See [http://915resolution.mango-lang.org/ 915resolution's home page]<br />
<br />
First you need to find a video mode which will be modified later. For that we need the GRUB command shell:<br />
{{hc|sh:grub> 915resolution -l|<br />
Intel 800/900 Series VBIOS Hack : version 0.5.3<br />
[...]<br />
'''Mode 30''' : 640x480, 8 bits/pixel<br />
[...]<br />
}}<br />
Next, we overwrite the {{ic|Mode 30}} with {{ic|1440x900}} resolution:<br />
{{hc|/etc/grub.d/00_header|<br />
[...]<br />
'''915resolution 30 1440 900 # Inserted line'''<br />
set gfxmode&#61;${GRUB_GFXMODE}<br />
[...]<br />
}}<br />
Lastly we need to set {{ic|GRUB_GFXMODE}} as described earlier, regenerate GRUB configuration file and reboot to test changes:<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
# reboot<br />
<br />
==== Background image and bitmap fonts ====<br />
<br />
GRUB comes with support for background images and bitmap fonts in {{ic|pf2}} format. The unifont font is included in the {{Pkg|grub-common}} package under the filename {{ic|unicode.pf2}}, or, as only ASCII characters under the name {{ic|ascii.pf2}}.<br />
<br />
Image formats supported include tga, png and jpeg, providing the correct modules are loaded. The maximum supported resolution depends on your hardware.<br />
<br />
Make sure you have set up the proper [[#Setting the framebuffer resolution|framebuffer resolution]].<br />
<br />
Edit {{ic|/etc/default/grub}} like this:<br />
GRUB_BACKGROUND="/boot/grub/myimage"<br />
#GRUB_THEME="/path/to/gfxtheme"<br />
GRUB_FONT="/path/to/font.pf2"<br />
<br />
{{Note|If you have installed GRUB on a separate partition, {{ic|/boot/grub/myimage}} becomes {{ic|/grub/myimage}}.}}<br />
<br />
To generate the changes and add the information into {{ic|grub.cfg}}, run: <br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
If adding the splash image was successful, the user will see {{ic|"Found background image..."}} in the terminal as the command is executed. <br />
If this phrase is not seen, the image information was probably not incorporated into the {{ic|grub.cfg}} file.<br />
<br />
If the image is not displayed, check:<br />
* The path and the filename in {{ic|/etc/default/grub}} are correct<br />
* The image is of the proper size and format (tga, png, 8-bit jpg)<br />
* The image was saved in the RGB mode, and is not indexed<br />
* The console mode is not enabled in {{ic|/etc/default/grub}}<br />
* The command {{ic|grub-mkconfig}} must be executed to place the background image information into the {{ic|/boot/grub/grub.cfg}} file<br />
<br />
==== Theme ====<br />
<br />
Here is an example for configuring Starfield theme which was included in GRUB package.<br />
<br />
Edit {{ic|/etc/default/grub}}<br />
GRUB_THEME="/usr/share/grub/themes/starfield/theme.txt"<br />
<br />
Generate the changes:<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
If configuring the theme was successful, you'll see {{ic|Found theme: /usr/share/grub/themes/starfield/theme.txt}} in the terminal.<br />
Your splash image will usually not be displayed when using a theme.<br />
<br />
==== Menu colors ====<br />
<br />
You can set the menu colors in GRUB. The available colors for GRUB can be found in [https://www.gnu.org/software/grub/manual/html_node/Theme-file-format.html the GRUB Manual].<br />
Here is an example:<br />
<br />
Edit {{ic|/etc/default/grub}}:<br />
GRUB_COLOR_NORMAL="light-blue/black"<br />
GRUB_COLOR_HIGHLIGHT="light-cyan/blue"<br />
<br />
Generate the changes:<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
==== Hidden menu ====<br />
<br />
One of the unique features of GRUB is hiding/skipping the menu and showing it by holding {{keypress|Esc}} when needed. You can also adjust whether you want to see the timeout counter.<br />
<br />
Edit {{ic|/etc/default/grub}} as you wish. Here is an example where the comments from the beginning of the two lines have been removed to enable the feature, the timeout has been set to five seconds and to be shown to the user:<br />
GRUB_HIDDEN_TIMEOUT=5<br />
GRUB_HIDDEN_TIMEOUT_QUIET=false<br />
<br />
and run:<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
==== Disable framebuffer ====<br />
<br />
Users who use NVIDIA proprietary driver might wish to disable GRUB's framebuffer as it can cause problems with the binary driver.<br />
<br />
To disable framebuffer, edit {{ic|/etc/default/grub}} and uncomment the following line:<br />
GRUB_TERMINAL_OUTPUT=console<br />
<br />
and run:<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
Another option if you want to keep the framebuffer in GRUB is to revert to text mode just before starting the kernel. To do that modify the variable in {{ic|/etc/default/grub}}:<br />
GRUB_GFXPAYLOAD_LINUX=text<br />
<br />
and rebuild the configuration as before.<br />
<br />
=== Other Options ===<br />
<br />
==== LVM ====<br />
<br />
If you use [[LVM]] for your {{ic|/boot}}, add the following before menuentry lines:<br />
<br />
insmod lvm<br />
<br />
and specify your root in the menuentry as:<br />
<br />
set root=lvm/''lvm_group_name''-''lvm_logical_boot_partition_name''<br />
<br />
Example:<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
insmod lvm<br />
set root=lvm/VolumeGroup-lv_boot<br />
# you can only set following two lines<br />
linux /vmlinuz-linux root=/dev/mapper/VolumeGroup-root ro<br />
initrd /initramfs-linux.img<br />
}<br />
<br />
==== RAID ====<br />
<br />
GRUB provides convenient handling of RAID volumes. You need to add {{ic|insmod mdraid}} which allows you to address the volume natively. For example, {{ic|/dev/md0}} becomes:<br />
set root=(md0)<br />
<br />
whereas a partitioned RAID volume (e.g. {{ic|/dev/md0p1}}) becomes:<br />
set root=(md0,1)<br />
<br />
==== Persistent block device naming ====<br />
One naming scheme for [[Persistent block device naming]] is the use of globally unique UUIDs to detect partitions instead of the "old" {{ic|/dev/sd*}}. Advantages are covered up in the above linked article. <br />
<br />
Persistent naming via filesystem UUIDs are used by default in GRUB. <br />
<br />
{{Note|The {{ic|/boot/grub.cfg}} file needs regeneration with the new UUID in {{ic|/etc/default/grub}} every time a relevant filesystem is resized or recreated. Remember this when modifying partitions & filesystems with a Live-CD.}}<br />
<br />
Whether to use UUIDs is controlled by an option in {{ic|/etc/default/grub}}:<br />
<br />
# GRUB_DISABLE_LINUX_UUID=true<br />
<br />
Either way, do not forget to generate the changes:<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
==== Using Labels ====<br />
<br />
It is possible to use labels, human-readable strings attached to filesystems, by using the {{ic|--label}} option to {{ic|search}}. First of all, label your existing partition:<br />
# tune2fs -L <LABEL> <PARTITION><br />
<br />
Then, add an entry using labels. An example of this:<br />
<br />
menuentry "Arch Linux, session texte" {<br />
search --label --set=root archroot<br />
linux /boot/vmlinuz-linux root=/dev/disk/by-label/archroot ro<br />
initrd /boot/initramfs-linux.img<br />
}<br />
<br />
==== Recall previous entry ====<br />
<br />
GRUB can remember the last entry you booted from and use this as the default entry to boot from next time. This is useful if you have multiple kernels (i.e., the current Arch one and the LTS kernel as a fallback option) or operating systems. To do this, edit {{ic|/etc/default/grub}} and change the value of {{ic|GRUB_DEFAULT}}:<br />
<br />
GRUB_DEFAULT=saved<br />
<br />
This ensures that GRUB will default to the saved entry. To enable saving the selected entry, add the following line to {{ic|/etc/default/grub}}:<br />
<br />
GRUB_SAVEDEFAULT=true<br />
<br />
{{Note|Manually added menu items, e.g. Windows in {{ic|/etc/grub.d/40_custom}} or {{ic|/boot/grub/custom.cfg}}, will need {{ic|savedefault}} added. Remember to regenerate([[#Generate config file]]) your configuration file.}}<br />
<br />
==== Changing the default menu entry ====<br />
<br />
To change the default selected entry, edit {{ic|/etc/default/grub}} and change the value of {{ic|GRUB_DEFAULT}}:<br />
<br />
Using numbers :<br />
GRUB_DEFAULT=0<br />
Grub identifies entries in generated menu counted from zero. That means 0 for the first entry which is the default value, 1 for the second and so on.<br />
<br />
Or using menu titles :<br />
GRUB_DEFAULT='Arch Linux, with Linux core repo kernel'<br />
<br />
{{Note|Remember to regenerate([[#Generate config file]]) your configuration file.}}<br />
<br />
==== Security ====<br />
<br />
If you want to secure GRUB so it is not possible for anyone to change boot parameters or use the command line, you can add a user/password combination to GRUB's configuration files. To do this, run the command {{ic|grub-mkpasswd-pbkdf2}}. Enter a password and confirm it:<br />
<br />
{{hc|grub-mkpasswd-pbkdf2|<br />
[...]<br />
Your PBKDF2 is grub.pbkdf2.sha512.10000.C8ABD3E93C4DFC83138B0C7A3D719BC650E6234310DA069E6FDB0DD4156313DA3D0D9BFFC2846C21D5A2DDA515114CF6378F8A064C94198D0618E70D23717E82.509BFA8A4217EAD0B33C87432524C0B6B64B34FBAD22D3E6E6874D9B101996C5F98AB1746FE7C7199147ECF4ABD8661C222EEEDB7D14A843261FFF2C07B1269A<br />
}}<br />
Then, add the following to {{ic|/etc/grub.d/00_header}}:<br />
{{hc|/etc/grub.d/00_header|<br />
cat << EOF<br />
<br />
set superusers<nowiki>=</nowiki>"'''username'''"<br />
password_pbkdf2 '''username''' '''<password>'''<br />
<br />
EOF<br />
}}<br />
where {{ic|<password>}} is the string generated by {{ic|grub-mkpasswd_pbkdf2}}.<br />
<br />
Regenerate your configuration file. Your GRUB command line, boot parameters and all boot entries are now protected.<br />
<br />
This can be relaxed and further customized with more users as described in the "Security" part of [https://www.gnu.org/software/grub/manual/grub.html#Security the GRUB manual].<br />
<br />
==== Root encryption ====<br />
<br />
To let GRUB automatically add the kernel parameters for root encryption,<br />
add {{ic|1=cryptdevice=/dev/yourdevice:label}} to {{ic|GRUB_CMDLINE_LINUX}} in {{ic|/etc/default/grub}}.<br />
<br />
{{Tip|If you're upgrading from a working GRUB Legacy configuration, check {{ic|/boot/grub/menu.lst.pacsave}} for the correct device/label to add. Look for them after the text {{ic|kernel /vmlinuz-linux}}.}}<br />
<br />
Example with root mapped to {{ic|/dev/mapper/root}}:<br />
<br />
GRUB_CMDLINE_LINUX="cryptdevice=/dev/sda2:root"<br />
<br />
Also, disable the usage of UUIDs for the rootfs:<br />
<br />
GRUB_DISABLE_LINUX_UUID=true<br />
<br />
Regenerate the configuration.<br />
<br />
==== Boot non-default entry only once ====<br />
<br />
The command {{ic|grub-reboot}} is very helpful to boot another entry than the default only once. GRUB loads the entry passed in the first command line argument, when the system is rebooted the next time. Most importantly GRUB returns to loading the default entry for all future booting. Changing the configuration file or selecting an entry in the GRUB menu is not necessary.<br />
{{Note|This requires {{ic|1=GRUB_DEFAULT=saved}} in {{ic|/etc/default/grub}} (and then regenerating {{ic|grub.cfg}}) or, in case of hand-made {{ic|grub.cfg}}, the line {{ic|1=set default="${saved_entry}"}}.}}<br />
<br />
=== Booting an ISO directly from GRUB ===<br />
<br />
Edit {{ic|/etc/grub.d/40_custom}} or {{ic|/boot/grub/custom.cfg}} to add an entry for the target ISO. When finished, update the GRUB menu as with the usual {{ic|grub-mkconfig -o /boot/grub/grub.cfg}} (as root).<br />
<br />
==== Arch ISO ====<br />
<br />
{{Note|The following examples assume the ISO is in {{ic|/archives}} on {{ic|hd0,6}}.}}<br />
{{Tip|For thumbdrives, use something like {{ic|(hd1,$partition)}} and either {{ic|/dev/sdb'''Y'''}} for the {{ic|img_dev}} parameter or [[Persistent_block_device_naming|a persistent name]], e.g. {{ic|img_dev&#61;/dev/disk/by-label/CORSAIR}}.}}<br />
<br />
===== x86_64 =====<br />
<br />
menuentry "Archlinux-2013.05.01-dual.iso" --class iso {<br />
set isofile="/archives/archlinux-2013.05.01-dual.iso"<br />
set partition="6"<br />
loopback loop (hd0,$partition)/$isofile<br />
linux (loop)/arch/boot/x86_64/vmlinuz archisolabel=ARCH_201305 img_dev=/dev/sda$partition img_loop=$isofile earlymodules=loop<br />
initrd (loop)/arch/boot/x86_64/archiso.img<br />
}<br />
<br />
===== i686 =====<br />
<br />
menuentry "Archlinux-2013.05.01-dual.iso" --class iso {<br />
set isofile="/archives/archlinux-2013.05.01-dual.iso"<br />
set partition="6"<br />
loopback loop (hd0,$partition)/$isofile<br />
linux (loop)/arch/boot/i686/vmlinuz archisolabel=ARCH_201305 img_dev=/dev/sda$partition img_loop=$isofile earlymodules=loop<br />
initrd (loop)/arch/boot/i686/archiso.img<br />
}<br />
<br />
==== Ubuntu ISO ====<br />
<br />
{{Note|The example assumes that the iso is in {{ic|/archives}} on {{ic|hd0,6}}. Users must adjust the location and hdd/partition in the lines below to match their systems.}}<br />
<br />
menuentry "ubuntu-13.04-desktop-amd64.iso" {<br />
set isofile="/archives/ubuntu-13.04-desktop-amd64.iso"<br />
loopback loop (hd0,6)/$isofile<br />
linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofile quiet noeject noprompt splash --<br />
initrd (loop)/casper/initrd.lz<br />
}<br />
<br />
menuentry "ubuntu-12.04-desktop-amd64.iso" {<br />
set isofile="/archives/ubuntu-12.04-desktop-amd64.iso"<br />
loopback loop (hd0,6)/$isofile<br />
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile quiet noeject noprompt splash --<br />
initrd (loop)/casper/initrd.lz<br />
}<br />
<br />
==== Other ISOs ====<br />
<br />
Other working configurations from [http://askubuntu.com/questions/141940/how-to-boot-live-iso-images link Source].<br />
<br />
== Using the command shell ==<br />
<br />
Since the MBR is too small to store all GRUB modules, only the menu and a few basic commands reside there. The majority of GRUB functionality remains in modules in {{ic|/boot/grub}}, which are inserted as needed. In error conditions (e.g. if the partition layout changes) GRUB may fail to boot. When this happens, a command shell may appear.<br />
<br />
GRUB offers multiple shells/prompts. If there is a problem reading the menu but the bootloader is able to find the disk, you will likely be dropped to the "normal" shell:<br />
sh:grub><br />
<br />
If there is a more serious problem (e.g. GRUB cannot find required files), you may instead be dropped to the "rescue" shell:<br />
grub rescue><br />
<br />
The rescue shell is a restricted subset of the normal shell, offering much less functionality. If dumped to the rescue shell, first try inserting the "normal" module, then starting the "normal" shell:<br />
grub rescue> set prefix=(hdX,Y)/boot/grub<br />
grub rescue> insmod (hdX,Y)/boot/grub/i386-pc/normal.mod<br />
rescue:grub> normal<br />
<br />
=== Pager support ===<br />
<br />
GRUB supports pager for reading commands that provide long output (like the {{ic|help}} command). This works only in normal shell mode and not in rescue mode. To enable pager, in GRUB command shell type:<br />
sh:grub> set pager=1<br />
<br />
== GUI configuration tools ==<br />
<br />
Following package may be installed:<br />
* {{App|grub-customizer|Customize the bootloader (GRUB or BURG)|https://launchpad.net/grub-customizer|{{AUR|grub-customizer}}}}<br />
* {{App|grub2-editor|KDE4 control module for configuring the GRUB bootloader|http://kde-apps.org/content/show.php?content&#61;139643|{{AUR|grub2-editor}}}}<br />
* {{App|kcm-grub2|This Kcm module manages the most common settings of GRUB|http://kde-apps.org/content/show.php?content&#61;137886|{{AUR|kcm-grub2}}}}<br />
* {{App|startupmanager|GUI app for changing the settings of GRUB Legacy, GRUB, Usplash and Splashy|http://sourceforge.net/projects/startup-manager/|{{AUR|startupmanager}}}}<br />
<br />
== parttool for hide/unhide ==<br />
<br />
If you have a Windows 9x paradigm with hidden {{ic|C:\}} disks GRUB can hide/unhide it using {{ic|parttool}}. For example, to boot the third {{ic|C:\}} disk of three Windows 9x installations on the CLI enter the CLI and:<br />
parttool hd0,1 hidden+ boot-<br />
parttool hd0,2 hidden+ boot-<br />
parttool hd0,3 hidden- boot+<br />
set root=hd0,3<br />
chainloader +1<br />
boot<br />
<br />
== Using the rescue console ==<br />
<br />
See [[#Using the command shell]] first. If unable to activate the standard shell, one possible solution is to boot using a live CD or some other rescue disk to correct configuration errors and reinstall GRUB. However, such a boot disk is not always available (nor necessary); the rescue console is surprisingly robust.<br />
<br />
The available commands in GRUB rescue include {{ic|insmod}}, {{ic|ls}}, {{ic|set}}, and {{ic|unset}}. This example uses {{ic|set}} and {{ic|insmod}}. {{ic|set}} modifies variables and {{ic|insmod}} inserts new modules to add functionality.<br />
<br />
Before starting, the user must know the location of their {{ic|/boot}} partition (be it a separate partition, or a subdirectory under their root):<br />
grub rescue> set prefix=(hdX,Y)/boot/grub<br />
<br />
where X is the physical drive number and Y is the partition number.<br />
<br />
To expand console capabilities, insert the {{ic|linux}} module:<br />
grub rescue> insmod (hdX,Y)/boot/grub/linux.mod<br />
<br />
{{Note|With a separate boot partition, omit {{ic|/boot}} from the path, (i.e. type {{ic|1=set prefix=(hdX,Y)/grub}} and {{ic|insmod (hdX,Y)/grub/linux.mod}}).}}<br />
<br />
This introduces the {{ic|linux}} and {{ic|initrd}} commands, which should be familiar (see [[#Configuration]]).<br />
<br />
An example, booting Arch Linux:<br />
set root=(hd0,5)<br />
linux /boot/vmlinuz-linux root=/dev/sda5<br />
initrd /boot/initramfs-linux.img<br />
boot<br />
<br />
With a separate boot partition, again change the lines accordingly:<br />
set root=(hd0,5)<br />
linux /vmlinuz-linux root=/dev/sda6<br />
initrd /initramfs-linux.img<br />
boot<br />
<br />
After successfully booting the Arch Linux installation, users can correct {{ic|grub.cfg}} as needed and then reinstall GRUB.<br />
<br />
To reinstall GRUB and fix the problem completely, changing {{ic|/dev/sda}} if needed. See [[#Bootloader installation]] for details.<br />
<br />
== Combining the use of UUIDs and basic scripting ==<br />
<br />
If you like the idea of using UUIDs to avoid unreliable BIOS mappings or are struggling with GRUB's syntax, here is an example boot menu item that uses UUIDs and a small script to direct GRUB to the proper disk partitions for your system. All you need to do is replace the UUIDs in the sample with the correct UUIDs for your system. The example applies to a system with a boot and root partition. You will obviously need to modify the GRUB configuration if you have additional partitions:<br />
<br />
menuentry "Arch Linux 64" {<br />
# Set the UUIDs for your boot and root partition respectively<br />
set the_boot_uuid=ece0448f-bb08-486d-9864-ac3271bd8d07<br />
set the_root_uuid=c55da16f-e2af-4603-9e0b-03f5f565ec4a<br />
<br />
# (Note: This may be the same as your boot partition)<br />
<br />
# Get the boot/root devices and set them in the root and grub_boot variables<br />
search --fs-uuid --set=root $the_root_uuid<br />
search --fs-uuid --set=grub_boot $the_boot_uuid<br />
<br />
# Check to see if boot and root are equal.<br />
# If they are, then append /boot to $grub_boot (Since $grub_boot is actually the root partition)<br />
if [ $the_boot_uuid == $the_root_uuid] ; then<br />
set grub_boot=$grub_boot/boot<br />
fi<br />
<br />
# $grub_boot now points to the correct location, so the following will properly find the kernel and initrd<br />
linux ($grub_boot)/vmlinuz-linux root=/dev/disk/by-uuid/$uuid_os_root ro<br />
initrd ($grub_boot)/initramfs-linux.img<br />
}<br />
<br />
== Troubleshooting ==<br />
<br />
=== Intel BIOS not booting GPT ===<br />
<br />
Some Intel BIOS's require at least one bootable MBR partition to be present at boot, causing GPT-partitioned boot setups to be unbootable.<br />
<br />
This can be circumvented by using (for instance) fdisk to mark one of the GPT partitions (preferably the 1007 KiB partition you've created for GRUB already) bootable in the MBR. This can be achieved, using fdisk, by the following commands: Start fdisk against the disk you're installing, for instance {{ic|fdisk /dev/sda}}, then press {{keypress|a}} and select the partition you wish to mark as bootable (probably #1) by pressing the corresponding number, finally press {{keypress|w}} to write the changes to the MBR.<br />
<br />
{{Note|The bootable-marking must be done in {{ic|fdisk}} or similar, not in GParted or others, as they will not set the bootable flag in the MBR.}}<br />
<br />
More information is available [http://www.rodsbooks.com/gdisk/bios.html here]<br />
<br />
=== Enable debug messages ===<br />
<br />
Add:<br />
<br />
set pager=1<br />
set debug=all<br />
<br />
to {{ic|grub.cfg}}.<br />
<br />
=== "No suitable mode found" error ===<br />
<br />
If you get this error when booting any menuentry:<br />
<br />
error: no suitable mode found<br />
Booting however<br />
<br />
Then you need to initialize GRUB graphical terminal ({{ic|gfxterm}}) with proper video mode ({{ic|gfxmode}}) in GRUB. This video mode is passed by GRUB to the linux kernel via 'gfxpayload'. In case of UEFI systems, if the GRUB video mode is not initialized, no kernel boot messages will be shown in the terminal (atleast until KMS kicks in).<br />
<br />
Copy {{ic|/usr/share/grub/unicode.pf2}} to ${GRUB_PREFIX_DIR} ({{ic|/boot/grub/}} in case of BIOS and UEFI systems). If GRUB UEFI was installed with {{ic|1=--boot-directory=/boot/efi/EFI}} set, then the directory is {{ic|/boot/efi/EFI/grub/}}:<br />
<br />
# cp /usr/share/grub/unicode.pf2 ${GRUB_PREFIX_DIR}<br />
<br />
If {{ic|/usr/share/grub/unicode.pf2}} does not exist, install {{Pkg|bdf-unifont}}, create the {{ic|unifont.pf2}} file and then copy it to {{ic|${GRUB_PREFIX_DIR<nowiki>}</nowiki>}}:<br />
<br />
# grub-mkfont -o unicode.pf2 /usr/share/fonts/misc/unifont.bdf<br />
<br />
Then, in the {{ic|grub.cfg}} file, add the following lines to enable GRUB to pass the video mode correctly to the kernel, without of which you will only get a black screen (no output) but booting (actually) proceeds successfully without any system hang.<br />
<br />
BIOS systems:<br />
<br />
insmod vbe<br />
<br />
UEFI systems:<br />
<br />
insmod efi_gop<br />
insmod efi_uga<br />
<br />
After that add the following code (common to both BIOS and UEFI):<br />
<br />
insmod font<br />
<br />
if loadfont ${prefix}/fonts/unicode.pf2<br />
then<br />
insmod gfxterm<br />
set gfxmode=auto<br />
set gfxpayload=keep<br />
terminal_output gfxterm<br />
fi<br />
<br />
As you can see for gfxterm (graphical terminal) to function properly, {{ic|unicode.pf2}} font file should exist in {{ic|${GRUB_PREFIX_DIR<nowiki>}</nowiki>}}.<br />
<br />
=== msdos-style error message ===<br />
<br />
grub-setup: warn: This msdos-style partition label has no post-MBR gap; embedding won't be possible!<br />
grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists.<br />
However, blocklists are UNRELIABLE and its use is discouraged.<br />
grub-setup: error: If you really want blocklists, use --force.<br />
<br />
This error may occur when you try installing GRUB in a VMware container. Read more about it [https://bbs.archlinux.org/viewtopic.php?pid=581760#p581760 here]. It happens when the first partition starts just after the MBR (block 63), without the usual space of 1 MiB (2048 blocks) before the first partition. Read [[#Master Boot Record (MBR) specific instructions]]<br />
<br />
=== GRUB UEFI drops to shell ===<br />
<br />
If GRUB loads but drops you into the rescue shell with no errors, it may be because of a missing or misplaced {{ic|grub.cfg}}. This will happen if GRUB UEFI was installed with {{ic|--boot-directory}} and {{ic|grub.cfg}} is missing OR if the partition number of the boot partition changed (which is hard-coded into the {{ic|grubx64.efi}} file).<br />
<br />
=== GRUB UEFI not loaded ===<br />
<br />
An example of a working EFI:<br />
{{hc|# efibootmgr -v|<br />
BootCurrent: 0000<br />
Timeout: 3 seconds<br />
BootOrder: 0000,0001,0002<br />
Boot0000* Grub HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\efi\grub\grub.efi)<br />
Boot0001* Shell HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\EfiShell.efi)<br />
Boot0002* Festplatte BIOS(2,0,00)P0: SAMSUNG HD204UI<br />
}}<br />
<br />
If the screen only goes black for a second and the next boot option is tried afterwards, according to [https://bbs.archlinux.org/viewtopic.php?pid=981560#p981560 this post], moving GRUB to the partition root can help. The boot option has to be deleted and recreated afterwards. The entry for GRUB should look like this then:<br />
Boot0000* Grub HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\grub.efi)<br />
<br />
=== Invalid signature ===<br />
<br />
If trying to boot Windows results in an "invalid signature" error, e.g. after reconfiguring partitions or adding additional hard drives, (re)move GRUB's device configuration and let it reconfigure:<br />
# mv /boot/grub/device.map /boot/grub/device.map-old<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
{{ic|grub-mkconfig}} should now mention all found boot options, including Windows. If it works, remove {{ic|/boot/grub/device.map-old}}.<br />
<br />
=== Boot freezes ===<br />
<br />
If booting gets stuck without any error message after GRUB loading the kernel and the initial ramdisk, try removing the {{ic|add_efi_memmap}} kernel parameter.<br />
<br />
=== Restore GRUB Legacy ===<br />
<br />
* Move GRUB v2 files out of the way:<br />
<br />
# mv /boot/grub /boot/grub.nonfunctional<br />
<br />
* Copy GRUB Legacy back to {{ic|/boot}}:<br />
<br />
# cp -af /boot/grub-legacy /boot/grub<br />
<br />
* Replace MBR and next 62 sectors of sda with backed up copy<br />
<br />
{{Warning|This command also restores the partition table, so be careful of overwriting a modified partition table with the old one. It '''will''' mess up your system.}}<br />
<br />
# dd if=/path/to/backup/first-sectors of=/dev/sdX bs=512 count=1<br />
<br />
A safer way is to restore only the MBR boot code use:<br />
<br />
# dd if=/path/to/backup/mbr-boot-code of=/dev/sdX bs=446 count=1<br />
<br />
== References ==<br />
<br />
# Official GRUB Manual - https://www.gnu.org/software/grub/manual/grub.html<br />
# Ubuntu wiki page for GRUB - https://help.ubuntu.com/community/Grub2<br />
# GRUB wiki page describing steps to compile for UEFI systems - https://help.ubuntu.com/community/UEFIBooting<br />
# Wikipedia's page on [[Wikipedia:BIOS Boot partition|BIOS Boot partition]]<br />
<br />
== See also ==<br />
<br />
# [https://github.com/the-ridikulus-rat/My_Shell_Scripts/blob/master/grub/grub_bios.sh A Linux Bash Shell script to compile and install GRUB for BIOS from BZR Source]<br />
# [https://github.com/the-ridikulus-rat/My_Shell_Scripts/blob/master/grub/grub_uefi.sh A Linux Bash Shell script to compile and install GRUB for UEFI from BZR Source]</div>Apouloshttps://wiki.archlinux.org/index.php?title=GRUB&diff=262561GRUB2013-06-12T17:47:54Z<p>Apoulos: </p>
<hr />
<div>[[Category:Boot loaders]]<br />
[[ar:GRUB]]<br />
[[cs:GRUB2]]<br />
[[de:GRUB]]<br />
[[es:GRUB2]]<br />
[[fr:GRUB2]]<br />
[[id:GRUB2]]<br />
[[it:GRUB2]]<br />
[[ru:GRUB2]]<br />
[[tr:GRUB2]]<br />
[[zh-CN:GRUB2]]<br />
[[zh-TW:GRUB2]]<br />
{{Article summary start}}<br />
{{Article summary text|Covers various aspects of version 2 of the GRand Unified Bootloader (GRUB).}}<br />
{{Article summary heading|Overview}}<br />
{{Article summary text|{{Boot process overview}}}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|BURG}} - BURG is a brand-new boot loader based on GRUB v2. It can be built on a wider range of OS, and has a highly configurable menu system which works in both text and graphic mode. <br />
{{Article summary wiki|GRUB Legacy}} - previous Version, now obsolete.<br />
{{Article summary heading|Resources}}<br />
{{Article summary wiki|GRUB EFI Examples}}<br />
{{Article summary link|GNU GRUB - GNU Project|https://www.gnu.org/software/grub/}}<br />
{{Article summary end}}<br />
<br />
[https://www.gnu.org/software/grub/ GRUB] - not to be confused with [[GRUB Legacy]] - is the next generation of the GRand Unified Bootloader. GRUB is derived from [http://www.nongnu.org/pupa/ PUPA] which was a research project to develop the next generation of what is now GRUB Legacy. GRUB has been rewritten from scratch to clean up everything and provide modularity and portability [https://www.gnu.org/software/grub/grub-faq.html#q1].<br />
<br />
In brief, the ''bootloader'' is the first software program that runs when a computer starts. It is responsible for loading and transferring control to the Linux kernel. The kernel, in turn, initializes the rest of the operating system.<br />
<br />
== Preface ==<br />
<br />
* The name ''GRUB'' officially refers to version ''2'' of the software, see [https://www.gnu.org/software/grub/]. If you are looking for the article on the legacy version, see [[GRUB Legacy]].<br />
* GRUB supports [[Btrfs]] as root (without a separate {{ic|/boot}} filesystem) compressed with either zlib or LZO<br />
<br />
=== Notes for current GRUB Legacy users ===<br />
<br />
* Upgrading from [[GRUB Legacy]] to GRUB is much the same as freshly installing GRUB, which is covered [[#Installation|below]]<br />
* There are differences in the commands of GRUB Legacy and GRUB. Familiarize yourself with [https://www.gnu.org/software/grub/manual/grub.html#Commands GRUB commands] before proceeding (e.g. "find" has been replaced with "search")<br />
* GRUB is now ''modular'' and no longer requires "stage 1.5". As a result, the bootloader itself is limited -- modules are loaded from the hard drive as needed to expand functionality (e.g. for [[LVM]] or RAID support)<br />
* Device naming has changed between GRUB Legacy and GRUB. Partitions are numbered from 1 instead of 0 while drives are still numbered from 0, and prefixed with partition-table type. For example, {{ic|/dev/sda1}} would be referred to as {{ic|(hd0,msdos1)}} (for MBR) or {{ic|(hd0,gpt1)}} (for GPT)<br />
<br />
==== Backup important data ====<br />
<br />
Although a GRUB installation should run smoothly, it is strongly recommended to keep the GRUB Legacy files before upgrading to GRUB v2.<br />
<br />
# mv /boot/grub /boot/grub-legacy<br />
<br />
Backup the MBR which contains the boot code and partition table (Replace {{ic|/dev/sd'''X'''}} with your actual disk path):<br />
<br />
# dd if=/dev/sdX of=/path/to/backup/mbr_backup bs=512 count=1<br />
<br />
Only 446 bytes of the MBR contain boot code, the next 64 contain the partition table. If you do not want to overwrite your partition table when restoring, it is strongly advised to backup only the MBR boot code:<br />
<br />
# dd if=/dev/sdX of=/path/to/backup/bootcode_backup bs=446 count=1<br />
<br />
If unable to install GRUB2 correctly, see [[#Restore GRUB Legacy]].<br />
<br />
=== Preliminary requirements ===<br />
<br />
==== BIOS systems ====<br />
<br />
===== GUID Partition Table (GPT) specific instructions =====<br />
<br />
GRUB in [[GPT|BIOS-GPT]] configuration requires a [http://www.gnu.org/software/grub/manual/html_node/BIOS-installation.html BIOS boot partition] to embed its {{ic|core.img}} in the absence of post-MBR gap in GPT partitioned systems (which is taken over by the GPT Primary Header and Primary Partition table). This partition is used by GRUB only in BIOS-GPT setups. No such partition type exists in case of MBR partitioning (at least not for GRUB). This partition is also not required if the system is UEFI based, as no embedding of bootsectors takes place in that case.<br />
<br />
For a BIOS-GPT configuration, create a 1007 KiB partition at the beginning of the disk using gdisk, cgdisk or GNU Parted with no filesystem. The size of 1007 KiB will allow for the following partition to be correctly alligned at 1024 KiB. If needed, the partition can also be located somewhere else on the disk, but it should be within the first 2 TiB region. Set the partition type to {{ic|ef02}} in (c)gdisk or {{ic|set <BOOT_PART_NUM> bios_grub on}} in GNU Parted.<br />
<br />
{{Note|<br />
* This partition should be created before {{ic|grub-install}} or {{ic|grub-setup}} is run<br />
* gdisk will only allow you to create this partition on the position which will waste the least amount of space (sector 34-2047) if you create it last, after all the other partitions. This is because gdisk will auto-align partitions to 2048-sector boundaries if possible<br />
}}<br />
<br />
===== Master Boot Record (MBR) specific instructions =====<br />
<br />
Usually the post-[[MBR]] gap (after the 512 byte MBR region and before the start of the 1st partition) in many MBR (or msdos disklabel) partitioned systems is 31 KiB when DOS compatibility cylinder alignment issues are satisfied in the partition table. However a post-MBR gap of about 1 to 2 MiB is recommended to provide sufficient room for embedding GRUB's {{ic|core.img}} ({{bug|24103}}). It is advisable to use a partitioner which supports 1 MiB partition alignment to obtain this space as well as satisfy other non-512 byte sector issues (which are unrelated to embedding of {{ic|core.img}}).<br />
<br />
==== UEFI systems ====<br />
<br />
{{Note|It is recommended to read and understand the [[Unified Extensible Firmware Interface|UEFI]], [[GUID Partition Table|GPT]] and [[UEFI Bootloaders]] pages.}}<br />
<br />
===== Create and Mount the UEFI System Partition =====<br />
<br />
Follow [[Unified Extensible Firmware Interface#EFI System Partition]] for instructions on creating a UEFI System Partition. Then mount the UEFI System Partition at {{ic|/boot/efi}}. If you have mounted the UEFI System Partition at some other mountpoint, replace {{ic|/boot/efi}} in the below instructions with that mountpoint:<br />
<br />
# mkdir -p /boot/efi<br />
# mount -t vfat <UEFI_SYSTEM_PARTITION> /boot/efi<br />
<br />
Create a {{ic|/boot/efi/EFI}} directory:<br />
<br />
# mkdir /boot/efi/EFI<br />
<br />
== Installation ==<br />
<br />
=== BIOS systems ===<br />
<br />
GRUB can be [[pacman|installed]] with the {{Pkg|grub-bios}} package from the [[official repositories]]. It will replace {{Pkg|grub-legacy}} or {{Pkg|grub}}, if it is installed.<br />
<br />
{{Note|Simply installing the package won't update the {{ic|/boot/grub/i386-pc/core.img}} file and the GRUB modules in {{ic|/boot/grub/i386-pc}}. You need to update them manually using {{ic|grub-install}} as explained below.}}<br />
<br />
==== Install boot files ====<br />
<br />
There are 3 ways to install GRUB boot files in BIOS booting:<br />
* [[#Install to GPT BIOS boot partition]] (recommended with [[GPT]])<br />
* [[#Install to 440-byte MBR boot code region]] (recommended with [[MBR]])<br />
* [[#Install to partition or partitionless disk]] (not recommended)<br />
* [[#Generate core.img alone]] (safest method, but requires another BIOS bootloader like [[GRUB Legacy]] or [[Syslinux]] to be installed to chainload {{ic|/boot/grub/i386-pc/core.img}})<br />
<br />
{{Note|See http://www.gnu.org/software/grub/manual/html_node/BIOS-installation.html for additional documentation.}}<br />
<br />
===== Install to GPT BIOS boot partition =====<br />
<br />
[[GUID Partition Table]] disks do not have a reserved "boot track". Therefore you must create a BIOS Boot Partition ({{ic|ef02}}) to hold the GRUB core image.<br />
<br />
Using GNU Parted, you can set this using a command such as the following:<br />
<br />
# parted /dev/disk set <partition-number> bios_grub on<br />
<br />
If you are using gdisk, set the partition type to {{ic|ef02}}. With partitioning programs that require setting the GUID directly, it should be {{ic|‘21686148-6449-6e6f-744e656564454649’}} (or, {{ic|[[wikipedia:BIOS_Boot_partition|Hah!IdontNeedEFI]]}}).<br />
<br />
{{Warning|Be very careful which partition you select when marking it as a BIOS Boot Partition. When GRUB finds a BIOS Boot Partition during installation, it will automatically overwrite part of it. Make sure that the partition does not contain any other data.}}<br />
<br />
To setup {{ic|grub-bios}} on a GPT disk, populate the {{ic|/boot/grub}} directory, generate the {{ic|/boot/grub/i386-pc/core.img}} file, and embed it in the BIOS Boot Partition, run:<br />
<br />
# modprobe dm-mod<br />
# grub-install --target=i386-pc --recheck --debug /dev/sda<br />
# mkdir -p /boot/grub/locale<br />
# cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo<br />
<br />
where {{ic|/dev/sda}} is the destination of the installation.<br />
<br />
Continue with [[GRUB#Generate config file]] below.<br />
<br />
===== Install to 440-byte MBR boot code region =====<br />
<br />
To setup {{ic|grub-bios}} in the 440-byte Master Boot Record boot code region, populate the {{ic|/boot/grub}} directory, generate the {{ic|/boot/grub/i386-pc/core.img}} file, embed it in the 31 KiB (minimum size - varies depending on partition alignment) post-MBR gap, and generate the configuration file, run:<br />
<br />
# modprobe dm-mod<br />
# grub-install --recheck /dev/sdX<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
where {{ic|/dev/sdX}} is the destination of the installation (in this case the MBR of the first SATA disk). If you use [[LVM]] for your {{ic|/boot}}, you can install GRUB on multiple physical disks.<br />
<br />
{{Warning|Make sure to check the {{ic|/boot}} directory if you use the latter. Sometimes the {{ic|boot-directory}} parameter creates another {{ic|/boot}} folder inside of {{ic|/boot}}. A wrong install would look like: {{ic|/boot/boot/grub/}}.}}<br />
<br />
===== Install to partition or partitionless disk =====<br />
<br />
{{Note|grub-bios does not encourage installation to a partition boot sector or a partitionless disk like GRUB Legacy or Syslinux does. This kind of setup is prone to breakage, especially during updates, and is not supported by Arch devs.}}<br />
<br />
To set up grub-bios to a partition boot sector, to a partitionless disk (also called superfloppy) or to a floppy disk, run (using for example {{ic|/dev/sdaX}} as the {{ic|/boot}} partition):<br />
<br />
# modprobe dm-mod <br />
# grub-install --target=i386-pc --recheck --debug --force /dev/sdaX<br />
# chattr -i /boot/grub/i386-pc/core.img<br />
# mkdir -p /boot/grub/locale<br />
# cp /usr/share/locale/en@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo<br />
# chattr +i /boot/grub/i386-pc/core.img<br />
<br />
You need to use the {{ic|--force}} option to allow usage of blocklists and should not use {{ic|1=--grub-setup=/bin/true}} (which is similar to simply generating {{ic|core.img}}).<br />
<br />
{{ic|grub-install}} will give out warnings like which should give you the idea of what might go wrong with this approach:<br />
<br />
/sbin/grub-setup: warn: Attempting to install GRUB to a partitionless disk or to a partition. This is a BAD idea.<br />
/sbin/grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. <br />
However, blocklists are UNRELIABLE and their use is discouraged.<br />
<br />
Without {{ic|--force}} you may get the below error and {{ic|grub-setup}} will not setup its boot code in the partition boot sector:<br />
<br />
/sbin/grub-setup: error: will not proceed with blocklists<br />
<br />
With {{ic|--force}} you should get:<br />
<br />
Installation finished. No error reported.<br />
<br />
The reason why {{ic|grub-setup}} does not by default allow this is because in case of partition or a partitionless disk is that {{ic|grub-bios}} relies on embedded blocklists in the partition bootsector to locate the {{ic|/boot/grub/i386-pc/core.img}} file and the prefix dir {{ic|/boot/grub}}. The sector locations of {{ic|core.img}} may change whenever the filesystem in the partition is being altered (files copied, deleted etc.). For more info see https://bugzilla.redhat.com/show_bug.cgi?id=728742 and https://bugzilla.redhat.com/show_bug.cgi?id=730915.<br />
<br />
The workaround for this is to set the immutable flag on {{ic|/boot/grub/i386-pc/core.img}} (using chattr command as mentioned above) so that the sector locations of the {{ic|core.img}} file in the disk is not altered. The immutable flag on {{ic|/boot/grub/i386-pc/core.img}} needs to be set only if {{ic|grub-bios}} is installed to a partition boot sector or a partitionless disk, not in case of installation to MBR or simple generation of {{ic|core.img}} without embedding any bootsector (mentioned above).<br />
<br />
===== Generate core.img alone =====<br />
<br />
To populate the {{ic|/boot/grub}} directory and generate a {{ic|/boot/grub/i386-pc/core.img}} file '''without''' embedding any {{ic|grub-bios}} bootsector code in the MBR, post-MBR region, or the partition bootsector, add {{ic|1=--grub-setup=/bin/true}} to {{ic|grub-install}}:<br />
<br />
# modprobe dm-mod<br />
# grub-install --target=i386-pc --grub-setup=/bin/true --recheck --debug /dev/sda<br />
# mkdir -p /boot/grub/locale<br />
# cp /usr/share/locale/en@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo<br />
<br />
You can then chainload GRUB's {{ic|core.img}} from GRUB Legacy or syslinux as a Linux kernel or a multiboot kernel.<br />
<br />
==== Generate config file ====<br />
<br />
Finally, generate a configuration for GRUB (this is explained in greater detail in the Configuration section):<br />
<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
{{Note|The file path is {{ic|/boot/grub/grub.cfg}}, NOT {{ic|/boot/grub/i386-pc/grub.cfg}}.}}<br />
<br />
If GRUB complains about "no suitable mode found" while booting, go to [[#"No suitable mode found" error]].<br />
<br />
If {{ic|grub-mkconfig}} fails, convert your {{ic|/boot/grub/menu.lst}} file to {{ic|/boot/grub/grub.cfg}} using:<br />
<br />
# grub-menulst2cfg /boot/grub/menu.lst /boot/grub/grub.cfg<br />
<br />
For example:<br />
<br />
{{hc|/boot/grub/menu.lst|<nowiki><br />
default=0<br />
timeout=5<br />
<br />
title Arch Linux Stock Kernel<br />
root (hd0,0)<br />
kernel /vmlinuz-linux root=/dev/sda2 ro<br />
initrd /initramfs-linux.img<br />
<br />
title Arch Linux Stock Kernel Fallback<br />
root (hd0,0)<br />
kernel /vmlinuz-linux root=/dev/sda2 ro<br />
initrd /initramfs-linux-fallback.img<br />
</nowiki>}}<br />
<br />
{{hc|/boot/grub/grub.cfg|<nowiki><br />
set default='0'; if [ x"$default" = xsaved ]; then load_env; set default="$saved_entry"; fi<br />
set timeout=5<br />
<br />
menuentry 'Arch Linux Stock Kernel' {<br />
set root='(hd0,1)'; set legacy_hdbias='0'<br />
legacy_kernel '/vmlinuz-linux' '/vmlinuz-linux' 'root=/dev/sda2' 'ro'<br />
legacy_initrd '/initramfs-linux.img' '/initramfs-linux.img'<br />
<br />
}<br />
<br />
menuentry 'Arch Linux Stock Kernel Fallback' {<br />
set root='(hd0,1)'; set legacy_hdbias='0'<br />
legacy_kernel '/vmlinuz-linux' '/vmlinuz-linux' 'root=/dev/sda2' 'ro'<br />
legacy_initrd '/initramfs-linux-fallback.img' '/initramfs-linux-fallback.img'<br />
}<br />
</nowiki>}}<br />
<br />
If you forgot to create a GRUB {{ic|/boot/grub/grub.cfg}} config file and simply rebooted into GRUB Command Shell, type:<br />
<br />
sh:grub> insmod legacycfg<br />
sh:grub> legacy_configfile ${prefix}/menu.lst<br />
<br />
Boot into Arch and re-create the proper GRUB {{ic|/boot/grub/grub.cfg}} config file.<br />
<br />
{{Note|This option works only in BIOS systems, not in UEFI systems.}}<br />
<br />
==== Multiboot ====<br />
This should work out of the box, but an extra utility needs to be installed: os-prober. Install it, then rerun grub-mkconfig -o /boot/grub/grub.cfg. If this fails, you can try manually adding an entry by following the instructions below.<br />
<br />
===== Microsoft Windows installed in BIOS-MBR mode =====<br />
<br />
{{Note|GRUB supports booting {{ic|bootmgr}} directly and chainload of partition boot sector is no longer required to boot Windows in a BIOS-MBR setup.}}<br />
<br />
{{Warning|It is the '''system partition''' that has {{ic|bootmgr}}, not your "real" Windows partition (usually C:). When showing all UUIDs with blkid, the system partition is the one with {{ic|LABEL&#61;"SYSTEM RESERVED"}} and is only about 100 MB in size (much like the boot partition for Arch). See [[Wikipedia:System partition and boot partition]] for more info.}}<br />
<br />
Throughout this section, it is assumed your Windows partition is /dev/sda1. A different partition will change every instance of hd0,msdos1. First, find the UUID of the NTFS filesystem of the Windows's SYSTEM PARTITION where the {{ic|bootmgr}} and its files reside. For example, if Windows {{ic|bootmgr}} exists at {{ic|/media/SYSTEM_RESERVED/bootmgr}}:<br />
<br />
For Windows Vista/7/8:<br />
<br />
# grub-probe --target=fs_uuid /media/SYSTEM_RESERVED/bootmgr<br />
69B235F6749E84CE<br />
<br />
# grub-probe --target=hints_string /media/SYSTEM_RESERVED/bootmgr<br />
--hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1<br />
<br />
{{Note|For Windows XP, replace {{ic|bootmgr}} with {{ic|ntldr}} in the above commands.}}<br />
<br />
Then, add the below code to {{ic|/etc/grub.d/40_custom}} or {{ic|/boot/grub/custom.cfg}} and regenerate {{ic|grub.cfg}} with {{ic|grub-mkconfig}} as explained above to boot Windows (XP, Vista, 7 or 8) installed in BIOS-MBR mode:<br />
<br />
For Windows Vista/7/8:<br />
<br />
menuentry "Microsoft Windows Vista/7/8 BIOS-MBR" {<br />
insmod part_msdos<br />
insmod ntfs<br />
insmod search_fs_uuid<br />
insmod ntldr <br />
search --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 69B235F6749E84CE<br />
ntldr /bootmgr<br />
}<br />
<br />
For Windows XP:<br />
<br />
menuentry "Microsoft Windows XP" {<br />
insmod part_msdos<br />
insmod ntfs<br />
insmod search_fs_uuid<br />
insmod ntldr <br />
search --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 69B235F6749E84CE<br />
ntldr /ntldr<br />
}<br />
<br />
{{ic|/etc/grub.d/40_custom}} can be used as a template to create {{ic|/etc/grub.d/nn_custom}}. Where {{ic|nn}} defines the precendence, indicating the order the script is executed. The order scripts are executed determine the placement in the grub boot menu.<br />
<br />
{{Note|{{ic|nn}} should be greater than 06 to ensure necessary scripts are executed first.}}<br />
<br />
=== UEFI systems ===<br />
<br />
{{Note|It is well know that different motherboard manufactures implement UEFI differently. Users experiencing problems getting Grub/EFI to work properly are encouraged to share detailed steps for hardware-specific cases where UEFI booting does not work as described below. In an effort to keep the parent [[GRUB]] article neat and tidy, see the [[GRUB EFI Examples]] page for these special cases.}}<br />
<br />
First [[Unified Extensible Firmware Interface#Detecting UEFI Firmware Arch|detect which UEFI firmware arch]] you have (either x86_64 or i386). Depending on the result, install the appropriate package:<br />
*For 64-bit aka x86_64 UEFI firmware, install {{Pkg|grub-efi-x86_64}}<br />
*For 32-bit aka i386 UEFI firmware, install {{Pkg|grub-efi-i386}}<br />
<br />
{{Note|Simply installing the package will not update the {{ic|core.efi}} file and the GRUB modules in the UEFI System Partition. You need to do this manually using {{ic|grub-install}} as explained below.}}<br />
<br />
==== Install boot files ====<br />
<br />
===== Install to UEFI system partition =====<br />
<br />
{{Note|<br />
* The below commands assume you are using {{ic|grub-efi-x86_64}} (for {{ic|grub-efi-i386}} replace {{ic|x86_64}} with {{ic|i386}} in the below commands)<br />
* To do this, you need to boot using UEFI and not the BIOS. If you booted by just copying the ISO file to the USB drive, you will need to follow [[Unified Extensible Firmware Interface#Create UEFI bootable USB from ISO|this guide]] or grub-install will show errors<br />
}}<br />
<br />
The UEFI system partition will need to be mounted at {{ic|/boot/efi/}} for the GRUB install script to detect it:<br />
<br />
# mkdir -p /boot/efi<br />
# mount -t vfat /dev/sdXY /boot/efi<br />
<br />
Install GRUB UEFI application to {{ic|/boot/efi/EFI/arch_grub}} and its modules to {{ic|/boot/grub/x86_64-efi}} (recommended) using:<br />
<br />
# modprobe dm-mod<br />
# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch_grub --recheck --debug<br />
# mkdir -p /boot/grub/locale<br />
# cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo<br />
<br />
{{Note|Without {{ic|--target}} or {{ic|--directory}} option, grub-install cannot determine for which firmware GRUB is being installed. In such cases {{ic|grub-install}} will show {{ic|source_dir doesn't exist. Please specify --target or --directory}} message.}}<br />
<br />
If you want to install GRUB modules and {{ic|grub.cfg}} at the directory {{ic|/boot/efi/EFI/grub}} and the {{ic|grubx64.efi}} application at {{ic|/boot/efi/EFI/arch_grub}} (ie. all the GRUB UEFI files inside the UEFISYS partition itself) use:<br />
<br />
# modprobe dm-mod <br />
# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch_grub --boot-directory=/boot/efi/EFI --recheck --debug<br />
# mkdir -p /boot/efi/EFI/grub/locale<br />
# cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/efi/EFI/grub/locale/en.mo<br />
<br />
The {{ic|--efi-directory}} option mentions the mountpoint of UEFI SYSTEM PARTITION , {{ic|--bootloader-id}} mentions the name of the directory used to store the {{ic|grubx64.efi}} file and {{ic|--boot-directory}} mentions the directory wherein the actual modules will be installed (and into which {{ic|grub.cfg}} should be created).<br />
<br />
The actual paths are:<br />
<br />
<efi-directory>/<EFI or efi>/<bootloader-id>/grubx64.efi<br />
<br />
<boot-directory>/grub/x86_64-efi/<all modules, grub.efi, core.efi, grub.cfg><br />
<br />
{{Note|the {{ic|--bootloader-id}} option does not change {{ic|<boot-directory>/grub}}, i.e. you cannot install the modules to {{ic|<boot-directory>/<bootloader-id>}}, the path is hard-coded to be {{ic|<boot-directory>/grub}}.}}<br />
<br />
In {{ic|<nowiki>--efi-directory=/boot/efi --boot-directory=/boot/efi/EFI --bootloader-id=grub</nowiki>}}:<br />
<br />
<efi-directory>/<EFI or efi>/<bootloader-id> == <boot-directory>/grub == /boot/efi/EFI/grub<br />
<br />
In {{ic|<nowiki>--efi-directory=/boot/efi --boot-directory=/boot/efi/EFI --bootloader-id=arch_grub</nowiki>}}:<br />
<br />
<efi-directory>/<EFI or efi>/<bootloader-id> == /boot/efi/EFI/arch_grub<br />
<boot-directory>/grub == /boot/efi/EFI/grub<br />
<br />
In {{ic|<nowiki>--efi-directory=/boot/efi --boot-directory=/boot --bootloader-id=arch_grub</nowiki>}}:<br />
<br />
<efi-directory>/<EFI or efi>/<bootloader-id> == /boot/efi/EFI/arch_grub<br />
<boot-directory>/grub == /boot/grub<br />
<br />
In {{ic|<nowiki>--efi-directory=/boot/efi --boot-directory=/boot --bootloader-id=grub</nowiki>}}:<br />
<br />
<efi-directory>/<EFI or efi>/<bootloader-id> == /boot/efi/EFI/grub<br />
<boot-directory>/grub == /boot/grub<br />
<br />
The {{ic|<nowiki><efi-directory>/<EFI or efi>/<bootloader-id>/grubx64.efi</nowiki>}} is an exact copy of {{ic|<nowiki><boot-directory>/grub/x86_64-efi/core.efi</nowiki>}}.<br />
<br />
{{Note|<br />
* In GRUB 2.00, the {{ic|grub-install}} option {{ic|--efi-directory}} replaces {{ic|--root-directory}} and the latter is deprecated<br />
* The options {{ic|--efi-directory}} and {{ic|--bootloader-id}} are specific to GRUB UEFI<br />
}}<br />
<br />
In all the cases the UEFI SYSTEM PARTITION should be mounted for {{ic|grub-install}} to install {{ic|grubx64.efi}} in it, which will be launched by the firmware (using the {{ic|efibootmgr}} created boot entry in non-Mac systems).<br />
<br />
If you notice carefully, there is no <device_path> option (Eg: {{ic|/dev/sda}}) at the end of the {{ic|grub-install}} command unlike the case of setting up GRUB for BIOS systems. Any <device_path> provided will be ignored by the install script as UEFI bootloaders do not use MBR or Partition boot sectors at all.<br />
<br />
You may now be able to UEFI boot your system by creating a {{ic|grub.cfg}} file by following [[#Generate UEFI Config file]] and [[#Create GRUB entry in the Firmware Boot Manager]].<br />
<br />
==== Generate config file ====<br />
<br />
Finally, generate a configuration for GRUB (this is explained in greater detail in the Configuration section):<br />
<br />
# grub-mkconfig -o <boot-directory>/grub/grub.cfg<br />
<br />
{{Note|The file path is {{ic|<boot-directory>/grub/grub.cfg}}, NOT {{ic|<boot-directory>/grub/x86_64-efi/grub.cfg}}.}}<br />
<br />
If you used {{ic|<nowiki>--boot-directory=/boot</nowiki>}}:<br />
<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
If you used {{ic|<nowiki>--boot-directory=/boot/efi/EFI</nowiki>}}:<br />
<br />
# grub-mkconfig -o /boot/efi/EFI/grub/grub.cfg<br />
<br />
This is independent of the value of {{ic|--bootloader-id}} option.<br />
<br />
If GRUB complains about "no suitable mode found" while booting, try [[#"No suitable mode found" error]].<br />
<br />
==== Create GRUB entry in the firmware boot manager ====<br />
<br />
{{ic|grub-install}} automatically tries to create a menu entry in the boot manager. If it doesn't, then see [[Beginners' Guide#GRUB]] for instructions to use {{ic|efibootmgr}} to create a menu entry. However, the problem is likely to be that you haven't booted your CD/USB in UEFI mode, as in [[Unified Extensible Firmware Interface#Create UEFI bootable USB from ISO]].<br />
<br />
==== Create GRUB standalone UEFI application ====<br />
<br />
It is possible to create a {{ic|grubx64_standalone.efi}} application which has all the modules embeddded in a memdisk within the UEFI application, thus removing the need for having a separate directory populated with all the GRUB UEFI modules and other related files. This is done using the {{ic|grub-mkstandalone}} command which is included in {{Pkg|grub-common}}.<br />
<br />
The easiest way to do this would be with the install command already mentioned before, but specifying the modules to include. For example:<br />
<br />
# grub-mkstandalone --directory="/usr/lib/grub/x86_64-efi/" --format="x86_64-efi" --compression="xz" \<br />
--output="/boot/efi/EFI/arch_grub/grubx64_standalone.efi" <any extra files you want to include><br />
<br />
The {{ic|grubx64_standalone.efi}} file expects {{ic|grub.cfg}} to be within its $prefix which is {{ic|(memdisk)/boot/grub}}. The memdisk is embedded within the efi app. The {{ic|grub-mkstandlone}} script allow passing files to be included in the memdisk image to be as the arguments to the script (in <any extra files you want to include>).<br />
<br />
If you have the {{ic|grub.cfg}} at {{ic|/home/user/Desktop/grub.cfg}}, then create a temporary {{ic|/home/user/Desktop/boot/grub/}} directory, copy the {{ic|/home/user/Desktop/grub.cfg}} to {{ic|/home/user/Desktop/boot/grub/grub.cfg}}, cd into {{ic|/home/user/Desktop/boot/grub/}} and run:<br />
<br />
# grub-mkstandalone --directory="/usr/lib/grub/x86_64-efi/" --format="x86_64-efi" --compression="xz" \<br />
--output="/boot/efi/EFI/arch_grub/grubx64_standalone.efi" "boot/grub/grub.cfg"<br />
<br />
The reason to cd into {{ic|/home/user/Desktop/boot/grub/}} and to pass the file path as {{ic|boot/grub/grub.cfg}} (notice the lack of a leading slash - boot/ vs /boot/ ) is because {{ic|dir1/dir2/file}} is included as {{ic|(memdisk)/dir1/dir2/file}} by the {{ic|grub-mkstandalone}} script. <br />
<br />
If you pass {{ic|/home/user/Desktop/grub.cfg}} the file will be included as {{ic|(memdisk)/home/user/Desktop/grub.cfg}}. If you pass {{ic|/home/user/Desktop/boot/grub/grub.cfg}} the file will be included as {{ic|(memdisk)/home/user/Desktop/boot/grub/grub.cfg}}. That is the reason for cd'ing into {{ic|/home/user/Desktop/boot/grub/}} and passing {{ic|boot/grub/grub.cfg}}, to include the file as {{ic|(memdisk)/boot/grub/grub.cfg}}, which is what {{ic|grub.efi}} expects the file to be.<br />
<br />
You need to create an UEFI Boot Manager entry for {{ic|/boot/efi/EFI/arch_grub/grubx64_standalone.efi}} using {{ic|efibootmgr}}. Follow [[#Create GRUB entry in the Firmware Boot Manager]].<br />
<br />
==== Multiboot ====<br />
<br />
===== Microsoft Windows installed in UEFI-GPT mode =====<br />
<br />
Find the UUID of the FAT32 filesystem in the UEFI SYSTEM PARTITION where the Windows UEFI Bootloader files reside. For example, if Windows {{ic|bootmgfw.efi}} exists at {{ic|/boot/efi/EFI/Microsoft/Boot/bootmgfw.efi}} (ignore the upper-lower case differences since that is immaterial in FAT filesystem):<br />
<br />
# grub-probe --target=fs_uuid /boot/efi/EFI/Microsoft/Boot/bootmgfw.efi<br />
1ce5-7f28<br />
<br />
# grub-probe --target=hints_string /boot/efi/EFI/Microsoft/Boot/bootmgfw.efi<br />
--hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1<br />
<br />
Then, add this code to {{ic|/etc/grub.d/40_custom}} to chainload Windows x86_64 (Vista SP1+, 7 or 8) installed in UEFI-GPT mode:<br />
<br />
menuentry "Microsoft Windows Vista/7/8 x86_64 UEFI-GPT" {<br />
insmod part_gpt<br />
insmod fat<br />
insmod search_fs_uuid<br />
insmod chain<br />
search --fs-uuid --set=root --hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1 1ce5-7f28<br />
chainloader /efi/Microsoft/Boot/bootmgfw.efi<br />
}<br />
<br />
Afterwards remake {{ic|/boot/grub/grub.cfg}}:<br />
<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
== Configuration ==<br />
<br />
You can also choose to automatically generate or manually edit {{ic|grub.cfg}}.<br />
<br />
{{Note|<br />
* For EFI systems, if GRUB was installed with the {{ic|--boot-directory}} option set, the {{ic|grub.cfg}} file must be placed in the same directory as {{ic|grubx64.efi}}. Otherwise, the {{ic|grub.cfg}} file goes in {{ic|/boot/grub/}}, just like in GRUB BIOS<br />
* [http://members.iinet.net/~herman546/p20/GRUB2%20Configuration%20File%20Commands.html Here] is a quite complete description of how to configure GRUB<br />
}}<br />
<br />
=== Automatically generating using grub-mkconfig ===<br />
<br />
The GRUB {{ic|menu.lst}} equivalent configuration files are {{ic|/etc/default/grub}} and {{ic|/etc/grub.d/*}}. {{ic|grub-mkconfig}} uses these files to generate {{ic|grub.cfg}}. By default the script outputs to stdout. To generate a {{ic|grub.cfg}} file run the command:<br />
<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
{{ic|/etc/grub.d/10_linux}} is set to automatically add menu items for Arch linux that work out of the box, to any generated configuration. Other operating systems may need to be added manually to {{ic|/etc/grub.d/40_custom}} or {{ic|/boot/grub/custom.cfg}}<br />
<br />
==== Additional arguments ====<br />
<br />
To pass custom additional arguments to the Linux image, you can set the {{ic|GRUB_CMDLINE_LINUX}} variable in {{ic|/etc/default/grub}}. <br />
<br />
For example, use {{ic|<nowiki>GRUB_CMDLINE_LINUX="resume=/dev/sdaX"</nowiki>}} where {{ic|sda'''X'''}} is your swap partition to enable resume after hibernation.<br />
<br />
You can also use {{ic|<nowiki>GRUB_CMDLINE_LINUX="resume=/dev/disk/by-uuid/${swap_uuid}"</nowiki>}}, where {{ic|${swap_uuid} }} is the [[Persistent_block_device_naming|UUID]] of your swap partition.<br />
<br />
Multiple entries are separated by spaces within the double quotes. So, for users who want both resume and systemd it would look like this:<br />
{{ic|<nowiki>GRUB_CMDLINE_LINUX="resume=/dev/sdaX init=/usr/lib/systemd/systemd"</nowiki>}}<br />
<br />
See [[Kernel parameters]] for more info.<br />
<br />
=== Manually creating grub.cfg ===<br />
<br />
{{Warning|Editing this file is strongly ''not'' recommended. The file is generated by the {{ic|grub-mkconfig}} command, and it is best to edit your {{ic|/etc/default/grub}} or one of the scripts in the {{ic|/etc/grub.d}} folder.}}<br />
<br />
A basic GRUB config file uses the following options:<br />
* {{ic|(hdX,Y)}} is the partition {{ic|Y}} on disk {{ic|X}}, partition numbers starting at 1, disk numbers starting at 0<br />
* {{ic|1=set default=N}} is the default boot entry that is chosen after timeout for user action<br />
* {{ic|1=set timeout=M}} is the time {{ic|M}} to wait in seconds for a user selection before default is booted<br />
* {{ic|<nowiki>menuentry "title" {entry options}</nowiki>}} is a boot entry titled {{ic|title}}<br />
* {{ic|1=set root=(hdX,Y)}} sets the boot partition, where the kernel and GRUB modules are stored (boot need not be a separate partition, and may simply be a directory under the "root" partition ({{ic|/}})<br />
<br />
An example configuration:<br />
<br />
{{hc|/boot/grub/grub.cfg|<nowiki><br />
# Config file for GRUB - The GNU GRand Unified Bootloader<br />
# /boot/grub/grub.cfg<br />
<br />
# DEVICE NAME CONVERSIONS<br />
#<br />
# Linux Grub<br />
# -------------------------<br />
# /dev/fd0 (fd0)<br />
# /dev/sda (hd0)<br />
# /dev/sdb2 (hd1,2)<br />
# /dev/sda3 (hd0,3)<br />
#<br />
<br />
# Timeout for menu<br />
set timeout=5<br />
<br />
# Set default boot entry as Entry 0<br />
set default=0<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
set root=(hd0,1)<br />
linux /vmlinuz-linux root=/dev/sda3 ro<br />
initrd /initramfs-linux.img<br />
}<br />
<br />
## (1) Windows<br />
#menuentry "Windows" {<br />
# set root=(hd0,3)<br />
# chainloader +1<br />
#}<br />
</nowiki>}}<br />
<br />
=== Dual-booting ===<br />
<br />
{{Note|If you want GRUB to automatically search for other systems, you may wish to install {{Pkg|os-prober}}.}}<br />
<br />
==== Using grub-mkconfig ====<br />
The best way to add other entries is editing the {{ic|/etc/grub.d/40_custom}} or {{ic|/boot/grub/custom.cfg}} . The entries in this file will be automatically added when running {{ic|grub-mkconfig}}.<br />
After adding the new lines, run:<br />
# grub-mkconfig -o /boot/grub/grub.cfg <br />
to generate an updated {{ic|grub.cfg}}.<br />
<br />
===== With GNU/Linux =====<br />
<br />
Assuming that the other distro is on partition {{ic|sda2}}:<br />
<br />
menuentry "Other Linux" {<br />
set root=(hd0,2)<br />
linux /boot/vmlinuz (add other options here as required)<br />
initrd /boot/initrd.img (if the other kernel uses/needs one)<br />
}<br />
<br />
===== With FreeBSD =====<br />
<br />
Requires that FreeBSD is installed on a single partition with UFS. Assuming it is installed on {{ic|sda4}}:<br />
<br />
menuentry "FreeBSD" {<br />
set root=(hd0,4)<br />
chainloader +1<br />
}<br />
<br />
===== With Windows =====<br />
<br />
This assumes that your Windows partition is {{ic|sda3}}. Remember you need to point set root and chainloader to the system reserve partition that windows made when it installed, not the actual partition windows is on. This example works if your system reserve partition is {{ic|sda3}}.<br />
<br />
# (2) Windows XP<br />
menuentry "Windows XP" {<br />
set root="(hd0,3)"<br />
chainloader +1<br />
}<br />
<br />
If the Windows bootloader is on an entirely different hard drive than GRUB, it may be necessary to trick Windows into believing that it is the first hard drive. This was possible with {{ic|drivemap}}. Assuming GRUB is on {{ic|hd0}} and Windows is on {{ic|hd2}}, you need to add the following after {{ic|set root}}:<br />
<br />
drivemap -s hd0 hd2<br />
<br />
==== With Windows via EasyBCD and NeoGRUB ====<br />
<br />
Since EasyBCD's NeoGRUB currently does not understand the GRUB menu format, chainload to it by replacing the contents of your {{ic|C:\NST\menu.lst}} file with lines similar to the following:<br />
<br />
default 0<br />
timeout 1<br />
<br />
title Chainload into GRUB v2<br />
root (hd0,7)<br />
kernel /boot/grub/i386-pc/core.img<br />
<br />
=== Visual configuration ===<br />
<br />
In GRUB it is possible, by default, to change the look of the menu. Make sure to initialize, if not done already, GRUB graphical terminal, gfxterm, with proper video mode, gfxmode, in GRUB. This can be seen in the section [[#"No suitable mode found" error]]. This video mode is passed by GRUB to the linux kernel via 'gfxpayload' so any visual configurations need this mode in order to be in effect.<br />
<br />
==== Setting the framebuffer resolution ====<br />
<br />
GRUB can set the framebuffer for both GRUB itself and the kernel. The old {{ic|1=vga=}} way is deprecated. The preferred method is editing {{ic|/etc/default/grub}} as the following sample:<br />
<br />
GRUB_GFXMODE=1024x768x32<br />
GRUB_GFXPAYLOAD_LINUX=keep<br />
<br />
To generate the changes, run: <br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
The {{ic|gfxpayload}} property will make sure the kernel keeps the resolution.<br />
<br />
{{Note|<br />
* If this example does not work for you try to replace {{ic|1=gfxmode="1024x768x32"}} by {{ic|1=vbemode="0x105"}}. Remember to replace the specified resolution with one suitable for your screen<br />
* To show all the modes you can use {{ic|1=# hwinfo --framebuffer}} (hwinfo is available in [community]), while at GRUB prompt you can use the {{ic|1=vbeinfo}} command<br />
}}<br />
<br />
If this method does not work for you, the deprecated {{ic|1=vga=}} method will still work. Just<br />
add it next to the {{ic|1="GRUB_CMDLINE_LINUX_DEFAULT="}} line in {{ic|/etc/default/grub}}<br />
for eg: {{ic|1="GRUB_CMDLINE_LINUX_DEFAULT="quiet splash vga=792"}} will give you a {{ic|1024x768}} resolution.<br />
<br />
You can choose one of these resolutions: {{ic|640×480}}, {{ic|800×600}}, {{ic|1024×768}}, {{ic|1280×1024}}, {{ic|1600×1200}}, {{ic|1920×1200}}<br />
<br />
==== 915resolution hack ====<br />
<br />
Some times for Intel graphic adapters neither {{ic|1=# hwinfo --framebuffer}} nor {{ic|1=vbeinfo}} will show you the desired resolution. In this case you can use {{ic|915resolution}} hack. This hack will temporarily modify video BIOS and add needed resolution. See [http://915resolution.mango-lang.org/ 915resolution's home page]<br />
<br />
First you need to find a video mode which will be modified later. For that we need the GRUB command shell:<br />
{{hc|sh:grub> 915resolution -l|<br />
Intel 800/900 Series VBIOS Hack : version 0.5.3<br />
[...]<br />
'''Mode 30''' : 640x480, 8 bits/pixel<br />
[...]<br />
}}<br />
Next, we overwrite the {{ic|Mode 30}} with {{ic|1440x900}} resolution:<br />
{{hc|/etc/grub.d/00_header|<br />
[...]<br />
'''915resolution 30 1440 900 # Inserted line'''<br />
set gfxmode&#61;${GRUB_GFXMODE}<br />
[...]<br />
}}<br />
Lastly we need to set {{ic|GRUB_GFXMODE}} as described earlier, regenerate GRUB configuration file and reboot to test changes:<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
# reboot<br />
<br />
==== Background image and bitmap fonts ====<br />
<br />
GRUB comes with support for background images and bitmap fonts in {{ic|pf2}} format. The unifont font is included in the {{Pkg|grub-common}} package under the filename {{ic|unicode.pf2}}, or, as only ASCII characters under the name {{ic|ascii.pf2}}.<br />
<br />
Image formats supported include tga, png and jpeg, providing the correct modules are loaded. The maximum supported resolution depends on your hardware.<br />
<br />
Make sure you have set up the proper [[#Setting the framebuffer resolution|framebuffer resolution]].<br />
<br />
Edit {{ic|/etc/default/grub}} like this:<br />
GRUB_BACKGROUND="/boot/grub/myimage"<br />
#GRUB_THEME="/path/to/gfxtheme"<br />
GRUB_FONT="/path/to/font.pf2"<br />
<br />
{{Note|If you have installed GRUB on a separate partition, {{ic|/boot/grub/myimage}} becomes {{ic|/grub/myimage}}.}}<br />
<br />
To generate the changes and add the information into {{ic|grub.cfg}}, run: <br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
If adding the splash image was successful, the user will see {{ic|"Found background image..."}} in the terminal as the command is executed. <br />
If this phrase is not seen, the image information was probably not incorporated into the {{ic|grub.cfg}} file.<br />
<br />
If the image is not displayed, check:<br />
* The path and the filename in {{ic|/etc/default/grub}} are correct<br />
* The image is of the proper size and format (tga, png, 8-bit jpg)<br />
* The image was saved in the RGB mode, and is not indexed<br />
* The console mode is not enabled in {{ic|/etc/default/grub}}<br />
* The command {{ic|grub-mkconfig}} must be executed to place the background image information into the {{ic|/boot/grub/grub.cfg}} file<br />
<br />
==== Theme ====<br />
<br />
Here is an example for configuring Starfield theme which was included in GRUB package.<br />
<br />
Edit {{ic|/etc/default/grub}}<br />
GRUB_THEME="/usr/share/grub/themes/starfield/theme.txt"<br />
<br />
Generate the changes:<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
If configuring the theme was successful, you'll see {{ic|Found theme: /usr/share/grub/themes/starfield/theme.txt}} in the terminal.<br />
Your splash image will usually not be displayed when using a theme.<br />
<br />
==== Menu colors ====<br />
<br />
You can set the menu colors in GRUB. The available colors for GRUB can be found in [https://www.gnu.org/software/grub/manual/html_node/Theme-file-format.html the GRUB Manual].<br />
Here is an example:<br />
<br />
Edit {{ic|/etc/default/grub}}:<br />
GRUB_COLOR_NORMAL="light-blue/black"<br />
GRUB_COLOR_HIGHLIGHT="light-cyan/blue"<br />
<br />
Generate the changes:<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
==== Hidden menu ====<br />
<br />
One of the unique features of GRUB is hiding/skipping the menu and showing it by holding {{keypress|Esc}} when needed. You can also adjust whether you want to see the timeout counter.<br />
<br />
Edit {{ic|/etc/default/grub}} as you wish. Here is an example where the comments from the beginning of the two lines have been removed to enable the feature, the timeout has been set to five seconds and to be shown to the user:<br />
GRUB_HIDDEN_TIMEOUT=5<br />
GRUB_HIDDEN_TIMEOUT_QUIET=false<br />
<br />
and run:<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
==== Disable framebuffer ====<br />
<br />
Users who use NVIDIA proprietary driver might wish to disable GRUB's framebuffer as it can cause problems with the binary driver.<br />
<br />
To disable framebuffer, edit {{ic|/etc/default/grub}} and uncomment the following line:<br />
GRUB_TERMINAL_OUTPUT=console<br />
<br />
and run:<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
Another option if you want to keep the framebuffer in GRUB is to revert to text mode just before starting the kernel. To do that modify the variable in {{ic|/etc/default/grub}}:<br />
GRUB_GFXPAYLOAD_LINUX=text<br />
<br />
and rebuild the configuration as before.<br />
<br />
=== Other Options ===<br />
<br />
==== LVM ====<br />
<br />
If you use [[LVM]] for your {{ic|/boot}}, add the following before menuentry lines:<br />
<br />
insmod lvm<br />
<br />
and specify your root in the menuentry as:<br />
<br />
set root=lvm/''lvm_group_name''-''lvm_logical_boot_partition_name''<br />
<br />
Example:<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
insmod lvm<br />
set root=lvm/VolumeGroup-lv_boot<br />
# you can only set following two lines<br />
linux /vmlinuz-linux root=/dev/mapper/VolumeGroup-root ro<br />
initrd /initramfs-linux.img<br />
}<br />
<br />
==== RAID ====<br />
<br />
GRUB provides convenient handling of RAID volumes. You need to add {{ic|insmod mdraid}} which allows you to address the volume natively. For example, {{ic|/dev/md0}} becomes:<br />
set root=(md0)<br />
<br />
whereas a partitioned RAID volume (e.g. {{ic|/dev/md0p1}}) becomes:<br />
set root=(md0,1)<br />
<br />
==== Persistent block device naming ====<br />
One naming scheme for [[Persistent block device naming]] is the use of globally unique UUIDs to detect partitions instead of the "old" {{ic|/dev/sd*}}. Advantages are covered up in the above linked article. <br />
<br />
Persistent naming via filesystem UUIDs are used by default in GRUB. <br />
<br />
{{Note|The {{ic|/boot/grub.cfg}} file needs regeneration with the new UUID in {{ic|/etc/default/grub}} every time a relevant filesystem is resized or recreated. Remember this when modifying partitions & filesystems with a Live-CD.}}<br />
<br />
Whether to use UUIDs is controlled by an option in {{ic|/etc/default/grub}}:<br />
<br />
# GRUB_DISABLE_LINUX_UUID=true<br />
<br />
Either way, do not forget to generate the changes:<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
==== Using Labels ====<br />
<br />
It is possible to use labels, human-readable strings attached to filesystems, by using the {{ic|--label}} option to {{ic|search}}. First of all, label your existing partition:<br />
# tune2fs -L <LABEL> <PARTITION><br />
<br />
Then, add an entry using labels. An example of this:<br />
<br />
menuentry "Arch Linux, session texte" {<br />
search --label --set=root archroot<br />
linux /boot/vmlinuz-linux root=/dev/disk/by-label/archroot ro<br />
initrd /boot/initramfs-linux.img<br />
}<br />
<br />
==== Recall previous entry ====<br />
<br />
GRUB can remember the last entry you booted from and use this as the default entry to boot from next time. This is useful if you have multiple kernels (i.e., the current Arch one and the LTS kernel as a fallback option) or operating systems. To do this, edit {{ic|/etc/default/grub}} and change the value of {{ic|GRUB_DEFAULT}}:<br />
<br />
GRUB_DEFAULT=saved<br />
<br />
This ensures that GRUB will default to the saved entry. To enable saving the selected entry, add the following line to {{ic|/etc/default/grub}}:<br />
<br />
GRUB_SAVEDEFAULT=true<br />
<br />
{{Note|Manually added menu items, e.g. Windows in {{ic|/etc/grub.d/40_custom}} or {{ic|/boot/grub/custom.cfg}}, will need {{ic|savedefault}} added. Remember to regenerate([[#Generate config file]]) your configuration file.}}<br />
<br />
==== Changing the default menu entry ====<br />
<br />
To change the default selected entry, edit {{ic|/etc/default/grub}} and change the value of {{ic|GRUB_DEFAULT}}:<br />
<br />
Using numbers :<br />
GRUB_DEFAULT=0<br />
Grub identifies entries in generated menu counted from zero. That means 0 for the first entry which is the default value, 1 for the second and so on.<br />
<br />
Or using menu titles :<br />
GRUB_DEFAULT='Arch Linux, with Linux core repo kernel'<br />
<br />
{{Note|Remember to regenerate([[#Generate config file]]) your configuration file.}}<br />
<br />
==== Security ====<br />
<br />
If you want to secure GRUB so it is not possible for anyone to change boot parameters or use the command line, you can add a user/password combination to GRUB's configuration files. To do this, run the command {{ic|grub-mkpasswd-pbkdf2}}. Enter a password and confirm it:<br />
<br />
{{hc|grub-mkpasswd-pbkdf2|<br />
[...]<br />
Your PBKDF2 is grub.pbkdf2.sha512.10000.C8ABD3E93C4DFC83138B0C7A3D719BC650E6234310DA069E6FDB0DD4156313DA3D0D9BFFC2846C21D5A2DDA515114CF6378F8A064C94198D0618E70D23717E82.509BFA8A4217EAD0B33C87432524C0B6B64B34FBAD22D3E6E6874D9B101996C5F98AB1746FE7C7199147ECF4ABD8661C222EEEDB7D14A843261FFF2C07B1269A<br />
}}<br />
Then, add the following to {{ic|/etc/grub.d/00_header}}:<br />
{{hc|/etc/grub.d/00_header|<br />
cat << EOF<br />
<br />
set superusers<nowiki>=</nowiki>"'''username'''"<br />
password_pbkdf2 '''username''' '''<password>'''<br />
<br />
EOF<br />
}}<br />
where {{ic|<password>}} is the string generated by {{ic|grub-mkpasswd_pbkdf2}}.<br />
<br />
Regenerate your configuration file. Your GRUB command line, boot parameters and all boot entries are now protected.<br />
<br />
This can be relaxed and further customized with more users as described in the "Security" part of [https://www.gnu.org/software/grub/manual/grub.html#Security the GRUB manual].<br />
<br />
==== Root encryption ====<br />
<br />
To let GRUB automatically add the kernel parameters for root encryption,<br />
add {{ic|1=cryptdevice=/dev/yourdevice:label}} to {{ic|GRUB_CMDLINE_LINUX}} in {{ic|/etc/default/grub}}.<br />
<br />
{{Tip|If you're upgrading from a working GRUB Legacy configuration, check {{ic|/boot/grub/menu.lst.pacsave}} for the correct device/label to add. Look for them after the text {{ic|kernel /vmlinuz-linux}}.}}<br />
<br />
Example with root mapped to {{ic|/dev/mapper/root}}:<br />
<br />
GRUB_CMDLINE_LINUX="cryptdevice=/dev/sda2:root"<br />
<br />
Also, disable the usage of UUIDs for the rootfs:<br />
<br />
GRUB_DISABLE_LINUX_UUID=true<br />
<br />
Regenerate the configuration.<br />
<br />
==== Boot non-default entry only once ====<br />
<br />
The command {{ic|grub-reboot}} is very helpful to boot another entry than the default only once. GRUB loads the entry passed in the first command line argument, when the system is rebooted the next time. Most importantly GRUB returns to loading the default entry for all future booting. Changing the configuration file or selecting an entry in the GRUB menu is not necessary.<br />
{{Note|This requires {{ic|1=GRUB_DEFAULT=saved}} in {{ic|/etc/default/grub}} (and then regenerating {{ic|grub.cfg}}) or, in case of hand-made {{ic|grub.cfg}}, the line {{ic|1=set default="${saved_entry}"}}.}}<br />
<br />
=== Booting an ISO directly from GRUB ===<br />
<br />
Edit {{ic|/etc/grub.d/40_custom}} or {{ic|/boot/grub/custom.cfg}} to add an entry for the target ISO. When finished, update the GRUB menu as with the usual {{ic|grub-mkconfig -o /boot/grub/grub.cfg}} (as root).<br />
<br />
==== Arch ISO ====<br />
<br />
{{Note|The following examples assume the ISO is in {{ic|/archives}} on {{ic|hd0,6}}.}}<br />
{{Tip|For thumbdrives, use something like {{ic|(hd1,$partition)}} and either {{ic|/dev/sdb'''Y'''}} for the {{ic|img_dev}} parameter or [[Persistent_block_device_naming|a persistent name]], e.g. {{ic|img_dev&#61;/dev/disk/by-label/CORSAIR}}.}}<br />
<br />
===== x86_64 =====<br />
<br />
menuentry "Archlinux-2013.05.01-dual.iso" --class iso {<br />
set isofile="/archives/archlinux-2013.05.01-dual.iso"<br />
set partition="6"<br />
loopback loop (hd0,$partition)/$isofile<br />
linux (loop)/arch/boot/x86_64/vmlinuz archisolabel=ARCH_201305 img_dev=/dev/sda$partition img_loop=$isofile earlymodules=loop<br />
initrd (loop)/arch/boot/x86_64/archiso.img<br />
}<br />
<br />
===== i686 =====<br />
<br />
menuentry "Archlinux-2013.05.01-dual.iso" --class iso {<br />
set isofile="/archives/archlinux-2013.05.01-dual.iso"<br />
set partition="6"<br />
loopback loop (hd0,$partition)/$isofile<br />
linux (loop)/arch/boot/i686/vmlinuz archisolabel=ARCH_201305 img_dev=/dev/sda$partition img_loop=$isofile earlymodules=loop<br />
initrd (loop)/arch/boot/i686/archiso.img<br />
}<br />
<br />
==== Ubuntu ISO ====<br />
<br />
{{Note|The example assumes that the iso is in {{ic|/archives}} on {{ic|hd0,6}}. Users must adjust the location and hdd/partition in the lines below to match their systems.}}<br />
<br />
menuentry "ubuntu-13.04-desktop-amd64.iso" {<br />
set isofile="/archives/ubuntu-13.04-desktop-amd64.iso"<br />
loopback loop (hd0,6)/$isofile<br />
linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofile quiet noeject noprompt splash --<br />
initrd (loop)/casper/initrd.lz<br />
}<br />
<br />
menuentry "ubuntu-12.04-desktop-amd64.iso" {<br />
set isofile="/archives/ubuntu-12.04-desktop-amd64.iso"<br />
loopback loop (hd0,6)/$isofile<br />
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile quiet noeject noprompt splash --<br />
initrd (loop)/casper/initrd.lz<br />
}<br />
<br />
==== Other ISOs ====<br />
<br />
Other working configurations from [http://askubuntu.com/questions/141940/how-to-boot-live-iso-images link Source].<br />
<br />
== Using the command shell ==<br />
<br />
Since the MBR is too small to store all GRUB modules, only the menu and a few basic commands reside there. The majority of GRUB functionality remains in modules in {{ic|/boot/grub}}, which are inserted as needed. In error conditions (e.g. if the partition layout changes) GRUB may fail to boot. When this happens, a command shell may appear.<br />
<br />
GRUB offers multiple shells/prompts. If there is a problem reading the menu but the bootloader is able to find the disk, you will likely be dropped to the "normal" shell:<br />
sh:grub><br />
<br />
If there is a more serious problem (e.g. GRUB cannot find required files), you may instead be dropped to the "rescue" shell:<br />
grub rescue><br />
<br />
The rescue shell is a restricted subset of the normal shell, offering much less functionality. If dumped to the rescue shell, first try inserting the "normal" module, then starting the "normal" shell:<br />
grub rescue> set prefix=(hdX,Y)/boot/grub<br />
grub rescue> insmod (hdX,Y)/boot/grub/i386-pc/normal.mod<br />
rescue:grub> normal<br />
<br />
=== Pager support ===<br />
<br />
GRUB supports pager for reading commands that provide long output (like the {{ic|help}} command). This works only in normal shell mode and not in rescue mode. To enable pager, in GRUB command shell type:<br />
sh:grub> set pager=1<br />
<br />
== GUI configuration tools ==<br />
<br />
Following package may be installed:<br />
* {{App|grub-customizer|Customize the bootloader (GRUB or BURG)|https://launchpad.net/grub-customizer|{{AUR|grub-customizer}}}}<br />
* {{App|grub2-editor|KDE4 control module for configuring the GRUB bootloader|http://kde-apps.org/content/show.php?content&#61;139643|{{AUR|grub2-editor}}}}<br />
* {{App|kcm-grub2|This Kcm module manages the most common settings of GRUB|http://kde-apps.org/content/show.php?content&#61;137886|{{AUR|kcm-grub2}}}}<br />
* {{App|startupmanager|GUI app for changing the settings of GRUB Legacy, GRUB, Usplash and Splashy|http://sourceforge.net/projects/startup-manager/|{{AUR|startupmanager}}}}<br />
<br />
== parttool for hide/unhide ==<br />
<br />
If you have a Windows 9x paradigm with hidden {{ic|C:\}} disks GRUB can hide/unhide it using {{ic|parttool}}. For example, to boot the third {{ic|C:\}} disk of three Windows 9x installations on the CLI enter the CLI and:<br />
parttool hd0,1 hidden+ boot-<br />
parttool hd0,2 hidden+ boot-<br />
parttool hd0,3 hidden- boot+<br />
set root=hd0,3<br />
chainloader +1<br />
boot<br />
<br />
== Using the rescue console ==<br />
<br />
See [[#Using the command shell]] first. If unable to activate the standard shell, one possible solution is to boot using a live CD or some other rescue disk to correct configuration errors and reinstall GRUB. However, such a boot disk is not always available (nor necessary); the rescue console is surprisingly robust.<br />
<br />
The available commands in GRUB rescue include {{ic|insmod}}, {{ic|ls}}, {{ic|set}}, and {{ic|unset}}. This example uses {{ic|set}} and {{ic|insmod}}. {{ic|set}} modifies variables and {{ic|insmod}} inserts new modules to add functionality.<br />
<br />
Before starting, the user must know the location of their {{ic|/boot}} partition (be it a separate partition, or a subdirectory under their root):<br />
grub rescue> set prefix=(hdX,Y)/boot/grub<br />
<br />
where X is the physical drive number and Y is the partition number.<br />
<br />
To expand console capabilities, insert the {{ic|linux}} module:<br />
grub rescue> insmod (hdX,Y)/boot/grub/linux.mod<br />
<br />
{{Note|With a separate boot partition, omit {{ic|/boot}} from the path, (i.e. type {{ic|1=set prefix=(hdX,Y)/grub}} and {{ic|insmod (hdX,Y)/grub/linux.mod}}).}}<br />
<br />
This introduces the {{ic|linux}} and {{ic|initrd}} commands, which should be familiar (see [[#Configuration]]).<br />
<br />
An example, booting Arch Linux:<br />
set root=(hd0,5)<br />
linux /boot/vmlinuz-linux root=/dev/sda5<br />
initrd /boot/initramfs-linux.img<br />
boot<br />
<br />
With a separate boot partition, again change the lines accordingly:<br />
set root=(hd0,5)<br />
linux /vmlinuz-linux root=/dev/sda6<br />
initrd /initramfs-linux.img<br />
boot<br />
<br />
After successfully booting the Arch Linux installation, users can correct {{ic|grub.cfg}} as needed and then reinstall GRUB.<br />
<br />
To reinstall GRUB and fix the problem completely, changing {{ic|/dev/sda}} if needed. See [[#Bootloader installation]] for details.<br />
<br />
== Combining the use of UUIDs and basic scripting ==<br />
<br />
If you like the idea of using UUIDs to avoid unreliable BIOS mappings or are struggling with GRUB's syntax, here is an example boot menu item that uses UUIDs and a small script to direct GRUB to the proper disk partitions for your system. All you need to do is replace the UUIDs in the sample with the correct UUIDs for your system. The example applies to a system with a boot and root partition. You will obviously need to modify the GRUB configuration if you have additional partitions:<br />
<br />
menuentry "Arch Linux 64" {<br />
# Set the UUIDs for your boot and root partition respectively<br />
set the_boot_uuid=ece0448f-bb08-486d-9864-ac3271bd8d07<br />
set the_root_uuid=c55da16f-e2af-4603-9e0b-03f5f565ec4a<br />
<br />
# (Note: This may be the same as your boot partition)<br />
<br />
# Get the boot/root devices and set them in the root and grub_boot variables<br />
search --fs-uuid --set=root $the_root_uuid<br />
search --fs-uuid --set=grub_boot $the_boot_uuid<br />
<br />
# Check to see if boot and root are equal.<br />
# If they are, then append /boot to $grub_boot (Since $grub_boot is actually the root partition)<br />
if [ $the_boot_uuid == $the_root_uuid] ; then<br />
set grub_boot=$grub_boot/boot<br />
fi<br />
<br />
# $grub_boot now points to the correct location, so the following will properly find the kernel and initrd<br />
linux ($grub_boot)/vmlinuz-linux root=/dev/disk/by-uuid/$uuid_os_root ro<br />
initrd ($grub_boot)/initramfs-linux.img<br />
}<br />
<br />
== Troubleshooting ==<br />
<br />
=== Intel BIOS not booting GPT ===<br />
<br />
Some Intel BIOS's require at least one bootable MBR partition to be present at boot, causing GPT-partitioned boot setups to be unbootable.<br />
<br />
This can be circumvented by using (for instance) fdisk to mark one of the GPT partitions (preferably the 1007 KiB partition you've created for GRUB already) bootable in the MBR. This can be achieved, using fdisk, by the following commands: Start fdisk against the disk you're installing, for instance {{ic|fdisk /dev/sda}}, then press {{keypress|a}} and select the partition you wish to mark as bootable (probably #1) by pressing the corresponding number, finally press {{keypress|w}} to write the changes to the MBR.<br />
<br />
{{Note|The bootable-marking must be done in {{ic|fdisk}} or similar, not in GParted or others, as they will not set the bootable flag in the MBR.}}<br />
<br />
More information is available [http://www.rodsbooks.com/gdisk/bios.html here]<br />
<br />
=== Enable debug messages ===<br />
<br />
Add:<br />
<br />
set pager=1<br />
set debug=all<br />
<br />
to {{ic|grub.cfg}}.<br />
<br />
=== "No suitable mode found" error ===<br />
<br />
If you get this error when booting any menuentry:<br />
<br />
error: no suitable mode found<br />
Booting however<br />
<br />
Then you need to initialize GRUB graphical terminal ({{ic|gfxterm}}) with proper video mode ({{ic|gfxmode}}) in GRUB. This video mode is passed by GRUB to the linux kernel via 'gfxpayload'. In case of UEFI systems, if the GRUB video mode is not initialized, no kernel boot messages will be shown in the terminal (atleast until KMS kicks in).<br />
<br />
Copy {{ic|/usr/share/grub/unicode.pf2}} to ${GRUB_PREFIX_DIR} ({{ic|/boot/grub/}} in case of BIOS and UEFI systems). If GRUB UEFI was installed with {{ic|1=--boot-directory=/boot/efi/EFI}} set, then the directory is {{ic|/boot/efi/EFI/grub/}}:<br />
<br />
# cp /usr/share/grub/unicode.pf2 ${GRUB_PREFIX_DIR}<br />
<br />
If {{ic|/usr/share/grub/unicode.pf2}} does not exist, install {{Pkg|bdf-unifont}}, create the {{ic|unifont.pf2}} file and then copy it to {{ic|${GRUB_PREFIX_DIR<nowiki>}</nowiki>}}:<br />
<br />
# grub-mkfont -o unicode.pf2 /usr/share/fonts/misc/unifont.bdf<br />
<br />
Then, in the {{ic|grub.cfg}} file, add the following lines to enable GRUB to pass the video mode correctly to the kernel, without of which you will only get a black screen (no output) but booting (actually) proceeds successfully without any system hang.<br />
<br />
BIOS systems:<br />
<br />
insmod vbe<br />
<br />
UEFI systems:<br />
<br />
insmod efi_gop<br />
insmod efi_uga<br />
<br />
After that add the following code (common to both BIOS and UEFI):<br />
<br />
insmod font<br />
<br />
if loadfont ${prefix}/fonts/unicode.pf2<br />
then<br />
insmod gfxterm<br />
set gfxmode=auto<br />
set gfxpayload=keep<br />
terminal_output gfxterm<br />
fi<br />
<br />
As you can see for gfxterm (graphical terminal) to function properly, {{ic|unicode.pf2}} font file should exist in {{ic|${GRUB_PREFIX_DIR<nowiki>}</nowiki>}}.<br />
<br />
=== msdos-style error message ===<br />
<br />
grub-setup: warn: This msdos-style partition label has no post-MBR gap; embedding won't be possible!<br />
grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists.<br />
However, blocklists are UNRELIABLE and its use is discouraged.<br />
grub-setup: error: If you really want blocklists, use --force.<br />
<br />
This error may occur when you try installing GRUB in a VMware container. Read more about it [https://bbs.archlinux.org/viewtopic.php?pid=581760#p581760 here]. It happens when the first partition starts just after the MBR (block 63), without the usual space of 1 MiB (2048 blocks) before the first partition. Read [[#Master Boot Record (MBR) specific instructions]]<br />
<br />
=== GRUB UEFI drops to shell ===<br />
<br />
If GRUB loads but drops you into the rescue shell with no errors, it may be because of a missing or misplaced {{ic|grub.cfg}}. This will happen if GRUB UEFI was installed with {{ic|--boot-directory}} and {{ic|grub.cfg}} is missing OR if the partition number of the boot partition changed (which is hard-coded into the {{ic|grubx64.efi}} file).<br />
<br />
=== GRUB UEFI not loaded ===<br />
<br />
An example of a working EFI:<br />
{{hc|# efibootmgr -v|<br />
BootCurrent: 0000<br />
Timeout: 3 seconds<br />
BootOrder: 0000,0001,0002<br />
Boot0000* Grub HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\efi\grub\grub.efi)<br />
Boot0001* Shell HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\EfiShell.efi)<br />
Boot0002* Festplatte BIOS(2,0,00)P0: SAMSUNG HD204UI<br />
}}<br />
<br />
If the screen only goes black for a second and the next boot option is tried afterwards, according to [https://bbs.archlinux.org/viewtopic.php?pid=981560#p981560 this post], moving GRUB to the partition root can help. The boot option has to be deleted and recreated afterwards. The entry for GRUB should look like this then:<br />
Boot0000* Grub HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\grub.efi)<br />
<br />
=== Invalid signature ===<br />
<br />
If trying to boot Windows results in an "invalid signature" error, e.g. after reconfiguring partitions or adding additional hard drives, (re)move GRUB's device configuration and let it reconfigure:<br />
# mv /boot/grub/device.map /boot/grub/device.map-old<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
{{ic|grub-mkconfig}} should now mention all found boot options, including Windows. If it works, remove {{ic|/boot/grub/device.map-old}}.<br />
<br />
=== Boot freezes ===<br />
<br />
If booting gets stuck without any error message after GRUB loading the kernel and the initial ramdisk, try removing the {{ic|add_efi_memmap}} kernel parameter.<br />
<br />
=== Restore GRUB Legacy ===<br />
<br />
* Move GRUB v2 files out of the way:<br />
<br />
# mv /boot/grub /boot/grub.nonfunctional<br />
<br />
* Copy GRUB Legacy back to {{ic|/boot}}:<br />
<br />
# cp -af /boot/grub-legacy /boot/grub<br />
<br />
* Replace MBR and next 62 sectors of sda with backed up copy<br />
<br />
{{Warning|This command also restores the partition table, so be careful of overwriting a modified partition table with the old one. It '''will''' mess up your system.}}<br />
<br />
# dd if=/path/to/backup/first-sectors of=/dev/sdX bs=512 count=1<br />
<br />
A safer way is to restore only the MBR boot code use:<br />
<br />
# dd if=/path/to/backup/mbr-boot-code of=/dev/sdX bs=446 count=1<br />
<br />
== References ==<br />
<br />
# Official GRUB Manual - https://www.gnu.org/software/grub/manual/grub.html<br />
# Ubuntu wiki page for GRUB - https://help.ubuntu.com/community/Grub2<br />
# GRUB wiki page describing steps to compile for UEFI systems - https://help.ubuntu.com/community/UEFIBooting<br />
# Wikipedia's page on [[Wikipedia:BIOS Boot partition|BIOS Boot partition]]<br />
<br />
== See also ==<br />
<br />
# [https://github.com/the-ridikulus-rat/My_Shell_Scripts/blob/master/grub/grub_bios.sh A Linux Bash Shell script to compile and install GRUB for BIOS from BZR Source]<br />
# [https://github.com/the-ridikulus-rat/My_Shell_Scripts/blob/master/grub/grub_uefi.sh A Linux Bash Shell script to compile and install GRUB for UEFI from BZR Source]</div>Apouloshttps://wiki.archlinux.org/index.php?title=Dropbox&diff=247160Dropbox2013-02-13T02:30:17Z<p>Apoulos: </p>
<hr />
<div>[[Category:Internet Applications]]<br />
[[de:Dropbox]]<br />
[[it:Dropbox]]<br />
[[zh-TW:Dropbox]]<br />
[https://www.dropbox.com Dropbox] is a file sharing system that recently introduced a GNU/Linux client. Use it to transparently sync files across computers and architectures. Simply drop files into your {{ic|~/Dropbox}} folder, and they will automatically sync to your centralized repository.<br />
<br />
==Installation==<br />
<br />
{{AUR|dropbox}} can be installed from the [[Arch User Repository|AUR]]. Alternatively, {{AUR|dropbox-experimental}} is also available.<br />
<br />
# After installing the package, you can start Dropbox from your application menu or run {{ic|dropboxd}} from the command-line. The client icon will appear in the system tray.<br />
# A pop-up will notify you that Dropbox is running from an unsupported location. Click on Don't ask again since you know that you have installed it from AUR rather than from the official homepage.<br />
# Eventually a pop-up will ask you to log in to your Dropbox account or create a new account. Enter your credentials.<br />
# After some time you will see a "Welcome to Dropbox" pop-up, which will give you the opportunity to view a short tour of Dropbox.<br />
# Press the "Finish and go to My Dropbox".<br />
<br />
For [[KDE]] users, no further steps are required (it is enough to install the above {{AUR|dropbox}} package from the AUR), as KDE saves running applications when logging out and restarts them automatically. Similarly for [[Xfce]] users, dropbox will be restarted automatically next time you login since the {{ic|dropbox.desktop}} file be placed in {{ic|~/.config/autostart}}.<br />
<br />
===Optional packages===<br />
<br />
*For a command-line interface, install {{AUR|dropbox-cli}} from the [[Arch User Repository|AUR]].<br />
*For integration with Nautilus, install {{AUR|nautilus-dropbox}} from the AUR. The Nautilus plugin will start Dropbox automatically.<br />
*For integration with Nemo, install {{AUR|nemo-dropbox-git}} from the AUR.<br />
*For integration with [[Thunar]], install {{AUR|thunar-dropbox}} from the AUR.<br />
*For [[KDE]] users, there is a KDE client available: {{AUR|kfilebox}} from the AUR.<br />
<br />
===Automatically Starting Dropbox===<br />
<br />
Dropbox can be automatically started by adding {{Ic|dropboxd}} to {{ic|~/.xinitrc}} (or {{ic|~/.config/openbox/autostart}}, depending on your setup). Alternatively, you can [[#Daemon|start it as a daemon]].<br />
<br />
== Alternative to install: use the web interface ==<br />
<br />
If all you need is basic access to the files in your Dropbox, you can use the web interface at https://www.dropbox.com/ to upload and download files to your Dropbox. This can be a viable alternative to running a Dropbox daemon and mirroring all the files on your own machine.<br />
<br />
==Daemon==<br />
{{out of date|This section is outdated and needs to be updated for [[systemd]].}}<br />
<br />
To run Dropbox as a daemon similarly to {{Ic|sshd}} or {{Ic|vsftpd}}, simply do one of the following:<br />
<br />
===dropbox-daemon Method===<br />
<br />
Install {{AUR|dropbox-daemon}}<br />
and configure your username in {{ic|/etc/conf.d/dropboxd.conf}}<br />
<br />
This allows you to start or stop Dropbox just like any other service.<br />
<br />
# /etc/rc.d/dropboxd start<br />
# /etc/rc.d/dropboxd stop<br />
# /etc/rc.d/dropboxd restart<br />
<br />
Place {{Ic|dropboxd}} in the DAEMONS array in {{ic|/etc/rc.conf}} for it to start at boot.:<br />
DAEMONS=(... '''@dropboxd''' ...)<br />
<br />
===Manual Method===<br />
<br />
As root, copy this into a file called {{ic|/etc/rc.d/dropboxd}} and set USER to your username.<br />
<br />
{{bc|<nowiki><br />
#!/bin/bash<br />
<br />
USER=yourusername<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
PID=`pidof -o %PPID /opt/dropbox/dropbox`<br />
<br />
case "$1" in<br />
start)<br />
stat_busy "Starting Dropbox Service"<br />
LANG=$LOCALE<br />
[ -z "$PID" ] && su -c "/usr/bin/dropboxd &" $USER<br />
if [ $? -gt 0 ]; then<br />
stat_fail<br />
else<br />
add_daemon dropboxd<br />
stat_done<br />
fi<br />
;;<br />
stop)<br />
stat_busy "Stopping Dropbox Service"<br />
[ ! -z "$PID" ] && kill $PID > /dev/null<br />
if [ $? -gt 0 ]; then<br />
stat_fail<br />
else<br />
rm_daemon dropboxd<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
sleep 3<br />
$0 start<br />
;;<br />
*)<br />
echo "usage: $0 {start|stop|restart}"<br />
;;<br />
esac<br />
exit 0<br />
</nowiki>}}<br />
<br />
An Organized Way:<br />
{{bc|<nowiki><br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
USER=yourusername<br />
DROPBOXD_PATH='/usr/bin/dropboxd'<br />
DROPBOX_PATH='/opt/dropbox/dropbox'<br />
<br />
PID=`pidof -o %PPID $DROPBOX_PATH`<br />
<br />
case "$1" in<br />
start)<br />
stat_busy "Starting Dropbox Service"<br />
if [ $USER = 'yourusername' ]; then<br />
echo "Please edit /etc/rc.d/dropboxd' 'USER' before using this script."<br />
stat_fail<br />
else<br />
LANG=$LOCALE<br />
[ -z "$PID" ] && su -c "$DROPBOXD_PATH &" $USER<br />
if [ $? -gt 0 ]; then<br />
stat_fail<br />
else<br />
add_daemon dropboxd<br />
stat_done<br />
fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy "Stopping Dropbox Service"<br />
[ ! -z "$PID" ] && kill $PID > /dev/null<br />
if [ $? -gt 0 ]; then<br />
stat_fail<br />
else<br />
rm_daemon dropboxd<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
sleep 3<br />
$0 start<br />
;;<br />
*)<br />
echo "usage: $0 {start|stop|restart}"<br />
;;<br />
esac<br />
exit 0<br />
</nowiki>}}<br />
<br />
Make the file executable with<br />
# chmod +x /etc/rc.d/dropboxd<br />
<br />
This allows you to start or stop {{Ic|dropboxd}} just like any other service. For example:<br />
<br />
# /etc/rc.d/dropboxd start<br />
# /etc/rc.d/dropboxd stop<br />
# /etc/rc.d/dropboxd restart<br />
<br />
To start it at boot, add it to your DAEMONS array in rc.conf: {{ic|/etc/rc.conf}}:<br />
DAEMONS=(... '''@dropboxd''' ...)<br />
<br />
== Systemd ==<br />
<br />
Recent versions of dropbox come with a systemd service file. Simply enable it for your user:-<br />
$ sudo systemctl enable dropbox@<user>.service<br />
<br />
<br />
==Without Nautilus (Another Way)==<br />
<br />
Another way to use Dropbox without Nautilus but with another file manager like Thunar or Pcmanfm is described below:<br />
<br />
1. Create a fake Nautilus script that will launch Thunar:<br />
$ sudo touch /usr/bin/nautilus && sudo chmod +x /usr/bin/nautilus && sudo nano /usr/bin/nautilus<br />
<br />
2. Insert this text into the file, then save and exit:<br />
#!/bin/bash<br />
exec thunar $2<br />
exit 0<br />
<br />
3. Launch Dropbox<br />
$ dropboxd<br />
<br />
4. Click on the Dropbox tray icon to open your Dropbox folder in Thunar.<br />
<br />
{{Note|In this way there is no need to create a Dropbox daemon in {{ic|/etc/rc.d/}} and to start it at boot via {{ic|/etc/rc.conf}} or to make it start via your session manager: just leave the "Start Dropbox on system startup" option flagged in the Preferences window.}}<br />
<br />
{{Note|If you already have Nautilus installed but do not want to use it, don't modify the existing file under {{ic|/usr/bin}}, just change the {{ic|/usr/bin}} for {{ic|/opt/dropbox}} in the step 2 above, like this: {{Ic|$ sudo touch /opt/dropbox/nautilus && sudo chmod +x /opt/dropbox/nautilus && sudo nano /opt/dropbox/nautilus}}. Dropbox will look in this path first!}}<br />
<br />
==Securing Your Dropbox==<br />
<br />
If you want to store sensitive data in your Dropbox, you should encrypt it before. Syncing to Dropbox is encrypted, but all files are (for the time being) stored on the server unencrypted just as you put them in your Dropbox.<br />
<br />
* Dropbox works with [[TrueCrypt]], and after you initially uploaded the TrueCrypt volume to Dropbox, performance is quite okay, because Dropbox has a working binary diff.<br />
<br />
* Another possibility is to use [[EncFS]], which has the advantage that all files are encrypted separately, i.e. you do not have to determine in advance the size of the content you want to encrypt and your encrypted directory grows and shrinks while you add/delete/modify files in it. You can also mount an encrypted volume at startup using the {{ic|-S}} option of {{Ic|encfs}} to avoid having to input the passphrase, but note that your encrypted files are not secure from someone who has direct access to your computer.<br />
<br />
==Multiple Dropbox Instances==<br />
<br />
If you need to separate or distinguish your data, personal and work usage for example, you can subscribe to Dropbox with different email addresses and have multiple directories synced to different instances.<br />
<br />
The basic principle and general how-to are described in the [http://www.dropboxwiki.com/Multiple_Instances_On_Unix Dropbox Wiki].<br />
<br />
{{Note|When dealing with multiple instances you have to select the Dropbox destination folder, which the Dropbox installer asks in the last step; usage examples may be {{ic|/home/dropbox-personal}}, {{ic|/home/dropbox-work}}, and so on.}}<br />
<br />
For convenience, here is a script that I use to accomplish the task: just add a dir in the "dropboxes" list to have another instance of Dropbox, referring to the dir, loaded at script startup.<br />
<br />
{{bc|<nowiki><br />
#!/bin/bash <br />
<br />
#******************************* <br />
# Multiple dropbox instances <br />
#******************************* <br />
<br />
dropboxes=(.dropbox-personal .dropbox-work) <br />
<br />
for dropbox in ${dropboxes[@]} <br />
do <br />
if ! [ -d $HOME/$dropbox ];then <br />
mkdir $HOME/$dropbox <br />
fi <br />
HOME=$HOME/$dropbox/ /usr/bin/dropbox start -i <br />
done <br />
</nowiki>}}<br />
<br />
==Dropbox on Laptops==<br />
<br />
Dropbox itself is pretty good at dealing with connectivity problems. If you have a laptop and roam between different network environments, Dropbox will have problems reconnecting if you do not restart it. The easiest way to solve this with [[netcfg]] is to use POST_UP and PRE_DOWN.<br />
<br />
In every network profile you use (or in the [[Netcfg#Per-interface_configuration]]), add the appropriate commands:<br />
{{bc|<nowiki><br />
POST_UP="any other code; su -c 'DISPLAY=:0 /usr/bin/dropboxd &' your_user"<br />
PRE_DOWN="any other code; killall dropbox"<br />
</nowiki>}}<br />
Obviously, your_user has to be edited and 'any other code;' can be omitted if you do not have any. The above will make sure that Dropbox is running only if there is a network profile active.<br />
<br />
If you have connectivity problem with [[NetworkManager]], [https://bbs.archlinux.org/viewtopic.php?pid=790905, this thread] on forum should be useful.<br />
<br />
==Known Issues==<br />
===Dropbox keeps saying Downloading files===<br />
But in fact now files are synced with your box. This problem is likely to appear when your Dropbox folder is located on a NTFS partition whose mount path contains spaces. See more in the [[https://bbs.archlinux.org/viewtopic.php?id=153368 forums]]. To resolve the problem pay attention to your entry in {{ic|/etc/fstab}}. Avoid spaces in the mount path and set write permissions:<br />
<br />
UUID=01CD2ABB65E17DE0 /run/media/username/Windows ntfs-3g uid=username,gid=users 0 0<br />
<br />
===Change the Dropbox location from the installation wizard===<br />
Some users experience the problem during setting-up Dropbox that they cannot select a Dropbox folder other than {{ic|/home/username/Dropbox}}. In this case when the window for changing the path is shown , hit CTRL+L, enter the location (e.g. /mnt/data/Dropbox) and click on the 'Choose' or 'Open' button.<br />
<br />
===Context menu entries in file manager do not work===<br />
Several file managers such as Thunar, Nautilus or its fork Nemo come with extensions that provide context menu entries for files and folders inside your Dropbox. Most of them will result in a browser action such as opening the file or folder in dropbox.com or sharing the link. If you experience these entries to not working, then you are likely to have not set the {{ic|$BROWSER}} variable which Dropbox requires. You can check that by <br />
<br />
echo $BROWSER<br />
<br />
To set your {{ic|$BROWSER}} variable open {{ic|~/.profile}} and replace {{ic|chromium}} with your default browser:<br />
<br />
if [ -n "$DISPLAY" ]; then<br />
BROWSER=chromium<br />
fi<br />
<br />
===Connecting...===<br />
{{Note|It seems that this issue has been fixed in later versions of dropbox (sometime before 1.6.0-2). It might be reasonable to test before installing one of the following scripts}}<br />
It may happen that Dropbox cannot connect successfully because it was loaded before an Internet connection was established. To solve the problem the content of the file {{ic|/opt/dropbox/dropboxd}} needs to be replaced with the following: <br />
<br />
<br />
#!/bin/sh<br />
<br />
# Copyright 2008 Evenflow, Inc., 2010 Dropbox<br />
#<br />
# Environment script for the dropbox executable.<br />
<br />
start_dropbox() {<br />
PAR=$(dirname $(readlink -f $0))<br />
OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH<br />
LD_LIBRARY_PATH=$PAR:$LD_LIBRARY_PATH <br />
<br />
TMP1=`ps ax|grep dropbox|grep -v grep`<br />
if [ -n "$TMP1" ]; then<br />
kill -9 $(pidof dropbox) >/dev/null 2>&1<br />
fi<br />
exec $PAR/dropbox $@ &<br />
}<br />
<br />
do_dropbox() {<br />
start_dropbox >/dev/null 2>&1<br />
while [ 1 ]; do<br />
sleep 5<br />
ERROR="$(net_test)"<br />
if [ -n "$ERROR" ]; then<br />
LAST_ERROR=1<br />
else<br />
if [ -n "$LAST_ERROR" ]; then<br />
# Connection seems to be up but last cycle was down<br />
LAST_ERROR=""<br />
start_dropbox >/dev/null 2>&1<br />
fi<br />
fi<br />
done<br />
<br />
}<br />
<br />
net_test() {<br />
TMP1="$(ip addr |grep "inet " |grep -v "127.0.0.1")"<br />
[ -z "$TMP1" ] && echo "error"<br />
}<br />
<br />
do_dropbox<br />
<br />
Following is an alternative script that will check for an actual Internet connection by using {{pkg|curl}} to check if any entry in a list of hosts and IP addresses is available.<br />
If none of the specified hosts are available, the script will wait and try again (albeit not forever).<br />
The way the script increments the waiting time is quite messy, but the logic goes like this:<br />
<br />
Start with a wait time of 5 seconds.<br />
<br />
Multiply by 1.5.<br />
<br />
Do this as long as the wait time is less than 1500 seconds (25 minutes), and the check_net()<br />
function returns non-zero values (failure).<br />
<br />
#!/bin/bash<br />
<br />
# Copyright 2008 Evenflow, Inc., 2010 Dropbox<br />
#<br />
# Environment script for the dropbox executable.<br />
<br />
WAIT_TIME=5 #initial time to wait between checking the internet connection<br />
#HOSTS="www.google.com www.wikipedia.org 8.8.8.8 208.67.222.222"<br />
HOSTS="www.google.com www.wikipedia.org "<br />
<br />
PAR=$(dirname $(readlink -f $0))<br />
OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH<br />
LD_LIBRARY_PATH=$PAR${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH<br />
<br />
#non-zero exit code iff none of the hosts could be reached<br />
check_net() {<br />
local ret=1<br />
for i in $HOSTS; do<br />
#ping -w2 -c2 $i > /dev/null 2>&1 && ret=0 && break<br />
curl -o /dev/null $i > /dev/null 2>&1 && ret=0 && break<br />
done<br />
echo $ret<br />
}<br />
<br />
#if dropbox is running; kill it. Then start dropbox<br />
start_dropbox() {<br />
local tmp=`ps ax|grep -E "[0-9] $PAR/dropbox"|grep -v grep`<br />
if [ -n "$tmp" ]; then<br />
kill -9 $(pidof dropbox) > /dev/null 2>&1<br />
fi<br />
exec $PAR/dropbox $@ > /dev/null 2>&1 &<br />
}<br />
<br />
#loop over: start dropbox iff check_net returns 0<br />
#loop (and with it, the entire script) terminates when dropbox has been restarted,<br />
#+ or the waiting time has exeeded 1500 seconds (it grows 50% with each iteration of the loop)<br />
attempt_startup() {<br />
while [ $WAIT_TIME -lt 1500 ] ; do<br />
if [ $(check_net) -eq 0 ]; then<br />
start_dropbox<br />
exit<br />
fi<br />
sleep $WAIT_TIME<br />
#WAIT_TIME=$(($WAIT_TIME+$WAIT_TIME/2))<br />
let "WAIT_TIME += WAIT_TIME/2"<br />
done<br />
}<br />
<br />
start_dropbox<br />
attempt_startup &<br />
<br />
{{Tip|When you update Dropbox via your preferred AUR helper, the file will (usually) be reverted to the default one. You can prevent this with {{ic|chattr +i /opt/dropbox/dropboxd}} which will make the file immutable. To reverse this action simply use {{ic|chattr -i /opt/dropbox/dropboxd}}. }}<br />
<br />
===Dropbox does not start - "This is usually because of a permission error"===<br />
<br />
====Check permissions====<br />
Make sure that you own Dropbox's directories before running the application. This includes<br />
*{{ic|~/.dropbox}} - Dropbox's configuration directory<br />
*{{ic|~/Dropbox}} - Dropbox's download directory (default)<br />
You can ensure this by changing their owner with {{ic|chown -R}}.<br />
<br />
This error could also be caused by {{ic|/var}} being full.<br />
<br />
====Re-linking your account====<br />
[https://www.dropbox.com/help/72 Dropbox's FAQ] suggests that this error may be caused by misconfiguration and is fixed by (re)moving the current configuration folder<br />
# mv ~/.dropbox ~/.dropbox.old<br />
and restarting Dropbox.<br />
<br />
====Errors caused by running out of space====<br />
A common error that might happen is that there is no more available space on your {{ic|/tmp}} and {{ic|/var}} partitions. If this happens, Dropbox will crash on startup with the following error in its log:<br />
{{bc|<br />
Exception: Not a valid FileCache file<br />
}}<br />
A detailed story of such an occurrence can be found in the [https://bbs.archlinux.org/viewtopic.php?pid=973458 forums]. Make sure there is enough space available before launching Dropbox.<br />
<br />
====Locale caused errors====<br />
Try starting {{Ic|dropboxd}} with this code:<br />
<br />
LANG=$LOCALE<br />
dropboxd<br />
<br />
(You can also use a different value for LANG; it must be in the format "en_US.UTF-8")<br />
This helps when running from a Bash script or Bash shell where {{ic|/etc/rc.d/functions}} has been loaded<br />
<br />
====Filesystem monitoring problem====<br />
If you have a lot of files to sync in your Dropbox folder, you might get the following error:<br />
<br />
Unable to monitor filesystem<br />
Please run: echo 100000 | sudo tee /proc/sys/fs/inotify/max_user_watches and restart Dropbox to correct the problem.<br />
<br />
This can be fixed easily by adding<br />
<br />
fs.inotify.max_user_watches = 100000<br />
<br />
to {{ic|/etc/sysctl.conf}} and restarting your computer.<br />
<br />
===Proxy Settings===<br />
The easiest way to set Dropbox's proxy settings is by defining them manually in the Proxies tab of the Preferences window. Alternatively, you can also set it to 'Auto-detect' and then export your proxy server to the http_proxy env variable prior to starting Dropbox (HTTP_PROXY is also usable)<br />
env http_proxy=http://your.proxy.here:port /usr/bin/dropboxd<br />
or<br />
export http_proxy=http://your.proxy.here:port<br />
/usr/bin/dropboxd<br />
<br />
Take note, Dropbox will only use proxy settings of the form http://your.proxy.here:port, not your.proxy.here:port as some other applications do.<br />
<br />
==Alternatives==<br />
*[[Ubuntu One]] - {{Pkg|ubuntuone-client}}<br />
*[https://spideroak.com/ Spider Oak] - {{AUR|spideroak}}<br />
*[http://kdropbox.deuteros.es/ KFileBox] - {{AUR|kfilebox}}<br />
*[https://www.wuala.com/ Wuala] - {{AUR|wuala}}</div>Apouloshttps://wiki.archlinux.org/index.php?title=DansGuardian&diff=244293DansGuardian2013-01-17T20:50:13Z<p>Apoulos: </p>
<hr />
<div>[[Category:Networking]]<br />
{{out of date}}<br />
{{poor writing}}<br />
{{expansion}}<br />
== Preface ==<br />
From the Dansguardian [http://dansguardian.org website].<br />
:::''DansGuardian is an award winning Open Source web content filter which currently runs on Linux, FreeBSD, OpenBSD, NetBSD, Mac OS X, HP-UX, and Solaris. It filters the actual content of pages based on many methods including phrase matching, PICS filtering and URL filtering. It does not purely filter based on a banned list of sites like lesser totally commercial filters.''<br />
<br />
:::''DansGuardian is designed to be completely flexible and allows you to tailor the filtering to your exact needs. It can be as draconian or as unobstructive as you want. The default settings are geared towards what a primary school might want but DansGuardian puts you in control of what you want to block.''<br />
<br />
:::''DansGuardian is a true web content filter. ''<br />
<br />
DansGuardian is excellent at filtering pages from the Internet as it examines both the URL and the content of the page, and it has many options to allow you to fine tune the process. To run DansGuardian, you will first need a proxy in place. DansGuardian will work with many proxy servers, such as [[Polipo]] or [https://aur.archlinux.org/packages.php?ID=11577 tinyproxy], but [[Squid]] is the recommended one.<br />
<br />
The original author of this article runs Squid and DansGuardian content filters at several schools in the UK, successfully blocking inappropriate content.<br />
<br />
== Installation ==<br />
<br />
DansGuardian is available from the AUR, under the name ''dansguardian''.<br />
<br />
This article is based on DansGuardian 2.8.0.6. DansGuardian is hereby referred to as DG.<br />
<br />
== Configuration ==<br />
=== Config Files ===<br />
Assuming you have [[Squid]] already set up, configuring DG is a relatively straightforward process. All of the configuration files, blocking templates, blacklists, etc are stored in {{Ic|/etc/dansguardian}}.<br />
<br />
DG has the concept of groups, which are groups of users or machines that have certain blocks applied to them. For now, we are just going to set up one group for everyone - the idea being that anyone who wants unfiltered access could just hit Squid directly. (This is not ideal.)<br />
<br />
Start by editing {{Ic|/etc/dansguardian/dansguardian.conf}}. The file is pretty well commented so you shouldn't have many problem problems following it through. The defaults are pretty sane. Be sure to check the options under Network Settings for {{Ic|filterip}}, {{Ic|filterport}}, {{Ic|proxyip}} and {{Ic|proxyport}}. You may also want to examine {{Ic|weightedphrasemode}} and {{Ic|phrasefiltermode}}. The filter mode is especially important if you are running this setup on older hardware.<br />
<br />
Next we need to edit the options for our first, and only, group. Edit the file {{Ic|/etc/dansguardian/dansguardianf1.conf}}. Once again this is pretty well commented, but you should pay attention to the {{Ic|naughtynesslimit}}.<br />
<br />
DG examines the content on a page and adds up the naughty words based on a weighting scheme, with worse words getting more points. If this total exceeds the {{Ic|naughtnesslimit}}, the page will be blocked. 50 is a good limit for young children, whereas 160 is good for young adults. In a corporate environment, you'd want this set around 200.<br />
<br />
=== Blacklists ===<br />
<br />
Adding websites to the block lists are done in the same directory, in the almost self-explanatory configuration files. DG provides a powerful regular expression URL and content filter, as well as ordinary URL blocklists. Some of the important files are:<br />
<br />
*bannedsitelist - The domains for your banned sites, e.g. "human-horse-love.com"<br />
*bannedurllist - If you just want to block part of a website, e.g. "bbc.co.uk/games"<br />
*exception* - This is where your domain/URL exceptions go. Sites in this list will not be checked and allowed straight through.<br />
*bannedregexpurllist - Very powerful. This is where you can put regular expressions to block certain URLs, e.g. "(.*q=.*xxx.*)" to stop searching for the word "xxx".<br />
<br />
Whenever you add or remove a URL from the list, you must tell DG you have done so. This can be done with:<br />
dansguardian -r<br />
Which will force DG to reload it's configuration. Doing it this way, rather than restarting the daemon, will mean that for the most part your users won't notice reloading. (I've noticed that straight after the reload, users may have trouble accessing web pages for about 5-10 seconds - if this is a problem you can always run a cronjob at 12am to run {{Ic|dansguardian -r}}).<br />
<br />
You can download a blacklist collection from [http://urlblacklist.com URLBlacklist], but be sure to read the [http://urlblacklist.com/?sec=faq FAQ] first, as you will, paradoxically, want to unsort the collection to enable DG to start faster. Once you have installed the blacklist under {{Ic|/etc/dansguardian}} you can add them to your DG configuration by opening the appropriate configuration file and adding:<br />
.Include</etc/dansguardian/blacklists/ads/domains><br />
.Include</etc/dansguardian/blacklists/drugs/domains><br />
etc...<br />
To the bottom of the file. Take a look around the blacklist collection to see what is available.<br />
<br />
=== "Access Denied" Template ===<br />
<br />
If you wish to change the page that gets displayed to users when a website is blocked, you need to edit the file:<br />
/usr/share/dansguardian/languages/<LANGUAGE>/template.html.<br />
<br />
=== Web Frontend ===<br />
If you would like a web-based frontend to manage Dansguardian, you could use [[Webmin]] with the Dansguardian [http://sourceforge.net/projects/dgwebminmodule/ Webmin Module].<br />
<br />
== Starting DansGuardian ==<br />
<br />
=== systemd ===<br />
Here is the {{ic|/etc/systemd/system/dansguardian.service}} from https://bugzilla.redhat.com/show_bug.cgi?id=772064<br />
{{hc|<br />
/etc/systemd/system/dansguardian.service|<br />
<nowiki><br />
[Unit]<br />
Description=DansGuardian Content Filter<br />
After=network.target<br />
<br />
[Service]<br />
Type=forking<br />
PIDFile=/run/dansguardian.pid<br />
ExecStart=/usr/sbin/dansguardian<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki><br />
}}<br />
<br />
Enable daemon with {{bc|systemctl enable dansguardian}}<br />
<br />
Start daemon with {{bc|systemctl start dansguardian}}<br />
<br />
=== sysvinit ===<br />
Dansguardian needs to start ''after'' your proxy has started, so run:<br />
/etc/rc.d/squid start<br />
/etc/rc.d/dansguardian start<br />
And ensure in your {{Ic|1=DAEMONS=()}} section of rc.conf, that DG starts after squid:<br />
DAEMONS=(... squid dansguardian ...)<br />
Without a valid proxy, DG will fail to start, so you will not want to background Squid. Depending on the size of your blacklists and your hardware, DG can take quite a while to start (30-60 seconds), so you may wish to background DG.<br />
DAEMONS=(... squid @dansguardian ...)</div>Apouloshttps://wiki.archlinux.org/index.php?title=VLC_media_player&diff=243635VLC media player2013-01-12T19:08:21Z<p>Apoulos: </p>
<hr />
<div>[[Category:Player]]<br />
[[ja:VLC media player]]<br />
{{Article summary start}}<br />
{{Article summary text|Installing and configuring the VLC multimedia player.}}<br />
{{Article summary end}}<br />
<br />
[http://www.videolan.org/vlc/ VLC] is a media player by the [http://www.videolan.org/ VideoLAN team] designed to emphasize portability and compatibility. Historically, it was groundbreaking for Linux media software by being the first player to ship with libdvdcss, letting it play encrypted DVDs. This is now a feature that almost all players include, and is no longer an advantage.<br />
<br />
==Installation==<br />
<br />
To install, simply run<br />
{{bc|# pacman -S vlc}}<br />
<br />
If you want to play audio CDs, you should also install {{ic|libcddb}}.<br />
<br />
==Language==<br />
<br />
It seems VLC does not offer an option to change language in its ''Preferences'' menu. But you can use the ''LANGUAGE='' prefix. For instance:<br />
{{bc|<nowiki>$ LANGUAGE=fr vlc %U</nowiki>}}<br />
will switch VLC interface to french.<br />
<br />
==Skins==<br />
<br />
VLC can be "skinned" for a different look and feel. You can obtain new skins for VLC from http://www.videolan.org/vlc/skins.php.<br />
<br />
Installation of skins is simple just download the skin you wish to use and copy it to:<br />
{{bc|~/.local/share/vlc/skins2}}<br />
Open up VLC, click tools->preferences. When the preferences window opens up you should be in the "Interface" tab<br />
<br />
Choose the "Use custom skin" radio button, and browse to the location of the downloaded skin.<br />
<br />
Restart VLC for the change to take effect.<br />
<br />
==Web Interface==<br />
<br />
Run VLC with the parameter "--extraintf=http" to use both the desktop and web interface. <br />
# vlc --extraintf=http<br />
<br />
Or you can enable this feature in the UI by navigating to "View" > "Add Interface" > "Web Interface".<br />
<br />
VLC defaults to port 8080: http://127.0.0.1:8080<br />
<br />
Edit /usr/share/vlc/lua/http/.hosts to allow remote connections. You will need to restart VLC in order for changes to take effect.<br />
<br />
==Control using hotkeys or cli==<br />
<br />
install {{ic|netcat-openbsd}}<br />
<br />
Get script at: http://crunchbang.org/forums/viewtopic.php?pid=112035%23p112035#p112035<br />
<br />
Follow instructions in script to setup a socket for vlc.<br />
<br />
Either run the script from the command line or register the script with keyboard shortcuts through your desktop. <br />
<br />
==Preventing multiple instances==<br />
<br />
The default settings for VLC is to open a new instance of the program for each file that is opened. This can be annoying if you are using VLC for something like playing your music collection. To remedy the problem you can do the following:<br />
<br />
#Open VLC<br />
#Go to Tools -> Preferences (Ctrl+P)<br />
#Go to the Interface tab and find the "Instances" section.<br />
#Tick "Allow only one instance"<br />
#Optionally tick "Enqueue files when in one instance mode" - This will keep the current file playing and add any newly opened files to the current playlist.<br />
<br />
==Troubleshooting==<br />
<br />
===PulseAudio Lag===<br />
When using PulseAudio as the audio output module, you might encounter audio/video sync problems. These problems can usually be [https://bbs.archlinux.org/viewtopic.php?pid=1101711#p1101711 fixed] by editing {{ic|/etc/pulse/default.pa}} or {{ic| ~/.pulse/default.pa}} to reflect the following changes.<br />
{{bc|1=.ifexists module-udev-detect.so<br />
load-module module-udev-detect '''tsched=0'''<br />
.else}}<br />
'''Update on this bug as of November 17th, 2012:''' It appears that the bug causing the audio lag between PulseAudio and VLC has been fixed upstream, so the above fix is not required. In fact, this fix might even cause a lag to occur, so remove {{ic|1='''tsched=0'''}}, if you had applied this fix.<br />
<br />
===Video broken or other issue after upgrade===<br />
Now and then VLC will have some issues with configuration even in minor releases. Before making bug reports, remove or rename your configuration located at {{ic|~/.config/vlc}} and confirm whether the issue is still there.<br />
<br />
==See also==<br />
*[[Common Applications#Multimedia]]<br />
*[http://www.videolan.org/vlc/ VLC homepage]<br />
*[http://wiki.videolan.org/Control_VLC_via_a_browser Control VLC via a browser]</div>Apouloshttps://wiki.archlinux.org/index.php?title=LIRC&diff=243275LIRC2013-01-09T00:01:01Z<p>Apoulos: </p>
<hr />
<div>[[Category:Other hardware]]<br />
[[Category:Audio/Video]]<br />
{{Article summary start}}<br />
{{Article summary text|This article covers using LIRC with serial or USB infrared devices.}}<br />
{{Article summary end}}<br />
<br />
[http://lirc.org/ LIRC] stands for "Linux Infrared Remote Control", a program to use infrared devices (like your remote control from your TV) with linux.<br />
<br />
==Supported hardware==<br />
<br />
First of all, check the [http://lirc.org/html/table.html official list of supported hardware]. Check the table to know, which LIRC kernel modules and lircd driver required for your infrared receiver.<br />
<br />
==Installation==<br />
<br />
[[pacman|Install]] the {{Pkg|lirc-utils}} package, which is available in the [[Official Repositories|official repositories]].<br />
<br />
The most of LIRC kernel drivers are already included in the mainline kernel. You need to install {{Pkg|lirc}} package only, if your hardware requires lirc_atiusb, lirc_i2c or lirc_wpc8769l modules.<br />
<br />
==Serial receivers==<br />
<br />
===Serial receivers that depend on lirc_serial===<br />
<br />
Make sure that your serial port is activated in the BIOS. There you can also set and lookup I/O address and IRQ settings of your ports.<br />
<br />
Now there might be a problem: the module lirc_serial is build to use ttyS0 (COM1), if your device is not connected to ttyS0, you will have to either change the module-options or [[LIRC#Building_the_LIRC_serial_module_for_another_ttySx|rebuild the LIRC module]]. If your device is connected to ttyS0, you can [[LIRC#Loading|skip this step]]<br />
<br />
To change the options for the lirc_serial module, you edit {{ic|/etc/modprobe.d/modprobe.conf}} and add this line:<br />
<br />
options lirc_serial io=0x2f8 irq=3<br />
<br />
You should change the values after io and irq to reflect you serial port settings, the values above may work for you if you are using ttyS1 (COM2) to connect your IR-device. But you will find the correct values by checking dmesg:<br />
<br />
$ dmesg | grep ttyS<br />
<br />
===Other serial receivers===<br />
<br />
See [[LIRC#Other_receivers]]<br />
<br />
===Building the lirc_serial module for another ttySx===<br />
<br />
Update abs<br />
<br />
# abs<br />
<br />
Copy the LIRC files to a directory you choose yourself:<br />
<br />
$ cp /var/abs/extra/system/lirc /some/dir<br />
<br />
$ cd /some/dir<br />
<br />
Edit the PKGBUILD in that directory.<br />
<br />
Replace the line:<br />
<br />
./configure --enable-sandboxed --prefix=/usr \<br />
--with-driver=all \\<br />
return 1[/code]<br />
<br />
with:<br />
<br />
./configure --enable-sandboxed --prefix=/usr \<br />
--with-driver=com2 \<br />
|| return 1[/code]<br />
<br />
Where you replace com2 with the com-port you need.<br />
<br />
Build and install the package:<br />
<br />
$ makepkg<br />
# pacman -U lirc-version.pkg.tar.gz<br />
<br />
===Loading===<br />
<br />
Now try to load the serial module:<br />
<br />
# modprobe lirc_serial<br />
<br />
If this produces an error which says your serial port is not ready, you have the problem that your serial port support is build into the kernel and not as a module (in the default arch kernel it is build into the kernel)<br />
<br />
If it is built into the kernel you will have to do the following (remember that it is built into the kernel, you will need to make some changes later too)<br />
<br />
You will have to release the serial port:<br />
<br />
# setserial /dev/ttySx uart none<br />
<br />
(Replace x with your port number)<br />
<br />
Load the module again:<br />
<br />
# modprobe lirc_serial<br />
<br />
Now it should not show any errors, and the modules lirc_serial should be listed in lsmod<br />
<br />
==USB receivers including most onboard devices==<br />
This outlines the general procedure, the mceusb module which is used by many devices is used as an example.<br />
<br />
# modprobe mceusb<br />
<br />
Start the LIRC daemon:<br />
<br />
$ /etc/rc.d/lircd start<br />
<br />
Test it with irw, it will output the commands received by the IR receiver that match your {{ic|lircd.conf}} file. So start irw, point your remote and start pressing buttons. <br />
<br />
$ irw<br />
000000037ff07bfe 00 One mceusb<br />
000000037ff07bfd 00 Two mceusb<br />
000000037ff07bfd 01 Two mceusb<br />
000000037ff07bf2 00 Home mceusb<br />
000000037ff07bf2 01 Home mceusb<br />
<br />
The above procedure however has been simplified and may not work that easily. One of the reasons the lircd daemon may not be working is because it expects to be run at startup and needs root permissions because it will create device nodes in {{ic|/dev}}. Try "man lircd" for more information.<br />
<br />
Continue with [[#Making a configuration file]]<br />
<br />
=== Setup a HID device with LIRC ===<br />
Some remotes are supported in the kernel where they are treated as a keyboard and mouse. Every button on the device is recognized as keyboard or mouse events which can be used even without LIRC. LIRC can still be used with these devices to gain greater control over the events raised and integrate with programs that expect a LIRC remote rather than a keyboard. As drivers are migrated to the kernel, devices which use to only be useable through LIRC with their own {{ic|lirc.conf}} files become standard HID devices.<br />
<br />
Some HID remotes actually simulate a USB infrared keyboard and mouse. These remotes show up as two devices so you need to add two LIRC devices to {{ic|lircd.conf}}.<br />
<br />
First we need the {{ic|/dev/input}} device for our remote:<br />
<br />
$ ls /sys/class/rc/rc0<br />
<br />
One of the files should be input''#'', where the number matches the event''#'' of the device. (To clarify you can check that directory, it will have an event''#'' file.<br />
<br />
{{Note|If you have more than one ir device then there may be multiple directories under {{ic|/sys/class/rc}}. Under event''#'' {{ic|cat name}} to verify which device you are looking at.}}<br />
<br />
then go to {{ic|/dev/input/by-id}}<br />
<br />
$ ls -l /dev/input/by-id<br />
<br />
You should find a file that symlinks to the input''#'' above, and possibly others with a similar names for mouse events.<br />
<br />
lrwxrwxrwx 1 root root 9 10月 14 06:43 usb-3353_3713-event-if00 -> ../event9<br />
lrwxrwxrwx 1 root root 10 10月 14 06:43 usb-3353_3713-event-if01 -> ../event10<br />
<br />
Here 'usb-3353_3713-event-if00' and 'usb-3353_3713-event-if01' are the Linux input device event for our HID device, one for the keyboard, another for the mouse.<br />
<br />
Then, we need to edit {{ic|/etc/conf.d/lircd.conf}}. This file contains the parameters for LIRC daemon<br />
<br />
#<br />
#Parameters for daemon<br />
#<br />
<br />
LIRC_DEVICE="/dev/input/by-id/usb-3353_3713-event-if00"<br />
LIRC_DRIVER="devinput"<br />
LIRC_EXTRAOPS=""<br />
LIRC_CONFIGFILE="/etc/lirc/lircd.conf"<br />
<br />
{{Note|Here we set up a LIRC device with the id 3353_3713, you should replace it with your own device input event name, whatever it is.}}<br />
<br />
The latest version of the config file for HID remotes exists in the LIRC git repository [http://lirc.git.sourceforge.net/git/gitweb.cgi?p=lirc/lirc;a=blob_plain;f=remotes/devinput/lircd.conf.devinput;hb=HEAD]. Simply save it as {{ic|/etc/lirc/lircd.conf}}.<br />
<br />
In order to launch the LIRC daemon for HID remote, You must enable evdev module first<br />
# modprobe evdev<br />
<br />
{{Note|LIRC 0.8.6 has changed the default socket location from {{ic|/dev/lircd}} to {{ic|/var/run/lirc/lircd}}, but many applications still look for the socket in the old location. Since lirc-utils 0.8.6-3 the {{ic|/etc/rc.d/lircd}} script creates a symlink from {{ic|/dev/lircd}} to the {{ic|/var/run/lirc/lircd}} socket when it starts the lircd daemon and removes the link when the daemon is stopped.}}<br />
<br />
==Other receivers==<br />
<br />
There are many receivers that do not need any kernel module at all. This applies to any type of receiver, including serial receivers and usb receivers. Check the next link to see what kernel modules you need to load, if any:<br />
<br />
[http://www.lirc.org/html/table.html LIRC supported devices]<br />
<br />
==Checking module based receivers==<br />
<br />
''NOTE: This section only applies if your device requires a lirc_[driver] kernel module.''<br />
<br />
Before you start using lirc, you should check if your receiver is working, and if there is IR interference. Possible sources of interference include monitors/televisions (especially plasma displays), fluorescent lamps and direct or ambient sunlight. Start the following command to display raw receiver input.<br />
<br />
# mode2 -d /dev/lirc0 <br />
<br />
If you press buttons on any IR remote, you should see a series of pulses and spaces. If there is very frequent output without pressing buttons on your remote, your receiver suffers from interference. You want to avoid such interference, e.g. by placing the receiver behind or under your plasma tv.<br />
<br />
If you can't make out where the interference is coming from, you can try to put a cardboard roll right in front of the receiving diode, so that it only gets light from a specific direction. Invoke mode2 as above. Then point at different locations till you receive IR noise.<br />
<br />
==LIRC daemon configuration==<br />
<br />
The lircd configuration lives under /etc/conf.d/lircd.conf, and it is all you need to setup your device if it does not require any special kernel module.<br />
<br />
{{Box|IMPORTANT:|lirc-utils package on ArchLinux has a bug. You will have to create your own systemd unit or find another workaround. See [https://bugs.archlinux.org/task/31890 bug#31890] |#DF0000|#FFDFDF}}<br />
<br />
==Making a configuration file==<br />
<br />
You need a configuration file for your remote control copied or symlinked to {{ic|/etc/lirc/lircd.conf}}. A number of devices have already been included with the lirc package, they can be found in {{ic|/usr/share/lirc/remotes}}. If your specific device is not included, the LIRC site offers configuration files for a large number of extra [http://lirc.sourceforge.net/remotes/ devices].<br />
<br />
If your device does not already have a config file, you can create it yourself with the following command. You should avoid interference (see above) while creating the config file. <br />
<br />
# irrecord -d /dev/lirc0 /tmp/my_remote<br />
<br />
Just follow the instructions. To get a list of valid button names, refer to the output of<br />
# irrecord --list-namespace<br />
The resulting file, {{ic|/tmp/my_remote}}, should then be copied to {{ic|/etc/lirc/lircd.conf}}. If you want to use several remotes, you repeat the irrecord step with each remote and different filenames, and then concatenate all the resulting files into {{ic|/etc/lirc/lircd.conf}}:<br />
<br />
# cat /tmp/my_remote /tmp/my_remote2 /tmp/my_remote3 > /etc/lirc/lircd.conf<br />
<br />
{{Note|As of lirc-0.8.6 the default location of lircd, lircmd and lircrcd config files was moved to {{ic|/etc/lirc/lircd.conf}}, {{ic|/etc/lirc/lircmd.conf}} and {{ic|/etc/lirc/lircrc}}. If the config files are not found in that location, they are still searched at the old location in {{ic|/etc/.}}}}<br />
<br />
===Testing===<br />
<br />
First start the lircd daemon:<br />
<br />
# /etc/rc.d/lircd start<br />
<br />
A good way to see if LIRC is running is to run irw.<br />
<br />
$ irw<br />
<br />
When you press a button, you should see something like this:<br />
<br />
0000000000000001 00 play sony2<br />
0000000000000001 01 play sony2<br />
0000000000000001 02 play sony2<br />
0000000000000001 03 play sony2<br />
<br />
In this case the remote is called sony2, the button is called play, and LIRC has seen it 4 times.<br />
<br />
==Run LIRC at bootup==<br />
<br />
Remember if you had to execute the setserial command while [[LIRC#Loading|loading]] the module?<br />
<br />
If so, [[LIRC#Your serial port support is compiled into the kernel|your serial port support is compiled into the kernel]]<br />
<br />
===Your serial port support is compiled as a module in the kernel===<br />
<br />
This is rather easy: you will just have to add lirc_serial to the modules list and lircd to the daemons list in {{ic|/etc/rc.conf}}<br />
<br />
===Your serial port support is compiled into the kernel===<br />
<br />
This is more complicated, you cannot just add the lirc_serial to the modules list in {{ic|/etc/rc.conf}}, as the serial port should be released first.<br />
<br />
So I created a custom startup script to fix this problem.<br />
<br />
{{hc|/etc/rc.d/start_lirc|<nowiki><br />
#!/bin/bash<br />
#/etc/rc.d/start_lirc<br />
#releases ttySx and loads lirc_serial module<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy "release ttySx"<br />
setserial /dev/ttySx uart none<br />
#load lirc module<br />
modprobe lirc_serial<br />
stat_done<br />
;;<br />
stop)<br />
stat_busy "unload lirc module"<br />
rmmod lirc_serial<br />
stat_done<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "usage: $0 {start|stop|restart}"<br />
esac<br />
exit 0<br />
</nowiki>}}<br />
<br />
Now load the daemons: add "start_lirc" and "lircd" to the daemons list in {{ic|/etc/rc.conf}}<br />
<br />
==Program specific configuration==<br />
<br />
===Generate your own lircrc with Mythbuntu's lircrc-generator===<br />
<br />
'''mythbuntu-lircrc-generator''' is intended to be started from a system with LIRC installed. It requires that you choose a remote via the LIRC package or have a {{ic|lircd.conf}} handy prior to running. It will then produce a sane {{ic|.lircrc}} for the current user.<br />
<br />
[https://aur.archlinux.org/packages.php?ID=33849 Mythbuntu's Lirc/Lircrc Generator is available on AUR]<br/><br />
[http://manpages.ubuntu.com/manpages/intrepid/man1/mythbuntu-lirc-generator.1.html Man page]<br />
<br />
===Enable LIRC support in xine===<br />
<br />
Now LIRC works, but you have no program that can communicate with LIRC. This section will explain how to make xine work, but you can use xmms and mplayer (and probably a lot of other programs too) to work with LIRC.<br />
<br />
====Compile xine with LIRC support====<br />
Download the xine-ui PKGBUILD with [https://wiki.archlinux.org/index.php/Arch_Build_System ABS].<br />
<br />
Add " --enable-lirc" to the {{ic|./configure}} line<br />
<br />
Compile:<br />
<br />
$ makepkg<br />
<br />
Uninstall old xine-ui and install the new one<br />
<br />
# pacman -R xine-ui<br />
# pacman -U xine-filename.pkg.tar.gz<br />
<br />
====Configure xine to use LIRC====<br />
<br />
Let xine produce a default {{ic|.lircrc}} file. In your home directory, type:<br />
<br />
$ xine --keymap=lirc>.lircrc<br />
<br />
Now, in order to have a functioning xine+lirc, edit the {{ic|.lircrc}} file to your preferences.<br />
<br />
However, you may choose to configure LIRC to control more than just xine. If this is the case, you will need to manually edit the {{ic|.lircrc}} file, and add elements. <br />
<br />
Xine-ui<br />
Mplayer<br />
Totem<br />
Vlc<br />
Rhythmbox <br />
<br />
All work with LIRC, but you must enable LIRC support in the program in some cases, such as VLC. Simply copy the vlc packagebuild and edit it so that "--enable-lirc" is one of the compile options for VLC not FFMPEG!<br />
<br />
===Configure Amarok2 to use LIRC===<br />
<br />
Depending on your controller model, the following configuration works with Amarok2-svn. This configuration file will work with the MCEUSB controller.<br />
<br />
{{hc|~/.lircrc|2=##amarok2<br />
<br />
begin<br />
button = Play<br />
prog = irexec<br />
repeat = 0<br />
config = qdbus org.mpris.amarok /Player Play<br />
end<br />
<br />
begin<br />
button = Pause<br />
prog = irexec<br />
repeat = 0<br />
config = qdbus org.mpris.amarok /Player Pause<br />
end<br />
<br />
begin<br />
button = Stop<br />
prog = irexec<br />
repeat = 0<br />
config = qdbus org.mpris.amarok /Player Stop<br />
end<br />
<br />
begin<br />
button = Skip<br />
prog = irexec<br />
repeat = 0<br />
config = qdbus org.mpris.amarok /Player Next<br />
end<br />
<br />
begin<br />
button = Replay<br />
prog = irexec<br />
repeat = 0<br />
config = qdbus org.mpris.amarok /Player Prev<br />
end}}<br />
<br />
===Configure Audacious(2) to use LIRC===<br />
Depending on your controller model, the following configuration works with all versions of Audacious, including the mercurial builds. This configuration file will work with the MCEUSB controller.<br />
<br />
{{hc|~/.lircrc|2=##audacious<br />
<br />
begin<br />
prog = audacious<br />
button = Play<br />
config = PLAY<br />
repeat = 0<br />
end<br />
<br />
begin<br />
prog = audacious<br />
button = Pause<br />
config = PAUSE<br />
repeat = 0<br />
end<br />
<br />
begin<br />
prog = audacious<br />
button = Stop<br />
config = STOP<br />
repeat = 0<br />
end<br />
<br />
begin<br />
prog = audacious<br />
button = Skip<br />
config = NEXT<br />
repeat = 0<br />
end<br />
<br />
begin<br />
prog = audacious<br />
button = Replay<br />
config = PREV<br />
repeat = 0<br />
end<br />
<br />
begin<br />
prog = audacious<br />
button = VolUp<br />
config = VOL_UP<br />
repeat = 1<br />
end<br />
<br />
begin<br />
prog = audacious<br />
button = VolDown<br />
config = VOL_DOWN<br />
repeat = 1<br />
end}}<br />
<br />
Additionally, there are other values that may be set according to the model set forth above. This was taken from the lirc.c file from audacious-plugins source code:<br />
<br />
{{hc|lirc.c|PLAY<br />
STOP<br />
PAUSE<br />
PLAYPAUSE<br />
NEXT<br />
PREV<br />
SHUFFLE<br />
REPEAT<br />
FWD<br />
BWD<br />
VOL_UP<br />
VOL_DOWN<br />
QUIT<br />
MUTE<br />
BAL_LEFT<br />
BAL_RIGHT<br />
BAL_CENTER<br />
LIST<br />
PLAYLIST_CLEAR<br />
PLAYLIST_ADD}}<br />
<br />
===Configure Mplayer to use LIRC===<br />
<br />
{{hc|~/.lircrc|2=##mplayer<br />
<br />
begin<br />
button = PLAY/PAUSE<br />
prog = mplayer<br />
config = pause<br />
repeat = 1<br />
end<br />
begin<br />
button = FWD<br />
prog = mplayer<br />
config = seek 5<br />
end<br />
begin<br />
button = REV<br />
prog = mplayer<br />
config = seek -5<br />
end<br />
begin<br />
button = MAXIMIZE<br />
prog = mplayer<br />
config = vo_fullscreen<br />
end<br />
}}<br />
<br />
only change PLAY/PAUSE, FWD etc. on keys from your /etc/lircd.conf<br />
<br />
==Device Specific Examples==<br />
=== X10 ===<br />
There is a dedicated wiki page with information about [[X10]]<br />
<br />
===Asus DH Deluxe series motherboard===<br />
Check the output of:<br />
{{bc|$ cat /dev/usb/hiddevX}}<br />
<br />
where X is 0,1 or bigger, and press some buttons on remote.<br />
If you can see reply, device works fine, follow steps:<br><br />
<br />
1. In file {{ic|/etc/conf.d/lircd.conf}} add:<br><br />
{{bc|1=LIRC_DRIVER="dvico"}}<br />
2. Reload LIRC: <br />
{{bc|/etc/rc.d/lircd restart}}<br />
<br />
===ASRock ION series (Nuvoton) quickstart===<br />
<br />
$ ln -s /usr/share/lirc/remotes/lirc_wb677/lircd.conf.wb677 /etc/lirc/lircd.conf<br />
$ /etc/rc.d/lircd restart<br />
<br />
===Streamzap PC Remote (USB)===<br />
{{Note|Xorg now auto recognizes this remote as a keybaord!}} <br />
To disable this behavior, add the following to {{ic|/etc/X11/xorg.conf.d/90-streamzap.conf}}:<br />
{{bc|Section "InputClass"<br />
Identifier "Ignore Streamzap IR"<br />
MatchProduct "Streamzap"<br />
MatchIsKeyboard "true"<br />
Option "Ignore" "true"<br />
EndSection}}<br />
<br />
#Install both packages (lirc lirc-utils)<br />
#Modprobe both kernel mods (lirc_dev and streamzap) (add these to your MODULES array in {{ic|/etc/rc.conf}} to survive a reboot)<br />
#Create your {{ic|/etc/lirc/lircd.conf}} (for this remote, copy {{ic|/usr/share/lirc/remotes/streamzap/lircd.conf.streamzap}} to {{ic|/etc/lirc/lircd.conf}})<br />
#Start lircd via /etc/rc.d/lircd start (add lircd to your DAEMONS array in {{ic|/etc/rc.conf}} to survive a reboot)<br />
#Test the remote/lirc with irw<br />
<br />
$ irw<br />
00000000000028cc 00 CH_UP Streamzap_PC_Remote<br />
00000000000028ce 00 CH_DOWN Streamzap_PC_Remote<br />
00000000000028c8 00 8 Streamzap_PC_Remote<br />
00000000000028c5 00 5 Streamzap_PC_Remote<br />
00000000000028d2 00 OK Streamzap_PC_Remote<br />
00000000000028d1 00 LEFT Streamzap_PC_Remote<br />
00000000000028d1 01 LEFT Streamzap_PC_Remote<br />
00000000000028d1 00 LEFT Streamzap_PC_Remote<br />
00000000000028d3 00 RIGHT Streamzap_PC_Remote<br />
00000000000028d3 00 RIGHT Streamzap_PC_Remote<br />
00000000000028d3 00 RIGHT Streamzap_PC_Remote<br />
00000000000028d3 00 RIGHT Streamzap_PC_Remote<br />
00000000000028d4 00 DOWN Streamzap_PC_Remote<br />
00000000000028d4 00 DOWN Streamzap_PC_Remote<br />
00000000000028d4 00 DOWN Streamzap_PC_Remote<br />
<br />
{{Note|When the batteries in this remote are low, it may stop working even though the red LED on the received still flashes when you hit buttons!}}<br />
<br />
<br />
=== Serial Port "Home Brew" IR Receiver ===<br />
Here's how to get a "Home Brew" serial port IR receiver working:<br />
<br />
1. Create a udev rule to give non-privleged users read/write access to the serial port. I will be using ttyS0 in my example.<br />
{{hc|/etc/udev/rules.d/z98-serial.rules|<br />
# For serial port ttyS0 and LIRC<br />
KERNEL&#61;&#61;"ttyS0",SUBSYSTEM&#61;&#61;"tty",DRIVERS&#61;&#61;"serial",MODE&#61;"0666"}}<br />
<br />
2. Create the needed modprobe configs<br />
{{hc|/etc/modules-load.d/lirc_serial.conf|lirc_serial}}<br />
{{hc|/etc/modprobe.d/lirc_serial.conf|install lirc_serial /usr/bin/setserial /dev/ttyS0 uart none && /sbin/modprobe --first-time --ignore-install lirc_serial<br />
options lirc_serial type&#61;0<br />
remove lirc_serial /sbin/modprobe -r --first-time --ignore-remove lirc_serial && /sbin/modprobe -r lirc_dev}}<br />
{{Note|Using [[udev]] rules to run the setserial command does not work in my experience because lirc_serial gets loaded before the serial port rules are applied.}}<br />
<br />
3. Install your systemd service file.<br />
{{hc|/etc/systemd/system/lirc.service|[Unit]<br />
Description&#61;Linux Infrared Remote Control<br />
After&#61;network.target<br />
<br />
[Service]<br />
Type&#61;simple<br />
PIDFile&#61;/run/lirc/lircd.pid<br />
ExecStartPre&#61;/bin/rm -f /dev/lirc /dev/lircd /var/run/lirc/lircd<br />
ExecStart&#61;/usr/sbin/lircd -n -r -P /run/lirc/lircd.pid -d /dev/lirc0 -o /run/lirc/lircd<br />
ExecStartPost&#61;/usr/bin/ln -sf /run/lirc/lircd /dev/lircd<br />
ExecStartPost&#61;/usr/bin/ln -sf /dev/lirc0 /dev/lirc<br />
ExecReload&#61;/bin/kill -SIGHUP $MAINPID<br />
<br />
[Install]<br />
WantedBy&#61;multi-user.target}}<br />
<br />
4. We still need the default tmpfiles to be created, so copy that config file to {{ic|/etc/tmpfiles.d/lirc.conf}}.<br />
{{bc|# cp -a /usr/lib/tmpfiles.d/lirc.conf /etc/tmpfiles.d/lirc.conf}}<br />
<br />
5. Create a {{ic|.lircrc}} file in your home directory for your user or a {{ic|/etc/lirc/lircrc}} file for system wide use.<br />
<br />
6. Have your service start at boot and then test with a reboot<br />
{{bc|1=# systemctl enable lirc.service<br />
# systemctl reboot}}<br />
<br />
or load the module and start the lirc.service.<br />
{{bc|# modprobe lirc_serial<br />
# systemctl start lirc.service}}<br />
<br />
=== Receivers that do not depend on a kernel module ===<br />
<br />
Usually, you only need to specify your the device where the receiver is plugged in and the lirc driver. This is an example for pinnacle or miro serial receivers):<br />
<br />
LIRC_DEVICE="/dev/ttySX"<br />
LIRC_DRIVER="pinsys"<br />
<br />
Then, start lircd daemon and create the remote/s configuration (/etc/lirc/lircd.conf), either by copying one of the configured defaults that comes with lirc-utils or by using irrecord. Even if you find your remote in the list of preconfigured remotes it might not work so you will have to use irrecord anyway.<br />
<br />
After this you can use irw to check the remote, create your ~/.lircrc to assign remote buttons to actions and start irexec if you need to run arbitrary commands.<br />
<br />
==Troubleshooting==<br />
<br />
===Buttons processed several times when pressed===<br />
Problem in module ir_core which processes IR commands with LIRC at the same time. Simply blacklist it by creating the following file:<br />
<br />
{{hc|/etc/modprobe.d/remote_blacklist.conf|<br />
# Prevent processing button several times when pressed<br />
blacklist ir_core<br />
}}<br />
<br />
===After upgrading or installing Arch, an existing configuration stopped working===<br />
====Kernel module change====<br />
As of kernel 2.6.36, LIRC modules have been included in the kernel. Arch's ''lirc'' package has included the older kernel modules, which work with ''lircd'' without any additional configuration. However, a recent update removed those older modules, which results in the stock kernel modules being used. Unfortunately, these kernel modules treat the remote as a keyboard by default, which is incompatible for lircd. To correct this, put the following line to {{ic|/etc/rc.local}}:<br />
{{hc|/etc/rc.local|echo lirc > /sys/class/rc/rc0/protocols}}<br />
<br />
You may also run that command as root to enable LIRC for your current session.<br />
<br />
Systemd has moved away from {{ic|rc.local}}. It is possible to use tmpfiles.d (read "man tmpfiles.d") to run the command {{ic|echo lirc > /sys/class/rc/rc0/protocols}}. Create the file {{ic|/etc/tmpfiles.d/lirc-protocols.conf}}:<br />
{{hc|/etc/tmpfiles.d/lirc-protocols.conf|<nowiki><br />
w /sys/class/rc/rc0/protocols - - - - lirc<br />
</nowiki>}}<br />
<br />
{{Note|It is also a good idea to remove the old LIRC kernel module from your MODULES array in {{ic|/etc/rc.conf}}, as it is no longer present.}}<br />
<br />
=== Problems using default systemd lirc.service file ===<br />
<br />
There is a bug in lirc-utils that makes lirc.service ignore /etc/conf.d/lircd.conf. See [[https://bugs.archlinux.org/task/31890 FS#31890]]<br />
<br />
{{ic|/var/log/lirc}} shows error finding /dev/lirc:<br />
{{bc|lircd: could not get file information for /dev/lirc}}<br />
<br />
Workaround: make a symbolic link for /dev/lirc that points to /dev/lirc0 with file {{hc|/etc/tmpfiles.d/lirc-dev.conf|<nowiki><br />
L /dev/lirc - - - - /dev/lirc0<br />
</nowiki>}}<br />
<br />
==See also==<br />
* http://www.mythtv.org/wiki/Category:Remote_Controls -- MythTV wiki main LIRC article<br />
* http://www.mythtv.org/wiki/MCE_Remote -- MythTV wiki on MCE remotes <br />
* http://en.gentoo-wiki.com/wiki/LIRC -- Gentoo wiki LIRC how-to<br />
* https://aur.archlinux.org/packages.php?ID=33849 -- Lirc/Lircrc Configuration Generator</div>Apouloshttps://wiki.archlinux.org/index.php?title=LIRC&diff=242927LIRC2013-01-04T03:45:45Z<p>Apoulos: </p>
<hr />
<div>[[Category:Other hardware]]<br />
[[Category:Audio/Video]]<br />
{{Article summary start}}<br />
{{Article summary text|This article covers using LIRC with serial or USB infrared devices.}}<br />
{{Article summary end}}<br />
<br />
[http://lirc.org/ LIRC] stands for "Linux Infrared Remote Control", a program to use infrared devices (like your remote control from your TV) with linux.<br />
<br />
==Supported hardware==<br />
<br />
First of all, check the [http://lirc.org/html/table.html official list of supported hardware]. Check the table to know, which LIRC kernel modules and lircd driver required for your infrared receiver.<br />
<br />
==Installation==<br />
<br />
[[pacman|Install]] the {{Pkg|lirc-utils}} package, which is available in the [[Official Repositories|official repositories]].<br />
<br />
The most of LIRC kernel drivers are already included in the mainline kernel. You need to install {{Pkg|lirc}} package only, if your hardware requires lirc_atiusb, lirc_i2c or lirc_wpc8769l modules.<br />
<br />
==Serial receivers==<br />
<br />
===Serial receivers that depend on lirc_serial===<br />
<br />
Make sure that your serial port is activated in the BIOS. There you can also set and lookup I/O address and IRQ settings of your ports.<br />
<br />
Now there might be a problem: the module lirc_serial is build to use ttyS0 (COM1), if your device is not connected to ttyS0, you will have to either change the module-options or [[LIRC#Building_the_LIRC_serial_module_for_another_ttySx|rebuild the LIRC module]]. If your device is connected to ttyS0, you can [[LIRC#Loading|skip this step]]<br />
<br />
To change the options for the lirc_serial module, you edit {{ic|/etc/modprobe.d/modprobe.conf}} and add this line:<br />
<br />
options lirc_serial io=0x2f8 irq=3<br />
<br />
You should change the values after io and irq to reflect you serial port settings, the values above may work for you if you are using ttyS1 (COM2) to connect your IR-device. But you will find the correct values by checking dmesg:<br />
<br />
$ dmesg | grep ttyS<br />
<br />
===Other serial receivers===<br />
<br />
See [[LIRC#Other_receivers]]<br />
<br />
===Building the lirc_serial module for another ttySx===<br />
<br />
Update abs<br />
<br />
# abs<br />
<br />
Copy the LIRC files to a directory you choose yourself:<br />
<br />
$ cp /var/abs/extra/system/lirc /some/dir<br />
<br />
$ cd /some/dir<br />
<br />
Edit the PKGBUILD in that directory.<br />
<br />
Replace the line:<br />
<br />
./configure --enable-sandboxed --prefix=/usr \<br />
--with-driver=all \\<br />
return 1[/code]<br />
<br />
with:<br />
<br />
./configure --enable-sandboxed --prefix=/usr \<br />
--with-driver=com2 \<br />
|| return 1[/code]<br />
<br />
Where you replace com2 with the com-port you need.<br />
<br />
Build and install the package:<br />
<br />
$ makepkg<br />
# pacman -U lirc-version.pkg.tar.gz<br />
<br />
===Loading===<br />
<br />
Now try to load the serial module:<br />
<br />
# modprobe lirc_serial<br />
<br />
If this produces an error which says your serial port is not ready, you have the problem that your serial port support is build into the kernel and not as a module (in the default arch kernel it is build into the kernel)<br />
<br />
If it is built into the kernel you will have to do the following (remember that it is built into the kernel, you will need to make some changes later too)<br />
<br />
You will have to release the serial port:<br />
<br />
# setserial /dev/ttySx uart none<br />
<br />
(Replace x with your port number)<br />
<br />
Load the module again:<br />
<br />
# modprobe lirc_serial<br />
<br />
Now it should not show any errors, and the modules lirc_serial should be listed in lsmod<br />
<br />
==USB receivers including most onboard devices==<br />
This outlines the general procedure, the mceusb module which is used by many devices is used as an example.<br />
<br />
# modprobe mceusb<br />
<br />
Start the LIRC daemon:<br />
<br />
$ /etc/rc.d/lircd start<br />
<br />
Test it with irw, it will output the commands received by the IR receiver that match your {{ic|lircd.conf}} file. So start irw, point your remote and start pressing buttons. <br />
<br />
$ irw<br />
000000037ff07bfe 00 One mceusb<br />
000000037ff07bfd 00 Two mceusb<br />
000000037ff07bfd 01 Two mceusb<br />
000000037ff07bf2 00 Home mceusb<br />
000000037ff07bf2 01 Home mceusb<br />
<br />
The above procedure however has been simplified and may not work that easily. One of the reasons the lircd daemon may not be working is because it expects to be run at startup and needs root permissions because it will create device nodes in {{ic|/dev}}. Try "man lircd" for more information.<br />
<br />
Continue with [[#Making a configuration file]]<br />
<br />
=== Setup a HID device with LIRC ===<br />
Some remotes are supported in the kernel where they are treated as a keyboard and mouse. Every button on the device is recognized as keyboard or mouse events which can be used even without LIRC. LIRC can still be used with these devices to gain greater control over the events raised and integrate with programs that expect a LIRC remote rather than a keyboard. As drivers are migrated to the kernel, devices which use to only be useable through LIRC with their own {{ic|lirc.conf}} files become standard HID devices.<br />
<br />
Some HID remotes actually simulate a USB infrared keyboard and mouse. These remotes show up as two devices so you need to add two LIRC devices to {{ic|lircd.conf}}.<br />
<br />
First we need the {{ic|/dev/input}} device for our remote:<br />
<br />
$ ls /sys/class/rc/rc0<br />
<br />
One of the files should be input''#'', where the number matches the event''#'' of the device. (To clarify you can check that directory, it will have an event''#'' file.<br />
<br />
{{Note|If you have more than one ir device then there may be multiple directories under {{ic|/sys/class/rc}}. Under event''#'' {{ic|cat name}} to verify which device you are looking at.}}<br />
<br />
then go to {{ic|/dev/input/by-id}}<br />
<br />
$ ls -l /dev/input/by-id<br />
<br />
You should find a file that symlinks to the input''#'' above, and possibly others with a similar names for mouse events.<br />
<br />
lrwxrwxrwx 1 root root 9 10月 14 06:43 usb-3353_3713-event-if00 -> ../event9<br />
lrwxrwxrwx 1 root root 10 10月 14 06:43 usb-3353_3713-event-if01 -> ../event10<br />
<br />
Here 'usb-3353_3713-event-if00' and 'usb-3353_3713-event-if01' are the Linux input device event for our HID device, one for the keyboard, another for the mouse.<br />
<br />
Then, we need to edit {{ic|/etc/conf.d/lircd.conf}}. This file contains the parameters for LIRC daemon<br />
<br />
#<br />
#Parameters for daemon<br />
#<br />
<br />
LIRC_DEVICE="/dev/input/by-id/usb-3353_3713-event-if00"<br />
LIRC_DRIVER="devinput"<br />
LIRC_EXTRAOPS=""<br />
LIRC_CONFIGFILE="/etc/lirc/lircd.conf"<br />
<br />
{{Note|Here we set up a LIRC device with the id 3353_3713, you should replace it with your own device input event name, whatever it is.}}<br />
<br />
The latest version of the config file for HID remotes exists in the LIRC git repository [http://lirc.git.sourceforge.net/git/gitweb.cgi?p=lirc/lirc;a=blob_plain;f=remotes/devinput/lircd.conf.devinput;hb=HEAD]. Simply save it as {{ic|/etc/lirc/lircd.conf}}.<br />
<br />
In order to launch the LIRC daemon for HID remote, You must enable evdev module first<br />
# modprobe evdev<br />
<br />
{{Note|LIRC 0.8.6 has changed the default socket location from {{ic|/dev/lircd}} to {{ic|/var/run/lirc/lircd}}, but many applications still look for the socket in the old location. Since lirc-utils 0.8.6-3 the {{ic|/etc/rc.d/lircd}} script creates a symlink from {{ic|/dev/lircd}} to the {{ic|/var/run/lirc/lircd}} socket when it starts the lircd daemon and removes the link when the daemon is stopped.}}<br />
<br />
==Other receivers==<br />
<br />
There are many receivers that do not need any kernel module at all. This applies to any type of receiver, including serial receivers and usb receivers. Check the next link to see what kernel modules you need to load, if any:<br />
<br />
[http://www.lirc.org/html/table.html LIRC supported devices]<br />
<br />
==Checking module based receivers==<br />
<br />
''NOTE: This section only applies if your device requires a lirc_[driver] kernel module.''<br />
<br />
Before you start using lirc, you should check if your receiver is working, and if there is IR interference. Possible sources of interference include monitors/televisions (especially plasma displays), fluorescent lamps and direct or ambient sunlight. Start the following command to display raw receiver input.<br />
<br />
# mode2 -d /dev/lirc0 <br />
<br />
If you press buttons on any IR remote, you should see a series of pulses and spaces. If there is very frequent output without pressing buttons on your remote, your receiver suffers from interference. You want to avoid such interference, e.g. by placing the receiver behind or under your plasma tv.<br />
<br />
If you can't make out where the interference is coming from, you can try to put a cardboard roll right in front of the receiving diode, so that it only gets light from a specific direction. Invoke mode2 as above. Then point at different locations till you receive IR noise.<br />
<br />
==LIRC daemon configuration==<br />
<br />
The lircd configuration lives under /etc/conf.d/lircd.conf, and it is all you need to setup your device if it does not require any special kernel module.<br />
<br />
{{Box|IMPORTANT:|lirc-utils package on ArchLinux has a bug. You will have to create your own systemd unit or find another workaround. See [https://bugs.archlinux.org/task/31890 bug#31890] |#DF0000|#FFDFDF}}<br />
<br />
==Making a configuration file==<br />
<br />
You need a configuration file for your remote control copied or symlinked to {{ic|/etc/lirc/lircd.conf}}. A number of devices have already been included with the lirc package, they can be found in {{ic|/usr/share/lirc/remotes}}. If your specific device is not included, the LIRC site offers configuration files for a large number of extra [http://lirc.sourceforge.net/remotes/ devices].<br />
<br />
If your device does not already have a config file, you can create it yourself with the following command. You should avoid interference (see above) while creating the config file. <br />
<br />
# irrecord -d /dev/lirc0 /tmp/my_remote<br />
<br />
Just follow the instructions. To get a list of valid button names, refer to the output of<br />
# irrecord --list-namespace<br />
The resulting file, {{ic|/tmp/my_remote}}, should then be copied to {{ic|/etc/lirc/lircd.conf}}. If you want to use several remotes, you repeat the irrecord step with each remote and different filenames, and then concatenate all the resulting files into {{ic|/etc/lirc/lircd.conf}}:<br />
<br />
# cat /tmp/my_remote /tmp/my_remote2 /tmp/my_remote3 > /etc/lirc/lircd.conf<br />
<br />
{{Note|As of lirc-0.8.6 the default location of lircd, lircmd and lircrcd config files was moved to {{ic|/etc/lirc/lircd.conf}}, {{ic|/etc/lirc/lircmd.conf}} and {{ic|/etc/lirc/lircrc}}. If the config files are not found in that location, they are still searched at the old location in {{ic|/etc/.}}}}<br />
<br />
===Testing===<br />
<br />
First start the lircd daemon:<br />
<br />
# /etc/rc.d/lircd start<br />
<br />
A good way to see if LIRC is running is to run irw.<br />
<br />
$ irw<br />
<br />
When you press a button, you should see something like this:<br />
<br />
0000000000000001 00 play sony2<br />
0000000000000001 01 play sony2<br />
0000000000000001 02 play sony2<br />
0000000000000001 03 play sony2<br />
<br />
In this case the remote is called sony2, the button is called play, and LIRC has seen it 4 times.<br />
<br />
==Run LIRC at bootup==<br />
<br />
Remember if you had to execute the setserial command while [[LIRC#Loading|loading]] the module?<br />
<br />
If so, [[LIRC#Your serial port support is compiled into the kernel|your serial port support is compiled into the kernel]]<br />
<br />
===Your serial port support is compiled as a module in the kernel===<br />
<br />
This is rather easy: you will just have to add lirc_serial to the modules list and lircd to the daemons list in {{ic|/etc/rc.conf}}<br />
<br />
===Your serial port support is compiled into the kernel===<br />
<br />
This is more complicated, you cannot just add the lirc_serial to the modules list in {{ic|/etc/rc.conf}}, as the serial port should be released first.<br />
<br />
So I created a custom startup script to fix this problem.<br />
<br />
{{hc|/etc/rc.d/start_lirc|<nowiki><br />
#!/bin/bash<br />
#/etc/rc.d/start_lirc<br />
#releases ttySx and loads lirc_serial module<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy "release ttySx"<br />
setserial /dev/ttySx uart none<br />
#load lirc module<br />
modprobe lirc_serial<br />
stat_done<br />
;;<br />
stop)<br />
stat_busy "unload lirc module"<br />
rmmod lirc_serial<br />
stat_done<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "usage: $0 {start|stop|restart}"<br />
esac<br />
exit 0<br />
</nowiki>}}<br />
<br />
Now load the daemons: add "start_lirc" and "lircd" to the daemons list in {{ic|/etc/rc.conf}}<br />
<br />
==Program specific configuration==<br />
<br />
===Generate your own lircrc with Mythbuntu's lircrc-generator===<br />
<br />
'''mythbuntu-lircrc-generator''' is intended to be started from a system with LIRC installed. It requires that you choose a remote via the LIRC package or have a {{ic|lircd.conf}} handy prior to running. It will then produce a sane {{ic|.lircrc}} for the current user.<br />
<br />
[https://aur.archlinux.org/packages.php?ID=33849 Mythbuntu's Lirc/Lircrc Generator is available on AUR]<br/><br />
[http://manpages.ubuntu.com/manpages/intrepid/man1/mythbuntu-lirc-generator.1.html Man page]<br />
<br />
===Enable LIRC support in xine===<br />
<br />
Now LIRC works, but you have no program that can communicate with LIRC. This section will explain how to make xine work, but you can use xmms and mplayer (and probably a lot of other programs too) to work with LIRC.<br />
<br />
====Compile xine with LIRC support====<br />
Download the xine-ui PKGBUILD with [https://wiki.archlinux.org/index.php/Arch_Build_System ABS].<br />
<br />
Add " --enable-lirc" to the {{ic|./configure}} line<br />
<br />
Compile:<br />
<br />
$ makepkg<br />
<br />
Uninstall old xine-ui and install the new one<br />
<br />
# pacman -R xine-ui<br />
# pacman -U xine-filename.pkg.tar.gz<br />
<br />
====Configure xine to use LIRC====<br />
<br />
Let xine produce a default {{ic|.lircrc}} file. In your home directory, type:<br />
<br />
$ xine --keymap=lirc>.lircrc<br />
<br />
Now, in order to have a functioning xine+lirc, edit the {{ic|.lircrc}} file to your preferences.<br />
<br />
However, you may choose to configure LIRC to control more than just xine. If this is the case, you will need to manually edit the {{ic|.lircrc}} file, and add elements. <br />
<br />
Xine-ui<br />
Mplayer<br />
Totem<br />
Vlc<br />
Rhythmbox <br />
<br />
All work with LIRC, but you must enable LIRC support in the program in some cases, such as VLC. Simply copy the vlc packagebuild and edit it so that "--enable-lirc" is one of the compile options for VLC not FFMPEG!<br />
<br />
===Configure Amarok2 to use LIRC===<br />
<br />
Depending on your controller model, the following configuration works with Amarok2-svn. This configuration file will work with the MCEUSB controller.<br />
<br />
{{hc|~/.lircrc|2=##amarok2<br />
<br />
begin<br />
button = Play<br />
prog = irexec<br />
repeat = 0<br />
config = qdbus org.mpris.amarok /Player Play<br />
end<br />
<br />
begin<br />
button = Pause<br />
prog = irexec<br />
repeat = 0<br />
config = qdbus org.mpris.amarok /Player Pause<br />
end<br />
<br />
begin<br />
button = Stop<br />
prog = irexec<br />
repeat = 0<br />
config = qdbus org.mpris.amarok /Player Stop<br />
end<br />
<br />
begin<br />
button = Skip<br />
prog = irexec<br />
repeat = 0<br />
config = qdbus org.mpris.amarok /Player Next<br />
end<br />
<br />
begin<br />
button = Replay<br />
prog = irexec<br />
repeat = 0<br />
config = qdbus org.mpris.amarok /Player Prev<br />
end}}<br />
<br />
===Configure Audacious(2) to use LIRC===<br />
Depending on your controller model, the following configuration works with all versions of Audacious, including the mercurial builds. This configuration file will work with the MCEUSB controller.<br />
<br />
{{hc|~/.lircrc|2=##audacious<br />
<br />
begin<br />
prog = audacious<br />
button = Play<br />
config = PLAY<br />
repeat = 0<br />
end<br />
<br />
begin<br />
prog = audacious<br />
button = Pause<br />
config = PAUSE<br />
repeat = 0<br />
end<br />
<br />
begin<br />
prog = audacious<br />
button = Stop<br />
config = STOP<br />
repeat = 0<br />
end<br />
<br />
begin<br />
prog = audacious<br />
button = Skip<br />
config = NEXT<br />
repeat = 0<br />
end<br />
<br />
begin<br />
prog = audacious<br />
button = Replay<br />
config = PREV<br />
repeat = 0<br />
end<br />
<br />
begin<br />
prog = audacious<br />
button = VolUp<br />
config = VOL_UP<br />
repeat = 1<br />
end<br />
<br />
begin<br />
prog = audacious<br />
button = VolDown<br />
config = VOL_DOWN<br />
repeat = 1<br />
end}}<br />
<br />
Additionally, there are other values that may be set according to the model set forth above. This was taken from the lirc.c file from audacious-plugins source code:<br />
<br />
{{hc|lirc.c|PLAY<br />
STOP<br />
PAUSE<br />
PLAYPAUSE<br />
NEXT<br />
PREV<br />
SHUFFLE<br />
REPEAT<br />
FWD<br />
BWD<br />
VOL_UP<br />
VOL_DOWN<br />
QUIT<br />
MUTE<br />
BAL_LEFT<br />
BAL_RIGHT<br />
BAL_CENTER<br />
LIST<br />
PLAYLIST_CLEAR<br />
PLAYLIST_ADD}}<br />
<br />
===Configure Mplayer to use LIRC===<br />
<br />
{{hc|~/.lircrc|2=##mplayer<br />
<br />
begin<br />
button = PLAY/PAUSE<br />
prog = mplayer<br />
config = pause<br />
repeat = 1<br />
end<br />
begin<br />
button = FWD<br />
prog = mplayer<br />
config = seek 5<br />
end<br />
begin<br />
button = REV<br />
prog = mplayer<br />
config = seek -5<br />
end<br />
begin<br />
button = MAXIMIZE<br />
prog = mplayer<br />
config = vo_fullscreen<br />
end<br />
}}<br />
<br />
only change PLAY/PAUSE, FWD etc. on keys from your /etc/lircd.conf<br />
<br />
==Device Specific Examples==<br />
=== X10 ===<br />
There is a dedicated wiki page with information about [[X10]]<br />
<br />
===Asus DH Deluxe series motherboard===<br />
Check the output of:<br />
{{bc|$ cat /dev/usb/hiddevX}}<br />
<br />
where X is 0,1 or bigger, and press some buttons on remote.<br />
If you can see reply, device works fine, follow steps:<br><br />
<br />
1. In file {{ic|/etc/conf.d/lircd.conf}} add:<br><br />
{{bc|1=LIRC_DRIVER="dvico"}}<br />
2. Reload LIRC: <br />
{{bc|/etc/rc.d/lircd restart}}<br />
<br />
===ASRock ION series (Nuvoton) quickstart===<br />
<br />
$ ln -s /usr/share/lirc/remotes/lirc_wb677/lircd.conf.wb677 /etc/lirc/lircd.conf<br />
$ /etc/rc.d/lircd restart<br />
<br />
===Streamzap PC Remote (USB)===<br />
{{Note|Xorg now auto recognizes this remote as a keybaord!}} <br />
To disable this behavior, add the following to {{ic|/etc/X11/xorg.conf.d/90-streamzap.conf}}:<br />
{{bc|Section "InputClass"<br />
Identifier "Ignore Streamzap IR"<br />
MatchProduct "Streamzap"<br />
MatchIsKeyboard "true"<br />
Option "Ignore" "true"<br />
EndSection}}<br />
<br />
#Install both packages (lirc lirc-utils)<br />
#Modprobe both kernel mods (lirc_dev and streamzap) (add these to your MODULES array in {{ic|/etc/rc.conf}} to survive a reboot)<br />
#Create your {{ic|/etc/lirc/lircd.conf}} (for this remote, copy {{ic|/usr/share/lirc/remotes/streamzap/lircd.conf.streamzap}} to {{ic|/etc/lirc/lircd.conf}})<br />
#Start lircd via /etc/rc.d/lircd start (add lircd to your DAEMONS array in {{ic|/etc/rc.conf}} to survive a reboot)<br />
#Test the remote/lirc with irw<br />
<br />
$ irw<br />
00000000000028cc 00 CH_UP Streamzap_PC_Remote<br />
00000000000028ce 00 CH_DOWN Streamzap_PC_Remote<br />
00000000000028c8 00 8 Streamzap_PC_Remote<br />
00000000000028c5 00 5 Streamzap_PC_Remote<br />
00000000000028d2 00 OK Streamzap_PC_Remote<br />
00000000000028d1 00 LEFT Streamzap_PC_Remote<br />
00000000000028d1 01 LEFT Streamzap_PC_Remote<br />
00000000000028d1 00 LEFT Streamzap_PC_Remote<br />
00000000000028d3 00 RIGHT Streamzap_PC_Remote<br />
00000000000028d3 00 RIGHT Streamzap_PC_Remote<br />
00000000000028d3 00 RIGHT Streamzap_PC_Remote<br />
00000000000028d3 00 RIGHT Streamzap_PC_Remote<br />
00000000000028d4 00 DOWN Streamzap_PC_Remote<br />
00000000000028d4 00 DOWN Streamzap_PC_Remote<br />
00000000000028d4 00 DOWN Streamzap_PC_Remote<br />
<br />
{{Note|When the batteries in this remote are low, it may stop working even though the red LED on the received still flashes when you hit buttons!}}<br />
<br />
<br />
=== Serial Port "Home Brew" IR Receiver ===<br />
Here's how to get a "Home Brew" serial port IR receiver working:<br />
<br />
1. Create a udev rule to give non-privleged users read/write access to the serial port. I will be using ttyS0 in my example.<br />
{{hc|/etc/udev/rules.d/z98-serial.rules|<br />
# For serial port ttyS0 and LIRC<br />
KERNEL&#61;&#61;"ttyS0",SUBSYSTEM&#61;&#61;"tty",DRIVERS&#61;&#61;"serial",MODE&#61;"0666"}}<br />
<br />
2. Create the needed modprobe configs<br />
{{hc|/etc/modules-load.d/lirc_serial.conf|lirc_serial}}<br />
{{hc|/etc/modprobe.d/lirc_serial.conf|install lirc_serial /usr/bin/setserial /dev/ttyS0 uart none && /sbin/modprobe --first-time --ignore-install lirc_serial<br />
options lirc_serial type&#61;0<br />
remove lirc_serial /sbin/modprobe -r --first-time --ignore-remove lirc_serial && /sbin/modprobe -r lirc_dev}}<br />
{{Note|Using [[udev]] rules to run the setserial command does not work in my experience because lirc_serial gets loaded before the serial port rules are applied.}}<br />
<br />
3. Install your systemd service file.<br />
{{hc|/etc/systemd/system/lirc.service|[Unit]<br />
Description&#61;Linux Infrared Remote Control<br />
After&#61;network.target<br />
<br />
[Service]<br />
Type&#61;simple<br />
PIDFile&#61;/run/lirc/lircd.pid<br />
ExecStartPre&#61;/bin/rm -f /dev/lirc /dev/lircd /var/run/lirc/lircd<br />
ExecStart&#61;/usr/sbin/lircd -n -r -P /run/lirc/lircd.pid -d /dev/lirc0 -o /run/lirc/lircd<br />
ExecStartPost&#61;/usr/bin/ln -sf /run/lirc/lircd /dev/lircd<br />
ExecStartPost&#61;/usr/bin/ln -sf /dev/lirc0 /dev/lirc<br />
ExecReload&#61;/bin/kill -SIGHUP $MAINPID<br />
<br />
[Install]<br />
WantedBy&#61;multi-user.target}}<br />
<br />
4. We still need the default tmpfiles to be created, so copy that config file to {{ic|/etc/tmpfiles.d/lirc.conf}}.<br />
{{bc|# cp -a /usr/lib/tmpfiles.d/lirc.conf /etc/tmpfiles.d/lirc.conf}}<br />
<br />
5. Create a {{ic|.lircrc}} file in your home directory for your user or a {{ic|/etc/lirc/lircrc}} file for system wide use.<br />
<br />
6. Have your service start at boot and then test with a reboot<br />
{{bc|1=# systemctl enable lirc.service<br />
# systemctl reboot}}<br />
<br />
or load the module and start the lirc.service.<br />
{{bc|# modprobe lirc_serial<br />
# systemctl start lirc.service}}<br />
<br />
=== Receivers that do not depend on a kernel module ===<br />
<br />
Usually, you only need to specify your the device where the receiver is plugged in and the lirc driver. This is an example for pinnacle or miro serial receivers):<br />
<br />
LIRC_DEVICE="/dev/ttySX"<br />
LIRC_DRIVER="pinsys"<br />
<br />
Then, start lircd daemon and create the remote/s configuration (/etc/lirc/lircd.conf), either by copying one of the configured defaults that comes with lirc-utils or by using irrecord. Even if you find your remote in the list of preconfigured remotes it might not work so you will have to use irrecord anyway.<br />
<br />
After this you can use irw to check the remote, create your ~/.lircrc to assign remote buttons to actions and start irexec if you need to run arbitrary commands.<br />
<br />
==Troubleshooting==<br />
<br />
===Buttons processed several times when pressed===<br />
Problem in module ir_core which processes IR commands with LIRC at the same time. Simply blacklist it by creating the following file:<br />
<br />
{{hc|/etc/modprobe.d/remote_blacklist.conf|<br />
# Prevent processing button several times when pressed<br />
blacklist ir_core<br />
}}<br />
<br />
===After upgrading or installing Arch, an existing configuration stopped working===<br />
====Kernel module change====<br />
As of kernel 2.6.36, LIRC modules have been included in the kernel. Arch's ''lirc'' package has included the older kernel modules, which work with ''lircd'' without any additional configuration. However, a recent update removed those older modules, which results in the stock kernel modules being used. Unfortunately, these kernel modules treat the remote as a keyboard by default, which is incompatible for lircd. To correct this, put the following line to {{ic|/etc/rc.local}}:<br />
{{hc|/etc/rc.local|echo lirc > /sys/class/rc/rc0/protocols}}<br />
You may also run that command as root to enable LIRC for your current session.<br />
<br />
{{Note|It is also a good idea to remove the old LIRC kernel module from your MODULES array in {{ic|/etc/rc.conf}}, as it is no longer present.}}<br />
<br />
=== Problems using default systemd lirc.service file ===<br />
<br />
There is a bug in lirc-utils that makes lirc.service ignore /etc/conf.d/lircd.conf. See [[https://bugs.archlinux.org/task/31890 FS#31890]]<br />
<br />
{{ic|/var/log/lirc}} shows error finding /dev/lirc:<br />
{{bc|lircd: could not get file information for /dev/lirc}}<br />
<br />
Workaround: make a symbolic link for /dev/lirc that points to /dev/lirc0 with file {{hc|/etc/tmpfiles.d/lirc-dev.conf|<nowiki><br />
L /dev/lirc - - - - /dev/lirc0<br />
</nowiki>}}<br />
<br />
==See also==<br />
* http://www.mythtv.org/wiki/Category:Remote_Controls -- MythTV wiki main LIRC article<br />
* http://www.mythtv.org/wiki/MCE_Remote -- MythTV wiki on MCE remotes <br />
* http://en.gentoo-wiki.com/wiki/LIRC -- Gentoo wiki LIRC how-to<br />
* https://aur.archlinux.org/packages.php?ID=33849 -- Lirc/Lircrc Configuration Generator</div>Apouloshttps://wiki.archlinux.org/index.php?title=LIRC&diff=242776LIRC2013-01-03T04:04:35Z<p>Apoulos: </p>
<hr />
<div>[[Category:Other hardware]]<br />
[[Category:Audio/Video]]<br />
{{Article summary start}}<br />
{{Article summary text|This article covers using LIRC with serial or USB infrared devices.}}<br />
{{Article summary end}}<br />
<br />
[http://lirc.org/ LIRC] stands for "Linux Infrared Remote Control", a program to use infrared devices (like your remote control from your TV) with linux.<br />
<br />
==Supported hardware==<br />
<br />
First of all, check the [http://lirc.org/html/table.html official list of supported hardware]. Check the table to know, which LIRC kernel modules and lircd driver required for your infrared receiver.<br />
<br />
==Installation==<br />
<br />
[[pacman|Install]] the {{Pkg|lirc-utils}} package, which is available in the [[Official Repositories|official repositories]].<br />
<br />
The most of LIRC kernel drivers are already included in the mainline kernel. You need to install {{Pkg|lirc}} package only, if your hardware requires lirc_atiusb, lirc_i2c or lirc_wpc8769l modules.<br />
<br />
==Serial receivers==<br />
<br />
===Serial receivers that depend on lirc_serial===<br />
<br />
Make sure that your serial port is activated in the BIOS. There you can also set and lookup I/O address and IRQ settings of your ports.<br />
<br />
Now there might be a problem: the module lirc_serial is build to use ttyS0 (COM1), if your device is not connected to ttyS0, you will have to either change the module-options or [[LIRC#Building_the_LIRC_serial_module_for_another_ttySx|rebuild the LIRC module]]. If your device is connected to ttyS0, you can [[LIRC#Loading|skip this step]]<br />
<br />
To change the options for the lirc_serial module, you edit {{ic|/etc/modprobe.d/modprobe.conf}} and add this line:<br />
<br />
options lirc_serial io=0x2f8 irq=3<br />
<br />
You should change the values after io and irq to reflect you serial port settings, the values above may work for you if you are using ttyS1 (COM2) to connect your IR-device. But you will find the correct values by checking dmesg:<br />
<br />
$ dmesg | grep ttyS<br />
<br />
===Other serial receivers===<br />
<br />
See [[LIRC#Other_receivers]]<br />
<br />
===Building the lirc_serial module for another ttySx===<br />
<br />
Update abs<br />
<br />
# abs<br />
<br />
Copy the LIRC files to a directory you choose yourself:<br />
<br />
$ cp /var/abs/extra/system/lirc /some/dir<br />
<br />
$ cd /some/dir<br />
<br />
Edit the PKGBUILD in that directory.<br />
<br />
Replace the line:<br />
<br />
./configure --enable-sandboxed --prefix=/usr \<br />
--with-driver=all \\<br />
return 1[/code]<br />
<br />
with:<br />
<br />
./configure --enable-sandboxed --prefix=/usr \<br />
--with-driver=com2 \<br />
|| return 1[/code]<br />
<br />
Where you replace com2 with the com-port you need.<br />
<br />
Build and install the package:<br />
<br />
$ makepkg<br />
# pacman -U lirc-version.pkg.tar.gz<br />
<br />
===Loading===<br />
<br />
Now try to load the serial module:<br />
<br />
# modprobe lirc_serial<br />
<br />
If this produces an error which says your serial port is not ready, you have the problem that your serial port support is build into the kernel and not as a module (in the default arch kernel it is build into the kernel)<br />
<br />
If it is built into the kernel you will have to do the following (remember that it is built into the kernel, you will need to make some changes later too)<br />
<br />
You will have to release the serial port:<br />
<br />
# setserial /dev/ttySx uart none<br />
<br />
(Replace x with your port number)<br />
<br />
Load the module again:<br />
<br />
# modprobe lirc_serial<br />
<br />
Now it should not show any errors, and the modules lirc_serial should be listed in lsmod<br />
<br />
==USB receivers including most onboard devices==<br />
This outlines the general procedure, the mceusb module which is used by many devices is used as an example.<br />
<br />
# modprobe mceusb<br />
<br />
Start the LIRC daemon:<br />
<br />
$ /etc/rc.d/lircd start<br />
<br />
Test it with irw, it will output the commands received by the IR receiver that match your {{ic|lircd.conf}} file. So start irw, point your remote and start pressing buttons. <br />
<br />
$ irw<br />
000000037ff07bfe 00 One mceusb<br />
000000037ff07bfd 00 Two mceusb<br />
000000037ff07bfd 01 Two mceusb<br />
000000037ff07bf2 00 Home mceusb<br />
000000037ff07bf2 01 Home mceusb<br />
<br />
The above procedure however has been simplified and may not work that easily. One of the reasons the lircd daemon may not be working is because it expects to be run at startup and needs root permissions because it will create device nodes in {{ic|/dev}}. Try "man lircd" for more information.<br />
<br />
Continue with [[#Making a configuration file]]<br />
<br />
=== Setup a HID device with LIRC ===<br />
Some remotes are supported in the kernel where they are treated as a keyboard and mouse. Every button on the device is recognized as keyboard or mouse events which can be used even without LIRC. LIRC can still be used with these devices to gain greater control over the events raised and integrate with programs that expect a LIRC remote rather than a keyboard. As drivers are migrated to the kernel, devices which use to only be useable through LIRC with their own {{ic|lirc.conf}} files become standard HID devices.<br />
<br />
Some HID remotes actually simulate a USB infrared keyboard and mouse. These remotes show up as two devices so you need to add two LIRC devices to {{ic|lircd.conf}}.<br />
<br />
First we need the {{ic|/dev/input}} device for our remote:<br />
<br />
$ ls /sys/class/rc/rc0<br />
<br />
One of the files should be input''#'', where the number matches the event''#'' of the device. (To clarify you can check that directory, it will have an event''#'' file.<br />
<br />
{{Note|If you have more than one ir device then there may be multiple directories under {{ic|/sys/class/rc}}. Under event''#'' {{ic|cat name}} to verify which device you are looking at.}}<br />
<br />
then go to {{ic|/dev/input/by-id}}<br />
<br />
$ ls -l /dev/input/by-id<br />
<br />
You should find a file that symlinks to the input''#'' above, and possibly others with a similar names for mouse events.<br />
<br />
lrwxrwxrwx 1 root root 9 10月 14 06:43 usb-3353_3713-event-if00 -> ../event9<br />
lrwxrwxrwx 1 root root 10 10月 14 06:43 usb-3353_3713-event-if01 -> ../event10<br />
<br />
Here 'usb-3353_3713-event-if00' and 'usb-3353_3713-event-if01' are the Linux input device event for our HID device, one for the keyboard, another for the mouse.<br />
<br />
Then, we need to edit {{ic|/etc/conf.d/lircd.conf}}. This file contains the parameters for LIRC daemon<br />
<br />
#<br />
#Parameters for daemon<br />
#<br />
<br />
LIRC_DEVICE="/dev/input/by-id/usb-3353_3713-event-if00"<br />
LIRC_DRIVER="devinput"<br />
LIRC_EXTRAOPS=""<br />
LIRC_CONFIGFILE="/etc/lirc/lircd.conf"<br />
<br />
{{Note|Here we set up a LIRC device with the id 3353_3713, you should replace it with your own device input event name, whatever it is.}}<br />
<br />
The latest version of the config file for HID remotes exists in the LIRC git repository [http://lirc.git.sourceforge.net/git/gitweb.cgi?p=lirc/lirc;a=blob_plain;f=remotes/devinput/lircd.conf.devinput;hb=HEAD]. Simply save it as {{ic|/etc/lirc/lircd.conf}}.<br />
<br />
In order to launch the LIRC daemon for HID remote, You must enable evdev module first<br />
# modprobe evdev<br />
<br />
{{Note|LIRC 0.8.6 has changed the default socket location from {{ic|/dev/lircd}} to {{ic|/var/run/lirc/lircd}}, but many applications still look for the socket in the old location. Since lirc-utils 0.8.6-3 the {{ic|/etc/rc.d/lircd}} script creates a symlink from {{ic|/dev/lircd}} to the {{ic|/var/run/lirc/lircd}} socket when it starts the lircd daemon and removes the link when the daemon is stopped.}}<br />
<br />
==Other receivers==<br />
<br />
There are many receivers that do not need any kernel module at all. This applies to any type of receiver, including serial receivers and usb receivers. Check the next link to see what kernel modules you need to load, if any:<br />
<br />
[http://www.lirc.org/html/table.html LIRC supported devices]<br />
<br />
==Checking module based receivers==<br />
<br />
''NOTE: This section only applies if your device requires a lirc_[driver] kernel module.''<br />
<br />
Before you start using lirc, you should check if your receiver is working, and if there is IR interference. Possible sources of interference include monitors/televisions (especially plasma displays), fluorescent lamps and direct or ambient sunlight. Start the following command to display raw receiver input.<br />
<br />
# mode2 -d /dev/lirc0 <br />
<br />
If you press buttons on any IR remote, you should see a series of pulses and spaces. If there is very frequent output without pressing buttons on your remote, your receiver suffers from interference. You want to avoid such interference, e.g. by placing the receiver behind or under your plasma tv.<br />
<br />
If you can't make out where the interference is coming from, you can try to put a cardboard roll right in front of the receiving diode, so that it only gets light from a specific direction. Invoke mode2 as above. Then point at different locations till you receive IR noise.<br />
<br />
==LIRC daemon configuration==<br />
<br />
The lircd configuration lives under /etc/conf.d/lircd.conf, and it is all you need to setup your device if it does not require any special kernel module.<br />
<br />
{{Box|IMPORTANT:|lirc-utils package on ArchLinux has a bug. You will have to create your own systemd unit or find another workaround. See [https://bugs.archlinux.org/task/31890 bug#31890] |#DF0000|#FFDFDF}}<br />
<br />
==Making a configuration file==<br />
<br />
You need a configuration file for your remote control copied or symlinked to {{ic|/etc/lirc/lircd.conf}}. A number of devices have already been included with the lirc package, they can be found in {{ic|/usr/share/lirc/remotes}}. If your specific device is not included, the LIRC site offers configuration files for a large number of extra [http://lirc.sourceforge.net/remotes/ devices].<br />
<br />
If your device does not already have a config file, you can create it yourself with the following command. You should avoid interference (see above) while creating the config file. <br />
<br />
# irrecord -d /dev/lirc0 /tmp/my_remote<br />
<br />
Just follow the instructions. To get a list of valid button names, refer to the output of<br />
# irrecord --list-namespace<br />
The resulting file, {{ic|/tmp/my_remote}}, should then be copied to {{ic|/etc/lirc/lircd.conf}}. If you want to use several remotes, you repeat the irrecord step with each remote and different filenames, and then concatenate all the resulting files into {{ic|/etc/lirc/lircd.conf}}:<br />
<br />
# cat /tmp/my_remote /tmp/my_remote2 /tmp/my_remote3 > /etc/lirc/lircd.conf<br />
<br />
{{Note|As of lirc-0.8.6 the default location of lircd, lircmd and lircrcd config files was moved to {{ic|/etc/lirc/lircd.conf}}, {{ic|/etc/lirc/lircmd.conf}} and {{ic|/etc/lirc/lircrc}}. If the config files are not found in that location, they are still searched at the old location in {{ic|/etc/.}}}}<br />
<br />
===Testing===<br />
<br />
First start the lircd daemon:<br />
<br />
# /etc/rc.d/lircd start<br />
<br />
A good way to see if LIRC is running is to run irw.<br />
<br />
$ irw<br />
<br />
When you press a button, you should see something like this:<br />
<br />
0000000000000001 00 play sony2<br />
0000000000000001 01 play sony2<br />
0000000000000001 02 play sony2<br />
0000000000000001 03 play sony2<br />
<br />
In this case the remote is called sony2, the button is called play, and LIRC has seen it 4 times.<br />
<br />
==Run LIRC at bootup==<br />
<br />
Remember if you had to execute the setserial command while [[LIRC#Loading|loading]] the module?<br />
<br />
If so, [[LIRC#Your serial port support is compiled into the kernel|your serial port support is compiled into the kernel]]<br />
<br />
===Your serial port support is compiled as a module in the kernel===<br />
<br />
This is rather easy: you will just have to add lirc_serial to the modules list and lircd to the daemons list in {{ic|/etc/rc.conf}}<br />
<br />
===Your serial port support is compiled into the kernel===<br />
<br />
This is more complicated, you cannot just add the lirc_serial to the modules list in {{ic|/etc/rc.conf}}, as the serial port should be released first.<br />
<br />
So I created a custom startup script to fix this problem.<br />
<br />
{{hc|/etc/rc.d/start_lirc|<nowiki><br />
#!/bin/bash<br />
#/etc/rc.d/start_lirc<br />
#releases ttySx and loads lirc_serial module<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
<br />
case "$1" in<br />
start)<br />
stat_busy "release ttySx"<br />
setserial /dev/ttySx uart none<br />
#load lirc module<br />
modprobe lirc_serial<br />
stat_done<br />
;;<br />
stop)<br />
stat_busy "unload lirc module"<br />
rmmod lirc_serial<br />
stat_done<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "usage: $0 {start|stop|restart}"<br />
esac<br />
exit 0<br />
</nowiki>}}<br />
<br />
Now load the daemons: add "start_lirc" and "lircd" to the daemons list in {{ic|/etc/rc.conf}}<br />
<br />
==Program specific configuration==<br />
<br />
===Generate your own lircrc with Mythbuntu's lircrc-generator===<br />
<br />
'''mythbuntu-lircrc-generator''' is intended to be started from a system with LIRC installed. It requires that you choose a remote via the LIRC package or have a {{ic|lircd.conf}} handy prior to running. It will then produce a sane {{ic|.lircrc}} for the current user.<br />
<br />
[https://aur.archlinux.org/packages.php?ID=33849 Mythbuntu's Lirc/Lircrc Generator is available on AUR]<br/><br />
[http://manpages.ubuntu.com/manpages/intrepid/man1/mythbuntu-lirc-generator.1.html Man page]<br />
<br />
===Enable LIRC support in xine===<br />
<br />
Now LIRC works, but you have no program that can communicate with LIRC. This section will explain how to make xine work, but you can use xmms and mplayer (and probably a lot of other programs too) to work with LIRC.<br />
<br />
====Compile xine with LIRC support====<br />
Download the xine-ui PKGBUILD with [https://wiki.archlinux.org/index.php/Arch_Build_System ABS].<br />
<br />
Add " --enable-lirc" to the {{ic|./configure}} line<br />
<br />
Compile:<br />
<br />
$ makepkg<br />
<br />
Uninstall old xine-ui and install the new one<br />
<br />
# pacman -R xine-ui<br />
# pacman -U xine-filename.pkg.tar.gz<br />
<br />
====Configure xine to use LIRC====<br />
<br />
Let xine produce a default {{ic|.lircrc}} file. In your home directory, type:<br />
<br />
$ xine --keymap=lirc>.lircrc<br />
<br />
Now, in order to have a functioning xine+lirc, edit the {{ic|.lircrc}} file to your preferences.<br />
<br />
However, you may choose to configure LIRC to control more than just xine. If this is the case, you will need to manually edit the {{ic|.lircrc}} file, and add elements. <br />
<br />
Xine-ui<br />
Mplayer<br />
Totem<br />
Vlc<br />
Rhythmbox <br />
<br />
All work with LIRC, but you must enable LIRC support in the program in some cases, such as VLC. Simply copy the vlc packagebuild and edit it so that "--enable-lirc" is one of the compile options for VLC not FFMPEG!<br />
<br />
===Configure Amarok2 to use LIRC===<br />
<br />
Depending on your controller model, the following configuration works with Amarok2-svn. This configuration file will work with the MCEUSB controller.<br />
<br />
{{hc|~/.lircrc|2=##amarok2<br />
<br />
begin<br />
button = Play<br />
prog = irexec<br />
repeat = 0<br />
config = qdbus org.mpris.amarok /Player Play<br />
end<br />
<br />
begin<br />
button = Pause<br />
prog = irexec<br />
repeat = 0<br />
config = qdbus org.mpris.amarok /Player Pause<br />
end<br />
<br />
begin<br />
button = Stop<br />
prog = irexec<br />
repeat = 0<br />
config = qdbus org.mpris.amarok /Player Stop<br />
end<br />
<br />
begin<br />
button = Skip<br />
prog = irexec<br />
repeat = 0<br />
config = qdbus org.mpris.amarok /Player Next<br />
end<br />
<br />
begin<br />
button = Replay<br />
prog = irexec<br />
repeat = 0<br />
config = qdbus org.mpris.amarok /Player Prev<br />
end}}<br />
<br />
===Configure Audacious(2) to use LIRC===<br />
Depending on your controller model, the following configuration works with all versions of Audacious, including the mercurial builds. This configuration file will work with the MCEUSB controller.<br />
<br />
{{hc|~/.lircrc|2=##audacious<br />
<br />
begin<br />
prog = audacious<br />
button = Play<br />
config = PLAY<br />
repeat = 0<br />
end<br />
<br />
begin<br />
prog = audacious<br />
button = Pause<br />
config = PAUSE<br />
repeat = 0<br />
end<br />
<br />
begin<br />
prog = audacious<br />
button = Stop<br />
config = STOP<br />
repeat = 0<br />
end<br />
<br />
begin<br />
prog = audacious<br />
button = Skip<br />
config = NEXT<br />
repeat = 0<br />
end<br />
<br />
begin<br />
prog = audacious<br />
button = Replay<br />
config = PREV<br />
repeat = 0<br />
end<br />
<br />
begin<br />
prog = audacious<br />
button = VolUp<br />
config = VOL_UP<br />
repeat = 1<br />
end<br />
<br />
begin<br />
prog = audacious<br />
button = VolDown<br />
config = VOL_DOWN<br />
repeat = 1<br />
end}}<br />
<br />
Additionally, there are other values that may be set according to the model set forth above. This was taken from the lirc.c file from audacious-plugins source code:<br />
<br />
{{hc|lirc.c|PLAY<br />
STOP<br />
PAUSE<br />
PLAYPAUSE<br />
NEXT<br />
PREV<br />
SHUFFLE<br />
REPEAT<br />
FWD<br />
BWD<br />
VOL_UP<br />
VOL_DOWN<br />
QUIT<br />
MUTE<br />
BAL_LEFT<br />
BAL_RIGHT<br />
BAL_CENTER<br />
LIST<br />
PLAYLIST_CLEAR<br />
PLAYLIST_ADD}}<br />
<br />
===Configure Mplayer to use LIRC===<br />
<br />
{{hc|~/.lircrc|2=##mplayer<br />
<br />
begin<br />
button = PLAY/PAUSE<br />
prog = mplayer<br />
config = pause<br />
repeat = 1<br />
end<br />
begin<br />
button = FWD<br />
prog = mplayer<br />
config = seek 5<br />
end<br />
begin<br />
button = REV<br />
prog = mplayer<br />
config = seek -5<br />
end<br />
begin<br />
button = MAXIMIZE<br />
prog = mplayer<br />
config = vo_fullscreen<br />
end<br />
}}<br />
<br />
only change PLAY/PAUSE, FWD etc. on keys from your /etc/lircd.conf<br />
<br />
==Device Specific Examples==<br />
=== X10 ===<br />
There is a dedicated wiki page with information about [[X10]]<br />
<br />
===Asus DH Deluxe series motherboard===<br />
Check the output of:<br />
{{bc|$ cat /dev/usb/hiddevX}}<br />
<br />
where X is 0,1 or bigger, and press some buttons on remote.<br />
If you can see reply, device works fine, follow steps:<br><br />
<br />
1. In file {{ic|/etc/conf.d/lircd.conf}} add:<br><br />
{{bc|1=LIRC_DRIVER="dvico"}}<br />
2. Reload LIRC: <br />
{{bc|/etc/rc.d/lircd restart}}<br />
<br />
===ASRock ION series (Nuvoton) quickstart===<br />
<br />
$ ln -s /usr/share/lirc/remotes/lirc_wb677/lircd.conf.wb677 /etc/lirc/lircd.conf<br />
$ /etc/rc.d/lircd restart<br />
<br />
===Streamzap PC Remote (USB)===<br />
{{Note|Xorg now auto recognizes this remote as a keybaord!}} <br />
To disable this behavior, add the following to {{ic|/etc/X11/xorg.conf.d/90-streamzap.conf}}:<br />
{{bc|Section "InputClass"<br />
Identifier "Ignore Streamzap IR"<br />
MatchProduct "Streamzap"<br />
MatchIsKeyboard "true"<br />
Option "Ignore" "true"<br />
EndSection}}<br />
<br />
#Install both packages (lirc lirc-utils)<br />
#Modprobe both kernel mods (lirc_dev and streamzap) (add these to your MODULES array in {{ic|/etc/rc.conf}} to survive a reboot)<br />
#Create your {{ic|/etc/lirc/lircd.conf}} (for this remote, copy {{ic|/usr/share/lirc/remotes/streamzap/lircd.conf.streamzap}} to {{ic|/etc/lirc/lircd.conf}})<br />
#Start lircd via /etc/rc.d/lircd start (add lircd to your DAEMONS array in {{ic|/etc/rc.conf}} to survive a reboot)<br />
#Test the remote/lirc with irw<br />
<br />
$ irw<br />
00000000000028cc 00 CH_UP Streamzap_PC_Remote<br />
00000000000028ce 00 CH_DOWN Streamzap_PC_Remote<br />
00000000000028c8 00 8 Streamzap_PC_Remote<br />
00000000000028c5 00 5 Streamzap_PC_Remote<br />
00000000000028d2 00 OK Streamzap_PC_Remote<br />
00000000000028d1 00 LEFT Streamzap_PC_Remote<br />
00000000000028d1 01 LEFT Streamzap_PC_Remote<br />
00000000000028d1 00 LEFT Streamzap_PC_Remote<br />
00000000000028d3 00 RIGHT Streamzap_PC_Remote<br />
00000000000028d3 00 RIGHT Streamzap_PC_Remote<br />
00000000000028d3 00 RIGHT Streamzap_PC_Remote<br />
00000000000028d3 00 RIGHT Streamzap_PC_Remote<br />
00000000000028d4 00 DOWN Streamzap_PC_Remote<br />
00000000000028d4 00 DOWN Streamzap_PC_Remote<br />
00000000000028d4 00 DOWN Streamzap_PC_Remote<br />
<br />
{{Note|When the batteries in this remote are low, it may stop working even though the red LED on the received still flashes when you hit buttons!}}<br />
<br />
<br />
=== Serial Port IR Receiver ===<br />
Here's how to get a "Home Brew" serial port IR receiver working:<br />
<br />
1. Create a udev rule to give non-privleged users read/write access to the serial port. I will be using ttyS0 in my example.<br />
{{hc|/etc/udev/rules.d/z98-serial.rules|<br />
# For serial port ttyS0 and LIRC<br />
KERNEL&#61;&#61;"ttyS0",SUBSYSTEM&#61;&#61;"tty",DRIVERS&#61;&#61;"serial",MODE&#61;"0666"}}<br />
<br />
2. Create the needed modprobe configs<br />
{{hc|/etc/modules-load.d/lirc_serial.conf|lirc_serial}}<br />
{{hc|/etc/modprobe.d/lirc_serial.conf|install lirc_serial /usr/bin/setserial /dev/ttyS0 uart none && /sbin/modprobe --first-time --ignore-install lirc_serial<br />
options lirc_serial type&#61;0<br />
remove lirc_serial /sbin/modprobe -r --first-time --ignore-remove lirc_serial && /sbin/modprobe -r lirc_dev}}<br />
{{Note|Using [[udev]] rules to run the setserial command does not work in my experience because lirc_serial gets loaded before the serial port rules are applied.}}<br />
<br />
3. Install your systemd service file.<br />
{{hc|/etc/systemd/system/lirc.service|[Unit]<br />
Description&#61;Linux Infrared Remote Control<br />
After&#61;network.target<br />
<br />
[Service]<br />
Type&#61;simple<br />
PIDFile&#61;/run/lirc/lircd.pid<br />
ExecStartPre&#61;/bin/rm -f /dev/lirc /dev/lircd /var/run/lirc/lircd<br />
ExecStart&#61;/usr/sbin/lircd -n -r -P /run/lirc/lircd.pid -d /dev/lirc0 -o /run/lirc/lircd<br />
ExecStartPost&#61;/usr/bin/ln -sf /run/lirc/lircd /dev/lircd<br />
ExecStartPost&#61;/usr/bin/ln -sf /dev/lirc0 /dev/lirc<br />
ExecReload&#61;/bin/kill -SIGHUP $MAINPID<br />
<br />
[Install]<br />
WantedBy&#61;multi-user.target}}<br />
<br />
4. We still need the default tmpfiles to be created, so copy that config file to {{ic|/etc/tmpfiles.d/lirc.conf}}.<br />
{{bc|# cp -a /usr/lib/tmpfiles.d/lirc.conf /etc/tmpfiles.d/lirc.conf}}<br />
<br />
5. Create a {{ic|.lircrc}} file in your home directory for your user or a {{ic|/etc/lirc/lircrc}} file for system wide use.<br />
<br />
6. Have your service start at boot and then test with a reboot<br />
{{bc|1=# systemctl enable lirc.service<br />
# systemctl reboot}}<br />
<br />
or load the module and start the lirc.service.<br />
{{bc|# modprobe lirc_serial<br />
# systemctl start lirc.service}}<br />
<br />
==Troubleshooting==<br />
<br />
===Buttons processed several times when pressed===<br />
Problem in module ir_core which processes IR commands with LIRC at the same time. Simply blacklist it by creating the following file:<br />
<br />
{{hc|/etc/modprobe.d/remote_blacklist.conf|<br />
# Prevent processing button several times when pressed<br />
blacklist ir_core<br />
}}<br />
<br />
===After upgrading or installing Arch, an existing configuration stopped working===<br />
====Kernel module change====<br />
As of kernel 2.6.36, LIRC modules have been included in the kernel. Arch's ''lirc'' package has included the older kernel modules, which work with ''lircd'' without any additional configuration. However, a recent update removed those older modules, which results in the stock kernel modules being used. Unfortunately, these kernel modules treat the remote as a keyboard by default, which is incompatible for lircd. To correct this, put the following line to {{ic|/etc/rc.local}}:<br />
{{hc|/etc/rc.local|echo lirc > /sys/class/rc/rc0/protocols}}<br />
You may also run that command as root to enable LIRC for your current session.<br />
<br />
{{Note|It is also a good idea to remove the old LIRC kernel module from your MODULES array in {{ic|/etc/rc.conf}}, as it is no longer present.}}<br />
<br />
=== Problems using default systemd lirc.service file ===<br />
<br />
lircd log complains:<br />
{{bc|<br />
could not get file information for /dev/lirc<br />
default_init(): No such file or directory<br />
}}<br />
<br />
Solution is to add a symbolic link for {{ic|/dev/lirc}} before starting the lirc daemon.<br />
<br />
1. Copy the system default {{ic|lirc.service}} file to {{ic|/etc/systemd/system/}}<br />
{{bc|# cp /usr/lib/systemd/system/lirc.service /etc/systemd/system/lirc.service}}<br />
<br />
2. Add the following line to {{ic|/etc/systemd/system/lirc.service}}:<br />
{{bc|<nowiki><br />
ExecStartPre=/usr/bin/ln -sf /dev/lirc0 /dev/lirc<br />
</nowiki>}}<br />
<br />
So now it looks like:<br />
{{hc|/etc/systemd/system/lirc.service<br />
|<nowiki><br />
[Unit]<br />
Description=Linux Infrared Remote Control<br />
<br />
[Service]<br />
EnvironmentFile=/etc/conf.d/lircd.conf<br />
ExecStartPre=/usr/bin/ln -sf /dev/lirc0 /dev/lirc<br />
ExecStartPre=/usr/bin/ln -sf /run/lirc/lircd /dev/lircd<br />
ExecStart=/usr/sbin/lircd --pidfile=/run/lirc/lircd.pid<br />
Type=forking<br />
PIDFile=/run/lirc/lircd.pid<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
3. disable/enable the lirc service to use the new service file {{ic|/etc/systemd/system/lirc.service}}<br />
{{bc|# systemctl disable lirc<br />
# systemctl enable lirc}}<br />
<br />
4. Restart the service<br />
{{bc|# systemctl restart lirc}}<br />
<br />
{{Note|Make sure you have the correct configuration file in {{ic|/etc/lirc/lircd.conf}}. Copy or link one from {{ic|/usr/share/lirc/remotes}} }}<br />
<br />
==See also==<br />
* http://www.mythtv.org/wiki/Category:Remote_Controls -- MythTV wiki main LIRC article<br />
* http://www.mythtv.org/wiki/MCE_Remote -- MythTV wiki on MCE remotes <br />
* http://en.gentoo-wiki.com/wiki/LIRC -- Gentoo wiki LIRC how-to<br />
* https://aur.archlinux.org/packages.php?ID=33849 -- Lirc/Lircrc Configuration Generator</div>Apouloshttps://wiki.archlinux.org/index.php?title=PulseAudio&diff=224945PulseAudio2012-09-25T00:03:16Z<p>Apoulos: Undo revision 224944 by Apoulos (talk)</p>
<hr />
<div>[[Category:Audio/Video]]<br />
[[cs:PulseAudio]]<br />
[[es:PulseAudio]]<br />
[[fr:PulseAudio]]<br />
[[it:PulseAudio]]<br />
[[pt:PulseAudio]]<br />
[[ru:PulseAudio]]<br />
[[tr:PulseAudio]]<br />
{{Article summary start}}<br />
{{Article summary text|'''PulseAudio''' is a general purpose sound server. For a list of features, see [[Wikipedia:PulseAudio#Features]].}}<br />
{{Article summary heading|Related Articles}}<br />
{{Article summary wiki|PulseAudio/Examples}}<br />
{{Article summary end}}<br />
<br />
==Installation==<br />
*Required PKG: {{Pkg|pulseaudio}}<br />
*Optional GUIs: {{Pkg|paprefs}} and {{Pkg|pavucontrol}}<br />
*Optional volume control via mapped keyboard keys: {{AUR|pulseaudio_ctl}}<br />
*Optional console mixer: {{AUR|ponymix-git}} and {{AUR|pamixer-git}}<br />
*Optional system tray icon: {{AUR|pasystray-git}}<br />
*Optional kde plasma applet: {{AUR|kdeplasma-applets-veromix}}<br />
{{Note|Add the users to audio group and (if applicable) re-login.}}<br />
<br />
==Running==<br />
{{Note|Pulseaudio requires dbus to function. This is very likely already added in the daemons array, if not consider adding it.}}<br />
{{Note|Most X11 environments start pulseaudio automatically with the X11 session.}}<br />
<br />
In the unlikely event that pulseaudio is not automatically called upon entering X, it can can be started with:<br />
$ pulseaudio --start<br />
<br />
PulseAudio can be stopped with:<br />
$ pulseaudio --kill<br />
<br />
==Equalizer==<br />
<br />
Newer pulseaudio versions have an intergrated 10-band equalizer system. In order to use the equalizer do the following:<br />
<br />
===Load equalizer sink module===<br />
<br />
$ pactl load-module module-equalizer-sink<br />
<br />
===Install and run the gui frontend===<br />
<br />
# pacman -S --needed python2-pyqt<br />
<br />
$ qpaeq<br />
<br />
{{Note|If qpaeq has no effect, install pavucontrol and change "ALSA Playback on" to "FFT based equalizer on ..." while the media player is running.}}<br />
<br />
===Load equalizer module on every boot===<br />
<br />
Edit the file {{ic|/etc/pulse/default.pa}} with your favorite editor and append the following lines:<br />
<br />
### Load the integrated pulseaudio equalizer module<br />
load-module module-equalizer-sink<br />
<br />
==Backend Configuration==<br />
===ALSA===<br />
*Recommended PKG: {{Pkg|pulseaudio-alsa}}<br />
*Optional PKGs: {{Pkg|lib32-libpulse}} and {{Pkg|lib32-alsa-plugins}}<br />
<br />
{{Note|Optional PKGs are needed only if running x86_64 and wanting to have sound for 32 bit programs (like Wine).}}<br />
<br />
For the applications that do not support PulseAudio and support ALSA it is '''recommended''' to install the PulseAudio plugin for ALSA. This package also contains the necessary {{ic|/etc/asound.conf}} for configuring ALSA to use PulseAudio.<br />
<br />
To prevent applications from using ALSA's OSS emulation and bypassing Pulseaudio (thereby preventing other applications from playing sound), make sure the module {{ic|snd_pcm_oss}} is not in the {{ic|MODULES}} array in {{ic|/etc/[[rc.conf]]}}. If it is currently loaded, disable it by executing:<br />
# rmmod snd_pcm_oss<br />
<br />
===OSS===<br />
There are multiple ways of making OSS-only programs play to PulseAudio:<br />
<br />
===={{Pkg|ossp}}====<br />
Start ossp with:<br />
rc.d start osspd<br />
<br />
Afterwards, add it to DAEMONS in rc.conf.<br />
<br />
====padsp wrapper (part of PulseAudio)====<br />
Programs using OSS can work with PulseAudio by starting it with padsp:<br />
<br />
$ padsp OSSprogram<br />
A few examples:<br />
$ padsp aumix<br />
$ padsp sox foo.wav -t ossdsp /dev/dsp<br />
<br />
One can also rename the program OSSprogram-bin and replace it with a script like this: <br />
{{hc|/usr/bin/OSSProgram|<nowiki><br />
#!/bin/sh<br />
if test -x /usr/bin/padsp; then<br />
exec /usr/bin/padsp /usr/bin/OSSprogram-bin "$@"<br />
else<br />
exec /usr/bin/OSSprogram "$@"<br />
fi<br />
</nowiki>}}<br />
<br />
===GStreamer===<br />
To make [[GStreamer]] use PulseAudio, you need to install {{Pkg|gstreamer0.10-good-plugins}}, execute {{ic|gstreamer-properties}} (part of ''gnome-media'' package) and select ''PulseAudio Sound Server'' in both Audio Input and Output. Alternatively, this can be done by setting the gconf variables {{ic|/system/gstreamer/0.10/default/audiosink}} to ''pulsesink'' and {{ic|/system/gstreamer/0.10/default/audiosrc}} to ''pulsesrc'':<br />
$ gconftool-2 -t string --set /system/gstreamer/0.10/default/audiosink pulsesink<br />
$ gconftool-2 -t string --set /system/gstreamer/0.10/default/audiosrc pulsesrc<br />
<br />
Some applications (like Rhythmbox) ignore the ''audiosink'' property, but rely instead on ''musicaudiosink'', which cannot be configured using {{ic|gstreamer-properties}} but needs to be manually set using {{ic|gconf-editor}} or the {{ic|gconftool-2}}:<br />
$ gconftool-2 -t string --set /system/gstreamer/0.10/default/musicaudiosink pulsesink<br />
<br />
===OpenAL===<br />
OpenAL Soft should use PulseAudio by default, but can be explicitly configured to do so: {{hc|/etc/openal/alsoft.conf|2=drivers=pulse,alsa}}<br />
<br />
===libao===<br />
Edit the libao configuration file:<br />
{{hc|/etc/libao.conf|2=default_driver=pulse}}<br />
<br />
===ESD===<br />
PulseAudio is a drop-in replacement for the enlightened sound daemon (ESD). While PulseAudio is running, ESD clients should be able to output to it without configuration.<br />
<br />
==Desktop Environments==<br />
===General X11===<br />
{{Note|As mentioned previously, PulseAudio is very likely launched automatically via either {{ic|/etc/X11/xinit/xinitrc.d/pulseaudio}} or the files in {{ic|/etc/xdg/autostart/}} if users have some DE installed.}}<br />
<br />
Check to see if PulseAudio is running:<br />
<br />
$ ps aux | grep pulse<br />
facade 1794 0.0 0.0 360464 6532 ? S<l 15:33 0:00 /usr/bin/pulseaudio --start<br />
facade 1827 0.0 0.0 68888 2608 ? S 15:33 0:00 /usr/lib/pulse/gconf-helper<br />
<br />
If Pulseaudio is not running and users are using X, the following will start PulseAudio with the needed the X11 plugins manually:<br />
$ start-pulseaudio-x11<br />
<br />
If you are not running Gnome, KDE or XFCE and your {{ic|~/.xinitrc}} does not source the scripts in {{ic|/etc/X11/xinit/xinitrc.d}} (such as is done in the example file {{ic|/etc/skel/.xinitrc}}) then you can launch PulseAudio on boot by adding the following line to ~/.xinitrc:<br />
/usr/bin/start-pulseaudio-x11<br />
<br />
===GNOME===<br />
As of GNOME 3, GNOME fully integrates with PulseAudio and no extra configuration is needed.<br />
<br />
===KDE 3===<br />
PulseAudio is ''not'' a drop-in replacement for aRts. Users of KDE 3 cannot use PulseAudio. However note, recent versions of puleaudio may have eliminated the prohibition:<br />
<br />
See: http://www.pulseaudio.org/wiki/PerfectSetup KDE 3 uses the artsd sound server by default. However, artsd itself can be configured to use an Esound backend. Edit kcmartsrc (either in /etc/kde or /usr/share/config for global configuration or .kde/share/config to configure only one user) like this:<br />
<br />
[Arts]<br />
Arguments=\s-F 10 -S 4096 -a esd -n -s 1 -m artsmessage -c drkonqi -l 3 -f<br />
NetworkTransparent=true<br />
SuspendTime=1<br />
<br />
===KDE 4 and Qt4===<br />
PulseAudio, it will be used by KDE4/Qt4 applications. For more information see the [http://www.pulseaudio.org/wiki/KDE KDE page in the PulseAudio wiki].<br />
<br />
One useful tidbit from that page is to add {{ic|load-module module-device-manager}} to {{ic|/etc/pulse/default.pa}}.<br />
<br />
Additionally, the {{AUR|kdeplasma-applets-veromix}} is available in the AUR as a KDE alternative to pavucontrol.<br />
<br />
===XFCE4===<br />
Applications running under XFCE4 can take advantage of Pulseaudio. To manage Pulseaudio settings you can use {{Pkg|pavucontrol}}.<br />
<br />
==Applications==<br />
===Audacious===<br />
[[Audacious]] natively supports PulseAudio. In order to use it, set Audacious Preferences -> Audio -> Current output plugin to 'PulseAudio Output Plugin'.<br />
<br />
===Java/OpenJDK 6===<br />
Create a wrapper for the java executable using padsp as seen on the [[Java#Java_sound_with_Pulseaudio|Java sound with Pulseaudio]] page.<br />
<br />
===Music Player Daemon (MPD)===<br />
[http://mpd.wikia.com/wiki/PulseAudio configure] [[MPD]] to use PulseAudio.<br />
<br />
===MPlayer===<br />
[[MPlayer]] natively supports PulseAudio output with the "{{ic|-ao pulse}}" option. It can also be configured to default to PulseAudio output, in {{ic|~/.mplayer/config}} for per-user, or {{ic|/etc/mplayer/mplayer.conf}} for system-wide:<br />
{{hc|/etc/mplayer/mplayer.conf|2=ao=pulse}}<br />
<br />
===Skype (x86_64 only)===<br />
Install {{Pkg|lib32-libpulse}}, otherwise the following error will occur when trying to initiate a call: "Problem with Audio Playback".<br />
<br />
==Troubleshooting==<br />
===No sound after install===<br />
<br />
====Muted audio device====<br />
If one experiences no audio output via any means while using ALSA, attempt to unmute the sound card. To do this, launch alsamixer and make sure each column has a green 00 under it (this can be toggled by pressing 'm')<br />
$ alsamixer -c 0<br />
<br />
====Bad configuration files====<br />
If after starting pulseaudio, the system outputs no sound, it may be necessary to delete the contents of {{ic|~/.pulse}}. Pulseaudio will automatically create new configuration files on its next start.<br />
<br />
====Flash Content====<br />
Since Adobe Flash does not directly support PulseAudio the recommended way is to [https://wiki.archlinux.org/index.php/PulseAudio#ALSA configure ALSA to use the virtual PulseAudio soundcard].<br />
<br />
Alternatively no sound from flash content may be fixed by installing {{AUR|libflashsupport-pulse}} from the AUR (not recommended as it seems to make the flash plugin crash rather frequently).<br />
<br />
{{Pkg|lib32-libpulse}} is another PKG users can consider if on a 64-bit Arch and using [multilib]'s flashplugin:<br />
<br />
# pacman -S lib32-libcanberra-pulse lib32-alsa-plugins<br />
<br />
====No cards====<br />
If PulseAudio starts, run {{ic|pacmd list}}. If no cards are reported, make sure that the ALSA devices are not in use:<br />
$ fuser -v /dev/snd/*<br />
$ fuser -v /dev/dsp<br />
<br />
Make sure any applications using the pcm or dsp files are shut down before restarting PulseAudio.<br />
<br />
====The only device shown is "dummy output"====<br />
This may be caused by different reasons, one of them being the .asoundrc file in $HOME is taking precedence over the systemwide /etc/asound.conf.<br />
<br />
The user file is modified also by the tool '''asoundconf''' or by its graphical variant '''asoundconf-gtk''' (the latter is named "Default sound card" in the menu) as soon as it runs. Prevent the effects of .asoundrc altogether by commenting the last line like this:<br />
<br />
#</home/<yourusername>/.asoundrc.asoundconf><br />
<br />
====KDE4====<br />
It may be that another output device set as preferred in phonon. Make sure that every setting reflects the preferred output device at the top, and check the playback streams tab in kmix to make sure that applications are using the device for output.<br />
<br />
===Bluetooth headset replay problems===<br />
Some user [https://bbs.archlinux.org/viewtopic.php?id=117420 report] huge delays or even no sound when the bluetooth connection does not send any data. This is due to an idle-suspend-module that puts the related sinks/sources automatically into suspend. As this can cause problems with headset, the responsible module can be deactivated. <br />
<br />
1. cp /etc/pulse/default.pa ~/.pulse/default.pa<br />
2. comment out the "load-module module-suspend-on-idle" line in ~/.pulse/default.pa<br />
3. pulseaudio -k && pulseaudio --start<br />
<br />
[http://robert.orzanna.de/2011/08/10/prevent-idle-suspend-with-a-bluetooth-headset-and-a2dp/ More information]<br />
<br />
===Automatically switch to Bluetooth or USB headset===<br />
Add the following to your /etc/pulse/default.pa:<br />
<br />
# automatically switch to newly-connected devices<br />
load-module module-switch-on-connect<br />
<br />
===Pulse overwrites ALSA settings===<br />
Pulseaudio usually overwrites the ALSA settings- for example set with alsamixer- at start up, even when the alsa daemon is loaded. Since there seems to be no other way to restrict this behaviour, a workaround is to restore the alsa settings again after pulseaudio had started. Add the following command to {{ic|.xinitrc}} {{ic|.bash_login}} or any other autostart file:<br />
<br />
restore_alsa() {<br />
while [ -z "`pidof pulseaudio`" ]; do<br />
sleep 0.5<br />
done<br />
alsactl -f /var/lib/alsa/asound.state restore <br />
}<br />
restore_alsa &<br />
<br />
===Daemon startup failed===<br />
Try resetting PulseAudio. To do that:<br />
$ pulseaudio --kill<br />
$ killall pulseaudio<br />
$ killall -9 pulseaudio<br />
$ rm -rf ~/.pulse*<br />
$ rm -rf /tmp/pulse*<br />
<br />
Afterwards, start PulseAudio again.<br />
<br />
===padevchooser===<br />
If one cannot launch the PulseAudio Device Chooser, first (re)start the Avahi daemon as follows:<br />
$ rc.d restart avahi-daemon<br />
<br />
===Glitches, skips or crackling===<br />
The PulseAudio sound server uses a timer-based audio scheduling instead of the traditional interrupt-driven approach. Timer-based scheduling may expose issues in some ALSA drivers. To turn timer-based scheduling off, replace the line:<br />
load-module module-udev-detect <br />
in {{ic|/etc/pulse/default.pa}} by:<br />
load-module module-udev-detect tsched=0<br />
Then restart the PulseAudio server.<br />
<br />
===Choppy sound===<br />
Choppy sound in pulsaudio can result from wrong settings for the sample rate in {{Ic|/etc/pulse/daemon.conf}}. Try changing the line <br />
; default-sample-rate = 44100<br />
to <br />
default-sample-rate = 48000<br />
and restart the PulseAudio server.<br />
<br />
If one experiences choppy sound in applications using openAL, change the sample rate in /etc/openal/alsoft.conf:<br />
frequency = 48000<br />
<br />
Setting the PCM volume above 0dB can cause clipping of the audio signal. Running {{ic|alsamixer -c0}} will allow you to see if this is the problem and if so fix it.<br />
<br />
===Volume adjustment does not work properly===<br />
Check:<br />
{{ic|/usr/share/pulseaudio/alsa-mixer/paths/analog-output.conf.common}}<br />
<br />
If the volume does not appear to increment/decrement properly using {{ic|alsamixer}} or {{ic|amixer}}, it may be due to pulseaudio having a larger number of increments (65537 to be exact). Try using larger values when changing volume (e.g. {{ic|amixer set Master 655+}}).<br />
<br />
===Volume gets louder every time a new application is started===<br />
Per default, it seems as if changing the volume in an application sets the global system volume to that level instead of only affecting the respective application. Applications setting their volume on startup will therefore cause the system volume to "jump".<br />
<br />
Fix this by uncommenting <br />
flat-volumes = no<br />
in<br />
/etc/pulse/daemon.conf<br />
and then restarting PulseAudio by executing<br />
pulseaudio --kill && pulseaudio --start<br />
<br />
When Pulse comes back after a few seconds, applications will not alter the global system volume anymore but have their own volume level again.<br />
<br />
{{Note|A previously installed and removed pulseaudio-equalizer may leave behind remnants of the setup in {{Ic|$HOME/.pulse/default.pa}} which can also cause maximized volume trouble. Comment that out as needed.}}<br />
<br />
===No mic on ThinkPad T400/T500/T420===<br />
Run<br />
alsamixer -c 0<br />
Maximize the volume of/unmute the "Internal Mic".<br />
<br />
Once you see the device with<br />
arecord -l<br />
you might still need to adjust the settings. The microphone and the audio jack are duplexed. Set the configuration of the internal audio in pavucontrol to ''Analog Stereo Duplex''.<br />
<br />
===No mic input on Acer Aspire One===<br />
Install pavucontrol, unlink the microphone channels and turn down the left one to 0.<br />
Reference: http://getsatisfaction.com/jolicloud/topics/deaf_internal_mic_on_acer_aspire_one#reply_2108048<br />
<br />
===Sound output is only mono on M-Audio Audiophile 2496 sound card===<br />
Add the following to /etc/pulseaudio/default.pa:<br />
load-module module-alsa-sink sink_name=delta_out device=hw:M2496 format=s24le channels=10 channel_map=left,right,aux0,aux1,aux2,aux3,aux4,aux5,aux6,aux7<br />
load-module module-alsa-source source_name=delta_in device=hw:M2496 format=s24le channels=12 channel_map=left,right,aux0,aux1,aux2,aux3,aux4,aux5,aux6,aux7,aux8,aux9<br />
set-default-sink delta_out<br />
set-default-source delta_in<br />
<br />
===Static Noise in Microphone Recording===<br />
If we are getting static noise in skype, gnome-sound-recorder, arecord, etc.'s recordings then the sound card samplerate is incorrect. That is why there is static noise in linux microphone recordings. To fix this We need to set sample-rate in /etc/pulse/daemon.conf for the sound hardware.<br />
<br />
====1. Determine soundcards in the system====<br />
This requires alsa-utils and related packages to be installed:<br />
$ arecord --list-devices<br />
<br />
output:<br />
**** List of CAPTURE Hardware Devices ****<br />
card 0: Intel [HDA Intel], device 0: ALC888 Analog [ALC888 Analog]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 0: Intel [HDA Intel], device 2: ALC888 Analog [ALC888 Analog]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
<br />
soundcard is hw:0,0<br />
<br />
====2. Determine sampling-rate of the sound card====<br />
arecord -f dat -r 60000 -D hw:0,0 -d 5 test.wav<br />
<br />
output:<br />
"Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 60000 Hz, Stereo<br />
Warning: rate is not accurate (requested = 60000Hz, '''got = 96000Hz''')<br />
please, try the plug plugin<br />
<br />
observe, the '''got = 96000Hz''', this is the max sample-rate of our card.<br />
<br />
====3. Setting the soundcard's sampling rate into pulse audio configuration====<br />
the default sample-rate in pulseaudio is<br />
grep "sample-rate" /etc/pulse/daemon.conf<br />
<br />
output:<br />
; default-sample-rate = 44100<br />
<br />
It is 44100 and is disabled. Let us set our sound card's settings into pulseaudio configuation file<br />
su -c "sed 's/; default-sample-rate = 44100/default-sample-rate = 96000/g' -i /etc/pulse/daemon.conf"<br />
<br />
Let us verify the changes to deamon.conf<br />
grep "sample-rate" /etc/pulse/daemon.conf <br />
output:<br />
default-sample-rate = 96000<br />
and it is done.<br />
<br />
====4. Restart pulseaudio to apply the new settings====<br />
pulseaudio --kill<br />
pulseaudio --start<br />
<br />
====5. Finally check by recording and playing it back====<br />
Let us record some voice using mic for say 10 seconds. Make sure the mic is not muted and all<br />
arecord -f cd -d 10 test-mic.wav<br />
<br />
After 10 seconds, let us play the recording...<br />
aplay test-mic.wav<br />
<br />
Now hopefully, there is no static noise in microphone recording anymore.<br />
<br />
=== My Bluetooth device is paired but does not play any sound ===<br />
[[Bluetooth#My_device_is_paired_but_no_sound_is_played_from_it|See the article in Bluetooth section]]<br />
<br />
=== Subwoofer stops working after end of every song ===<br />
Known issue: https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/494099<br />
<br />
To fix this, must edit: {{ic|/etc/pulse/daemon.conf}} and enable {{ic|enable-lfe-remixing}} :<br />
{{hc|/etc/pulse/daemon.conf|<nowiki><br />
enable-lfe-remixing = yes<br />
</nowiki>}}<br />
<br />
=== Pulseaudio uses wrong microphone ===<br />
If Pulseaudio uses the wrong microphone, and changing the Input Device with Pavucontrol did not help, take a look at alsamixer. It seems that Pavucontrol does not always set the input source correctly.<br><br />
Run:<br />
<br />
$ alsamixer<br />
<br />
press F6 and choose your sound card, e.g. HDA Intel. Now press F5 to display all items. Try to find the item: {{ic|Input Source}}. With the up/down arrow keys you are able to change the input source. <br><br />
Now try if the correct microphone is used for recording.<br />
<br />
==External links==<br />
*[http://www.pulseaudio.org/wiki/PerfectSetup http://www.pulseaudio.org/wiki/PerfectSetup] - A good guide to make your configuration perfect<br />
*[http://www.alsa-project.org/main/index.php/Asoundrc http://www.alsa-project.org/main/index.php/Asoundrc] - Alsa wiki on .asoundrc<br />
*[http://www.pulseaudio.org/ http://www.pulseaudio.org/] - PulseAudio official site<br />
*[http://www.pulseaudio.org/wiki/FAQ http://www.pulseaudio.org/wiki/FAQ] - PulseAudio FAQ</div>Apouloshttps://wiki.archlinux.org/index.php?title=PulseAudio&diff=224944PulseAudio2012-09-25T00:01:40Z<p>Apoulos: </p>
<hr />
<div>[[Category:Audio/Video]]<br />
[[cs:PulseAudio]]<br />
[[es:PulseAudio]]<br />
[[fr:PulseAudio]]<br />
[[it:PulseAudio]]<br />
[[pt:PulseAudio]]<br />
[[ru:PulseAudio]]<br />
[[tr:PulseAudio]]<br />
{{Article summary start}}<br />
{{Article summary text|'''PulseAudio''' is a general purpose sound server. For a list of features, see [[Wikipedia:PulseAudio#Features]].}}<br />
{{Article summary heading|Related Articles}}<br />
{{Article summary wiki|PulseAudio/Examples}}<br />
{{Article summary end}}<br />
<br />
==Installation==<br />
*Required PKG: {{Pkg|pulseaudio}}<br />
*Optional GUIs: {{Pkg|paprefs}} and {{Pkg|pavucontrol}}<br />
*Optional volume control via mapped keyboard keys: {{AUR|pulseaudio_ctl}}<br />
*Optional console mixer: {{AUR|ponymix-git}} and {{AUR|pamixer-git}}<br />
*Optional system tray icon: {{AUR|pasystray-git}}<br />
*Optional kde plasma applet: {{AUR|kdeplasma-applets-veromix}}<br />
{{Note|Add the users to audio group and (if applicable) re-login.}}<br />
<br />
==Running==<br />
{{Note|Pulseaudio requires dbus to function. This is very likely already added in the daemons array, if not consider adding it.}}<br />
{{Note|Most X11 environments start pulseaudio automatically with the X11 session.}}<br />
<br />
In the unlikely event that pulseaudio is not automatically called upon entering X, it can can be started with:<br />
$ pulseaudio --start<br />
<br />
PulseAudio can be stopped with:<br />
$ pulseaudio --kill<br />
<br />
==Equalizer==<br />
<br />
Newer pulseaudio versions have an intergrated 10-band equalizer system. In order to use the equalizer do the following:<br />
<br />
===Load equalizer sink module===<br />
<br />
$ pactl load-module module-equalizer-sink<br />
<br />
===Install and run the gui frontend===<br />
<br />
# pacman -S --needed python2-pyqt<br />
<br />
$ qpaeq<br />
<br />
{{Note|If qpaeq has no effect, install pavucontrol and change "ALSA Playback on" to "FFT based equalizer on ..." while the media player is running.}}<br />
<br />
===Load equalizer module on every boot===<br />
<br />
Edit the file {{ic|/etc/pulse/default.pa}} with your favorite editor and append the following lines:<br />
<br />
### Load the integrated pulseaudio equalizer module<br />
load-module module-equalizer-sink<br />
<br />
<br />
==Backend Configuration==<br />
===ALSA===<br />
*Recommended PKG: {{Pkg|pulseaudio-alsa}}<br />
*Optional PKGs: {{Pkg|lib32-libpulse}} and {{Pkg|lib32-alsa-plugins}}<br />
<br />
{{Note|Optional PKGs are needed only if running x86_64 and wanting to have sound for 32 bit programs (like Wine).}}<br />
<br />
For the applications that do not support PulseAudio and support ALSA it is '''recommended''' to install the PulseAudio plugin for ALSA. This package also contains the necessary {{ic|/etc/asound.conf}} for configuring ALSA to use PulseAudio.<br />
<br />
To prevent applications from using ALSA's OSS emulation and bypassing Pulseaudio (thereby preventing other applications from playing sound), make sure the module {{ic|snd_pcm_oss}} is not in the {{ic|MODULES}} array in {{ic|/etc/[[rc.conf]]}}. If it is currently loaded, disable it by executing:<br />
# rmmod snd_pcm_oss<br />
<br />
===OSS===<br />
There are multiple ways of making OSS-only programs play to PulseAudio:<br />
<br />
===={{Pkg|ossp}}====<br />
Start ossp with:<br />
rc.d start osspd<br />
<br />
Afterwards, add it to DAEMONS in rc.conf.<br />
<br />
====padsp wrapper (part of PulseAudio)====<br />
Programs using OSS can work with PulseAudio by starting it with padsp:<br />
<br />
$ padsp OSSprogram<br />
A few examples:<br />
$ padsp aumix<br />
$ padsp sox foo.wav -t ossdsp /dev/dsp<br />
<br />
One can also rename the program OSSprogram-bin and replace it with a script like this: <br />
{{hc|/usr/bin/OSSProgram|<nowiki><br />
#!/bin/sh<br />
if test -x /usr/bin/padsp; then<br />
exec /usr/bin/padsp /usr/bin/OSSprogram-bin "$@"<br />
else<br />
exec /usr/bin/OSSprogram "$@"<br />
fi<br />
</nowiki>}}<br />
<br />
===GStreamer===<br />
To make [[GStreamer]] use PulseAudio, you need to install {{Pkg|gstreamer0.10-good-plugins}}, execute {{ic|gstreamer-properties}} (part of ''gnome-media'' package) and select ''PulseAudio Sound Server'' in both Audio Input and Output. Alternatively, this can be done by setting the gconf variables {{ic|/system/gstreamer/0.10/default/audiosink}} to ''pulsesink'' and {{ic|/system/gstreamer/0.10/default/audiosrc}} to ''pulsesrc'':<br />
$ gconftool-2 -t string --set /system/gstreamer/0.10/default/audiosink pulsesink<br />
$ gconftool-2 -t string --set /system/gstreamer/0.10/default/audiosrc pulsesrc<br />
<br />
Some applications (like Rhythmbox) ignore the ''audiosink'' property, but rely instead on ''musicaudiosink'', which cannot be configured using {{ic|gstreamer-properties}} but needs to be manually set using {{ic|gconf-editor}} or the {{ic|gconftool-2}}:<br />
$ gconftool-2 -t string --set /system/gstreamer/0.10/default/musicaudiosink pulsesink<br />
<br />
===OpenAL===<br />
OpenAL Soft should use PulseAudio by default, but can be explicitly configured to do so: {{hc|/etc/openal/alsoft.conf|2=drivers=pulse,alsa}}<br />
<br />
===libao===<br />
Edit the libao configuration file:<br />
{{hc|/etc/libao.conf|2=default_driver=pulse}}<br />
<br />
===ESD===<br />
PulseAudio is a drop-in replacement for the enlightened sound daemon (ESD). While PulseAudio is running, ESD clients should be able to output to it without configuration.<br />
<br />
==Desktop Environments==<br />
===General X11===<br />
{{Note|As mentioned previously, PulseAudio is very likely launched automatically via either {{ic|/etc/X11/xinit/xinitrc.d/pulseaudio}} or the files in {{ic|/etc/xdg/autostart/}} if users have some DE installed.}}<br />
<br />
Check to see if PulseAudio is running:<br />
<br />
$ ps aux | grep pulse<br />
facade 1794 0.0 0.0 360464 6532 ? S<l 15:33 0:00 /usr/bin/pulseaudio --start<br />
facade 1827 0.0 0.0 68888 2608 ? S 15:33 0:00 /usr/lib/pulse/gconf-helper<br />
<br />
If Pulseaudio is not running and users are using X, the following will start PulseAudio with the needed the X11 plugins manually:<br />
$ start-pulseaudio-x11<br />
<br />
If you are not running Gnome, KDE or XFCE and your {{ic|~/.xinitrc}} does not source the scripts in {{ic|/etc/X11/xinit/xinitrc.d}} (such as is done in the example file {{ic|/etc/skel/.xinitrc}}) then you can launch PulseAudio on boot by adding the following line to ~/.xinitrc:<br />
/usr/bin/start-pulseaudio-x11<br />
<br />
===GNOME===<br />
As of GNOME 3, GNOME fully integrates with PulseAudio and no extra configuration is needed.<br />
<br />
===KDE 3===<br />
PulseAudio is ''not'' a drop-in replacement for aRts. Users of KDE 3 cannot use PulseAudio. However note, recent versions of puleaudio may have eliminated the prohibition:<br />
<br />
See: http://www.pulseaudio.org/wiki/PerfectSetup KDE 3 uses the artsd sound server by default. However, artsd itself can be configured to use an Esound backend. Edit kcmartsrc (either in /etc/kde or /usr/share/config for global configuration or .kde/share/config to configure only one user) like this:<br />
<br />
[Arts]<br />
Arguments=\s-F 10 -S 4096 -a esd -n -s 1 -m artsmessage -c drkonqi -l 3 -f<br />
NetworkTransparent=true<br />
SuspendTime=1<br />
<br />
===KDE 4 and Qt4===<br />
PulseAudio, it will be used by KDE4/Qt4 applications. For more information see the [http://www.pulseaudio.org/wiki/KDE KDE page in the PulseAudio wiki].<br />
<br />
One useful tidbit from that page is to add {{ic|load-module module-device-manager}} to {{ic|/etc/pulse/default.pa}}.<br />
<br />
Additionally, the {{AUR|kdeplasma-applets-veromix}} is available in the AUR as a KDE alternative to pavucontrol.<br />
<br />
===XFCE4===<br />
Applications running under XFCE4 can take advantage of Pulseaudio. To manage Pulseaudio settings you can use {{Pkg|pavucontrol}}.<br />
<br />
==Applications==<br />
===Audacious===<br />
[[Audacious]] natively supports PulseAudio. In order to use it, set Audacious Preferences -> Audio -> Current output plugin to 'PulseAudio Output Plugin'.<br />
<br />
===Java/OpenJDK 6===<br />
Create a wrapper for the java executable using padsp as seen on the [[Java#Java_sound_with_Pulseaudio|Java sound with Pulseaudio]] page.<br />
<br />
===Music Player Daemon (MPD)===<br />
[http://mpd.wikia.com/wiki/PulseAudio configure] [[MPD]] to use PulseAudio.<br />
<br />
===MPlayer===<br />
[[MPlayer]] natively supports PulseAudio output with the "{{ic|-ao pulse}}" option. It can also be configured to default to PulseAudio output, in {{ic|~/.mplayer/config}} for per-user, or {{ic|/etc/mplayer/mplayer.conf}} for system-wide:<br />
{{hc|/etc/mplayer/mplayer.conf|2=ao=pulse}}<br />
<br />
===Skype (x86_64 only)===<br />
Install {{Pkg|lib32-libpulse}}, otherwise the following error will occur when trying to initiate a call: "Problem with Audio Playback".<br />
<br />
==Troubleshooting==<br />
===No sound after install===<br />
<br />
====Muted audio device====<br />
If one experiences no audio output via any means while using ALSA, attempt to unmute the sound card. To do this, launch alsamixer and make sure each column has a green 00 under it (this can be toggled by pressing 'm')<br />
$ alsamixer -c 0<br />
<br />
====Bad configuration files====<br />
If after starting pulseaudio, the system outputs no sound, it may be necessary to delete the contents of {{ic|~/.pulse}}. Pulseaudio will automatically create new configuration files on its next start.<br />
<br />
====Flash Content====<br />
Since Adobe Flash does not directly support PulseAudio the recommended way is to [https://wiki.archlinux.org/index.php/PulseAudio#ALSA configure ALSA to use the virtual PulseAudio soundcard].<br />
<br />
Alternatively no sound from flash content may be fixed by installing {{AUR|libflashsupport-pulse}} from the AUR (not recommended as it seems to make the flash plugin crash rather frequently).<br />
<br />
{{Pkg|lib32-libpulse}} is another PKG users can consider if on a 64-bit Arch and using [multilib]'s flashplugin:<br />
<br />
# pacman -S lib32-libcanberra-pulse lib32-alsa-plugins<br />
<br />
====No cards====<br />
If PulseAudio starts, run {{ic|pacmd list}}. If no cards are reported, make sure that the ALSA devices are not in use:<br />
$ fuser -v /dev/snd/*<br />
$ fuser -v /dev/dsp<br />
<br />
Make sure any applications using the pcm or dsp files are shut down before restarting PulseAudio.<br />
<br />
====The only device shown is "dummy output"====<br />
This may be caused by different reasons, one of them being the .asoundrc file in $HOME is taking precedence over the systemwide /etc/asound.conf.<br />
<br />
The user file is modified also by the tool '''asoundconf''' or by its graphical variant '''asoundconf-gtk''' (the latter is named "Default sound card" in the menu) as soon as it runs. Prevent the effects of .asoundrc altogether by commenting the last line like this:<br />
<br />
#</home/<yourusername>/.asoundrc.asoundconf><br />
<br />
====KDE4====<br />
It may be that another output device set as preferred in phonon. Make sure that every setting reflects the preferred output device at the top, and check the playback streams tab in kmix to make sure that applications are using the device for output.<br />
<br />
===Bluetooth headset replay problems===<br />
Some user [https://bbs.archlinux.org/viewtopic.php?id=117420 report] huge delays or even no sound when the bluetooth connection does not send any data. This is due to an idle-suspend-module that puts the related sinks/sources automatically into suspend. As this can cause problems with headset, the responsible module can be deactivated. <br />
<br />
1. cp /etc/pulse/default.pa ~/.pulse/default.pa<br />
2. comment out the "load-module module-suspend-on-idle" line in ~/.pulse/default.pa<br />
3. pulseaudio -k && pulseaudio --start<br />
<br />
[http://robert.orzanna.de/2011/08/10/prevent-idle-suspend-with-a-bluetooth-headset-and-a2dp/ More information]<br />
<br />
===Automatically switch to Bluetooth or USB headset===<br />
Add the following to your /etc/pulse/default.pa:<br />
<br />
# automatically switch to newly-connected devices<br />
load-module module-switch-on-connect<br />
<br />
===Pulse overwrites ALSA settings===<br />
Pulseaudio usually overwrites the ALSA settings- for example set with alsamixer- at start up, even when the alsa daemon is loaded. Since there seems to be no other way to restrict this behaviour, a workaround is to restore the alsa settings again after pulseaudio had started. Add the following command to {{ic|.xinitrc}} {{ic|.bash_login}} or any other autostart file:<br />
<br />
restore_alsa() {<br />
while [ -z "`pidof pulseaudio`" ]; do<br />
sleep 0.5<br />
done<br />
alsactl -f /var/lib/alsa/asound.state restore <br />
}<br />
restore_alsa &<br />
<br />
===Daemon startup failed===<br />
Try resetting PulseAudio. To do that:<br />
$ pulseaudio --kill<br />
$ killall pulseaudio<br />
$ killall -9 pulseaudio<br />
$ rm -rf ~/.pulse*<br />
$ rm -rf /tmp/pulse*<br />
<br />
Afterwards, start PulseAudio again.<br />
<br />
===padevchooser===<br />
If one cannot launch the PulseAudio Device Chooser, first (re)start the Avahi daemon as follows:<br />
$ rc.d restart avahi-daemon<br />
<br />
===Glitches, skips or crackling===<br />
The PulseAudio sound server uses a timer-based audio scheduling instead of the traditional interrupt-driven approach. Timer-based scheduling may expose issues in some ALSA drivers. To turn timer-based scheduling off, replace the line:<br />
load-module module-udev-detect <br />
in {{ic|/etc/pulse/default.pa}} by:<br />
load-module module-udev-detect tsched=0<br />
Then restart the PulseAudio server.<br />
<br />
===Choppy sound===<br />
Choppy sound in pulsaudio can result from wrong settings for the sample rate in {{Ic|/etc/pulse/daemon.conf}}. Try changing the line <br />
; default-sample-rate = 44100<br />
to <br />
default-sample-rate = 48000<br />
and restart the PulseAudio server.<br />
<br />
If one experiences choppy sound in applications using openAL, change the sample rate in /etc/openal/alsoft.conf:<br />
frequency = 48000<br />
<br />
Setting the PCM volume above 0dB can cause clipping of the audio signal. Running {{ic|alsamixer -c0}} will allow you to see if this is the problem and if so fix it.<br />
<br />
===Volume adjustment does not work properly===<br />
Check:<br />
{{ic|/usr/share/pulseaudio/alsa-mixer/paths/analog-output.conf.common}}<br />
<br />
If the volume does not appear to increment/decrement properly using {{ic|alsamixer}} or {{ic|amixer}}, it may be due to pulseaudio having a larger number of increments (65537 to be exact). Try using larger values when changing volume (e.g. {{ic|amixer set Master 655+}}).<br />
<br />
===Volume gets louder every time a new application is started===<br />
Per default, it seems as if changing the volume in an application sets the global system volume to that level instead of only affecting the respective application. Applications setting their volume on startup will therefore cause the system volume to "jump".<br />
<br />
Fix this by uncommenting <br />
flat-volumes = no<br />
in<br />
/etc/pulse/daemon.conf<br />
and then restarting PulseAudio by executing<br />
pulseaudio --kill && pulseaudio --start<br />
<br />
When Pulse comes back after a few seconds, applications will not alter the global system volume anymore but have their own volume level again.<br />
<br />
{{Note|A previously installed and removed pulseaudio-equalizer may leave behind remnants of the setup in {{Ic|$HOME/.pulse/default.pa}} which can also cause maximized volume trouble. Comment that out as needed.}}<br />
<br />
===No mic on ThinkPad T400/T500/T420===<br />
Run<br />
alsamixer -c 0<br />
Maximize the volume of/unmute the "Internal Mic".<br />
<br />
Once you see the device with<br />
arecord -l<br />
you might still need to adjust the settings. The microphone and the audio jack are duplexed. Set the configuration of the internal audio in pavucontrol to ''Analog Stereo Duplex''.<br />
<br />
===No mic input on Acer Aspire One===<br />
Install pavucontrol, unlink the microphone channels and turn down the left one to 0.<br />
Reference: http://getsatisfaction.com/jolicloud/topics/deaf_internal_mic_on_acer_aspire_one#reply_2108048<br />
<br />
===Sound output is only mono on M-Audio Audiophile 2496 sound card===<br />
Add the following to /etc/pulseaudio/default.pa:<br />
load-module module-alsa-sink sink_name=delta_out device=hw:M2496 format=s24le channels=10 channel_map=left,right,aux0,aux1,aux2,aux3,aux4,aux5,aux6,aux7<br />
load-module module-alsa-source source_name=delta_in device=hw:M2496 format=s24le channels=12 channel_map=left,right,aux0,aux1,aux2,aux3,aux4,aux5,aux6,aux7,aux8,aux9<br />
set-default-sink delta_out<br />
set-default-source delta_in<br />
<br />
===Static Noise in Microphone Recording===<br />
If we are getting static noise in skype, gnome-sound-recorder, arecord, etc.'s recordings then the sound card samplerate is incorrect. That is why there is static noise in linux microphone recordings. To fix this We need to set sample-rate in /etc/pulse/daemon.conf for the sound hardware.<br />
<br />
====1. Determine soundcards in the system====<br />
This requires alsa-utils and related packages to be installed:<br />
$ arecord --list-devices<br />
<br />
output:<br />
**** List of CAPTURE Hardware Devices ****<br />
card 0: Intel [HDA Intel], device 0: ALC888 Analog [ALC888 Analog]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 0: Intel [HDA Intel], device 2: ALC888 Analog [ALC888 Analog]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
<br />
soundcard is hw:0,0<br />
<br />
====2. Determine sampling-rate of the sound card====<br />
arecord -f dat -r 60000 -D hw:0,0 -d 5 test.wav<br />
<br />
output:<br />
"Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 60000 Hz, Stereo<br />
Warning: rate is not accurate (requested = 60000Hz, '''got = 96000Hz''')<br />
please, try the plug plugin<br />
<br />
observe, the '''got = 96000Hz''', this is the max sample-rate of our card.<br />
<br />
====3. Setting the soundcard's sampling rate into pulse audio configuration====<br />
the default sample-rate in pulseaudio is<br />
grep "sample-rate" /etc/pulse/daemon.conf<br />
<br />
output:<br />
; default-sample-rate = 44100<br />
<br />
It is 44100 and is disabled. Let us set our sound card's settings into pulseaudio configuation file<br />
su -c "sed 's/; default-sample-rate = 44100/default-sample-rate = 96000/g' -i /etc/pulse/daemon.conf"<br />
<br />
Let us verify the changes to deamon.conf<br />
grep "sample-rate" /etc/pulse/daemon.conf <br />
output:<br />
default-sample-rate = 96000<br />
and it is done.<br />
<br />
====4. Restart pulseaudio to apply the new settings====<br />
pulseaudio --kill<br />
pulseaudio --start<br />
<br />
====5. Finally check by recording and playing it back====<br />
Let us record some voice using mic for say 10 seconds. Make sure the mic is not muted and all<br />
arecord -f cd -d 10 test-mic.wav<br />
<br />
After 10 seconds, let us play the recording...<br />
aplay test-mic.wav<br />
<br />
Now hopefully, there is no static noise in microphone recording anymore.<br />
<br />
=== My Bluetooth device is paired but does not play any sound ===<br />
[[Bluetooth#My_device_is_paired_but_no_sound_is_played_from_it|See the article in Bluetooth section]]<br />
<br />
=== Subwoofer stops working after end of every song ===<br />
Known issue: https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/494099<br />
<br />
To fix this, must edit: {{ic|/etc/pulse/daemon.conf}} and enable {{ic|enable-lfe-remixing}} :<br />
{{hc|/etc/pulse/daemon.conf|<nowiki><br />
enable-lfe-remixing = yes<br />
</nowiki>}}<br />
<br />
=== Pulseaudio uses wrong microphone ===<br />
If Pulseaudio uses the wrong microphone, and changing the Input Device with Pavucontrol did not help, take a look at alsamixer. It seems that Pavucontrol does not always set the input source correctly.<br><br />
Run:<br />
<br />
$ alsamixer<br />
<br />
press F6 and choose your sound card, e.g. HDA Intel. Now press F5 to display all items. Try to find the item: {{ic|Input Source}}. With the up/down arrow keys you are able to change the input source. <br><br />
Now try if the correct microphone is used for recording.<br />
<br />
==External links==<br />
*[http://www.pulseaudio.org/wiki/PerfectSetup http://www.pulseaudio.org/wiki/PerfectSetup] - A good guide to make your configuration perfect<br />
*[http://www.alsa-project.org/main/index.php/Asoundrc http://www.alsa-project.org/main/index.php/Asoundrc] - Alsa wiki on .asoundrc<br />
*[http://www.pulseaudio.org/ http://www.pulseaudio.org/] - PulseAudio official site<br />
*[http://www.pulseaudio.org/wiki/FAQ http://www.pulseaudio.org/wiki/FAQ] - PulseAudio FAQ</div>Apouloshttps://wiki.archlinux.org/index.php?title=Xfce&diff=201115Xfce2012-05-12T00:50:15Z<p>Apoulos: In 4.10, start Xfce with startxfce4 –with-ck-launch. (see http://docs.xfce.org/xfce/xfce4-session/advanced)</p>
<hr />
<div>[[Category:Desktop environments]]<br />
[[tr:Xfce_Masaüstü_Ortamı]]<br />
{{i18n|Xfce}}<br />
[[de:Xfce]]<br />
[[fr:Xfce]]<br />
[[pl:XFCE]]<br />
<br />
{{Article summary start}}<br />
{{Article summary text|Xfce is a lightweight desktop environment for Unix-like operating systems. It aims to be fast and lightweight, while still being visually appealing and user friendly. This article covers its installation, configuration, and troubleshooting.}}<br />
{{Article summary text|Xfce uses the [[GTK+]] toolkit.}}<br />
{{Article summary heading|Overview}}<br />
{{Article summary text|{{Graphical user interface overview}}}}<br />
{{Article summary end}}<br />
<br />
From [http://www.xfce.org/about/ Xfce - About]:<br />
<br />
:''Xfce embodies the traditional UNIX philosophy of modularity and re-usability. It consists of a number of components that provide the full functionality one can expect of a modern desktop environment. They are packaged separately and you can pick among the available packages to create the optimal personal working environment.''<br />
<br />
== What is Xfce? ==<br />
Xfce is a Desktop Environment, like [[GNOME]] or [[KDE]]. It contains a suite of apps like a root window app, window manager, file manager, panel, etc. Xfce is written using the GTK2 toolkit, and contains its own development environment (libraries, daemons, etc), similar to other big DEs.<br />
<br />
==Features==<br />
{{expansion}}<br />
*Lighter on resources than the other major DEs (KDE, GNOME).<br />
*Most settings are exposed via a GUI, Xfce does not try to hide stuff from the user.<br />
*Xfwm has an optional built-in compositor which allows for true transparency and all the benefits of GPU acceleration (minimizes tearing, etc.).<br />
*It works great with multiple monitors.<br />
*Xfce4 is stable, mature software.<br />
<br />
==Installation==<br />
<br />
Before starting, make sure you have the [[Xorg|X server]] installed and configured correctly.<br />
<br />
{{Note|Xfce is somewhat modular. That means there is no need for you to run every part, you can pick and choose some of them.}}<br />
<br />
The base Xfce system can be [[pacman|installed]] with the group {{Grp|xfce4}}, available in the [[Official Repositories]]. Pacman will ask you to select the packages to install, but you probably want to get them all by simply pressing {{Keypress|Enter}}. Additional packages, like panel plugins, are available in the {{Grp|xfce4-goodies}} group. If you wish to admire 'Tips and Tricks' on login, install the {{Pkg|fortune-mod package}}.<br />
<br />
{{Tip|Installing [[Gamin]] (the successor of [[FAM]]) is highly recommended.}}<br />
<br />
In order to get the xfce4-mixer to work with [[ALSA]], you need to install {{Pkg|gstreamer0.10-base-plugins}}. See [[#OSS|below]] for help with [[OSS]].<br />
<br />
== Running Xfce ==<br />
<br />
===Automatically at boot time===<br />
There are two methods to start Xfce (and in fact, any desktop or window manager) at boot time:<br />
<br />
* Run Xfce through a Display Manager<br />
* Run Xfce automatically using [[Bash#Configuration_file_overview|bash_profile]] or [[inittab]]<br />
<br />
See [[Display Manager]] for details about installing and configuring a Display Manager (be sure to configure it properly for [[PolicyKit]]). See [[Start X at Boot]] for configuration instructions on using bash_profile or inittab.<br />
<br />
===Manually===<br />
<br />
You can execute:<br />
$ startxfce4<br />
from the console, or configure [[xinitrc]] and use xinit or startx.<br />
<br />
If you have not created a {{ic|~/.xinitrc}} yet, do so with:<br />
<br />
$ cp /etc/skel/.xinitrc ~/.xinitrc<br />
<br />
and add the following line:<br />
<br />
exec startxfce4 -with-ck-launch<br />
<br />
Example:<br />
{{hc|~/.xinitrc|<nowiki>#!/bin/sh<br />
<br />
if [ -d /etc/X11/xinit/xinitrc.d ]; then<br />
for f in /etc/X11/xinit/xinitrc.d/*; do<br />
[ -x "$f" ] && . "$f"<br />
done<br />
unset f<br />
fi<br />
<br />
exec startxfce4 -with-ck-launch</nowiki>}}<br />
<br />
{{Note|<br />
*{{ic|-with-ck-launch}} starts a clean ConsoleKit session needed by Xfce for power management, automounting, shutting down, rebooting, etc. ConsoleKit/PolicyKit capable display managers such as gdm do this for you automatically and thus the command doesn't need to be specified seperatly.<br />
*{{pkg|xorg-xdm}} is also ConsoleKit/PolicyKit capable since version 1.1.11. Unless you happen to run an old version, you must '''not''' use {{ic|-with-ck-launch}} from your .xinitrc or .xsession for xdm.<br />
*[[SLiM]] is also ConsoleKit capable since version 1.3.3. Unless you happen to run an old version, you must '''not''' use {{ic|-with-ck-launch}} from your .xinitrc or slim.conf login_cmd.<br />
*In case you are wondering, {{ic|dbus-launch}} will be launched by the {{ic|xinitrc.d}} code at the beginning of the file. {{ic|dbus-launch}} starts a dbus-daemon instance to provide communication with PolicyKit.<br />
*The proper command for launching Xfce is {{ic|startxfce4}}: do not start {{ic|xfce4-session}} directly, since it is already run by {{ic|startxfce4}} itself.}}<br />
{{Note|{{ic|dbus-launch}} should actually be called '''after''' launching ConsoleKit, otherwise there will be authorization problems when mounting disks as a regular user, see {{Bug|25031}}. For a '''temporary''' workaround you can edit the {{ic|xinitrc.d}} script at the beginning of the file as follows, and '''keep an eye on the evolution of the bug report''' (and possibly vote it):<br />
{{hc|~/.xinitrc [temporary workaround]|<nowiki>#!/bin/sh<br />
<br />
if [ -d /etc/X11/xinit/xinitrc.d ]; then<br />
for f in /etc/X11/xinit/xinitrc.d/*; do<br />
# Do not launch dbus before ConsoleKit (FS#25031)<br />
#[ -x "$f" ] && . "$f"<br />
[ "$f" -ne "/etc/X11/xinit/xinitrc.d/30-dbus" ] && [ -x "$f" ] && . "$f"<br />
done<br />
unset f<br />
fi<br />
<br />
exec startxfce4 -with-ck-launch</nowiki>}}<br />
There is still no need to start {{ic|dbus-launch}} explicitly since {{ic|startxfce4}} takes care of doing that anyway.}}<br />
<br />
===Shutting down, rebooting, and automounting from within Xfce===<br />
* Make sure that '''dbus''' is enabled in the {{ic|DAEMONS}} array in {{ic|/etc/rc.conf}}.<br />
* If a display manager is used:<br />
** Make sure that you are using {{ic|exec startxfce4 -with-ck-launch}} in {{ic|~/.xinitrc}} (along with sourcing xinitrc.d scripts, which is done for you in the skel file) '''or''' a ConsoleKit/PolicyKit capable [[display manager]].<br />
* If no display manager is used:<br />
** Make sure you use the bash_profile method to auto-login (not inittab).<br />
** For automounting to work the default Policykit has to be [https://bbs.archlinux.org/viewtopic.php?pid=881377#p881377 edited]. You can also install {{pkg|polkit-gnome}} for authorization.<br />
* If you want to automount removable disk in thunar, install {{pkg|thunar-volman}} and {{pkg|gamin}}, and make sure {{pkg|gvfs}} and {{pkg|gvfs-afc}} is installed, see [https://bbs.archlinux.org/viewtopic.php?id=119992 details] .<br />
<br />
==Tips==<br />
===Panel===<br />
====How to customize xfce panel background====<br />
Edit {{ic|~/.gtkrc-2.0}}.<br />
Note that you must place the image in the same directory as the configuration, which is {{ic|~/}}. You can not specify the path to the image, or it will not work.<br />
style "panel-background" {<br />
bg_pixmap[NORMAL] = "foo.bar"<br />
bg_pixmap[PRELIGHT] = "foo.bar"<br />
bg_pixmap[ACTIVE] = "foo.bar"<br />
bg_pixmap[SELECTED] = "foo.bar"<br />
bg_pixmap[INSENSITIVE] = "foo.bar"<br />
}<br />
widget_class "*Panel*" style "panel-background"<br />
<br />
==== Replacements for the default 'menu' panel applet ====<br />
The "Ubuntu System Panel" (GNOME) panel applet has similar features to those found in its KDE v4.2 equivalent. It can be added to an Xfce panel via the 'XfApplet' panel applet, which allows GNOME applets to be used in Xfce.<br />
<br />
It is available in the [[Arch User Repository|AUR]] as the {{AUR|usp2}} package.<br />
<br />
====How to remove menu entries from the System menu====<br />
===== Method 1 =====<br />
With the built-in menu editor, you cannot remove menu entries from the System menu. Here’s how to hide them:<br />
# Open Terminal (Xfce menu > System > Terminal) and go to the {{ic|/usr/share/applications}} folder: {{bc|$ cd /usr/share/applications}}<br />
# This folder should be full of {{ic|.desktop}} files. To see a list type: {{bc|$ ls}}<br />
# Add {{ic|1=NoDisplay=true}} to the {{ic|.desktop}} file. For example, if you want to hide Firefox, type in the terminal:{{bc|1=$ sudo sh -c 'echo "NoDisplay=true" >> firefox.desktop'}} This command appends the text {{ic|1=NoDisplay=true}} to the end of the {{ic|.desktop}} file.<br />
<br />
===== Method 2 =====<br />
Another method is to copy the entire contents of the global applications directory over to your local applications directory, and then proceed to modify and/or disable unwanted .desktop entries. This will survive application updates that overwrite changes under {{ic|/usr/share/applications/}}.<br />
# In a terminal, copy everything from {{ic|/usr/share/applications}} to {{ic|~/.local/share/applications/}}: {{bc|$ cp /usr/share/applications/* ~/.local/share/applications/}}<br />
# For any entry you wish to hide from the menu, add the {{ic|1=NoDisplay=true}} option: {{bc|1=$ echo "NoDisplay=true" >> ~/.local/share/applications/foo.desktop}}<br />
<br />
You can also edit the application's category by editing the {{ic|.desktop}} file with a text editor and modifying the {{ic|1=Categories=}} line.<br />
<br />
===== Method 3 =====<br />
The third method is the '''cleanest''' and recommended in the [http://wiki.xfce.org/howto/customize-menu Xfce wiki].<br />
<br />
Create the file {{ic|~/.config/menus/xfce-applications.menu}} and copy the folowing in it:<br />
{{bc|<nowiki><br />
<!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 1.0//EN"<br />
"http://www.freedesktop.org/standards/menu-spec/1.0/menu.dtd"><br />
<br />
<Menu><br />
<Name>Xfce</Name><br />
<MergeFile type="parent">/etc/xdg/menus/xfce-applications.menu</MergeFile><br />
<br />
<Exclude><br />
<Filename>xfrun4.desktop</Filename><br />
<br />
<Filename>exo-terminal-emulator.desktop</Filename><br />
<Filename>exo-file-manager.desktop</Filename><br />
<Filename>exo-mail-reader.desktop</Filename><br />
<Filename>exo-web-browser.desktop</Filename><br />
<br />
<Filename>xfce4-about.desktop</Filename><br />
<Filename>xfhelp4.desktop</Filename><br />
</Exclude><br />
<br />
<Layout><br />
<Merge type="all"/><br />
<Separator/><br />
<br />
<Menuname>Settings</Menuname><br />
<Separator/><br />
<br />
<Filename>xfce4-session-logout.desktop</Filename><br />
</Layout><br />
<br />
</Menu><br />
</nowiki>}}<br />
<br />
The {{ic|<MergeFile>}} tag includes the default Xfce menu in our file. This is important.<br />
<br />
The {{ic|<Exclude>}} tag excludes applications which we do not want to appear in the menu. Here we excluded some Xfce default shortcuts, but you can exclude {{ic|firefox.desktop}} or any other application.<br />
<br />
The {{ic|<Layout>}} tag defines the layout of the menu. The applications can be organized in folders or however we wish. For more details see the aforementioned Xfce wiki page.<br />
===== Method 4 =====<br />
Alternatively a tool called [http://lxmed.sourceforge.net/ lxmed] can be used. Lxmed is a GUI tool written in Java for editing menu entires in LXDE, but it also works in Xfce4. Lxmed is available in the {{AUR|lxmed}} package from the [[AUR]].<br />
<br />
==== But what do you do with menu entries which do not show up in /usr/share/applications (e.g., apps installed via Wine)? ==== <br />
I have found some shortcuts that show in the category “Other” in this directory:<br />
{{ic|~/.local/share/applications/wine/}}.<br />
<br />
====Panel autohide delay====<br />
Add this to {{ic|~/.gtkrc-2.0}}.<br />
style "xfce-panel-window-style"<br />
{<br />
# Time in miliseconds before the panel will unhide on an enter event<br />
XfcePanelWindow::popup-delay = 225<br />
<br />
# Time in miliseconds before the panel will hide on a leave event<br />
XfcePanelWindow::popdown-delay = 350<br />
}<br />
class "XfcePanelWindow" style "xfce-panel-window-style"<br />
<br />
====Panel at desktop level====<br />
<br />
If you want a panel at desktop level (i.e., other windows will stack over it) you need a little hack, ensure you have installed the '''wmctrl''' package.<br />
<br />
Create a script in {{ic|~/.config/xfce4/fixpanels.sh}} with this content and make it executable (you can use {{ic|chmod 755 fixpanels.sh}}).<br />
<br />
#!/bin/bash<br />
set -e<br />
<br />
function getPanelIdImpl() {<br />
# get panel id<br />
PANEL="`wmctrl -l | sed -n -e '/ xfce4-panel$/ s_ .*$__ p' | sed -n -e $1' p'`"<br />
}<br />
<br />
function getPanelId() {<br />
# eventually await the panel to appear<br />
getPanelIdImpl $1<br />
while [ x = x$PANEL ] ;do<br />
sleep 0.5s<br />
getPanelIdImpl $1<br />
done<br />
}<br />
<br />
function putPanelDown() {<br />
PANEL=""<br />
getPanelId $1<br />
wmctrl -i -r $PANEL -b add,below<br />
}<br />
<br />
#Uncomment here the panels you want to put at desktop level. <br />
#putPanelDown 1<br />
#putPanelDown 2<br />
<br />
Once wrote the script, and tested it, you need to auto-execute it at each login. You can use the {{ic|Session and StartUp -> Application Autostart}} gui.<br />
<br />
This passage will put your panels at desktop level, but if your panel is sticking to a border the maximized windows will not stack over it. You can enable this behavior with the following command, fortunately you need to do this only once. (change the $ID with the panel number of interest)<br />
<br />
xfconf-query -c xfce4-panel -p /panels/panel-$ID/disable-struts -n -t bool -s true<br />
<br />
=== Desktop ===<br />
<br />
==== Use a transparent background for desktop icon titles ====<br />
To change the default white background of desktop icon titles to something more suitable, edit the {{ic|.gtkrc-2.0}} file in your home directory (or create the file if needed) and add the following:<br />
style "xfdesktop-icon-view" {<br />
XfdesktopIconView::label-alpha = 10<br />
base[NORMAL] = "#000000"<br />
base[SELECTED] = "#71B9FF"<br />
base[ACTIVE] = "#71FFAD"<br />
fg[NORMAL] = "#ffffff"<br />
fg[SELECTED] = "#71B9FF"<br />
fg[ACTIVE] = "#71FFAD" }<br />
widget_class "*XfdesktopIconView*" style "xfdesktop-icon-view"<br />
<br />
==== Hide selected partitions on the desktop ====<br />
If you wish to prevent certain partitions or drives appearing on the desktop, you can create a udev rule, for example {{ic|/etc/udev/rules.d/10-local.rules}}:<br />
<br />
KERNEL=="sda1", ENV{UDISKS_IGNORE}="1"<br />
KERNEL=="sda2", ENV{UDISKS_IGNORE}="1"<br />
<br />
Would show all partitions with the exception of sda1 and sda2 on your desktop.<br />
<br />
==== Switch to old desktop right click menu without Thunar things ====<br />
xfconf-query -c xfce4-desktop -v --create -p /desktop-icons/style -t int -s 0<br />
<br />
==== Adding the kill window shortcut ====<br />
<br />
Xfce does not support the ''kill window'' shortcut directly, but you can add one with a simple script. Ensure you have the '''xorg-xkill''' package installed.<br />
<br />
Create a script in {{ic|~/.config/xfce4/killwindow.sh}} with this content and make it executable (you can use {{ic|chmod 755 killwindow.sh}}).<br />
<br />
xkill -id "`xprop -root -notype | sed -n '/^_NET_ACTIVE_WINDOW/ s/^.*# *\|\,.*$//g p'`"<br />
<br />
Now associate a shortcut using {{ic|Settings -> Keyboard}} to that script.<br />
<br />
=== XFWM4 ===<br />
==== How to enable the compositor in Xfce ====<br />
Xfce comes with a builtin compositor adding the option for fancy window effects, shadows and transparency and so on. It can be enabled in the Window Manager Tweaks and works on the fly. No additional settings are needed in your {{ic|/etc/xorg.conf}}. To enable and adjust settings, go to:<br />
<br />
Menu --> Settings --> Window Manager Tweaks<br />
<br />
==== Disable window roll-up ====<br />
xfconf-query -c xfwm4 -p /general/mousewheel_rollup -s false<br />
<br />
=== Commands for the settings manager ===<br />
<br />
There is no official documentation for the commands executed. One must look at {{ic|.desktop}} files {{ic|/usr/share/applications/}} folder. For the people who like to know exactly what is happening, here is a handy list to save the effort:<br />
<br />
xfce4-accessibility-settings<br />
xfce4-power-manager-settings<br />
xfce4-settings-editor<br />
xfdesktop-settings<br />
xfce4-display-settings<br />
xfce4-keyboard-settings<br />
xfce4-mouse-settings<br />
xfce4-session-settings<br />
xfce4-settings-manager<br />
xfce4-appearance-settings<br />
xfwm4-settings<br />
xfwm4-tweaks-settings<br />
xfwm4-workspace-settings<br />
orage -p<br />
<br />
To review all the available setting manager commands run the following in a terminal:<br />
<br />
$ grep '^Exec=' /usr/share/applications/xfce*settings* | sed -e 's_^.*=_ _'<br />
<br />
===Session===<br />
====Customizing Startup Applications====<br />
This includes getting necessary environment variables into the GUI runtime.<br />
<br />
* Copy the file {{ic|/etc/xdg/xfce4/xinitrc}} to {{ic|~/.config/xfce4/}}<br />
* Edit this file. For example, you can add something like this somehwere in the middle:<br />
source $HOME/.bashrc<br />
# start rxvt-unicode server<br />
urxvtd -q -o -f<br />
<br />
====Switch between users====<br />
It is possible to switch between X sessions thanks to [http://goodies.xfce.org/projects/panel-plugins/xfswitch-plugin xfswitch-plugin ]. It adds an icon to the Xfce panel, and requires gdm to work at the moment.<br />
<br />
xfswitch-plugin is available through [https://aur.archlinux.org/packages.php?ID=40677 AUR ]<br />
<br />
==== Modify XML settings files directly ====<br />
It may be useful, especially when upgrading, to manually edit .xml files in the {{ic|~/.config/xfce4/xfconf/}} folder. For application keyboard shortcuts for example, the file is {{ic|~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml}}. It is faster to copy and paste the XML keys that you want rather than using the GUI.<br />
<br />
===Removable Devices===<br />
If you want an icon appearing on your desktop and in thunar when you plug in external devices, make sure gvfs is installed:<br />
<br />
# pacman -S --needed gvfs<br />
<br />
You could also need to install gvfs-afc (read [https://bbs.archlinux.org/viewtopic.php?pid=889018 this discussion]):<br />
<br />
# pacman -S gvfs-afc<br />
<br />
It is also a good idea to install thunar-volman (included in the {{ic|xfce4-goodies}} group):<br />
<br />
# pacman -S thunar-volman<br />
<br />
Udisk and a udisk wrapper are recommended if you want to automount optical and external drives easily<br />
<br />
* [http://igurublog.wordpress.com/downloads/script-devmon/ devmon] - devmon ([https://aur.archlinux.org/packages.php?ID=45842 AUR]) is a configuration-less bash wrapper script for udisks which automounts optical discs and removable drives. It can also selectively autostart apps or execute commands after mounting, ignore specified devices and volume labels, and unmount removable drives.<br />
<br />
===How to add themes to XFCE===<br />
1. Go to [http://www.xfce-look.org www.xfce-look.org] and click "Themes" in the left navbar. Look around for a theme you want and click "Download".<br />
<br />
2. Go to the directory where you downloaded the tarball/file and extract it using Squeeze/Xarchiver/CLI.<br />
<br />
3. Move the extracted folder to {{ic|/usr/share/themes}} (for all users) or {{ic|~/.themes}} (for just you). Inside {{ic|/usr/share/themes/abc}}, there is a folder that you create called xfwm4 that will contain whatever files that is included with that theme.<br />
<br />
4. GTK theme is available here:<br />
Menu --> Settings --> Appearance<br />
You select your xfwm theme in:<br />
Menu --> Settings --> Window Manager<br />
<br />
=== Cursors ===<br />
Main article: [[X11 Cursors]]<br />
<br />
If you have alternative X cursor themes installed, Xfce can find them with:<br />
Menu --> Settings --> Mouse --> Theme<br />
<br />
=== Icons ===<br />
1. First find and download your desired icon pack. Recommended places to download icons from are [http://www.customize.org Customize.org], [http://opendesktop.org Opendesktop.org] and [http://xfce-look.org/ Xfce-look.org].<br />
<br />
2. Go to the directory where you downloaded the icon pack and extract it. Example {{ic|tar -xzf /home/user/downloads/icon-pack.tar.gz}}.<br />
<br />
3. Move the extracted folder containing the icons to {{ic|/usr/share/icons}} (if you want all users on the system to make use of the icons) or {{ic|~/.icons}} (if only you want to use the icons).<br />
<br />
Optional: run {{ic|gtk-update-icon-cache -f -t ~/.icons/<theme_name>}} to update icon cache<br />
<br />
4. Switch your icons by going to:<br />
Menu --> Settings --> Appearance --> Icons<br />
<br />
When you have icon theme problems, it's also recommended to install the {{Pkg|hicolor-icon-theme}} package if it wasn't already installed.<br />
<br />
=== Fonts ===<br />
<br />
If you find the standard fonts rather thick and or slightly out of focus open Settings>Appearence click on the Fonts tab and under Hinting: change to Full<br />
<br />
You could also try using a custom DPI setting.<br />
<br />
=== Sound ===<br />
<br />
==== Configuring xfce4-mixer ====<br />
<br />
{{Pkg|xfce4-mixer}} is the GUI mixer app / panel plugin made by the Xfce team. It is part of the xfce4 group, so you probably already have it installed. Xfce 4.6 uses {{Pkg|gstreamer}} as the backend to control volume, so first you have to make gstreamer cooperate with xfce4-mixer. One or more of the gstreamer plugin packages listed as optional dependencies to xfce4-mixer must be installed. Without one of these required plugins packages, the following error arises when clicking on the mixer panel item.<br />
<br />
GStreamer was unable to detect any sound devices. Some sound system specific GStreamer packages may be missing. It may also be a permissions problem.<br />
<br />
(It is probably not a permissions problem. It is no longer required to add audio users to the "audio" group.) Which plugins are needed depends on the hardware. Most people should be fine with {{Pkg|gstreamer0.10-base-plugins}}. <br />
<br />
pacman -S gstreamer0.10-base-plugins<br />
<br />
If the xfce4-mixer panel item was already running before one of the plugins packages was installed, logout and login to see if it worked, or just remove the mixer plugin from the panel and add it again. If that doesn't work, you might need more or different gstreamer plugins. Try to install gstreamer0.10-good-plugins or gstreamer0.10-bad-plugins.<br />
<br />
pacman -S gstreamer0.10-good-plugins<br />
<br />
pacman -S gstreamer0.10-bad-plugins<br />
<br />
For further details, for example how to set the default sound card, see [[Advanced Linux Sound Architecture]]. Alternatively you can use [[PulseAudio]] together with {{Pkg|pavucontrol}}.<br />
<br />
==== How do I get xfce4-mixer and OSS4 to work together? ====<br />
<br />
If you tried the above section to get {{Pkg|xfce4-mixer}} to work and it does not work at all, then you may have to compile gstreamer0.10-good-plugins yourself. Download the PKGBUILD and other files needed from ABS or [http://projects.archlinux.org/svntogit/packages.git/tree/gstreamer0.10-good/repos here], edit the PKGBUILD, add --enable-oss. <br />
<br />
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var \<br />
'''--enable-oss \'''<br />
--disable-static --enable-experimental \<br />
--disable-schemas-install \<br />
--disable-hal \<br />
--with-package-name="GStreamer Good Plugins (Archlinux)" \<br />
--with-package-origin="http://www.archlinux.org/"<br />
<br />
and then run makepkg -i. <br />
<br />
makepkg -i<br />
<br />
Still not working? Try this package in AUR [https://aur.archlinux.org/packages.php?ID=17024 gstreamer0.10-good-plugins-ossv4], modify the pkgver to the newest in the PKGBUILD, and it should work.<br />
<br />
Other LINKS: [http://www.4front-tech.com/forum/ OSS forum]<br />
<br />
==== Change volume with keyboard volume buttons ====<br />
<br />
Go to <br />
Settings --> Keyboard<br />
Click the "Application Shortcuts" tab and add click the "Add" button. Add the following by entering the command, then pressing the corresponding button at the next window:<br />
<br />
===== ALSA =====<br />
For the raise volume button:<br />
amixer set Master 5%+<br />
For the lower volume button:<br />
amixer set Master 5%-<br />
For the mute button:<br />
amixer set Master toggle<br />
<br />
You can also run these commands to set the above commands to the standard XF86Audio keys:<br />
xfconf-query -c xfce4-keyboard-shortcuts -p /commands/custom/XF86AudioRaiseVolume -n -t string -s "amixer set Master 5%+"<br />
xfconf-query -c xfce4-keyboard-shortcuts -p /commands/custom/XF86AudioLowerVolume -n -t string -s "amixer set Master 5%-"<br />
xfconf-query -c xfce4-keyboard-shortcuts -p /commands/custom/XF86AudioMute -n -t string -s "amixer set Master toggle"<br />
<br />
If {{ic|amixer set Master toggle}} does not work, try the PCM channel ({{ic|amixer set PCM toggle}}) instead.<br />
<br />
The channel must have a "mute" option for the toggle command to work. To check whether or not your Master channel supports toggling mute, run {{ic|alsamixer}} in a terminal and look for the double M's (MM) under the Master channel. If they are not present, then it does not support the mute option. If, for example, you had to change the toggle button to use the PCM channel, make sure to also set the PCM channel as the Mixer Track under Xfce Mixer properties.<br />
<br />
===== OSS =====<br />
Use one of these scripts: http://www.opensound.com/wiki/index.php/Tips_And_Tricks#Using_multimedia_keys_with_OSS<br />
<br />
If using ossvol (recommended), add:<br />
ossvol -i 1<br />
for the volume up button<br />
ossvol -d 1<br />
for the volume down button<br />
ossvol -t<br />
for the mute/unmute button<br />
<br />
===== Xfce4-volumed =====<br />
<br />
[https://aur.archlinux.org/packages.php?ID=31693 xfce4-volumed] daemon from the [[AUR]] automatically maps volume keys of your keyboard to Xfce-mixer. Additionally you get OSD through Xfce4-notifyd when changing volume. Xfce4-volumed does not need any configuration and is started automatically with Xfce.<br />
<br />
{{accuracy|reason=There should be a short explanation of what this does and why it fixes the issue (bug?).}}<br />
<br />
If you use pulseaudio and xfce4-volumed unmute doesn't work, try this:<br />
<br />
$ xfconf-query -c xfce4-mixer -p /active-card -s `xfconf-query -c xfce4-mixer -p /sound-card`<br />
<br />
=== Screenshots ===<br />
<br />
==== Using print-screen key ====<br />
<br />
A simple way is to use a command-line screenshot utility:<br />
<br />
# pacman -S scrot<br />
<br />
Then go to:<br />
<br />
XFCE Menu --> Settings --> Keyboard >>> Application Shortcuts.<br />
<br />
Add the "scrot" command to use the "PrintScreen" key.<br />
<br />
All screenshots will be placed in your home folder with unique names (i.e. {{ic|2009-02-19-063052_1280x1024_scrot.png}}).<br />
<br />
====Screenshooter====<br />
<br />
There is also an a screenshot plugin for the Xfce panel, which can be used instead of scrot, that is available in extra:<br />
<br />
# pacman -S xfce4-screenshooter<br />
<br />
You can add a keyboard binding for it using the command<br />
<br />
xfce4-screenshooter -f<br />
<br />
instead of "scrot". You will get a dialog window after pressing "Print" where you can copy the image to the clipboard or save it.<br />
<br />
=== Change mount options ===<br />
<br />
A common problem when automounting USB sticks formatted with fat filesystem is the inability to properly show characters as umlauts, ñ, ß, etc. This may be solved changing the default iocharset to utf8, which is easily done adding a line to {{ic|/etc/xdg/xfce4/mount.rc}}:<br />
<br />
[vfat]<br />
uid=<auto><br />
shortname=winnt<br />
'''utf8=true'''<br />
# FreeBSD specific option<br />
longnames=true<br />
<br />
Note that when using utf-8, the system will distinct between upper- and lowercases, potentially corrupting your files. Be careful.<br />
<br />
It is also recommendable to mount vfat devices with the '''flush''' option, so that when copying to USB sticks data flushes more often, thus making thunar's progress bar to stays up until things are on the disk.<br />
<br />
[vfat]<br />
flush=true<br />
<br />
===Terminal tango color theme===<br />
Open with your favorite editor<br />
<br />
~/.config/Terminal/terminalrc<br />
<br />
And add(replace) this lines:<br />
<br />
ColorForeground=White<br />
ColorBackground=#323232323232<br />
ColorPalette1=#2e2e34343636<br />
ColorPalette2=#cccc00000000<br />
ColorPalette3=#4e4e9a9a0606<br />
ColorPalette4=#c4c4a0a00000<br />
ColorPalette5=#34346565a4a4<br />
ColorPalette6=#757550507b7b<br />
ColorPalette7=#060698989a9a<br />
ColorPalette8=#d3d3d7d7cfcf<br />
ColorPalette9=#555557575353<br />
ColorPalette10=#efef29292929<br />
ColorPalette11=#8a8ae2e23434<br />
ColorPalette12=#fcfce9e94f4f<br />
ColorPalette13=#72729f9fcfcf<br />
ColorPalette14=#adad7f7fa8a8<br />
ColorPalette15=#3434e2e2e2e2<br />
ColorPalette16=#eeeeeeeeecec<br />
<br />
== Troubleshooting ==<br />
<br />
=== User directories (Desktop, Images, etc...) are still in English ===<br />
If your primary language isn't English, you may need to force Xfce changing the name of the user directories buy modifying/creting the two following files (this exemple is for French):<br />
<br />
{{ic|~/.config/user-dirs.locale}}<br />
fr_FR<br />
{{ic|~/.config/user-dirs.dirs}}<br />
XDG_DESKTOP_DIR="$HOME/Bureau"<br />
XDG_DOWNLOAD_DIR="$HOME/Téléchargements"<br />
XDG_TEMPLATES_DIR="$HOME/Exemples"<br />
XDG_PUBLICSHARE_DIR="$HOME/Public"<br />
XDG_DOCUMENTS_DIR="$HOME/Documents"<br />
XDG_MUSIC_DIR="$HOME/Musiques"<br />
XDG_PICTURES_DIR="$HOME/Images"<br />
XDG_VIDEOS_DIR="$HOME/Vidéos"<br />
<br />
=== Unable to open external windows partitions ===<br />
If you have external partitions like a fat32 drive connected via eSata, and launching them from the desktop results in a dialog telling you 'Authentication is required', you need to ensure polkit-gnome is installed and PolicyKit Authentication Agent is started by xfce4.<br />
pacman -S polkit-gnome<br />
Restart xfce4 and go:<br />
Applications Menu > Settings > Sessions and Startup<br />
Check that PolicyKit Authentication Agent is enabled under the Application Autostart tab.<br />
<br />
=== xfce4-power-manager is not working ===<br />
Check you have added dbus to the {{ic|DAEMONS}} array in {{ic|/etc/[[rc.conf]]}}.<br />
<br />
=== Keyboard shortcuts are not working ===<br />
Under Xfce 4.6 there is a problem where the user's [http://bugzilla.xfce.org/show_bug.cgi?id=5639 keyboard shortcuts will intermittently not work]. This is usually the case when the settings helper is either not running or has been started improperly due to a conflict. This bug has been fixed in Xfce 4.8, which replaced 4.6 in the main repositories.<br />
<br />
A workaround is to disable ''xfce4-settings-helper-autostart'' from autostarting in a user's session. The settings helper daemon will start upon loading an Xfce session, anyways. The following two steps seem to have resolved this issue.<br />
<br />
Remove or rename the global autostart .desktop file:<br />
mv /etc/xdg/autostart/xfce4-settings-helper-autostart.desktop /etc/xdg/autostart/xfce4-settings-helper-autostart.desktop.disabled<br />
<br />
Remove or rename the local autostart .desktop file:<br />
mv ~/.config/autostart/xfce4-settings-helper-autostart.desktop ~/.config/autostart/xfce4-settings-helper-autostart.desktop.disabled<br />
<br />
After logging out and logging back in, your shortcut keys should be working fine now.<br />
<br />
=== Xfce4-xkb-plugin settings issue ===<br />
There's a bug in version ''0.5.4.1-1'' which causes xkb-plugin to ''lose keyboard, layout switching and compose key'' settings. As a workaround you may enable ''Use system defaults'' option in keyboard settings. To do so run<br />
xfce4-keyboard-settings<br />
Go to ''Layout'' tab and set the ''Use system defaults'' flag, then reconfigure xkb-plugin.<br />
<br />
=== Thunar does not display any thumbnail ===<br />
<br />
Thunar relies on '''Tumbler''' to generate thumbnails. You can install Tumbler by issuing<br />
<br />
pacman -S tumbler<br />
<br />
More details in [[Thunar#Thunar_Thumbnailers|Thunar's page]].<br />
<br />
=== Locales ignored with GDM ===<br />
Become superuser and add your locale to /var/lib/AccountsService/users/$USER:<br />
su -c "nano /var/lib/AccountsService/users/$USER"<br />
Replace hu_HU.UTF-8 with your own locale:<br />
[User]<br />
Language=hu_HU.UTF-8<br />
XSession=xfce<br />
You may also do it with sed. Note the backslash before .UTF-8:<br />
su -c "sed -i 's/Language=.*/Language=hu_HU\.UTF-8/' /var/lib/AccountsService/users/$USER"<br />
Restart GDM to take effect.<br />
<br />
=== Restore default settings ===<br />
If for any reason you need to revert back to the default settings, try renaming {{ic|~/.config/xfce4-session/}} and {{ic|~/.config/xfce4/}}<br />
<br />
$ mv ~/.config/xfce4-session/ ~/.config/xfce4-session-bak<br />
$ mv ~/.config/xfce4/ ~/.config/xfce4-bak<br />
<br />
Logout and login for changes to take effect.<br />
<br />
=== NVIDIA and xfce4-sensors-plugin ===<br />
To detect and use sensors of nvidia gpu you need to install {{AUR|libxnvctrl}} and then recompile {{Pkg|xfce4-sensors-plugin}} package.<br />
<br />
=== Session failure ===<br />
If the window manager doesn't load correctly (The mouse is a X and you can't close windows) you maybe got an session error.<br />
To remove a corrupt session you can delete the session folder at the {{ic|.cache}} folder.<br />
# rm -r ~/.cache/sessions/<br />
The easy way to reload the session is to reboot the computer. You can also restart xfce.<br />
<br />
=== Clock/notification area no longer pushed to the right edge of the panel in Xfce 4.10 ===<br />
<br />
This is due to a change in the Window Buttons panel plugin which no longer expands to fill the available space.<br />
<br />
To emulate the old behavior, add a transparent separator between the window buttons and the clock/notification area, setting its expand property.<br />
<br />
== Related Articles ==<br />
* [[Thunar]]<br />
* [[Improve GTK Application Looks]]<br />
* [[Autostart applications#Graphical]]<br />
<br />
== External Resources ==<br />
* http://docs.xfce.org/ - The complete documentation.<br />
* [http://www.xfce-look.org/ Xfce-Look] - Themes, wallpapers, and more.<br />
* [http://xfce.wikia.com/wiki/Frequently_Asked_Questions Xfce Wikia] - How to edit the auto generated menu with the menu editor<br />
* [http://wiki.xfce.org Xfce Wiki]</div>Apouloshttps://wiki.archlinux.org/index.php?title=GNOME/Keyring&diff=133810GNOME/Keyring2011-03-15T21:32:47Z<p>Apoulos: </p>
<hr />
<div>{{stub}}<br />
[[Category:Daemons_and_system_services (English)]]<br />
[[Category:Desktop environments (English)]]<br />
<br />
= GNOME Keyring =<br />
The GNOME Keyring stores passwords in an encrypted file that can be accessed by applications.<br />
<br />
== Manage using GUI ==<br />
pacman -S seahorse<br />
It is possible to leave the gnome keyring password blank. In seahorse, on the Passwords tab, right click on "Passwords: login" and pick "Change password." Enter the old password and leave empty the new password. You will be warned about using unencrypted storage; continue by pushing "Use Unsafe Storage."<br />
<br />
== SSH Keys ==<br />
To add your SSH key:<br />
<br />
$ ssh-add ~/.ssh/id_dsa<br />
Enter passphrase for /home/mith/.ssh/id_dsa:<br />
<br />
To list automatically loaded keys:<br />
<br />
$ ssh-add -L<br />
<br />
To disable all keys;<br />
<br />
$ ssh-add -D<br />
<br />
Now when you connect to a server, the key will be found and a dialog will popup asking you for the passphrase. It has an option to automatically unlock the key when you login. If you check this you won't need to enter your passphrase again!<br />
<br />
== Unlock at Startup ==<br />
GNOME's login manager (gdm) will automatically unlock the keyring once you login, for others it isn't so easy.<br />
<br />
For SLiM, see [[SLiM#SLiM_and_Gnome_Keyring]]</div>Apoulos