https://wiki.archlinux.org/api.php?action=feedcontributions&user=Wide-eye&feedformat=atomArchWiki - User contributions [en]2024-03-28T14:44:03ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Chroot&diff=261088Chroot2013-06-04T13:06:35Z<p>Wide-eye: move bash to usr/bin</p>
<hr />
<div>[[Category:System recovery]]<br />
[[es:Change Root]]<br />
[[fa:تغییر ریشه]]<br />
[[fr:Chroot]]<br />
[[ja:Change Root]]<br />
[[ro:Chroot]]<br />
[[zh-CN:Change Root]]<br />
[[Wikipedia:Chroot|Chroot]] is the process of changing of the apparent disk root directory (and the current running process and its children) to another root directory. When you change root to another directory you cannot access files and commands outside that directory. This directory is called a ''chroot jail''. Changing root is commonly done for system maintenance, such as reinstalling the bootloader or resetting a forgotten password.<br />
<br />
== Requirements ==<br />
<br />
* You'll need to boot from another working Linux environment (e.g. from a LiveCD or USB flash media, or from another installed Linux distribution).<br />
<br />
* Root privileges are required in order to chroot.<br />
<br />
* Be sure that the architecture of the Linux environment you have booted into matches the architecture of the root directory you wish to enter (i.e. i686, x86_64). You can find the architecture of your current environment with:<br />
<br />
: {{bc|# uname -m}}<br />
<br />
* If you need any kernel modules loaded in the chroot environment, load them before chrooting. It may also be useful to initialize your swap ({{ic|swapon /dev/sdxY}}) and to establish an internet connection before chrooting.<br />
<br />
== Mount the partitions ==<br />
<br />
The root partition of the Linux system that you're trying to chroot into needs to be mounted first. To find out the device name assigned by the kernel, run:<br />
<br />
# lsblk /dev/sda<br />
<br />
You can also run the following to get an idea of your partition layout.<br />
<br />
# fdisk -l<br />
<br />
Now create a directory where you would like to mount the root partition and mount it:<br />
<br />
# mkdir /mnt/arch<br />
# mount /dev/sda3 /mnt/arch<br />
<br />
Next, if you have separate partitions for other parts of your system (e.g. {{ic|/boot}}, {{ic|/home}}, {{ic|/var}}, etc), you should mount them, as well:<br />
<br />
# mount /dev/sda1 /mnt/arch/boot/<br />
# mount /dev/sdb5 /mnt/arch/home/<br />
# mount ...<br />
<br />
While it's possible to mount filesystems after you've chrooted, it is more convenient to do so beforehand. The reasoning for this is that you'll have to unmount the temporary filesystems after you exit the chroot, so this lets you umount all the filesystems with a single command. This also allows for a safer shutdown. Because the external Linux environment knows all mounted partitions, it can safely unmount them during shutdown.<br />
<br />
== Change root ==<br />
<br />
Mount the temporary filesystems as root:<br />
<br />
{{Note|Using a newer (2012) Arch release, the following commands can be replaced with {{ic|arch-chroot /mnt/arch}}. You must have {{pkg|arch-install-scripts}} installed to run arch-chroot. The following commands may still be used if you're using a different Linux distribution.}}<br />
<br />
cd /mnt/arch<br />
mount -t proc proc proc/<br />
mount -t sysfs sys sys/<br />
mount -o bind /dev dev/<br />
mount -t devpts pts dev/pts/<br />
<br />
If you have established an internet connection and want to use it in the chroot environment, you may have to copy over your DNS configuration to be able to resolve hostnames.<br />
<br />
cp -L /etc/resolv.conf etc/resolv.conf<br />
<br />
Now chroot into your installed system and define your shell:<br />
<br />
chroot /mnt/arch /usr/bin/bash<br />
<br />
{{Note|If you see the error {{ic|chroot: cannot run command '/usr/bin/bash': Exec format error}}, it is likely that the two architectures do not match.}}<br />
{{Note|If you see the error {{ic|chroot: '/usr/bin/bash': permission denied}}, remount with the exec permission: {{ic|mount -o remount,exec /mnt/arch}}.}}<br />
Optionally, to source your Bash configuration ({{ic|~/.bashrc}} and {{ic|/etc/bash.bashrc}}), run:<br />
<br />
source ~/.bashrc<br />
source /etc/profile<br />
<br />
Optionally, create a unique prompt to be able to differentiate your chroot environment:<br />
<br />
export PS1="(chroot) $PS1"<br />
<br />
== Run graphical chrooted applications ==<br />
<br />
If you have [[X]] running on your system, you can start graphical applications from the chroot environment.<br />
<br />
To allow the chroot environment to connect to an X server, open a terminal inside the X server (i.e. inside the desktop of the user that is currently logged in), then run the following command which gives permission to anyone to connect to the user's X server:<br />
<br />
$ xhost +<br />
<br />
Then, to direct the applications to the X server from chroot, set the DISPLAY environment variable inside the chroot to match the DISPLAY variable of the user that owns the X server. So for example, run <br />
<br />
$ echo $DISPLAY<br />
<br />
as the user that owns the X server to see the value of DISPLAY. If the value is ":0" (for example), then in the chroot environment run<br />
<br />
# export DISPLAY=:0<br />
<br />
Now you can launch GUI apps from the chroot command line. ;)<br />
<br />
== Perform system maintenance ==<br />
<br />
At this point you can perform whatever system maintenance you require inside the chroot environment. A few common examples are:<br />
<br />
* Reinstall the bootloader.<br />
* Rebuild your [[mkinitcpio|initramfs]] image.<br />
* Upgrade or [[Downgrading_Packages|downgrade]] packages.<br />
* Reset a [[Password_Recovery|forgotten password]].<br />
<br />
== Exit the chroot environment ==<br />
<br />
When you're finished with system maintenance, exit the chroot:<br />
<br />
# exit<br />
<br />
Then unmount the temporary filesystems and any mounted devices:<br />
<br />
# umount {proc,sys,dev/pts,dev,boot,[...],}<br />
<br />
Finally, attempt to unmount your root partition:<br />
<br />
# cd ..<br />
# umount arch/<br />
<br />
{{Note|If you get an error saying that {{ic|/mnt}} (or any other partition) is busy, this can mean one of two things:<br />
<br />
* A program was left running inside of the chroot.<br />
<br />
* Or, more frequently, a sub-mount still exists (e.g. {{ic|/mnt/arch/boot}} within {{ic|/mnt/arch}}). Check with {{ic|lsblk}} to see if there are any mountpoints left:<br />
<br />
: {{bc|lsblk /dev/sda}}<br />
<br />
: If you are still unable to unmount a partition, use the {{ic|--force}} option:<br />
<br />
: {{bc|# umount -f /mnt}}}}<br />
<br />
After this, you will be able to safely reboot.<br />
<br />
== Example ==<br />
This may protect your system from Internet attacks during browsing: <br />
{{bc|1=<br />
# # as root: <br />
# cd /home/''user''<br />
# mkdir myroot<br />
# pacman -S arch-install-scripts<br />
# # pacstrap must see myroot as mounted: <br />
# mount --bind myroot myroot<br />
# pacstrap -i myroot base base-devel<br />
# mount -t proc proc myroot/proc/<br />
# mount -t sysfs sys myroot/sys/<br />
# mount -o bind /dev myroot/dev/<br />
# mount -t devpts pts myroot/dev/pts/<br />
# cp -i /etc/resolv.conf myroot/etc/<br />
# chroot myroot<br />
# # inside chroot: <br />
# passwd # set a password <br />
# useradd -m -s /usr/bin/bash ''user''<br />
# passwd ''user'' # set a password<br />
# # in a shell outside the chroot: <br />
# pacman -S xorg-server-xnest<br />
# # in a shell outside the chroot you can run this as ''user'': <br />
$ Xnest -ac -geometry 1024x716+0+0 :1<br />
# # continue inside the chroot: <br />
# pacman -S xterm<br />
# DISPLAY=:1<br />
# xterm<br />
# # xterm is now running in Xnest <br />
# pacman -S xorg-server xorg-xinit xorg-server-utils<br />
# pacman -S openbox<br />
# # for java we need icedtea-web which requires some fonts: <br />
# nano /etc/locale.gen<br />
# # uncomment en_US.UTF-8 UTF-8, save and exit <br />
# locale-gen<br />
# echo LANG=en_US.UTF-8 > /etc/locale.conf<br />
# export LANG=en_US.UTF-8<br />
# pacman -S ttf-dejavu<br />
# pacman -S icedtea-web<br />
# pacman -S firefox<br />
# firefox<br />
# # firefox is now running in Xnest <br />
# exit<br />
# # outside chroot: <br />
# chroot --userspec=''user'' myroot<br />
# # inside chroot as ''user'': <br />
$ DISPLAY=:1<br />
$ openbox &<br />
$ HOME="/home/''user''"<br />
$ firefox<br />
}}<br />
See also: [https://help.ubuntu.com/community/BasicChroot Basic Chroot]</div>Wide-eyehttps://wiki.archlinux.org/index.php?title=Intel_graphics&diff=182297Intel graphics2012-02-05T18:42:01Z<p>Wide-eye: /* KMS (Kernel Mode Setting) */ the video option is used to configure kms, a warning to remove it is incorrect.</p>
<hr />
<div>[[Category: Graphics (English)]][[Category: X Server (English)]]<br />
{{i18n|Intel}}<br />
[[fr:Intel]]<br />
{{Article summary start}}<br />
{{Article summary text|Information on Intel graphics cards/chipsets and the ''intel'' video driver.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|ATI}}<br />
{{Article summary wiki|NVIDIA}}<br />
{{Article summary wiki|Poulsbo}}<br />
{{Article summary wiki|Xorg}}<br />
{{Article summary end}}<br />
<br />
Since Intel provides and supports open source drivers, Intel graphics are now essentially plug-and-play.<br />
<br />
{{note|For use within the console without [[Xorg|X]], see [[Uvesafb]].}}<br />
<br />
=== Models ===<br />
It is a popular mistake to think of "Intel 945G" and "Intel GMA 945" as being the same graphics chip with different names. As a matter of fact, the latter does not exist. Intel uses "GMA" to indicate the graphics core, or the GPU. Anything other than that is actually the model of the '''motherboard chipset''', like "915G", "945GM", "G965" or "G45".<br />
<br />
The more common GPUs and their corresponding motherboard chipsets are:<br />
<br />
* Intel GMA 900 (910, 915)<br />
* Intel GMA 950 (945)<br />
<br />
The "i810" chipset (again, motherboard; not GPU) is actually really old and was manufactured long before the 9xx product line with which the GMA onboard-graphics branding began. Similarly, alternative names for the 910, 915 and 945 chips may include the {{ic|i}} prefix.<br />
<br />
See [[Wikipedia:Intel_GMA#Table_of_GMA_graphics_cores_and_chipsets|this]] for a list.<br />
<br />
=== Driver ===<br />
* {{Pkg|xf86-video-intel}}<br />
<br />
== Installation ==<br />
Prerequisite: [[Xorg]]<br />
<br />
[[pacman|Install]] the {{Pkg|xf86-video-intel}} package which is available in the [[Official Repositories|official repositories]].<br />
<br />
You may need to install {{Pkg|lib32-intel-dri}} in 64-bit systems to use acceleration in 32-bit programs.<br />
<br />
{{Note|{{Pkg|lib32-intel-dri}} is found in the [[Official_Repositories#.5Bmultilib.5D|[multilib] repository]].}}<br />
<br />
== Configuration ==<br />
<br />
There is no need for any kind of configuration to get the Xorg running (an {{ic|xorg.conf}} is unneeded, but needs to be configured correctly if present).<br />
<br />
One thing that you should have already done from the start (not a configuration step per se) is to add your user to the relevant [[Users and Groups|group]]:<br />
<br />
# gpasswd -a username video<br />
<br />
== KMS (Kernel Mode Setting) ==<br />
<br />
[[KMS]] is required in order to run X and a desktop environment such as [[GNOME]], [[KDE]], [[Xfce]], [[LXDE]], etc. KMS is supported by Intel chipsets that use the i915 DRM driver and is enabled by default as of kernel v2.6.32. Versions 2.10 and newer of the {{Pkg|xf86-video-intel}} driver no longer support UMS, making the use of KMS mandatory<sup>[https://www.archlinux.org/news/484/]</sup>. KMS is typically initialized after the kernel is bootstrapped. It is possible, however, to enable KMS during bootstrap itself, allowing the entire boot process to run at the native resolution.<br />
<br />
{{Note|When using KMS, you ''must'' remove any references to {{ic|vga}} from the kernel line in {{ic|/boot/grub/menu.lst}}}}<br />
<br />
To proceed, add the {{ic|i915}} module to the {{ic|MODULES}} line in {{ic|/etc/mkinitcpio.conf}}:<br />
MODULES="'''i915'''"<br />
<br />
{{Note|If you have a first generation Core i{3,5,7} series processor with an integrated GPU, failure to add {{ic|i915}} to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}} will likely cause the error {{ic|kernel: intel ips [...]: failed to get i915 symbols, graphics turbo disabled}}.}}<br />
<br />
{{Note|You may need to add the {{ic|intel_agp}} module too if the system complains at boot time.}}<br />
<br />
Now, regenerate the initramfs:<br />
# mkinitcpio -p linux<br />
<br />
and reboot the system. Everything should work now. If you are having problems, try explicitly enabling KMS by adding {{ic|1=i915.modeset=1}} to your kernel line in {{ic|/boot/grub/menu.lst}}:<br />
# (0) Arch Linux<br />
title Arch Linux<br />
root (hd0,0)<br />
kernel /boot/vmlinuz-linux root=/dev/... '''i915.modeset=1'''<br />
initrd /boot/initramfs-linux.img<br />
and make sure that you do not use the {{ic|1=vga=...}} property nor {{ic|nomodeset}}. Now, reboot and Xorg will work.<br />
<br />
If you ever want to disable KMS, you can change the {{ic|i915.modeset}} option to 0 in [[GRUB]]'s {{ic|/boot/grub/menu.lst}}, without rebuilding anything:<br />
# (0) Arch Linux<br />
title Arch Linux<br />
root (hd0,0)<br />
kernel /boot/vmlinuz-linux root=/dev/... '''i915.modeset=0'''<br />
initrd /boot/initramfs-linux.img<br />
{{ic|1=i915.modeset=0}} is the Intel equivalent to {{ic|nomodeset}} for other video cards.<br />
{{Note|Adding {{ic|nomodeset}} to the kernel boot line might prevent GNOME 3's gnome-shell or KDE's desktop effects from running.}}<br />
<br />
For disabling it without having to edit {{ic|/boot/grub/menu.lst}}, turn on the machine and when you see [[GRUB]]'s screen, hit a key to disable the timeout. Select the kernel you want to boot (probably the one already selected) and hit {{Keypress|e}} for "edit". Now select the line starting with "kernel" and hit {{Keypress|e}} again for editing. You can now add the {{ic|i915.modeset}} option and disable KMS by setting it to 0. Press {{Keypress|Enter}} and then {{Keypress|b}} to boot. Note that this will be temporary, so it will be enabled again upon rebooting.<br />
<br />
{{Note|Downgrade to kernel 2.6.31.6-1 or disable modesetting with kernel boot parameter if you get a blank screen during boot process with the Intel GMA 950.}}<br />
<br />
=== See also ===<br />
* [[KMS]] &mdash; Arch wiki article on kernel mode setting<br />
* Arch Linux forums: [https://bbs.archlinux.org/viewtopic.php?pid=522665#p522665 Intel 945GM, Xorg, Kernel - performance]<br />
<br />
== Tips and tricks ==<br />
<br />
=== Setting scaling mode ===<br />
<br />
This can be useful for some full screen applications.<br />
xrandr --output LVDS1 --set PANEL_FITTING param<br />
where {{ic|param}} can be<br />
* {{ic|center}}: resolution will be kept exactly as defined, no scaling will be made,<br />
* {{ic|full}}: scale the resolution so it uses the entire screen or<br />
* {{ic|full_aspect}}: scale the resolution to the maximum possible but keep the aspect ratio.<br />
If it does not work, you can try<br />
xrandr --output LVDS1 --set "scaling mode" param<br />
where {{ic|param}} is one of {{ic|"Full"}}, {{ic|"Center"}} or {{ic|"Full aspect"}}.<br />
<br />
=== KMS Issue: console is limited to small area ===<br />
<br />
One of the low-resolution video ports may be enabled on boot which is causing the terminal to utilize a small area of the screen.<br />
To fix, explicitly disable the port with an i915 module setting. For example, add the following to the end of the kernel line in {{ic|/boot/grub/menu.lst}}:<br />
video=SVIDEO-1:d<br />
<br />
If that does not work, you may also try disabling TV1 or VGA1 instead of SVIDEO-1.<br />
<br />
=== Hardware acceleration ===<br />
<br />
If you want to enable hardware accelerated video decode/encode in multimedia applications (such as VLC or MPlayer) for Intel HD graphics controllers (G45, Sandybridge), [[pacman|install]] the {{pkg|libva-driver-intel}} package, available in the [[Official Repositories]].<br />
<br />
==Supported hardware==<br />
See http://intellinuxgraphics.org/documentation.html.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Glxgears shows low performance results ===<br />
<br />
If you run glxgears in order to check your system's graphics performance, you may notice that glxgears shows results around '''60 FPS''':<br />
<br />
...<br />
311 frames in 5.0 seconds = 61.973 FPS<br />
311 frames in 5.0 seconds = 62.064 FPS<br />
311 frames in 5.0 seconds = 62.026 FPS<br />
...<br />
<br />
That is happening not because there is a performance regression, but because your system graphics are using vertical sync (vsync), that means, your display's native frames per second.<br />
<br />
{{Note|glxgears is not a benchmark for performance comparison between two or more systems.}}<br />
{{Note|To disable '''VSync''' just add in your {{ic|/etc/X11/xorg.conf.d/20-intel.conf}} in '''Section "Device"''' string '''Option "SwapbuffersWait" "false"''' }}<br />
<br />
=== Blank screen during boot, when "Loading modules" ===<br />
<br />
If you are using "late start" KMS and the screen goes blank when "Loading modules", it may help to add {{ic|i915}} and {{ic|intel_agp}} to the initramfs. See [[Intel#KMS (Kernel Mode Setting)|KMS]] above.<br />
<br />
Alternatively, appending the following to the kernel command line seems to work as well:<br />
video=SVIDEO-1:d<br />
<br />
=== External monitor connected to laptop flashes black every 30 seconds ===<br />
<br />
If your laptop uses Intel HD graphics and your external LCD is flashing to black every 30 seconds, upgrading your video driver and kernel may help. As of now using {{Pkg|xf86-video-intel}} version 2.14.0-1 and kernel 2.6.37-5 have solved this issue.<br />
<br />
=== Only a single low-resolution present ===<br />
<br />
If Xorg starts with 800x600 and does not find any other resolutions, it may be because you have an {{ic|/etc/X11/xorg.conf}} file left over from your NVIDIA setup. Simply changing the driver from "nvidia" to "intel" is not sufficient when moving from NVIDIA's {{ic|xorg.conf}} to Intel's. Try to delete {{ic|/etc/X11/xorg.conf}}, letting the driver pick the settings itself.<br />
<br />
=== Video tearing ===<br />
Install VA-API support by installing the {{Pkg|libva-driver-intel}} package. Use a VAAPI supported video player. If you use mplayer, install {{Pkg|mplayer-vaapi}}, and use -vo vaapi parameter. To fix tearing on flash videos, try to enable hardware video decoding from {{ic|/etc/adobe/mms.cfg}} and add line {{ic|1=EnableLinuxHWVideoDecode=1}}. If hardware video decoding is still not working, you can also try adding {{ic|1=OverrideGPUValidation = 1}}.<br />
<br />
=== X freeze/crash with intel driver ===<br />
If you have issue with X crashing, or GPU hang, or problem with frozen X, then the fix may be [https://bbs.archlinux.org/viewtopic.php?pid=938004#p938004 to use the "Shadow" option]:<br />
{{hc|/etc/X11/xorg.conf.d/20-intel.conf|<br />
Section "Device"<br />
Identifier "old intel stuff"<br />
Driver "intel"<br />
Option "Shadow" "True"<br />
Option "DRI" "false"<br />
EndSection}}<br />
<br />
Because it disables (most) video acceleration functions, using this fix (Option "Shadow" "True") may cause [https://bbs.archlinux.org/viewtopic.php?pid=973673 problems with gnome-screenshot] and similar programs like {{pkg|gimp}}, or {{pkg|gcolor2}}.<br />
<br />
Another option that can help on some implementations is to enable semaphores in the kernel video driver, by adding {{ic|1=i915.semaphores=1}} to the kernel command line. To make this change permanent on [[GRUB2]] installations, changing the kernel command-line entry in {{ic|/etc/default/grub}} and re-running {{ic|grub-mkconfig}} will make that change permanent.<br />
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash i915.semaphores=1"</div>Wide-eyehttps://wiki.archlinux.org/index.php?title=Pacman/Tips_and_tricks&diff=166563Pacman/Tips and tricks2011-10-20T00:51:54Z<p>Wide-eye: /* Reinstalling all installed packages */ derp</p>
<hr />
<div>[[Category:Package management (English)]] {{DISPLAYTITLE:pacman Tips}}<br />
{{i18n|Pacman Tips}}<br />
<br />
{{Article summary start|Summary}}<br />
{{Article summary text|This is a collection of common tips for new pacman users.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|pacman}}<br />
{{Article summary wiki|Mirrors}}<br />
{{Article summary wiki|Creating Packages}}<br />
{{Article summary wiki|Custom local repository}}<br />
{{Article summary end}}<br />
<br />
==General==<br />
''Basic pacman modifications and improvements''<br />
<br />
===Color output===<br />
The most effective method of colorizing pacman is installing {{Package AUR|pacman-color}} from the [[AUR]].<br />
<br />
{{Note|The package installs a separate pacman binary patched for colored output (pacman-color), so you may want to use an [[alias]].}}<br />
<br />
Besides that, there are numerous scripts and hacks devised by members of the Arch Linux community:<br />
<br />
====Simple Bash script====<br />
Colorized pacman search output:<br />
<nowiki><br />
pacs() {<br />
local CL='\\e['<br />
local RS='\\e[0;0m'<br />
<br />
echo -e "$(pacman -Ss "$@" | sed "<br />
/^core/ s,.*,${CL}1;31m&${RS},<br />
/^extra/ s,.*,${CL}0;32m&${RS},<br />
/^community/ s,.*,${CL}1;35m&${RS},<br />
/^[^[:space:]]/ s,.*,${CL}0;36m&${RS},<br />
")"<br />
}<br />
</nowiki><br />
<br />
To use it simply type {{Codeline|pacs}} instead of {{Codeline|pacman -Ss}}.<br />
<br />
====Python script====<br />
[[RepoSearch|This one]] also searches the [[AUR]].<br />
<br />
====Using acoc====<br />
There is another, more general possibility of colorizing arbitrary command output. Download the small [http://www.ruby-lang.org/en/ Ruby] tool [http://raa.ruby-lang.org/project/acoc/ acoc], and its requirements, [http://raa.ruby-lang.org/project/ansicolor/ term-ansicolor] and [http://raa.ruby-lang.org/cache/ruby-tpty/ tpty]. Some applications like {{Codeline|ls}} will not run without tpty because they need to be started from a terminal (or pseudo terminal, in this case), or else they behave differently.<br />
<br />
Installation is relatively straightforward:<br />
$ tar xf tpty-0.0.1.tar.gz<br />
$ cd tpty-0.0.1<br />
$ ruby extconf.rb<br />
$ make<br />
$ ruby ./test.rb<br />
# make install<br />
<br />
$ tar xf term-ansicolor-1.0.1.tar.gz<br />
$ cd term-ansicolor-1.0.1<br />
# ruby install.rb<br />
<br />
And now acoc itself:<br />
$ tar xf acoc-0.7.1.tar.gz<br />
$ cd acoc-0.7.1<br />
# make install<br />
<br />
Now, just read the section ''Advanced Installation'' in acoc's {{Filename|INSTALL}} file, and configure acoc as prefered. Create a link for pacman as well, since that is primarily what this is being done for.<br />
<br />
Once acoc runs, optionally add these lines to {{filename|acoc.conf}}:<br />
[pacman -Si]<br />
/^Name\s+:\s([\w.-]+)/ bold<br />
[pacman -Qi]<br />
/^Name\s+:\s([\w.-]+)/ bold<br />
[pacman -Qi$]<br />
/^([\w.-]+)\s([\w.-]+)/ bold,clear<br />
[pacman -Ss]<br />
/^([\w.-]+)\/([\w.-]+)\s+([\w.-]+)/ clear,bold,clear<br />
[pacman -Qs]<br />
/^([\w.-]+)\/([\w.-]+)\s+([\w.-]+)/ clear,bold,clear<br />
[pacman -Sl]<br />
/^([\w.-]+)\s([\w.-]+)\s([\w.-]+)/ clear,bold,clear<br />
[pacman -Qo]<br />
/^([\w.-\/]+)\sis\sowned\sby\s([\w.-]+)\s([\w.-]+)/ clear,bold,clear<br />
[pacman -Qe$]<br />
/^([\w.-]+)\s([\w.-]+)/ bold,clear<br />
[pacman -Qg$]<br />
/^([\w.-]+)\s([\w.-]+)/ clear,bold<br />
<br />
The above lines make pacman print all package names in bold, which is particularly helpful when doing, e.g. {{Codeline|pacman -Ss xfce}}. If desiring a more colorful output, modify the lines to suit. Read the acoc documentation contained in the source package for more information.<br />
<br />
===Aliases===<br />
The following instructions allow users to run some of the more common pacman commands without the need to type them fully.<br />
<br />
====Configure the shell====<br />
Add the following examples, which work in both [[Bash]] and [[Zsh]]:<br />
# Pacman alias examples<br />
alias pacupg='sudo pacman -Syu' # Synchronize with repositories before upgrading packages that are out of date on the local system.<br />
alias pacin='sudo pacman -S' # Install specific package(s) from the repositories<br />
alias pacins='sudo pacman -U' # Install specific package not from the repositories but from a file <br />
alias pacre='sudo pacman -R' # Remove the specified package(s), retaining its configuration(s) and required dependencies<br />
alias pacrem='sudo pacman -Rns' # Remove the specified package(s), its configuration(s) and unneeded dependencies<br />
alias pacrep='pacman -Si' # Display information about a given package in the repositories<br />
alias pacreps='pacman -Ss' # Search for package(s) in the repositories<br />
alias pacloc='pacman -Qi' # Display information about a given package in the local database<br />
alias paclocs='pacman -Qs' # Search for package(s) in the local database<br />
<br />
# Additional pacman alias examples<br />
alias pacupd='sudo pacman -Sy && sudo abs' # Update and refresh the local package and ABS databases against repositories<br />
alias pacinsd='sudo pacman -S --asdeps' # Install given package(s) as dependencies of another package<br />
alias pacmir='sudo pacman -Syy' # Force refresh of all package lists after updating /etc/pacman.d/mirrorlist<br />
<br />
====Usage====<br />
Perform the respective commands by simply typing the alias name. For example, to synchronize with repositories before upgrading packages that are out of date on the local system:<br />
$ pacupg<br />
Install packages from repositories:<br />
$ pacin <package1> <package2> <package3><br />
Install a custom built package:<br />
$ pacins /path/to/<package><br />
Completely remove a locally installed package:<br />
$ pacrem <package><br />
Search for available packages in the repositories:<br />
$ pacreps <keywords><br />
Display information about a package (e.g. size, dependencies) in the repositories:<br />
$ pacrep <keywords><br />
<br />
====Notes====<br />
The aliases used above are merely examples. By following the syntax samples above, rename the aliases as convenient. For example:<br />
alias pacrem='sudo pacman -Rns'<br />
alias pacout='sudo pacman -Rns'<br />
<br />
In the case above, the commands {{Codeline|pacrem}} and {{Codeline|pacout}} both call Bash to execute the same command.<br />
<br />
===Operations and Bash syntax===<br />
In addition to pacman's standard set of features, there are ways to extend its usability through rudimentary [[Bash]] commands/syntax.<br />
<br />
* To install a number of packages sharing similar patterns in their names -- not the entire group nor all matching packages; eg. {{package Official|kdemod}}:<br />
pacman -S kdemod-{applets,theme,tools}<br />
* Of course, that is not limited and can be expanded to however many levels needed:<br />
pacman -S kdemod-{ui-{kde,kdemod},kdeartwork}<br />
* Sometimes, {{codeline|-s}}'s builtin ERE can cause a lot of unwanted results, so it has to be limited to match the package name only; not the description nor any other field:<br />
pacman -Ss '^vim-'<br />
* pacman has the {{Codeline|-q}} operand to hide the version column, so it is possible to query and reinstall packages with "compiz" as part of their name:<br />
pacman -S $(pacman -Qq | grep compiz)<br />
* You may want to get the list of installed packages sorted by size, which may be useful when freeing space on your hard drive.<br />
pacman -Qi | awk '/^Name/ {pkg=$3} /Size/ {print $4$5,pkg}' | sort -n<br />
<br />
==Installation and recovery==<br />
''Alternative ways of getting and restoring packages''<br />
<br />
===Installing packages from a CD/DVD/ISO===<br />
<!-- could easily be adapted to work with usb sticks --><br />
*First mount the CD (replace ''cdrom'' with ''dvd'' if needed):<br />
# mount /mnt/cdrom<br />
<br />
:If working with an .iso file instead, first create a directory under /mnt:<br />
# mkdir /mnt/iso<br />
:Then mount the image:<br />
# mount -t iso9660 -o ro,loop /path/to/iso /mnt/iso<br />
<br />
*Configure pacman:<br />
# nano -w /etc/pacman.conf<br />
<br />
*Add the following ''before'' other repositories (e.g. extra, core, etc.). This ensures the files from the CD/DVD/iso take precedence over those in the standard repositories:<br />
# Settings for using a cd-rom as a repository.<br />
[custom]<br />
Server = file:///mnt/cdrom/arch/pkg<br />
:Again, replace ''cdrom'' as appropiate.<br />
<br />
Once {{Filename|pacman.conf}} has been edited, sync pacman in order to be able to use the new repository.<br />
<br />
====Using packages from an Arch core image====<br />
<br />
In order to use packages from an Arch core image (e.g. to set up wireless support while offline), mount the core repository:<br />
# mount -o loop /path/to/arch_core_image/i686/repo-core-i686.sfs /mnt/iso<br />
Then edit {{Filename|pacman.conf}}'s <code>[core]</code> section, (temporarily) replacing the default entry with a reference to the mounted image:<br />
[core]<br />
#Include = /etc/pacman.d/mirrorlist<br />
Server = file:///mnt/iso<br />
Finally, sync Pacman:<br />
# pacman -Syu<br />
<br />
===Custom local repository===<br />
pacman 3 introduced a new script named {{Codeline|repo-add}} which makes generating a database for a personal repository much easier. Use {{Codeline|repo-add --help}} for more details on its usage.<br />
<br />
Simply store all of the built packages to be included in the repository in one directory, and execute the following command (where ''repo'' is the name of the custom repository):<br />
$ repo-add /path/to/repo.db.tar.gz /path/to/*.pkg.tar.gz<br />
<br />
Note that when using {{Codeline|repo-add}}, the database and the packages do not need to be in the same directory. But when using pacman with that database, they should be together.<br />
<br />
To add a new package (and remove the old if it exists), run:<br />
$ repo-add /path/to/repo.db.tar.gz /path/to/packagetoadd-1.0-1-i686.pkg.tar.gz<br />
<br />
{{Note|If there is a package that needs to be removed from the repository, read up on {{Codeline|repo-remove}}.}}<br />
<br />
Once the local repository has been made, add the repository to {{Filename|pacman.conf}}. The name of the {{Filename|db.tar.gz}} file is the repository name. Reference it directly using a ''file://'' url, or access it via FTP using ftp://localhost/path/to/directory.<br />
<br />
If willing, add the custom repository to the [[Unofficial user repositories|list of unofficial user repositories]], so that the community can benefit from it.<br />
<br />
===Network shared pacman cache===<br />
{{Tip|See [http://xyne.archlinux.ca/projects/pacserve/ pacserve] for an alternate solution.}}<br />
<br />
In order to share packages between multiple computers, simply share {{Filename|/var/cache/pacman/}} using any network-based mount protocol. This section shows how to use shfs or sshfs to share a package cache plus the related library-directories between multiple computers on the same local network. Keep in mind that a network shared cache can be slow depending on the file-system choice, among other factors.<br />
<br />
First, install any network-supporting filesystem; for example [[sshfs]], [[shfs]], [[ftpfs]], [[smbfs]] or [[nfs]]<br />
{{Tip|To use sshfs or shfs, consider reading [[Using SSH Keys]].}}<br />
<br />
Then, to share the actual packages, mount {{Filename|/var/cache/pacman/pkg}} from the server to {{Filename|/var/cache/pacman/pkg}} on every client machine.<br />
<br />
To have shared package databases, mount {{Filename|<nowiki>/var/lib/pacman/sync/{core,extra,testing,community}</nowiki>}} in the same way. Proceed to place the appropriate lines in {{Filename|/etc/fstab}}.<br />
<br />
====Preventing unwanted cache purges====<br />
By default, {{Codeline|pacman -Sc}} removes package tarballs from the cache that correspond to packages that are not installed on the machine the command was issued on. Because pacman cannot predict what packages are installed on all machines that share the cache, it will end up deleting files that should not be.<br />
<br />
To clean up the cache so that only ''outdated'' tarballs are deleted, add this entry in the {{Codeline|[options]}} section of {{Filename|/etc/pacman.conf}}:<br />
CleanMethod = KeepCurrent<br />
<br />
===Backing up and retrieving a list of installed packages===<br />
It is good practice to keep periodic backups of all pacman-installed packages. In the event of a system crash which is unrecoverable by other means, pacman can then easily reinstall the very same packages onto a new installation.<br />
<br />
*First, backup the current list of non-local packages:<br />
$ comm -23 <(pacman -Qeq) <(pacman -Qmq) > pkglist<br />
<br />
*Store the pkglist on a USB key or other convenient medium.<br />
<br />
*Copy the pkglist file to the new installation, and navigate to the directory containing it.<br />
<br />
*Issue the following command to install from the backup list:<br />
# pacman -S $(< pkglist)<br />
<br />
===List downloaded packages that are not in base or base-devel===<br />
<br />
The following command will list any installed packages that are not in base/base-devel, and as such were likely installed manually by the user:<br />
<br />
comm -23 <(pacman -Qeq) <(pacman -Qgq base base-devel | sort )<br />
<br />
===Reinstalling all installed packages===<br />
If you mess up your system (rm -rf) you can repair by having pacman reinstall all of your packages. <br />
<br />
If your system does not contain any foreign(AUR) packages you can run:<br />
# pacman -Qeq | pacman -S -<br />
# pacman -Qdq | pacman -S --asdeps -<br />
<br />
If you have foreign packages this will error as packages will not be found in the repositories. The following will make a list of all packages and remove the foreign packages seen with pacman -Qmq. combining a command to list all packages, and another to hide the list of foreign packages is required.<br />
<br />
The following will reinstall every package found in the repositories, preserving asdeps/explicitly installed info<br />
# comm -23 <(pacman -Qeq) <(pacman -Qmq) | pacman -S -<br />
# comm -23 <(pacman -Qdq) <(pacman -Qmq) | pacman -S --asdeps -<br />
<br />
===Restore pacman's local database===<br />
Signs that pacman needs a local database restoration:<br />
*{{Codeline|pacman -Q}} gives absolutely no output, and {{Codeline|pacman -Syu}} erroneously reports that the system is up to date.<br />
*When trying to install a package using {{Codeline|pacman -S package}} it outputs a list of already satisfied dependencies.<br />
<br />
Most likely, pacman's database of installed software, {{Filename|/var/lib/pacman/local}}, has been corrupted or deleted. While this is a serious problem, it can be restored by following the instructions below.<br />
<br />
Firstly, make sure pacman's log file is present:<br />
$ ls /var/log/pacman.log<br />
<br />
If it does not exist, it is ''not'' possible to continue with this method. You may be able to use [http://bbs.archlinux.org/viewtopic.php?pid=670876 Xyne's package detection script] to recreate the database. If not, then the likely solution is to re-install the entire system.<br />
<br />
====Log filter script====<br />
Create a script with the following content <sup>based on [http://bbs.archlinux.org/viewtopic.php?id=38531]</sup>:<br />
{{file|name=log2pkglist.awk|content=<br />
<nowiki><br />
#!/bin/awk -f<br />
<br />
$3 ~ /^(installed|upgraded)$/ {<br />
pkg[$4] = 1<br />
next<br />
} <br />
<br />
$3 == "removed" {<br />
pkg[$4] = 0<br />
} <br />
<br />
END {<br />
for (i in pkg) if (pkg[i]) print i<br />
}<br />
</nowiki><br />
}}<br />
<br />
Make the script executable:<br />
$ chmod +x log2pkglist.awk<br />
<br />
====Generating the package recovery list====<br />
Run the script and pipe the output to a temporary list:<br />
$ ./log2pkglist.awk /var/log/pacman.log > pkglist.orig<br />
<br />
Optionally edit {{Filename|pkglist.orig}} and remove anything that should not be re-installed. This might be the situation with custom packages made with [[ABS]], for example.<br />
<br />
Here is a way to automatically restrict the list to packages available in a repository:<br />
$ { cat pkglist.orig; pacman -Slq; } | sort | uniq -d > pkglist<br />
<br />
Check if some important ''base'' package are missing, and add them to the list:<br />
$ comm -23 <(pacman -Sgq base) pkglist.orig >> pkglist<br />
<br />
Proceed once the contents of {{Filename|pkglist}} are satisfactory, since they will be used it restore pacman's installed package database; {{Filename|/var/lib/pacman/local}}.<br />
<br />
====Performing the recovery====<br />
As a normal user, make temporary directories for the cache, database, and root:<br />
<pre><br />
tmp=~/tmp<br />
mkdir -p "${tmp}"<br />
<br />
pushd "${tmp}"<br />
dbpath=$(readlink -f ./dbpath)<br />
root=$(readlink -f ./root)<br />
cache=$(readlink -f ./cache)<br />
log=/dev/null<br />
mkdir -p "${dbpath}" "${cache}" "${root}"<br />
popd<br />
<br />
recovery-pacman() {<br />
fakeroot pacman "$@" \<br />
--dbpath "${dbpath}" \<br />
--root "${root}" \<br />
--cache "${cache}" \<br />
--log "${log}" \<br />
--noscriptlet \<br />
#<br />
}<br />
</pre><br />
<br />
Populate the temporary sync database:<br />
$ recovery-pacman -Sy<br />
or copy the system's sync database:<br />
$ cp -r /var/lib/pacman/sync "${dbpath}"<br />
<br />
To avoid downloading and/or processing packages that are present in the system's local database (or whatever remains of it), optionally copy it into the temporary location:<br />
$ cp -r /var/lib/pacman/local "${dbpath}"<br />
<br />
Generate the temporary local recovery database from the previously generated {{filename|pkglist}}:<br />
$ recovery-pacman -S --nodeps --needed $(< pkglist)<br />
<br />
{{note|Because {{codeline|--noscriptlet}} is needed, the files owned by packages in the fake root will not be representative of a real install.}}<br />
<br />
After revising the database, conclude by copying it to the real destination:<br />
# cp -r "${dbpath}"/local /var/lib/pacman<br />
<br />
Finally update the local database so that packages that are not required by any other package are marked as explicitly installed and the other as dependences. You will need be extra careful in the future when removing packages, but with the original database lost is the best we can do.<br />
# pacman -D --asdeps $(pacman -Qq)<br />
# pacman -D --asexplicit $(pacman -Qtq)<br />
<br />
===Removing everything but base group===<br />
If it is ever necessary to remove all packages except the base group on a ''severely'' broken system, try this one liner:<br />
# pacman -Rs $(comm -23 <(pacman -Qeq) <(pacman -Qgq base))<br />
<br />
Copied from a [http://mailman.archlinux.org/pipermail/arch-general/2010-February/011527.html message] on the archlinux.org mailing list.<br />
<br />
===Recovering a USB key from existing install===<br />
If you have Arch installed on a USB key and manage to mess it up (e.g. removing it while it is still being written to), then it is possible to re-install all the packages and hopefully get it back up and working again (assuming USB key is mounted in /newarch)<br />
# pacman -S $(pacman -Qq --dbpath /newarch/var/lib/pacman) --root /newarch --dbpath /newarch/var/lib/pacman<br />
<br />
===Extracting contents of a .pkg file===<br />
The .pkg files ending in .xz are simply tar'ed archives that can be decompressed using "$ tar -Jxvf package.tar.xz". If you want to extract a couple of files out of a .pkg file, this would be a way to do it.<br />
<br />
==Maintenance==<br />
''House keeping, in the interest of keeping a clean system and following [[The Arch Way]]''<br />
<br />
===Miscellaneous procedures===<br />
For ''recursively'' removing orphans (''be careful''):<br />
# pacman -Rs $(pacman -Qtdq)<br />
<br />
To get a sorted list of local packages and their size:<br />
$ LC_ALL=C pacman -Qi | sed -n '/^Name[^:]*: \(.*\)/{s//\1 /;x};/^Installed[^:]*: \(.*\)/{s//\1/;H;x;s/\n//;p}' | sort -nk2 | column -t<br />
<br />
====Getting a list of files not owned by any package====<br />
Periodic checks for files outside of pacman database are recommended. These files are often some 3rd party applications installed using the usual procedure (e.g. '''./configure; make; make install'''). Search the file-system for these files (or symlinks) using this simple script:<br />
{{file|name=pacman-disowned|content=<br />
<nowiki><br />
#!/bin/sh<br />
<br />
tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$<br />
db=$tmp/db<br />
fs=$tmp/fs<br />
<br />
mkdir "$tmp"<br />
trap 'rm -rf "$tmp"' EXIT<br />
<br />
pacman -Qlq | sort -u > "$db"<br />
<br />
find /bin /etc /lib /sbin /usr \<br />
! -name lost+found \<br />
\( -type d -printf '%p/\n' -o -print \) | sort > "$fs"<br />
<br />
comm -23 "$fs" "$db"<br />
</nowiki><br />
}}<br />
<br />
To generate the list:<br />
$ pacman-disowned > non-db.txt<br />
<br />
Note that one ''should not'' delete all files listed in {{filename|non-db.txt}} without confirming each entry. There could be various configuration files, logs, etc., so use this list responsibly and only proceed after extensively searching for cross-references using {{Codeline|grep}}.<br />
<br />
===Selective cache purge===<br />
[[CacheClean|Here]] is a Python script to clean the {{Filename|/var/cache/pacman/pkg}} directory while allowing to specify how many package versions should be retained. <sup>[http://bbs.archlinux.org/viewtopic.php?id=9104]</sup></div>Wide-eyehttps://wiki.archlinux.org/index.php?title=Pacman/Tips_and_tricks&diff=166562Pacman/Tips and tricks2011-10-20T00:51:21Z<p>Wide-eye: rewrite section with pipes and taking care of dependancies.</p>
<hr />
<div>[[Category:Package management (English)]] {{DISPLAYTITLE:pacman Tips}}<br />
{{i18n|Pacman Tips}}<br />
<br />
{{Article summary start|Summary}}<br />
{{Article summary text|This is a collection of common tips for new pacman users.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|pacman}}<br />
{{Article summary wiki|Mirrors}}<br />
{{Article summary wiki|Creating Packages}}<br />
{{Article summary wiki|Custom local repository}}<br />
{{Article summary end}}<br />
<br />
==General==<br />
''Basic pacman modifications and improvements''<br />
<br />
===Color output===<br />
The most effective method of colorizing pacman is installing {{Package AUR|pacman-color}} from the [[AUR]].<br />
<br />
{{Note|The package installs a separate pacman binary patched for colored output (pacman-color), so you may want to use an [[alias]].}}<br />
<br />
Besides that, there are numerous scripts and hacks devised by members of the Arch Linux community:<br />
<br />
====Simple Bash script====<br />
Colorized pacman search output:<br />
<nowiki><br />
pacs() {<br />
local CL='\\e['<br />
local RS='\\e[0;0m'<br />
<br />
echo -e "$(pacman -Ss "$@" | sed "<br />
/^core/ s,.*,${CL}1;31m&${RS},<br />
/^extra/ s,.*,${CL}0;32m&${RS},<br />
/^community/ s,.*,${CL}1;35m&${RS},<br />
/^[^[:space:]]/ s,.*,${CL}0;36m&${RS},<br />
")"<br />
}<br />
</nowiki><br />
<br />
To use it simply type {{Codeline|pacs}} instead of {{Codeline|pacman -Ss}}.<br />
<br />
====Python script====<br />
[[RepoSearch|This one]] also searches the [[AUR]].<br />
<br />
====Using acoc====<br />
There is another, more general possibility of colorizing arbitrary command output. Download the small [http://www.ruby-lang.org/en/ Ruby] tool [http://raa.ruby-lang.org/project/acoc/ acoc], and its requirements, [http://raa.ruby-lang.org/project/ansicolor/ term-ansicolor] and [http://raa.ruby-lang.org/cache/ruby-tpty/ tpty]. Some applications like {{Codeline|ls}} will not run without tpty because they need to be started from a terminal (or pseudo terminal, in this case), or else they behave differently.<br />
<br />
Installation is relatively straightforward:<br />
$ tar xf tpty-0.0.1.tar.gz<br />
$ cd tpty-0.0.1<br />
$ ruby extconf.rb<br />
$ make<br />
$ ruby ./test.rb<br />
# make install<br />
<br />
$ tar xf term-ansicolor-1.0.1.tar.gz<br />
$ cd term-ansicolor-1.0.1<br />
# ruby install.rb<br />
<br />
And now acoc itself:<br />
$ tar xf acoc-0.7.1.tar.gz<br />
$ cd acoc-0.7.1<br />
# make install<br />
<br />
Now, just read the section ''Advanced Installation'' in acoc's {{Filename|INSTALL}} file, and configure acoc as prefered. Create a link for pacman as well, since that is primarily what this is being done for.<br />
<br />
Once acoc runs, optionally add these lines to {{filename|acoc.conf}}:<br />
[pacman -Si]<br />
/^Name\s+:\s([\w.-]+)/ bold<br />
[pacman -Qi]<br />
/^Name\s+:\s([\w.-]+)/ bold<br />
[pacman -Qi$]<br />
/^([\w.-]+)\s([\w.-]+)/ bold,clear<br />
[pacman -Ss]<br />
/^([\w.-]+)\/([\w.-]+)\s+([\w.-]+)/ clear,bold,clear<br />
[pacman -Qs]<br />
/^([\w.-]+)\/([\w.-]+)\s+([\w.-]+)/ clear,bold,clear<br />
[pacman -Sl]<br />
/^([\w.-]+)\s([\w.-]+)\s([\w.-]+)/ clear,bold,clear<br />
[pacman -Qo]<br />
/^([\w.-\/]+)\sis\sowned\sby\s([\w.-]+)\s([\w.-]+)/ clear,bold,clear<br />
[pacman -Qe$]<br />
/^([\w.-]+)\s([\w.-]+)/ bold,clear<br />
[pacman -Qg$]<br />
/^([\w.-]+)\s([\w.-]+)/ clear,bold<br />
<br />
The above lines make pacman print all package names in bold, which is particularly helpful when doing, e.g. {{Codeline|pacman -Ss xfce}}. If desiring a more colorful output, modify the lines to suit. Read the acoc documentation contained in the source package for more information.<br />
<br />
===Aliases===<br />
The following instructions allow users to run some of the more common pacman commands without the need to type them fully.<br />
<br />
====Configure the shell====<br />
Add the following examples, which work in both [[Bash]] and [[Zsh]]:<br />
# Pacman alias examples<br />
alias pacupg='sudo pacman -Syu' # Synchronize with repositories before upgrading packages that are out of date on the local system.<br />
alias pacin='sudo pacman -S' # Install specific package(s) from the repositories<br />
alias pacins='sudo pacman -U' # Install specific package not from the repositories but from a file <br />
alias pacre='sudo pacman -R' # Remove the specified package(s), retaining its configuration(s) and required dependencies<br />
alias pacrem='sudo pacman -Rns' # Remove the specified package(s), its configuration(s) and unneeded dependencies<br />
alias pacrep='pacman -Si' # Display information about a given package in the repositories<br />
alias pacreps='pacman -Ss' # Search for package(s) in the repositories<br />
alias pacloc='pacman -Qi' # Display information about a given package in the local database<br />
alias paclocs='pacman -Qs' # Search for package(s) in the local database<br />
<br />
# Additional pacman alias examples<br />
alias pacupd='sudo pacman -Sy && sudo abs' # Update and refresh the local package and ABS databases against repositories<br />
alias pacinsd='sudo pacman -S --asdeps' # Install given package(s) as dependencies of another package<br />
alias pacmir='sudo pacman -Syy' # Force refresh of all package lists after updating /etc/pacman.d/mirrorlist<br />
<br />
====Usage====<br />
Perform the respective commands by simply typing the alias name. For example, to synchronize with repositories before upgrading packages that are out of date on the local system:<br />
$ pacupg<br />
Install packages from repositories:<br />
$ pacin <package1> <package2> <package3><br />
Install a custom built package:<br />
$ pacins /path/to/<package><br />
Completely remove a locally installed package:<br />
$ pacrem <package><br />
Search for available packages in the repositories:<br />
$ pacreps <keywords><br />
Display information about a package (e.g. size, dependencies) in the repositories:<br />
$ pacrep <keywords><br />
<br />
====Notes====<br />
The aliases used above are merely examples. By following the syntax samples above, rename the aliases as convenient. For example:<br />
alias pacrem='sudo pacman -Rns'<br />
alias pacout='sudo pacman -Rns'<br />
<br />
In the case above, the commands {{Codeline|pacrem}} and {{Codeline|pacout}} both call Bash to execute the same command.<br />
<br />
===Operations and Bash syntax===<br />
In addition to pacman's standard set of features, there are ways to extend its usability through rudimentary [[Bash]] commands/syntax.<br />
<br />
* To install a number of packages sharing similar patterns in their names -- not the entire group nor all matching packages; eg. {{package Official|kdemod}}:<br />
pacman -S kdemod-{applets,theme,tools}<br />
* Of course, that is not limited and can be expanded to however many levels needed:<br />
pacman -S kdemod-{ui-{kde,kdemod},kdeartwork}<br />
* Sometimes, {{codeline|-s}}'s builtin ERE can cause a lot of unwanted results, so it has to be limited to match the package name only; not the description nor any other field:<br />
pacman -Ss '^vim-'<br />
* pacman has the {{Codeline|-q}} operand to hide the version column, so it is possible to query and reinstall packages with "compiz" as part of their name:<br />
pacman -S $(pacman -Qq | grep compiz)<br />
* You may want to get the list of installed packages sorted by size, which may be useful when freeing space on your hard drive.<br />
pacman -Qi | awk '/^Name/ {pkg=$3} /Size/ {print $4$5,pkg}' | sort -n<br />
<br />
==Installation and recovery==<br />
''Alternative ways of getting and restoring packages''<br />
<br />
===Installing packages from a CD/DVD/ISO===<br />
<!-- could easily be adapted to work with usb sticks --><br />
*First mount the CD (replace ''cdrom'' with ''dvd'' if needed):<br />
# mount /mnt/cdrom<br />
<br />
:If working with an .iso file instead, first create a directory under /mnt:<br />
# mkdir /mnt/iso<br />
:Then mount the image:<br />
# mount -t iso9660 -o ro,loop /path/to/iso /mnt/iso<br />
<br />
*Configure pacman:<br />
# nano -w /etc/pacman.conf<br />
<br />
*Add the following ''before'' other repositories (e.g. extra, core, etc.). This ensures the files from the CD/DVD/iso take precedence over those in the standard repositories:<br />
# Settings for using a cd-rom as a repository.<br />
[custom]<br />
Server = file:///mnt/cdrom/arch/pkg<br />
:Again, replace ''cdrom'' as appropiate.<br />
<br />
Once {{Filename|pacman.conf}} has been edited, sync pacman in order to be able to use the new repository.<br />
<br />
====Using packages from an Arch core image====<br />
<br />
In order to use packages from an Arch core image (e.g. to set up wireless support while offline), mount the core repository:<br />
# mount -o loop /path/to/arch_core_image/i686/repo-core-i686.sfs /mnt/iso<br />
Then edit {{Filename|pacman.conf}}'s <code>[core]</code> section, (temporarily) replacing the default entry with a reference to the mounted image:<br />
[core]<br />
#Include = /etc/pacman.d/mirrorlist<br />
Server = file:///mnt/iso<br />
Finally, sync Pacman:<br />
# pacman -Syu<br />
<br />
===Custom local repository===<br />
pacman 3 introduced a new script named {{Codeline|repo-add}} which makes generating a database for a personal repository much easier. Use {{Codeline|repo-add --help}} for more details on its usage.<br />
<br />
Simply store all of the built packages to be included in the repository in one directory, and execute the following command (where ''repo'' is the name of the custom repository):<br />
$ repo-add /path/to/repo.db.tar.gz /path/to/*.pkg.tar.gz<br />
<br />
Note that when using {{Codeline|repo-add}}, the database and the packages do not need to be in the same directory. But when using pacman with that database, they should be together.<br />
<br />
To add a new package (and remove the old if it exists), run:<br />
$ repo-add /path/to/repo.db.tar.gz /path/to/packagetoadd-1.0-1-i686.pkg.tar.gz<br />
<br />
{{Note|If there is a package that needs to be removed from the repository, read up on {{Codeline|repo-remove}}.}}<br />
<br />
Once the local repository has been made, add the repository to {{Filename|pacman.conf}}. The name of the {{Filename|db.tar.gz}} file is the repository name. Reference it directly using a ''file://'' url, or access it via FTP using ftp://localhost/path/to/directory.<br />
<br />
If willing, add the custom repository to the [[Unofficial user repositories|list of unofficial user repositories]], so that the community can benefit from it.<br />
<br />
===Network shared pacman cache===<br />
{{Tip|See [http://xyne.archlinux.ca/projects/pacserve/ pacserve] for an alternate solution.}}<br />
<br />
In order to share packages between multiple computers, simply share {{Filename|/var/cache/pacman/}} using any network-based mount protocol. This section shows how to use shfs or sshfs to share a package cache plus the related library-directories between multiple computers on the same local network. Keep in mind that a network shared cache can be slow depending on the file-system choice, among other factors.<br />
<br />
First, install any network-supporting filesystem; for example [[sshfs]], [[shfs]], [[ftpfs]], [[smbfs]] or [[nfs]]<br />
{{Tip|To use sshfs or shfs, consider reading [[Using SSH Keys]].}}<br />
<br />
Then, to share the actual packages, mount {{Filename|/var/cache/pacman/pkg}} from the server to {{Filename|/var/cache/pacman/pkg}} on every client machine.<br />
<br />
To have shared package databases, mount {{Filename|<nowiki>/var/lib/pacman/sync/{core,extra,testing,community}</nowiki>}} in the same way. Proceed to place the appropriate lines in {{Filename|/etc/fstab}}.<br />
<br />
====Preventing unwanted cache purges====<br />
By default, {{Codeline|pacman -Sc}} removes package tarballs from the cache that correspond to packages that are not installed on the machine the command was issued on. Because pacman cannot predict what packages are installed on all machines that share the cache, it will end up deleting files that should not be.<br />
<br />
To clean up the cache so that only ''outdated'' tarballs are deleted, add this entry in the {{Codeline|[options]}} section of {{Filename|/etc/pacman.conf}}:<br />
CleanMethod = KeepCurrent<br />
<br />
===Backing up and retrieving a list of installed packages===<br />
It is good practice to keep periodic backups of all pacman-installed packages. In the event of a system crash which is unrecoverable by other means, pacman can then easily reinstall the very same packages onto a new installation.<br />
<br />
*First, backup the current list of non-local packages:<br />
$ comm -23 <(pacman -Qeq) <(pacman -Qmq) > pkglist<br />
<br />
*Store the pkglist on a USB key or other convenient medium.<br />
<br />
*Copy the pkglist file to the new installation, and navigate to the directory containing it.<br />
<br />
*Issue the following command to install from the backup list:<br />
# pacman -S $(< pkglist)<br />
<br />
===List downloaded packages that are not in base or base-devel===<br />
<br />
The following command will list any installed packages that are not in base/base-devel, and as such were likely installed manually by the user:<br />
<br />
comm -23 <(pacman -Qeq) <(pacman -Qgq base base-devel | sort )<br />
<br />
===Reinstalling all installed packages===<br />
If you mess up your system (rm -rf) you can repair by having pacman reinstall all of your packages. <br />
<br />
If your system does not contain any foreign(AUR) packages you can run:<br />
# pacman -Qeq | pacman -S -<br />
# pacman -Qdq | pacman -S --asdeps -<br />
<br />
If you have foreign packages will error as packages will not be found in the repositories. The following will make a list of all packages and remove the foreign packages seen with pacman -Qmq. combining a command to list all packages, and another to hide the list of foreign packages is required.<br />
<br />
The following will reinstall every package found in the repositories, preserving asdeps/explicitly installed info<br />
# comm -23 <(pacman -Qeq) <(pacman -Qmq) | pacman -S -<br />
# comm -23 <(pacman -Qdq) <(pacman -Qmq) | pacman -S --asdeps -<br />
<br />
===Restore pacman's local database===<br />
Signs that pacman needs a local database restoration:<br />
*{{Codeline|pacman -Q}} gives absolutely no output, and {{Codeline|pacman -Syu}} erroneously reports that the system is up to date.<br />
*When trying to install a package using {{Codeline|pacman -S package}} it outputs a list of already satisfied dependencies.<br />
<br />
Most likely, pacman's database of installed software, {{Filename|/var/lib/pacman/local}}, has been corrupted or deleted. While this is a serious problem, it can be restored by following the instructions below.<br />
<br />
Firstly, make sure pacman's log file is present:<br />
$ ls /var/log/pacman.log<br />
<br />
If it does not exist, it is ''not'' possible to continue with this method. You may be able to use [http://bbs.archlinux.org/viewtopic.php?pid=670876 Xyne's package detection script] to recreate the database. If not, then the likely solution is to re-install the entire system.<br />
<br />
====Log filter script====<br />
Create a script with the following content <sup>based on [http://bbs.archlinux.org/viewtopic.php?id=38531]</sup>:<br />
{{file|name=log2pkglist.awk|content=<br />
<nowiki><br />
#!/bin/awk -f<br />
<br />
$3 ~ /^(installed|upgraded)$/ {<br />
pkg[$4] = 1<br />
next<br />
} <br />
<br />
$3 == "removed" {<br />
pkg[$4] = 0<br />
} <br />
<br />
END {<br />
for (i in pkg) if (pkg[i]) print i<br />
}<br />
</nowiki><br />
}}<br />
<br />
Make the script executable:<br />
$ chmod +x log2pkglist.awk<br />
<br />
====Generating the package recovery list====<br />
Run the script and pipe the output to a temporary list:<br />
$ ./log2pkglist.awk /var/log/pacman.log > pkglist.orig<br />
<br />
Optionally edit {{Filename|pkglist.orig}} and remove anything that should not be re-installed. This might be the situation with custom packages made with [[ABS]], for example.<br />
<br />
Here is a way to automatically restrict the list to packages available in a repository:<br />
$ { cat pkglist.orig; pacman -Slq; } | sort | uniq -d > pkglist<br />
<br />
Check if some important ''base'' package are missing, and add them to the list:<br />
$ comm -23 <(pacman -Sgq base) pkglist.orig >> pkglist<br />
<br />
Proceed once the contents of {{Filename|pkglist}} are satisfactory, since they will be used it restore pacman's installed package database; {{Filename|/var/lib/pacman/local}}.<br />
<br />
====Performing the recovery====<br />
As a normal user, make temporary directories for the cache, database, and root:<br />
<pre><br />
tmp=~/tmp<br />
mkdir -p "${tmp}"<br />
<br />
pushd "${tmp}"<br />
dbpath=$(readlink -f ./dbpath)<br />
root=$(readlink -f ./root)<br />
cache=$(readlink -f ./cache)<br />
log=/dev/null<br />
mkdir -p "${dbpath}" "${cache}" "${root}"<br />
popd<br />
<br />
recovery-pacman() {<br />
fakeroot pacman "$@" \<br />
--dbpath "${dbpath}" \<br />
--root "${root}" \<br />
--cache "${cache}" \<br />
--log "${log}" \<br />
--noscriptlet \<br />
#<br />
}<br />
</pre><br />
<br />
Populate the temporary sync database:<br />
$ recovery-pacman -Sy<br />
or copy the system's sync database:<br />
$ cp -r /var/lib/pacman/sync "${dbpath}"<br />
<br />
To avoid downloading and/or processing packages that are present in the system's local database (or whatever remains of it), optionally copy it into the temporary location:<br />
$ cp -r /var/lib/pacman/local "${dbpath}"<br />
<br />
Generate the temporary local recovery database from the previously generated {{filename|pkglist}}:<br />
$ recovery-pacman -S --nodeps --needed $(< pkglist)<br />
<br />
{{note|Because {{codeline|--noscriptlet}} is needed, the files owned by packages in the fake root will not be representative of a real install.}}<br />
<br />
After revising the database, conclude by copying it to the real destination:<br />
# cp -r "${dbpath}"/local /var/lib/pacman<br />
<br />
Finally update the local database so that packages that are not required by any other package are marked as explicitly installed and the other as dependences. You will need be extra careful in the future when removing packages, but with the original database lost is the best we can do.<br />
# pacman -D --asdeps $(pacman -Qq)<br />
# pacman -D --asexplicit $(pacman -Qtq)<br />
<br />
===Removing everything but base group===<br />
If it is ever necessary to remove all packages except the base group on a ''severely'' broken system, try this one liner:<br />
# pacman -Rs $(comm -23 <(pacman -Qeq) <(pacman -Qgq base))<br />
<br />
Copied from a [http://mailman.archlinux.org/pipermail/arch-general/2010-February/011527.html message] on the archlinux.org mailing list.<br />
<br />
===Recovering a USB key from existing install===<br />
If you have Arch installed on a USB key and manage to mess it up (e.g. removing it while it is still being written to), then it is possible to re-install all the packages and hopefully get it back up and working again (assuming USB key is mounted in /newarch)<br />
# pacman -S $(pacman -Qq --dbpath /newarch/var/lib/pacman) --root /newarch --dbpath /newarch/var/lib/pacman<br />
<br />
===Extracting contents of a .pkg file===<br />
The .pkg files ending in .xz are simply tar'ed archives that can be decompressed using "$ tar -Jxvf package.tar.xz". If you want to extract a couple of files out of a .pkg file, this would be a way to do it.<br />
<br />
==Maintenance==<br />
''House keeping, in the interest of keeping a clean system and following [[The Arch Way]]''<br />
<br />
===Miscellaneous procedures===<br />
For ''recursively'' removing orphans (''be careful''):<br />
# pacman -Rs $(pacman -Qtdq)<br />
<br />
To get a sorted list of local packages and their size:<br />
$ LC_ALL=C pacman -Qi | sed -n '/^Name[^:]*: \(.*\)/{s//\1 /;x};/^Installed[^:]*: \(.*\)/{s//\1/;H;x;s/\n//;p}' | sort -nk2 | column -t<br />
<br />
====Getting a list of files not owned by any package====<br />
Periodic checks for files outside of pacman database are recommended. These files are often some 3rd party applications installed using the usual procedure (e.g. '''./configure; make; make install'''). Search the file-system for these files (or symlinks) using this simple script:<br />
{{file|name=pacman-disowned|content=<br />
<nowiki><br />
#!/bin/sh<br />
<br />
tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$<br />
db=$tmp/db<br />
fs=$tmp/fs<br />
<br />
mkdir "$tmp"<br />
trap 'rm -rf "$tmp"' EXIT<br />
<br />
pacman -Qlq | sort -u > "$db"<br />
<br />
find /bin /etc /lib /sbin /usr \<br />
! -name lost+found \<br />
\( -type d -printf '%p/\n' -o -print \) | sort > "$fs"<br />
<br />
comm -23 "$fs" "$db"<br />
</nowiki><br />
}}<br />
<br />
To generate the list:<br />
$ pacman-disowned > non-db.txt<br />
<br />
Note that one ''should not'' delete all files listed in {{filename|non-db.txt}} without confirming each entry. There could be various configuration files, logs, etc., so use this list responsibly and only proceed after extensively searching for cross-references using {{Codeline|grep}}.<br />
<br />
===Selective cache purge===<br />
[[CacheClean|Here]] is a Python script to clean the {{Filename|/var/cache/pacman/pkg}} directory while allowing to specify how many package versions should be retained. <sup>[http://bbs.archlinux.org/viewtopic.php?id=9104]</sup></div>Wide-eyehttps://wiki.archlinux.org/index.php?title=Mkinitcpio&diff=106462Mkinitcpio2010-05-16T02:27:54Z<p>Wide-eye: /* Using net */ added required package.</p>
<hr />
<div>[[Category:Boot process (English)]]<br />
[[Category:Kernel (English)]]<br />
[[Category:HOWTOs (English)]]<br />
{{i18n|mkinitcpio}} {{DISPLAYTITLE:mkinitcpio}}<br />
{{Article summary start}}<br />
{{Article summary text|A detailed guide to the Arch initramfs creation utility.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Arch Boot Process}}<br />
{{Article summary end}}<br />
<br />
'''mkinitcpio''' is the next generation of initramfs creation.<br />
<br />
From [[Wikipedia:initrd]]:<br />
<br />
:''An '''initial ramdisk''' is a temporary file system used in the [[boot process]] of the Linux kernel. '''initrd''' and '''initramfs''' refer to slightly different schemes for loading this file system into memory. Both are commonly used to make preparations before the real root file system can be mounted.''<br />
<br />
== Overview ==<br />
<br />
mkinitcpio is a Bash script used to create an initial ramdisk environment. From the [http://projects.archlinux.org/mkinitcpio.git/tree/mkinitcpio.5.txt mkinitcpio man page]:<br />
<br />
:''The initial ramdisk is in essence a very small environment (early userspace) which loads various kernel modules and sets up necessary things before handing over control to init. This makes it possible to have, for example, encrypted root filesystems and root filesystems on a software RAID array. mkinitcpio allows for easy extension with custom hooks, has autodetection at runtime, and many other features.''<br />
<br />
Traditionally, the kernel was responsible for all hardware detection and initialization tasks early in the [[boot process]] before mounting the root filesystem and passing control to {{Codeline|init}}. However, as technology advances, these tasks have become increasingly complex. <br />
<br />
Nowadays, the root filesystem may be on a wide range of hardware, from SCSI to SATA to USB drives, controlled by a variety of drive controllers from different manufacturers. Additionally, the root filesystem may be encrypted or compressed; within a software RAID array or a logical volume group. The simple way to handle that complexity is to pass management into userspace: an initial ramdisk. <br />
<br />
See also: [http://archlinux.me/brain0/2010/02/13/early-userspace-in-arch-linux/ /dev/brain0 &raquo; Blog Archive &raquo; Early Userspace in Arch Linux].<br />
<br />
mkinitcpio is a modular tool for building an init ramfs cpio image, offering many advantages over alternative methods, including:<br />
<br />
* The use of '''busybox''' to provide a small and lightweight base for early userspace (prior to version 0.6, [http://www.archlinux.org/news/486/ '''klibc'''] was used instead).<br />
* Support for '''[[udev]]''' for hardware autodetection at runtime, thus preventing the loading of unnecessary modules.<br />
* Being an extendable hook-based init script, custom hooks can easily be included in [[pacman]] packages.<br />
* Support for '''lvm2''', '''dm-crypt''' for both legacy and LUKS volumes, '''raid''', '''mdadm''', and '''swsusp''' and '''suspend2''' for resuming and booting from USB mass storage devices.<br />
* The ability to allow many features to be configured from the kernel command line without needing to rebuild the image.<br />
* Support for the inclusion of the image in a kernel, thus making a self-contained kernel image possible.<br />
<br />
mkinitcpio has been developed by '''phrakture''' and '''tpowa''' with some help from the community.<br />
<br />
== Installation ==<br />
<br />
The {{Package Official|mkinitcpio}} package is available in the [core] repository, and is installed by default as a member of the '''base''' group:<br />
# pacman -S mkinitcpio<br />
<br />
Users may wish to install the latest development version of mkinitcpio from Git:<br />
$ git clone git://projects.archlinux.org/mkinitcpio.git<br />
<br />
== Image creation and activation ==<br />
<br />
By default, the mkinitcpio script generates two images after kernel installation or upgrades: {{Filename|/boot/kernel26.img}} and {{Filename|/boot/kernel26-fallback.img}}. The ''fallback'' image utilizes the same configuration file as the ''default'' image, except the '''autodetect''' hook is skipped during creation, thus including a full range of modules. The '''autodetect''' hook detects required modules and tailors the image for specific hardware, shrinking the initramfs. <br />
<br />
Users may create any number of initramfs images with a variety of different configurations. The desired image must be specified for the bootloader, often in its configuration file ({{Filename|/boot/grub/menu.lst}} for [[GRUB]] users). After changes are made to the configuration file, the image must be regenerated. For the stock Arch Linux kernel, {{Package Official|kernel26}}, this is accomplished with the command:<br />
<br />
# mkinitcpio -p kernel26<br />
<br />
The {{Codeline|-p}} switch specifies a ''preset'' to utilize; most kernel packages provide a related mkinitcpio preset file, found in {{Filename|/etc/mkinitcpio.d}} (e.g. {{Filename|/etc/mkinitcpio.d/kernel26.preset}} for <tt>kernel26</tt>). A preset is a predefined definition of how to create an initramfs image instead of specifying the configuration file and output file every time.<br />
<br />
{{Warning|{{Filename|preset}} files are used to automatically regenerate the initramfs after a kernel update; be careful when editing them.}}<br />
<br />
Users can manually create an image using an alternate configuration file:<br />
<br />
# mkinitcpio -c /etc/mkinitcpio-custom.conf -g /boot/kernel26-custom.img<br />
<br />
This will generate the initramfs image for the currently running kernel and save it at {{Filename|/boot/kernel26-custom.img}}. <br />
<br />
If creating an image for a kernel other than the one currently running, add the kernel version to the command line:<br />
<br />
# mkinitcpio -g /boot/kernel26.img -k 2.6.16-ARCH<br />
<br />
== Configuration ==<br />
<br />
The primary configuration file for '''mkinitcpio''' is {{Filename|/etc/mkinitcpio.conf}}. Additionally, preset definitions are provided by kernel packages in the {{Filename|/etc/mkinitcpio.d}} directory (e.g. {{Filename|/etc/mkinitcpio.d/kernel26.preset}}).<br />
<br />
{{Warning|'''lvm2''', '''raid''', '''mdadm''', and '''encrypt''' are '''NOT''' enabled by default. Please read this section carefully for instructions if these hooks are required.}}<br />
<br />
{{Note|Users with multiple hardware disk controllers that use the same node names but different kernel modules (e.g. two SCSI/SATA or two IDE controllers) should ensure the correct order of modules is specified in {{Filename|/etc/mkinitcpio.conf}}. Otherwise, the root device location may change between boots, resulting in kernel panics.<br />
<br />
A more elegant alternative is to use [[persistent block device naming]] to ensure that the right devices are mounted.}}<br />
<br />
Users can modify five variables within the configuration file:<br />
<br />
; {{Codeline|MODULES}}: Kernel modules to be loaded before any boot hooks are run. <br />
; {{Codeline|BINARIES}}: Additional binaries to be included in the initramfs image.<br />
; {{Codeline|FILES}}: Additional files to be included in the intramfs image.<br />
; {{Codeline|HOOKS}}: Hooks are scripts that execute in the initial ramdisk.<br />
; {{Codeline|COMPRESSION}}: Used to compress the initramfs image.<br />
<br />
=== HOOKS ===<br />
<br />
A hook is a script that executes in the initial ramdisk. Hooks are found within the {{Filename|/lib/initcpio/install}} directory; for a list of available hooks:<br />
<br />
$ ls -1 /lib/initcpio/install<br />
<br />
Use mkinitcpio's {{Codeline|-H}} option to output help for a specific hook. For example, to display information about the '''base''' hook:<br />
<br />
$ mkinitcpio -H base<br />
<br />
Hooks are listed in order of execution, and are used to add files or modules to the image. Thus, hooks can affect ''installation'' &ndash; when mkinitcpio is run to generate the image &ndash; and/or ''runtime'' &ndash; via an included script that is run during boot. Scripts can be found within the {{Filename|/lib/initcpio/hooks}} directory.<br />
<br />
The default configuration will work for most users with a standard setup:<br />
<br />
HOOKS="base udev autodetect pata scsi sata filesystems"<br />
<br />
If using the image on more than one machine, remove the '''autodetect''' hook, which tailors the image to the build machine:<br />
<br />
HOOKS="base udev pata scsi sata filesystems"<br />
<br />
For support for encrypted volumes on LVM2 volume groups:<br />
<br />
HOOKS="base udev autodetect pata scsi sata lvm2 encrypt filesystems"<br />
<br />
A table of common hooks and their function follows. Note that this table is not complete, as packages can provide custom hooks. <br />
<br />
{| border="1" <br />
|+ '''Common hooks'''<br />
|-<br />
! Hook || Installation || Runtime<br />
|-<br />
| '''base''' || Sets up all initial directories and installs base utilities and libraries. Always add this hook unless you know what you are doing. || --<br />
|-<br />
| '''udev''' || Adds udev to your image || Udev will be used to create your root device node and detect the needed modules for your root device. As it simplifies things, using the udev hook is recommended.<br />
|-<br />
| '''autodetect''' || Shrinks your initramfs to a smaller size by autodetecting your needed modules. Be sure to verify included modules are correct and none are missing. This hook must be run before other subsystem hooks in order to take advantage of auto-detection. Any hooks placed before 'autodetect' will be installed in full. || --<br />
|-<br />
| '''ide''' || Adds legacy IDE modules to the image. You may choose to use this if your root device is on an IDE disk. Also use the '''autodetect''' hook if you want to minimize your image size || Loads legacy IDE modules. You will need the '''udev''' hook unless you specify the needed modules manually (see MODULES section below).<br />
|-<br />
| '''pata''' || Adds the new libata/PATA IDE modules to the image. Use this if your root device is on a IDE disk. Also use the '''autodetect''' hook if you want to minimize your image size || Loads IDE modules. You will need the '''udev''' hook unless you specify the needed modules manually (see MODULES section below). PATA is the kernel's new IDE driver. PATA utilizes SCSI emulation and will change {{Filename|/dev/hd''x''}} to {{Filename|/dev/sd''x''}}. [http://archlinux.org/news/272/ More information].<br />
|-<br />
| '''sata''' || Adds serial ATA modules to the image. Use this if your root device is on a SATA disk. Also use the '''autodetect''' hook if you want to minimize your image size. || Loads SATA modules. You will need the '''udev''' hook unless you specify the needed modules manually (see MODULES section below).<br />
|-<br />
| '''scsi''' || Adds SCSI modules to the image. Use this if your root device is on a SCSI disk. Also use the '''autodetect''' hook if you want to minimize your image size. || Loads SCSI modules. You will need the '''udev''' hook unless you specify the needed modules manually (see MODULES section below).<br />
|-<br />
| '''usb''' || Adds USB modules to the image. Use this if your root device is on a USB mass storage device or if your USB mass storage device needs to be accessed otherwise (checked, mounted, etc.) at boot time. || Loads USB modules. You will need the '''udev''' hook unless you specify the needed modules manually (see MODULES section below).<br />
|-<br />
| '''usbinput''' || Adds USB HID modules to the image. Use this if you have an USB keyboard and need it in early userspace (either for entering encryption passphrases or for failsafe mode). || Loads USB HID modules. You will need the '''udev''' hook unless you specify the needed modules manually (see MODULES section below).<br />
|-<br />
| '''fw''' || Adds FireWire modules to the image. Use this if your root device is on a FW mass storage device. || Loads FW modules. You will need the '''udev''' hook unless you specify the needed modules manually (see MODULES section below).<br />
|-<br />
| '''net''' || Adds the necessary modules for a network device. For PCMCIA net devices please add the '''pcmcia''' hook too. || Loads network modules. You will need the '''udev''' hook unless you specify the needed modules manually (see MODULES section below). See [[#Customizing the kernel command line]] for further configuration.<br />
|-<br />
| '''pcmcia''' || Adds the necessary modules for PCMCIA devices. You need to have {{Package Official|pcmciautils}} installed to use this. || Loads pcmcia modules. You will need the '''udev''' hook unless you specify the needed modules manually (see MODULES section below).<br />
|-<br />
| '''[[DSDT|dsdt]]''' || Loads a custom ACPI DSDT file during boot. Place your custom DSDT file for inclusion at {{Filename|/lib/initcpio/custom.dsdt}} || The custom DSDT file is automatically used by the kernel if it is present in initramfs.<br />
|-<br />
| '''filesystems''' || This includes necessary filesystem modules into your image. This hook is '''required''' unless you specify your filesystem modules in MODULES. || This will detect the filesystem type at runtime, load the module and pass it to kinit. (Will NOT detect '''reiser4''', which must be added to modules list.)<br />
|-<br />
| '''lvm2''' || Adds the device mapper kernel module and the {{Codeline|lvm}} tool to the image. You need to have the {{Package Official|lvm2}} package installed to use this. || Enables all LVM2 volume groups. This is necessary if you have your root filesystem on LVM.<br />
|-<br />
| '''raid''' || Adds the modules and {{Codeline|mdassamble}} for a software RAID setup. This hook has been superseded by the '''mdadm''' hook. You need to have {{Package Official|mdadm}} installed to use this. || Loads the necessary modules for software raid devices, and assembles the raid devices when run. See [[#Customizing the kernel command line]] for further configuration.<br />
|-<br />
| '''mdadm''' || This hook supersedes the above '''raid''' hook. It supports assembling the arrays from {{Filename|/etc/mdadm.conf}}, or autodetection during boot. || Loads the necessary modules for software raid devices, and assembles the raid devices when run. See [[#Customizing the kernel command line]] for further configuration.<br />
|-<br />
| '''encrypt''' || Adds the '''dm-crypt''' kernel module and the {{Codeline|cryptsetup}} tool to the image. You need to have the {{Package Official|cryptsetup}} package installed to use this. || Detects and unlocks an encrypted root partition. See [[#Customizing the kernel command line]] for further configuration.<br />
|-<br />
| '''resume''' || -- || This tries to resume from the "suspend to disk" state. Works with both ''swsusp'' and ''[[suspend2]]''. See [[#Customizing the kernel command line]] for further configuration.<br />
|-<br />
| '''firmware''' || Adds {{Filename|/lib/firmware}} files. || Loads firmware. You will need the '''udev''' hook to get firmware loaded. <br />
|-<br />
| '''keymap''' || Adds keymap and consolefonts from [[rc.conf]]. || Loads the specified keymap and consolefont from {{Filename|rc.conf}} during early userspace.<br />
|}<br />
<br />
=== MODULES ===<br />
<br />
The MODULES array is used to specify modules to load before anything else is done. To accelerate the boot process, users may opt to disable the '''udev''' hook and list required modules here instead:<br />
<br />
MODULES="piix ide_disk reiserfs"<br />
<br />
[...]<br />
<br />
HOOKS="base autodetect ide filesystems"<br />
<br />
{{Note|If using '''reiser4''', it ''must'' be added to the modules list.}}<br />
<br />
{{Box YELLOW|TODO:|Find out which modules fail on modern kernels.}}<br />
Known modules that are not autoloaded during boot process (status stock kernel 2.6.18):<br />
<br />
<tt>scsi_transport_sas, ultrastor, qlogicfas, eata, BusLogic, pas16, wd7000, sym53c416, g_NCR5380_mmio, fdomain, u14-34f, dtc initio, in2000, imm, t128, aha1542, aha152x, atp870u, g_NCR5380, NCR53c406a, qlogicfas408, megaraid_mm, advansys</tt><br />
<br />
If one of the above modules are required for the root device, consider explicitly adding it to {{Filename|/etc/mkinitcpio.conf}} to avoid kernel panics.<br />
<br />
=== BINARIES and FILES ===<br />
<br />
These options allow users to add files to the image. Both BINARIES and FILES are added before hooks are run, and may be used to override files used or provided by a hook. BINARIES are dependency-parsed, meaning any required libraries will also be added. FILES are added ''as-is''. For example:<br />
<br />
FILES="/etc/modprobe.d/modprobe.conf"<br />
<br />
BINARIES="/usr/bin/cal"<br />
<br />
== Runtime customization ==<br />
<br />
Runtime configuration options can be passed to {{Codeline|init}} and certain hooks via the kernel command line. Kernel command line parameters are often supplied by the bootloader. For example, a typical Arch Linux [[GRUB]] entry:<br />
<br />
{{File<br />
|name=/boot/grub/menu.lst<br />
|content=<nowiki><br />
...<br />
<br />
# (0) Arch Linux<br />
title Arch Linux [/boot/vmlinuz26]<br />
root (hd0,0)<br />
kernel /vmlinuz26 root=/dev/sda3 ro<br />
initrd /kernel26.img<br />
<br />
...<br />
</nowiki>}}<br />
<br />
In this case, {{Codeline|<nowiki>root=/dev/sda3</nowiki>}} and {{Codeline|ro}} are kernel command line parameters. The options discussed below can be appended to the kernel command line to alter default behavior. See [[Arch Boot Process]] for more information.<br />
<br />
=== init ===<br />
<br />
''The following options alter the default behavior of {{Codeline|init}} in the initramfs environment. See {{Filename|/lib/initcpio/init}} for details.''<br />
<br />
; {{Codeline|break}}: If {{Codeline|<nowiki>break=y</nowiki>}} is specified, init pauses early in the boot process (after loading modules) and launches an interactive shell which can be used for troubleshooting purposes. (Normal boot continues after logout.)<br />
<br />
; {{Codeline|disablehooks}}: Disable hooks at runtime by adding {{Codeline|<nowiki>disablehooks=hook1{,hook2,...}</nowiki>}}. For example: <pre>disablehooks=resume</pre><br />
<br />
; {{Codeline|disablemodules}}: Blacklist modules at runtime by adding {{Codeline|<nowiki>disablemodules=mod1{,mod2,...}</nowiki>}}. For example: <pre>disablemodules=ata_piix</pre><br />
<br />
; {{Codeline|earlymodules}}: Alter the order in which modules are loaded by specifying modules to load early via {{Codeline|<nowiki>earlymodules=mod1{,mod2,...}</nowiki>}}. (This may be used, for example, to ensure the correct ordering of multiple network interfaces.)<br />
<br />
; {{Codeline|rootdelay}}: Pause for ten seconds before mounting the root file system by appending {{Codeline|rootdelay}}. (This may be used, for example, if booting from a USB hard drive that takes longer to initialize.)<br />
<br />
=== Using raid ===<br />
<br />
First add the 'mdadm' hook to the HOOKS list and any required raid modules to the MODULES list in '''/etc/mkinitcpio.conf'''.<br />
<br />
'''Kernel Parameters: '''<br />
Using the 'mdadm' hook, you no longer need to configure your RAID array in the GRUB parameters. The 'mdadm' hook will either use your /etc/mdadm.conf file, or automatically detect the arrays during the init phase of boot.<br />
<br />
=== Using net ===<br />
<br />
'''Required Packages:'''<br />
<br />
net requires the mkinitcpio-nfs-utils package to be installed.<br />
<br />
'''Kernel Parameters:''' <br />
<br />
'''ip=''' <br />
<br />
An interface spec can be either short form, which is just the name of<br />
an interface (eth0 or whatever), or long form. The long form consists<br />
of up to seven elements, separated by colons:<br />
<br />
ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf><br />
nfsaddrs= is an alias to ip= and can be used too.<br />
<br />
''Parameter explanation:''<br />
<client-ip> IP address of the client. If empty, the address will<br />
either be determined by RARP/BOOTP/DHCP. What protocol<br />
is used de- pends on the <autoconf> parameter. If this<br />
parameter is not empty, autoconf will be used.<br />
<br />
<server-ip> IP address of the NFS server. If RARP is used to<br />
determine the client address and this parameter is NOT<br />
empty only replies from the specified server are<br />
accepted. To use different RARP and NFS server,<br />
specify your RARP server here (or leave it blank), and<br />
specify your NFS server in the `nfsroot' parameter<br />
(see above). If this entry is blank the address of the<br />
server is used which answered the RARP/BOOTP/DHCP<br />
request.<br />
<br />
<gw-ip> IP address of a gateway if the server is on a different<br />
subnet. If this entry is empty no gateway is used and the<br />
server is assumed to be on the local network, unless a<br />
value has been received by BOOTP/DHCP.<br />
<br />
<netmask> Netmask for local network interface. If this is empty,<br />
the netmask is derived from the client IP address assuming<br />
classful addressing, unless overridden in BOOTP/DHCP reply.<br />
<br />
<hostname> Name of the client. If empty, the client IP address is<br />
used in ASCII notation, or the value received by<br />
BOOTP/DHCP.<br />
<br />
<device> Name of network device to use. If this is empty, all<br />
devices are used for RARP/BOOTP/DHCP requests, and the<br />
first one we receive a reply on is configured. If you<br />
have only one device, you can safely leave this blank.<br />
<br />
<autoconf> Method to use for autoconfiguration. If this is either<br />
'rarp', 'bootp', or 'dhcp' the specified protocol is<br />
used. If the value is 'both', 'all' or empty, all<br />
protocols are used. 'off', 'static' or 'none' means<br />
no autoconfiguration.<br />
''Examples:''<br />
ip=127.0.0.1:::::lo:none --> Enable the loopback interface.<br />
ip=192.168.1.1:::::eth2:none --> Enable static eth2 interface.<br />
ip=:::::eth0:dhcp --> Enable dhcp protocol for eth0 configuration.<br />
'''nfsroot='''<br />
<br />
If the 'nfsroot' parameter is NOT given on the command line, the default<br />
"/tftpboot/%s" will be used.<br />
<br />
nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]<br />
<br />
''Parameter explanation:''<br />
<br />
<server-ip> Specifies the IP address of the NFS server. If this field<br />
is not given, the default address as determined by the<br />
`ip' variable (see below) is used. One use of this<br />
parameter is for example to allow using different servers<br />
for RARP and NFS. Usually you can leave this blank.<br />
<br />
<root-dir> Name of the directory on the server to mount as root. If<br />
there is a "%s" token in the string, the token will be<br />
replaced by the ASCII-representation of the client's IP<br />
address.<br />
<br />
<nfs-options> Standard NFS options. All options are separated by commas.<br />
If the options field is not given, the following defaults<br />
will be used:<br />
port = as given by server portmap daemon<br />
rsize = 1024<br />
wsize = 1024<br />
timeo = 7<br />
retrans = 3<br />
acregmin = 3<br />
acregmax = 60<br />
acdirmin = 30<br />
acdirmax = 60<br />
flags = hard, nointr, noposix, cto, ac<br />
<br />
'''root=/dev/nfs'''<br />
If you don't use nfsroot= parameter you need to set root=/dev/nfs <br />
to boot from a nfs root by autoconfiguration.<br />
<br />
=== Using lvm ===<br />
<br />
If your root device is on lvm, you have to add the '''lvm2''' hook. You have to pass your root device on the kernel command line in the format<br />
<br />
root=/dev/mapper/<volume group name>-<logical volume name><br />
<br />
for example<br />
<br />
root=/dev/mapper/myvg-root<br />
<br />
=== Using encrypted root ===<br />
<br />
If your root volume is encrypted, you need to add the '''encrypt''' hook. Then specify your root device on the kernel command line, just as if it was unencrypted.<br />
<br />
For an encrypted partition on an sata or scsi disk:<br />
root=/dev/sda5<br />
<br />
For an encrypted lvm volume:<br />
root=/dev/mapper/myvg-root<br />
<br />
The root device will be automatically changed to ''/dev/mapper/root''.<br />
<br />
==== Using LUKS volumes ====<br />
<br />
If you use LUKS for hard disk encryption, the init script will detect the encryption automatically if the '''encrypt''' hook is enabled. It will then ask for a passphrase and try to unlock the volume.<br />
<br />
If this fails try to add you filesystem-module to the module list in /etc/mkinitcpio.conf if it's not compiled into your kernel.<br />
<br />
==== Using a key-file ====<br />
<br />
You can use a keyfile to encrypt your root-fs. Use the following format:<br />
<br />
cryptkey=device:fs-type:path<br />
<br />
Device is the device-file representing the device your key is stored on (e.g. /dev/sda1), fs-type is the filesystemtype of this device (e.g. ext3) and path is the path to the keyfile inside the fs of this device.<br />
<br />
==== Using legacy cryptsetup volumes ====<br />
<br />
If you are using a legacy cryptsetup volume, you have to specify all cryptsetup options necessary to unlock it on the kernel command line. The option format is<br />
<br />
crypto=hash:cipher:keysize:offset:skip<br />
<br />
representing cryptsetup's --hash, --cipher, --keysize, --offset and --skip options. If you omit an option, cryptsetup's default value is used, so you can just specify<br />
<br />
crypto=::::<br />
<br />
if you created your volume with the default settings.<br />
<br />
'''NOTE:''' For technical reasons, it is not possible to verify the correctness of your passphrase with legacy cryptsetup volumes. If you typed it wrong, mounting will simply fail. It is recommended that you use LUKS instead.<br />
<br />
==== Using loop-aes volumes ====<br />
<br />
'''mkinitcpio''' does not support loop-aes yet.<br />
<br />
== Troubleshooting ==<br />
<br />
=== mkinitcpio hangs on 'autodetect' during kernel upgrade ===<br />
This [http://bugs.archlinux.org/task/10061 '''bug'''] sometimes causes mkinitcpio to hang when upgrading the kernel. It has been noted that certain usb devices and pata hard drives/chipsets may irritate the issue, but the actual cause is currently unknown (2010-03-01). The best known method to circumvent this bug is to edit '/etc/mkinitcpio.conf' and remove 'autodetect' from the HOOKS parameter. Once removed, force reinstall the kernel with 'pacman -Sf kernel26', and mkinitcpio should process cleanly.<br />
<br />
Reboot the system, and then add 'autodetect' back to the HOOKS parameter, and force reinstall the kernel again to complete this workaround. While running on the new kernel, 'autodetect' seems to process successfully.<br />
<br />
NOTE: Be very careful modifying 'etc/mkinitcpio.conf'. Review the procedures BEFORE modifying, and make a backup. Some systems may need another hook for pata/ide, or sata if the respective hook is not yet present. If mkinitcpio fails during a kernel upgrade, and the issue is not resolved before a reboot is executed, this will most likely result in a kernel panic/nonfunctioning system!<br />
<br />
=== Extracting the image ===<br />
<br />
If you are curious about what is inside the initrd image you can extract it and poke at the files inside of it. <br />
<br />
The initrd image is a '''cpio''' archive, generated by the <tt>gen_init_cpio</tt> command, optionally compressed with one the 3 compression schemes understood by the kernel: namely '''gzip''' or '''bzip2''' or '''lzma'''. Only kernels later than 2.6.30 undertand bzip2 and lzma compression.<br />
<br />
<tt>bsdtar</tt> is powerful enough to autodetect the compression used and to extract to the current directory.<br />
<br />
You can list the files in the image with:<br />
$ bsdtar -t -f /boot/kernel26.img<br />
<br />
And to extract them all in the current directory:<br />
$ bsdtar -x -f /boot/kernel26.img</div>Wide-eyehttps://wiki.archlinux.org/index.php?title=Working_with_the_serial_console&diff=91678Working with the serial console2010-01-10T21:47:31Z<p>Wide-eye: Added basic info on using screen as a terminal emulator</p>
<hr />
<div>[[Category:HOWTOs (English)]]<br />
=Introduction=<br />
<br />
Configure your Arch Linux machine, so you can connect to it via the serial console port (com port).<br />
This will enable you to administer the machine, even if it has no keyboard, mouse, monitor or network attached to it (a headless server).<br />
<br />
As of Arch Linux 2007.x, installation of Arch Linux is possible via the serial console as well.<br />
<br />
A basic environment for this scenario is two machines, connected using a serial cable (9-pin connector cable).<br />
The administering machine can be any Linux or Windows machine with a terminal emulator program (putty or Minicom for example)<br />
<br />
The configuration instructions below will enable grub menu selection, boot messages and terminal forwarding to the serial console.<br />
<br />
=Configuration=<br />
<br />
===Configure console access on the target machine===<br />
<br />
1. Edit the grub.conf file:<br />
<br />
<pre><br />
# vi /boot/grub/menu.lst<br />
</pre><br />
<br />
Add these lines to the general area of the configuration:<br />
<br />
<pre><br />
serial --unit=0 --speed=9600<br />
terminal --timeout=5 serial console<br />
</pre><br />
<br />
Add the console parameters at the end of your current kernel line:<br />
<br />
<pre><br />
console=ttyS0,9600<br />
</pre><br />
<br />
For example, the kernel line should look something like this after modification:<br />
<br />
<pre><br />
kernel /vmlinuz26 root=/dev/md0 ro md=0,/dev/sda3,/dev/sdb3 vga=773 console=ttyS0,9600<br />
</pre><br />
<br />
2. Edit the inittab file: <br />
<br />
<pre><br />
# vi /etc/inittab<br />
</pre><br />
<br />
Add a new agetty line below the existing ones :<br />
<br />
<pre><br />
c0:2345:respawn:/sbin/agetty 9600 ttyS0 linux<br />
</pre><br />
<br />
3. Edit the securetty file:<br />
<pre><br />
# vi /etc/securetty<br />
</pre><br />
<br />
Below the existing tty's add an entry for the the serial console:<br />
<pre><br />
ttyS0<br />
</pre><br />
<br />
4. Reboot the machine<br />
<br />
Note that in all of the steps above ttyS1 can also be used, in case that your machine has more than one serial port.<br />
<br />
=Making Connections=<br />
<br />
===Connect using a terminal emulator program===<br />
<br />
Perform these steps on the machine used to connect the remote console.<br />
<br />
====Minicom====<br />
<br />
1. Install Minicom:<br />
<br />
<pre><br />
# pacman -S minicom<br />
</pre><br />
<br />
2. Start Minicom in setup mode:<br />
<br />
<pre><br />
# minicom -s<br />
</pre><br />
<br />
3. Using the textual navigation menu change the serial port settings to the following:<br />
<br />
<pre><br />
Serial Device: /dev/ttyS0<br />
Bps/Par/Bits: 9600 8N1<br />
</pre><br />
<br />
Press Enter to exit the menus (pressing Esc will not save changes)<br />
<br />
4. Remove the modem Init and Reset strings:<br />
<br />
Under the 'Modem and Dialing' menu delete the Init and Reset strings.<br />
<br />
5. Save the setup:<br />
<br />
From the main menu, choose 'save setup as dfl'<br />
<br />
6. Exit Minicom:<br />
<br />
From the main menu, choose 'Exit from Minicom'<br />
<br />
7. Connect to the target machine:<br />
<br />
While the serial cable is connected to the target machine, start the Minicom program:<br />
<br />
<pre><br />
# minicom<br />
</pre><br />
<br />
8. Exiting Minicom<br />
<br />
To finish the session press 'ctrl-A' and then 'X'.<br />
<br />
====Screen====<br />
<br />
Screen is able to connect to a serial port. It will connect to a standard 9200 speed port without options.<br />
<br />
<pre><br />
# screen /dev/ttyS0<br />
</pre><br />
<br />
If needed see the section "WINDOW TYPES" in the screen man page for details on setting the baud rate.<br />
<br />
====Windows Options====<br />
<br />
On Windows machines, connect to the serial port using programs like Putty or Hyper Terminal.<br />
<br />
=Installing Arch Linux using the serial console=<br />
<br />
1. Connect to the target machine using the method described above.<br />
<br />
2. Boot the target machine using the Arch Linux installation CD.<br />
<br />
After a while, output from the console will start showing on screen and setup can be started normally.<br />
<br />
Note that after setup is complete, the console settings will not be saved on the target machine, in order to avoid having to connect a keyboard and monitor, configure console access on the target machine before rebooting.<br />
<br />
Note that while a port speed of 9600 is used in all of the examples in this document, working with higher values is recommended (List of available speeds is displayed in Minicom by pressing 'Ctrl-A' and then 'P')</div>Wide-eyehttps://wiki.archlinux.org/index.php?title=Install_Arch_from_network_via_PXE&diff=47816Install Arch from network via PXE2008-08-18T16:18:52Z<p>Wide-eye: modified to work with the archlive installer</p>
<hr />
<div>[[Category: Getting and installing Arch (English)]]<br />
[[Category: HOWTOs (English)]]<br />
{{stub}}<br />
<br />
= Network booting =<br />
<br />
Did your tiny laptop come without a CDROM drive, and doesn't allow you to boot from a usb drive? Fear not, you can boot using pxe and a usb drive:<br />
<br />
== Requisites ==<br />
<br />
You need at least the following:<br />
* a server capable of running ISC DHCPD or DNSMasq<br />
* a server capable of running (a)tftpd<br />
* the Arch Linux [http://www.archlinux.org/download/ usb installation image] (either ftp or core will work)<br />
<br />
== Preparing dhcpd ==<br />
<br />
Make sure your DHCP server is able to tell your clients where to find the TFTPd running.<br />
<br />
Using ISC dhcpd:<br />
<br />
subnet 192.168.42.0 netmask 255.255.255.0 {<br />
allow bootp; # accept bootp requests<br />
filename "pxelinux.0"; # the PXELinux boot agent<br />
next-server <tftp-server-IP>; # where does tftp live?<br />
}<br />
<br />
Using dnsmasq:<br />
<br />
dhcp-boot=pxelinux.0,<tftp-server-hostname>,<tftp-server-IP><br />
<br />
== Preparing tftpd ==<br />
<br />
Assuming your downloaded the usb install img to /root, we're going to mount the image, copy the kernel and desired initrd into the tftp environment, typically found in <code>/var/tftpboot</code>.<br />
<br />
<br />
~# pacman -S tftp-hpa mkpxelinux<br />
...<br />
~# cd /var/tftpboot<br />
/var/tftpboot# mkdir pxelinux.cfg<br />
/var/tftpboot# mkdir temp<br />
/var/tftpboot# mount -t ext2 -o ro,loop,offset=32256 archlinux-2008.06-core-i686.img temp/<br />
/var/tftpboot# cp temp/boot/{archlive.img,vmlinuz26} ./<br />
<br />
== Create a pxelinux config ==<br />
<br />
create a pxelinux bootloader config including the options found in the "boot Archlive" section of menu.lst. save it as: pxelinux.cfg/default<br />
<br />
FIXME: add example<br />
<br />
<br />
== cleanup ==<br />
<br />
/var/tftpboot# umount temp && rmdir temp<br />
/var/tftpboot# cp /usr/share/mkpxelinux/pxelinux.0 .<br />
<br />
<br />
Your Arch Linux network installer is now ready.<br />
<br />
Don't forget to add record for in.tftpd to hosts.allow.<br />
<br />
== Drive containing the root image ==<br />
<br />
You will need a drive attached via usb containing the squashfs image used as /<br />
<br />
As of 2008.06 the usb installer will only look in usb storage devices for this root filesystem image. if it cannot find this image the installer will panic. <br />
<br />
The simplest way is to plug in a normal usb installer before booting. created as outlined in the arch install guide. but since you are not booting from the usb image directly, only the _files_ in the partition are really required. <br />
<br />
If you want to create a custom image: for the 2008.06 usb installer, it's layout is as follows: the first partition, is formatted as ext2 to contain the files. <br />
<br />
FIXME: find out if any ext2 partition will work not just the first one on the drive.<br />
<br />
FIXME: add step by step.<br />
<br />
== Using it ==<br />
<br />
Now make sure the <code>dhcpd</code> and <code>tftpd</code> daemons are running. Boot your destination machine over PXE (usually something like F12 (on Dells) or F11 (on Supermicro's), or enable it in the BIOS).<br />
<br />
When you get the PXEBoot prompt, type 'arch' or hit return to start the installer. the install should now progress the same as if you booted from the usb drive.<br />
<br />
That's all!</div>Wide-eyehttps://wiki.archlinux.org/index.php?title=CUPS&diff=44337CUPS2008-07-06T17:39:35Z<p>Wide-eye: kill spam kill!</p>
<hr />
<div>[[Category:Printers (English)]]<br />
[[Category:HOWTOs (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|CUPS}}<br />
{{i18n_entry|Рolski|CUPS (Polski)}}<br />
{{i18n_links_end}}<br />
=Introduction=<br />
<br />
==What is CUPS?==<br />
<br />
Straight from the CUPS website: "The Common UNIX Printing System ("CUPS") is a cross-platform printing solution for all UNIX environments. It is based on the "Internet Printing Protocol" and provides complete printing services to most Postscript and raster printers. CUPS is provided under the GNU GPL..." Although there are other printing packages such as LPRNG, CUPS is quite popular and relatively easily to use. It is the default printing system on Arch Linux as well as many other Linux distributions.<br />
<br />
==Troubleshooting CUPS & components==<br />
<br />
The best way to get printing working is to set 'LogLevel' in '/etc/cups/cupsd.conf' to:<br />
<pre><br />
LogLevel debug2<br />
</pre><br />
And then viewing the output from '/var/log/cups/error_log' like this:<br />
<pre><br />
tail -n 100 -f /var/log/cups/error_log<br />
</pre><br />
The characters at the left of the output stands for:<br />
<pre><br />
D = Debug<br />
E = Error<br />
I = Information<br />
etc...<br />
</pre><br />
These files may also prove useful.<br />
<pre><br />
/var/log/cups/page_log 'spits out a new entry each time a print is successful.'<br />
/var/log/cups/access_log 'lists all cupsd http1.1 server activity'<br />
</pre><br />
<br />
Of course it's important to know how CUPS work if you want to solve your problems, this is somewhat correct:<br />
<br />
# An application sends a .ps file(PostScript, a script language that details how the page will look) to CUPS when you select 'print'(99% of apps do).<br />
# CUPS then looks at your printers PPD file(printer description file) and figures out what filters it needs to use to convert the .ps file to a language that the printer understands(like PJL,PCL). Usually it needs ghostscript.<br />
# GhostScript takes the input and figures out which filters it should use,then applies them and converts the .ps file to a format understood by the printer.<br />
# Then it is sent to the backend. For example, if you have your printer connected to a USB port, it uses the USB backend.<br />
<br />
Print a document and watch 'error_log' to get a more detailed and correct image of the printing process.<br />
<br />
=Installing CUPS=<br />
<br />
==Packages==<br />
<br />
You will need CUPS and Ghostscript for sure:<br />
# pacman -S cups ghostscript gsfonts<br />
<br />
* <b>cups</b> - The actual CUPS software<br />
* <b>ghostscript</b> - An interpreter for the Postscript language<br />
* <b>gsfonts</b> - Ghostscript standard Type1 fonts<br />
<br />
<br />
Some of the following driver packages, it depends on the printer you own. If unsure, install gutenprint.<br />
<br />
* <b>gutenprint</b> - A collection of high quality drivers for Canon, Epson, Lexmark, Sony, Olympus, and PCL printers for use with Ghostscript, CUPS, Foomatic, and the Gimp.<br />
* <b>foomatic</b>, <b>foomatic-db</b>, <b>foomatic-db-engine</b>, <b>foomatic-db-ppd</b> and <b>foomatic-filters</b> - Foomatic is a database-driven system for integrating free software printer drivers with common spoolers under Unix<br />
* Installing <b>foomatic-filters</b> should solve your problems if the cups error.log is reporting "stopped with status 22!"<br />
* <b>hplip</b> - HP Linux inkjet driver. Provides support for DeskJet, OfficeJet, Photosmart, Business Inkjet and some LaserJet printer models.<br />
* <b>cups-pdf</b> - A nice package that allows one to setup a virtual PDF Printer that generates a PDF out of anything sent to it.<br />
<br />
<br />
If your system is connected to a networked printer using the samba protocol or if the system is to be a print server for Windows clients:<br />
# pacman -S samba<br />
<br />
==Download Printer PPD==<br />
<br />
Depending on your printer, this step is optional and may not be needed as the standard CUPS installation already comes with quite a few PPD (Postscript Printer Description) files. Moreover, the <i>foomatic-filters</i>, <i>gimp-print</i> and <i>hplip</i> packages already include quite a few PPD files which will automatically be detected by CUPS.<br />
<br />
<br />
Here's an explanation of what a PPD file is from the Linux Printing website: "For every PostScript printer the manufacturers provide a PPD file which contains all printer-specific information about the particular printer model: Basic printer capabilities as whether the printer is a color printer, fonts, PostScript level, etc., and especially the user-adjustable options, as paper size, resolution, etc."<br />
<br />
<br />
*To get the PPD file for your printer, go to http://www.linuxprinting.org/printer_list.cgi and select the manufacturer and model of your printer.<br />
<br />
<br />
*Now, you will need to copy the file to the cups folder so it can detect the file. If you are in the folder where you downloaded the PPD file, you can use the following command:<br />
<br />
<pre><br />
# cp your_printer.ppd /usr/share/cups/model/<br />
</pre><br />
<br />
<br />
If you cannot find your printer on the website, you may want to try similar models or using generic printer drivers. Just do some googling or ask your manufacturer (good luck with that...).<br />
<br />
=Configuring Cups=<br />
<br />
==Options==<br />
<br />
Now that you have cups installed, you have a variety of options on how to setup CUPS. You can always use the tried and true command line. Likewise, various desktop environments such as Gnome and KDE have useful programs that can help you manage your printers. However, in order to make this process easy for the largest amount of users, we will use the web interface provided by CUPS.<br />
<br />
Please note that if you are planning on connecting to a network printer, rather than one that is directly connected to your computer, you may wish to jump to the Printer Sharing section first. Linux to Linux printer sharing is quite easy and involves very little configuration. Windows to Linux and vice-versa requires a little bit more effort, but is relatively easy as well.<br />
<br />
==Kernel Modules==<br />
<br />
Before we can use the CUPS web interface, we must install the appropriate kernel modules. The following are steps that I got from the Gentoo Printing Guide. <br />
===USB printers===<br />
If you want to use a USB printer with a 2.6.x kernel, use the following command:<br />
<br />
<pre><br />
# modprobe usblp<br />
</pre><br />
<br />
If you are using a USB printer and a 2.4.x kernel, use the following command:<br />
<br />
<pre><br />
# modprobe printer<br />
</pre><br />
<br />
Note, this assumes that you are using the stock kernels from Arch Linux. If you custom-rolled your own, you may need to run this first:<br />
<br />
<pre><br />
# modprobe usbcore<br />
</pre><br />
<br />
Once you have the modules installed, you should plug in your printer and check if the kernel detected it by running the following:<br />
<br />
<pre><br />
# tail /var/log/messages.log<br />
</pre><br />
<br />
or<br />
<br />
<pre><br />
# dmesg<br />
</pre><br />
<br />
<br />
You should see something like this:<br />
<br />
<pre><br />
Feb 19 20:17:11 kernel: printer.c: usblp0: USB Bidirectional<br />
printer dev 2 if 0 alt 0 proto 2 vid 0x04E8 pid 0x300E<br />
Feb 19 20:17:11 kernel: usb.c: usblp driver claimed interface cfef3920<br />
Feb 19 20:17:11 kernel: printer.c: v0.13: USB Printer Device Class driver<br />
</pre><br />
<br />
===Parallel port printers===<br />
If you plan on using a parallel port printer, the configuration is pretty much the same. Kernel 2.6.x users have to first type in:<br />
<br />
<pre><br />
# modprobe lp<br />
</pre><br />
<br />
And then both 2.4.x and 2.6.x kernel users can enter in:<br />
<br />
<pre><br />
# modprobe parport<br />
# modprobe parport_pc<br />
</pre><br />
<br />
Once again, you can check your setup by running:<br />
# tail /var/log/messages.log<br />
You should see something like this:<br />
<br />
<pre><br />
# lp0: using parport0 (polling).<br />
</pre><br />
<br />
<br />
Note: Installing my Brother HL 1250 i found that permissions for the device don't let cups to write on the device, so practically it doesn't print. To fix it:<br />
<br />
<pre><br />
[root@mihal usb]# cd /dev/usb/<br />
[root@mihal usb]# ls<br />
lp0<br />
[root@mihal usb]# chgrp lp lp0<br />
<br />
</pre><br />
<br />
===Auto-loading===<br />
You may also want to have the system automatically load the kernel module every time the computer starts up. To do this use your favorite text editor to open up <code>/etc/rc.conf</code> and add the appropriate module to the <i>MODULES=()</i> line. Here's a portion of the text from my <code>rc.conf</code> file:<br />
<br />
<pre><br />
MODULES=(!usbserial scsi_mod sd_mod snd-ymfpci snd-pcm-oss lp parport parport_pc ide-scsi)<br />
</pre><br />
<br />
==CUPS Daemon==<br />
<br />
With the kernel modules installed, you are now ready to start the actual CUPS daemon. To do this, simply run this command:<br />
<br />
<pre><br />
# /etc/rc.d/cups start<br />
</pre><br />
<br />
If you want to have cups start up automatically every time you start your computer, than you need to add it to your DAEMONS=() line in the <i>/etc/rc.conf</i> file. For example:<br />
<br />
<pre><br />
# DAEMONS=(pcmcia syslogd klogd !fam esd mono network autofs cups crond gdm)<br />
</pre><br />
<br />
==Web Interface and tool kit.==<br />
<br />
Once the daemon is running, if a web interface is available. Open up your browser and go to:<br />
<br />
<i>http://localhost:631</i><br />
<br />
(You may need to replace ''localhost'' with your hostname found in ''/etc/hosts'')<br />
<br />
'''or''' install "Gnome Cups Manager" GUI frontend (see Appendix: A.1 [http://wiki.archlinux.org/index.php/CUPS_Setup#Alternative_CUPS_Interfaces Alternative CUPS Interfaces])<br />
<br />
From here, all you have to do is follow the various wizards to add your printer. To setup my Samsung ML-1250 printer, I started out by click on <i>Manage Printers</i>, and then <i>Add Printer</i>. I was then prompted for a username and password. I just logged in as root. I entered in ml1250 for my printer name, My Room for location and then Peter's Samsung ML-1250 Laster Printer for description. Next you will select the device. Since my printer is a USB device, I just selected <i>USB Printer #1</i>. The name of my printer also showed up next to the label <i>USB Printer #1</i>, so look for that. Next, I simply chose the appropriate drivers and the installation was complete.<br />
<br />
Once the installation is complete, you can test your configuration by pressing the Print Test Page button.<br />
<br />
=Printer Sharing=<br />
<br />
==Linux to Linux==<br />
<br />
Once you have CUPS setup on your Linux print server, sharing the printer with another Linux box is relatively easy. There are several ways to configure such a scenario, here we will describe the manual setup. On the server computer (the one managing and connecting to the printer) simply open up the <i>/etc/cups/cupsd.conf</i> file and allow access to the server by modifying the location lines. For instance:<br />
<br />
<pre><br />
<Location /><br />
Order Deny,Allow<br />
Deny From All<br />
Allow From 127.0.0.1<br />
Allow From 10.0.0.*<br />
</Location><br />
</pre><br />
<br />
You will also need to make sure the server is listening on the IP address your client will be addressing. Add the following line after "Listen localhost:631":<br />
<br />
<pre><br />
Listen 10.0.0.1:631<br />
</pre><br />
<br />
using your server's IP address instead of 10.0.0.1.<br />
<br />
Add the IP address of the client computer by doing Allow From client_ip_address. After you make your modifications, you will want to restart CUPS by doing:<br />
<br />
<pre><br />
# /etc/rc.d/cups restart<br />
</pre><br />
<br />
On the client side, open up <i>/etc/cups/client.conf</i> and edit the ServerName option to match the ip address or the name of your server. For instance I named my server beast and have entry in my hosts file to point to it. So in my <i>client.conf</i> file, I just edited this line:<br />
<br />
<pre><br />
ServerName beast<br />
</pre><br />
<br />
Next, run the following command to update the client computer:<br />
<br />
<pre><br />
# lpq<br />
</pre><br />
<br />
You should see something like this:<br />
<br />
<pre><br />
ml1250 is ready<br />
no entries<br />
</pre><br />
<br />
There are more configuration possibilities including an automatic configuration which are described in detail on http://localhost:631/sam.html#CLIENT_SETUP (this link works on your printer server).<br />
<br />
when prompted for username and password use root to access<br />
then follow the instructions from here<br />
http://www.digitalhermit.com/linux/printing/<br />
if its a TCP/IP printer use Jetdirect<br />
<br />
That's it for Linux to Linux printer sharing.<br />
<br />
==Linux to Windows==<br />
<br />
If you are connected to a Windows print server (or any other Samba capable print server), you can skip the section about kernel modules and such. All you have to do is start the CUPS daemon and complete the web interface as specified in section 3.3 and 3.4. Before this, you need to activate the Samba CUPS backend. You can do this by entering the following command:<br />
<br />
<pre><br />
# ln -s `which smbspool` /usr/lib/cups/backend/smb<br />
</pre><br />
<br />
Note that the symbol before is ` (underneath the ~ on a standard US keyboard) and not '. After this, you will have to restart CUPS using the command specified in the previous section. Next, simply login into the CUPS web interface and choose to add a new printer. For device, there should be an option that says something to the effect Windows Printer Via Samba near the button of the device list. For the device location enter:<br />
<br />
<pre><br />
smb://username:password@hostname/printer_name<br />
</pre><br />
<br />
Or without a password:<br />
<br />
<pre><br />
smb://username@hostname/printer_name<br />
</pre><br />
<br />
Make sure that the user actually has access to the printer on Windows computer. Select the appropriate drivers and that's about it. If the computer is located on a domain, make sure the username includes the domain: <br />
smb://username:password@domain/hostname/printer_name<br />
<br />
Note: if your network contains many printers use "lpoptions -d your_desired_default_printer_name" to set your preferred printer<br />
<br />
Note: I, thepizzaking, was having 'NT_STATUS_ACCESS_DENIED' errors and to fix them I needed to use a slightly different syntax:<br />
<pre><br />
smb://workgroup/username:password@hostname/printer_name<br />
</pre><br />
<br />
==Windows to Linux==<br />
<br />
Sometimes, you might want to allow a Windows computer to connect to your computer. There are a few ways to do this, and the one I am most familiar with is using Samba. In order to do this, you will have to edit your <i>/etc/samba/smb.conf</i> file to allow access to your printers. Your smb.conf can look something like this:<br />
<br />
<pre><br />
[global]<br />
workgroup = Heroes<br />
server string = Arch Linux Print Server<br />
security = user<br />
<br />
[printers]<br />
comment = All Printers<br />
path = /var/spool/samba<br />
browseable = yes<br />
# to allow user 'guest account' to print.<br />
guest ok = no<br />
writable = no<br />
printable = yes<br />
create mode = 0700<br />
write list = @adm root neocephas<br />
</pre><br />
<br />
That should be enough to share your printer, but you just might want to add an individual printer entry:<br />
<br />
<pre><br />
[ML1250]<br />
comment = Samsung ML-1250 Laser Printer<br />
printer=ml1250<br />
path = /var/spool/samba<br />
printing = cups<br />
printable = yes<br />
printer admin = @admin root neocephas<br />
user client driver = yes<br />
# to allow user 'guest account' to print.<br />
guest ok = no<br />
writable = no<br />
write list = @adm root neocephas<br />
valid users = @adm root neocephas<br />
</pre><br />
<br />
Please note that in my configuration I made it so that users must have a valid account to access the printer. To have a public printer, set guest ok to yes, and remove the valid users line. To add accounts, you must setup a regular Linux account and then setup a Samba password on the server. For instance:<br />
<br />
<pre><br />
# useradd neocephas<br />
# smbpasswd -a neocephas<br />
</pre><br />
<br />
After setting up any user accounts that you need, you will also need to set up the samba spool folder:<br />
<br />
<pre><br />
# mkdir /var/spool/samba<br />
# chmod 777 /var/spool/samba<br />
</pre><br />
<br />
The next items that need changing are /etc/cups/mime.convs and /etc/cups/mime.types:<br />
<br />
mime.convs:<br />
<pre><br />
# The following line is found at near the end of the file. Uncomment it.<br />
application/octet-stream application/vnd.cups-raw 0 -<br />
</pre><br />
<br />
mime.types:<br />
<pre><br />
# Again near the end of the file.<br />
application/octet-stream<br />
</pre><br />
<br />
The changes to mime.convs and mime.types are needed to make CUPS print Microsoft Office document files. Many people seem to need that.<br />
<br />
After this restart your Samba daemon:<br />
<br />
<pre><br />
# /etc/rc.d/samba restart<br />
</pre><br />
<br />
Obvious, there are a lot of tweaks and customization that can be done with setting up a Samba print server, so I advise you to look at the Samba and CUPS documentation for more help. The <i>smb.conf.example</i> file also has some good samples to that you might want to look at.<br />
<br />
==Windows 2000 and Windows XP to Linux==<br />
<br />
For the most modern flavors of Windows an alternative way of connecting to your Linux printer server is to use the CUPS protocol directly. The Windows client will need to be using Windows 2000 or Windows XP. Make sure you allows the clients to access the print server by editing the location settings as specified in section 4.1.<br />
<br />
On the Windows computer, go to the printer control panel and choose to Add a New Printer. Next, choose to give an url. For the url type in the location of your printer:<br />
<br />
<i>http://host_ip_address:631/printers/printer_name</i><br />
<br />
where host_ip_address is the Linux server's IP address and printer_name is the name of the printer you are connecting to. After this, install the printer drivers for the Windows computer. If you setup the CUPS server to use its own printer drivers, then you can just select a generic postscript printer for the Windows client. You can then test your print setup by printing a test page.<br />
<br />
==Others to Linux, Linux to others==<br />
<br />
More information on interfacing CUPS with other printing systems can be found in the CUPS manual, e.g. on http://localhost:631/sam.html#PRINTING_OTHER<br />
<br />
=Appendix=<br />
<br />
==Alternative CUPS Interfaces==<br />
<br />
If you are a GNOME user, you can manage and configure your printer by using the gnome-cups-manager.<br />
<br />
Update: this package is now available through pacman if you have the "community" repository uncommented in /etc/pacman.conf<br />
<br />
pacman -S gnome-cups-manager<br />
<br />
The package is also still available from the [http://aur.archlinux.org/packages.php?do_Details=1&ID=66&O=0&L=0&C=0&K=cups&SB=&SO=&PP=25&do_MyPackages=0&do_Orphans=0&SeB=nd AUR].<br />
<br />
KDE users can modify their printers from the Control Center. Both should refer the those desktop environments' documentation for more information on how to use the interfaces.<br />
<br />
There is also gtklp. It is in the "extra" repository.<br />
<br />
pacman -S gtklp<br />
<br />
==PDF Virtual Printer==<br />
<br />
A nice little package that I submitted to the incoming folder (ftp://ftp.archlinux.org/incoming) is CUPS-PDF. This package allows one to setup a virtual printer that will generate a PDF from anything sent to it. For example, I wrote this document in AbiWord and then printed it to the Virtual Printer which generated a pdf in my <i>/var/spool/cups-pdf/neocephas</i> folder. Obviously, this package is not necessary, but it can be quite useful. After downloading the package from the ftp server and installing it, you can set it up as you would for any other printer in the web interface. Select Virtual PDF Printer as the device and choose Postscript -> Postscript Color Printer for the drivers.<br />
<br />
==Online Resources==<br />
<br />
Here is a listing of websites that may be of use to you:<br />
<br />
* <b>Official CUPS documentation on your computer</b> http://localhost:631/documentation.html<br />
* <b>Official CUPS Website</b> - http://www.cups.org/<br />
* <b>Linux Printing</b> - http://www.linuxprinting.org/<br />
* <b>Tips and Suggestions on common CUPS problems</b> - http://home.nyc.rr.com/computertaijutsu/cups.html<br />
* <b>Gentoo's Printing Guide</b> - http://www.gentoo.org/doc/en/printing-howto.xml<br />
* <b>Arch Linux User Forums</b> - http://bbs.archlinux.org/<br />
<br />
==Specialized Cases==<br />
<br />
This section is dedicated to specific problems and their solutions. If you managed to get some <i>unusual</i> printer working, please put the solution here.<br />
<br />
===Printing does not work/aborts with the HP Deskjet 700 Series Printers.===<br />
<br />
*The solution is to install <b>pnm2ppa</b> printer filter for the HP Deskjet 700 series. Without this the print jobs will be aborted by the system. A [[ABS - The Arch Build System | PKGBUILD]] for pnm2ppa can be found in [http://aur.archlinux.org/packages.php?do_Details=1&ID=696&O=0&L=0&C=0&K=pnm&SB=n&SO=a&PP=25&do_MyPackages=0&do_Orphans=0 AUR].<br />
<br />
===Getting HP LaserJet 1010 to work===<br />
I had to compile ghostscript myself because ESP gs in rep was 7.07 and had not fixed some bugs like ESP 8.15.1 had. I never downloaded 'foomatic' in rep. I think that is an old package. <br />
<pre><br />
$ pacman -Qs cups a2ps psutils foo ghost<br />
local/cups 1.1.23-3<br />
The CUPS Printing System<br />
local/a2ps 4.13b-3<br />
a2ps is an Any to PostScript filter<br />
local/psutils p17-3<br />
A set of postscript utilities.<br />
local/foomatic-db 3.0.2-1<br />
Foomatic is a system for using free software printer drivers with common<br />
spoolers on Unix<br />
local/foomatic-db-engine 3.0.2-1<br />
Foomatic is a system for using free software printer drivers with common<br />
spoolers on Unix<br />
local/foomatic-db-ppd 3.0.2-1<br />
Foomatic is a system for using free software printer drivers with common<br />
spoolers on Unix<br />
local/foomatic-filters 3.0.2-1<br />
Foomatic is a system for using free software printer drivers with common<br />
spoolers on Unix<br />
local/espgs 8.15.1-1<br />
ESP Ghostscript<br />
</pre><br />
I also had to set LogLevel in /etc/cups/cupsd.conf to debug2 before i saw that I missed some "Nimbus" fonts. Then I had to rename & put them where the log told me to. Some fancy google searching had to be applied, example: http://www.google.com/search?q=n019003l+filetype%3Apfb since the fonts turned out to be proprietary (i'm sure windows comes with these default). Nevertheless after downloading them(about 7 fonts) and putting them in the correct folder printing started working.<br />
<br />
Before that i were getting all the errors said here: http://linuxprinting.org/show_printer.cgi?recnum=HP-LaserJet_1010 'Unsupport PCL' etc...<br />
<br />
I'm sure it could have worked with ESP gs 7.07 too(in rep) if i was smart enough to turn on DebugLevel2 sooner :/ UPDATE: yeah it did... maybe this info is useful for someone else though.. sorry for the inconvenience.<br />
<br />
===Getting HP LaserJet 1020 to work===<br />
After a lot of tries with hplib and gutenprint I finally found the solution to get my printer HP Laserjet 1020 printing. <br />
<br />
First of all you only need to install cups and ghostscript. Then follow the link on http://www.linuxprinting.org/show_printer.cgi?recnum=HP-LaserJet_1020 to the http://foo2zjs.rkkda.com/ printer driver page and follow the install instructions. Log in as root. After you downloaded the package and extracted the archive, change into the foo2zjs directory. Now you can follow the original installation instructions with a minor modification to change the userid for printing:<br /><br />
<br />
$ make<br />
$ ./getweb 1020<br />
<br />
Open the ''Makefile''<br />
$ nano Makefile<br />
and search for the line<br />
# LPuid=-olp<br />
and modify it to<br />
# LPuid=-oroot<br />
then continue with the script<br />
$ make install<br />
$ make install-hotplug<br />
$ make cups<br />
<br />
Or you can use the package foo2zjs from AUR and modify the PKGBUILD: change the line<br />
<br />
./getweb all<br />
<br />
to<br />
<br />
./getweb 1020<br />
<br />
(or if you're setting another printer change this line to what you need).<br />
<br />
As a last step add and configure the printer in the CUPS manager. The printer should be recognized automatically. It works fine for root and all users. When booting the operating system, the printer is initialized and indicates its working.<br />
<br />
=== Printer connected to an Airport Express Station ===<br />
The first thing to do is to scan the airport express station. It<br />
seems that there are different addresses depending on the model.<br />
<pre><br />
[root@somostation somos]# nmap 192.168.0.4<br />
<br />
Starting Nmap 4.20 ( http://insecure.org ) at 2007-06-26 00:50 CEST<br />
Interesting ports on 192.168.0.4:<br />
Not shown: 1694 closed ports<br />
PORT STATE SERVICE<br />
5000/tcp open UPnP<br />
9100/tcp open jetdirect<br />
10000/tcp open snet-sensor-mgmt<br />
MAC Address: 00:14:51:70:D5:66 (Apple Computer)<br />
<br />
Nmap finished: 1 IP address (1 host up) scanned in 25.815 seconds<br />
</pre><br />
With my station the port is 9100. The airport station is accessed like<br />
an HP JetDirect printer.<br />
After, you can edit your printer.conf file in this way:<br />
<pre><br />
# Printer configuration file for CUPS v1.2.11<br />
# Written by cupsd on 2007-06-26 00:44<br />
<Printer LaserSim><br />
Info SAMSUNG ML-1510 gdi<br />
Location SomoStation<br />
DeviceURI socket://192.168.0.4:9100<br />
State Idle<br />
StateTime 1182811465<br />
Accepting Yes<br />
Shared Yes<br />
JobSheets none none<br />
QuotaPeriod 0<br />
PageLimit 0<br />
KLimit 0<br />
OpPolicy default<br />
ErrorPolicy stop-printer<br />
</Printer><br />
</pre><br />
It should work. I had a few problems. There were resolved by removing foomatic and installing foomatic-db, foomatic-db-engine, foomatic-db-ppd instead.<br />
<br />
===Performing Utility Functions on Epson Printers===<br />
<br />
====Escputil====<br />
<br />
Here we explain how to perform some of the utility functions such as nozzle cleaning and nozzle checks on Epson printers. We will use the escputil utility, which is part of the gutenprint package.<br />
<br />
There is a man page ("man escputil") that provides pretty good information, but it does not include necessary information on how to identify your printer. There are two parameters that can be used. One is --printer; what it expects is the name you used to identify your printer when you configured it. The other is --raw-device. What this option expects is is something beginning with "/dev". If your printer is a serial printer, and the only serial printer, it is "/dev/lp0". If it is an usb printer, it is "/dev/usb/lp0". If you have more than one printer, they will have names ending in "lp1", "lp2", etc. <br />
<br />
* To clean the printer heads:<br />
<br />
escputil -u --clean-head<br />
<br />
* To prints the nozzle-check pattern, allowing you to verify that the previous head cleaning worked. (Or to determine that you need to clean the heads)<br />
<br />
escputil -u --nozzle-check<br />
<br />
If you want to perform an operation that requires 2-way communication with a printer, you must use the "--raw-device" specification, and your user must root or be a member of the group "lp". <br />
<br />
* The following is an example of getting the printer's internal identification:<br />
<br />
sudo escputil --raw-device=/dev/usb/lp0 --identify<br />
<br />
* To prints out the ink levels of the printer:<br />
<br />
sudo escputil --raw-device=/dev/usb/lp0 --ink-level<br />
<br />
====Mtink====<br />
<br />
This is a printer status monitor which enables to get the remaining ink quantity, to print test patterns, to reset printer and to clean nozzle. It use an intuitive graphical user interface. Package can be downloaded from [http://aur.archlinux.org/packages.php?do_Details=1&ID=476&O=0&L=0&C=0&K=mtink&SB=n&SO=a&PP=25&do_MyPackages=0&do_Orphans=0&SeB=nd AUR].<br />
<br />
==Another Source for Printer Drivers==<br />
<br />
On <i>http://www.turboprint.de/english.html</i> is a really good printer driver for many printers not yet supported by Linux (especially Canon i*). The only problem is that high-quality-prints are either marked with a turboprint-logo or you have to pay for it... It's not Open-Source.<br />
<br />
{{Wikipedia|Common_Unix_Printing_System}}<br />
<br />
=Troubleshooting=<br />
==As a result of upgrade==<br />
<br />
===Error with gnutls===<br />
After updating, if you get something like :<br />
/usr/sbin/cupsd: error while loading shared libraries: libgnutls.so.13: cannot open shared object file: No such file or directory<br />
<br />
You need to update gnutls:<br />
<br />
pacman -Sy gnutls<br />
<br />
In addition, in /etc/cups, there will be a file named cupsd.conf.pacnew. Rename it cupsd.conf.<br />
<br />
===All jobs are "stopped"===<br />
After updating CUPS, if all jobs sent to the printer become "stopped", delete the printer and add it again.<br />
Using the CUPS web interface (http://localhost:631), go to Printers > Delete Printer.<br />
<br />
''Note:'' If you don't remember your printer's settings, go to Printers > Modify Printer. Copy down the information displayed, click 'Modify Printer' to proceed to the next page(s), etc.</div>Wide-eyehttps://wiki.archlinux.org/index.php?title=Talk:VCS_package_guidelines&diff=44292Talk:VCS package guidelines2008-07-06T08:03:46Z<p>Wide-eye: doh</p>
<hr />
<div>Q: Any reason for using 'svn co' instead of 'svn export'? export is way faster for these situations and it doesn't create all the .svn files.<br />
<br />
A: Look at http://bbs.archlinux.org/viewtopic.php?pid=245213<br />
<br />
<br />
----<br />
<br />
<br />
Just wondering if the versionpkg part will be removed - I hear that makepkg now has versionpkgs functionality...<br />
--[[User:Ak5|ak5]] 16:55, 8 June 2008 (EDT)<br />
<br />
-- done (wide-eye)</div>Wide-eyehttps://wiki.archlinux.org/index.php?title=Talk:VCS_package_guidelines&diff=44291Talk:VCS package guidelines2008-07-06T08:00:34Z<p>Wide-eye: </p>
<hr />
<div>Q: Any reason for using 'svn co' instead of 'svn export'? export is way faster for these situations and it doesn't create all the .svn files.<br />
<br />
A: Look at http://bbs.archlinux.org/viewtopic.php?pid=245213<br />
<br />
<br />
----<br />
<br />
<br />
Just wondering if the versionpkg part will be removed - I hear that makepkg now has versionpkgs functionality...<br />
--[[User:Ak5|ak5]] 16:55, 8 June 2008 (EDT)<br />
-- done</div>Wide-eyehttps://wiki.archlinux.org/index.php?title=VCS_package_guidelines&diff=44290VCS package guidelines2008-07-06T07:59:23Z<p>Wide-eye: removed obsolete versionpkg, added tip on the new makepkg behavior</p>
<hr />
<div>[[Category:Package management (English)]]<br />
[[Category:Development (English)]]<br />
[[Category:Package development (English)]]<br />
[[Category:HOWTOs (English)]]<br />
<br />
:''This is actually very easy and doesn't require any special knowledge. However, the more you know about cvs and svn the easier it is. Many people introduce custom variables into the PKGBUILD that can overcomplicate things. These are not ''really'' necessary but do help to clarify the syntax of the cvs/svn/git commands, which can appear quite complex.''<br />
<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|Arch CVS %26 SVN PKGBUILD guidelines}}<br />
{{i18n_entry|繁體中文|Arch CVS %26 SVN PKGBUILD 編寫指南}}<br />
{{i18n_entry|简体中文|Arch CVS %26 SVN %26 GIT PKGBUILD 编写指南}}<br />
{{i18n_links_end}}<br />
<br />
<br />
==A few tips==<br />
<br />
* Suffix <code>pkgname</code> with <code>-cvs</code> or <code>-svn</code> or <code>-git</code> where applicable - this prevents confusion with non-development versions e.g. fluxbox-svn or fvwm-cvs vs fluxbox and fvwm.<br />
* When makepkg is run it will check for newer revisions and then bump pkgver to the latest. If this is not what you want see the --holdver in [http://www.archlinux.org/pacman/makepkg.8.html man makepkg]<br />
* You must also be careful about pacman conflicts. For example fluxbox-svn will conflict with fluxbox. In this case you need to use the <tt>conflicts=</tt> field<br />
conflicts=('fluxbox')<br />
: You should also use the <tt>provides=</tt> field so that pkgs that require fluxbox to be installed recognize your fluxbox-svn pkg as fluxbox<br />
provides=('fluxbox')<br />
: You should AVOID using <tt>replaces=</tt> it generally causes unnecessary problems<br />
*When using/defining the cvsroot use anonymous<b>:</b>@ rather than anonymous@ to avoid having to press enter to give blank password ''OR'' anonymous<b>:password</b>@ - if a password is required.<br />
* cvs and svn PKGBUILDs may not require a source or md5sum array but these fields '''must''' be included in the PKGBUILD if you wish to submit it to the AUR, otherwise the pkg will be rejected. They may be left blank though.<br />
<pre>source=()<br />
md5sums=()</pre><br />
* It is rarely necessary to use the pkgrel field when building CVS/SVN/GIT pkgs - any changes to the pkg will often be on another day and so are usually accounted for by a change in pkgver (assuming pkgver is used to hold a date format)<br />
* don't forget to include cvs or subversion in <code>makedepends=</code> as necessary<br />
* to preserve the integrity of the checked out code it is usually possible to build in a separate build dir e.g. having checked out source code to src/$_cvsmod from $startdir you can use:<br />
<pre> mkdir src/$_cvsmod-build<br />
<br />
cd src/$_cvsmod-build<br />
../$_cvsmod/configure</pre><br />
''OR'' if that fails you can try:<br />
<pre> cp -r src/$_cvsmod src/$_cvsmod-build<br />
cd src/$_cvsmod-build</pre><br />
<br />
* With the introduction of the AUR it is most important to avoid using backtick execution to create pkg variables<br />
** For cvs pkgs you should avoid <code>pkgver=`date +%y%m%d`</code> - this also interferes with the functionality of the AUR. Instead it is still possible to use a date format for the $pkgver variable and to use the cvs -D option to check out code from that date (see below)<br />
** For svn you can use the revision number. An easy way to find the revision number is to use the following command:<br />
svn log $_svntrunk --limit 1 | sed -e '/^r/!d' -e 's/^r\([0-9]\+\) .*/\1/;q'<br />
That command grabs the most recent log entry from the svn repo and finds the revision number, which is prefixed with an r. This is from the fluxbox svn log, the revision number is in the top left, r4084<br />
<pre><br />
------------------------------------------------------------------------<br />
r4084 | mathias | 2005-07-20 19:29:01 +0100 (Wed, 20 Jul 2005) | 16 lines<br />
<br />
Changed some *Focus options, just to make some things a bit more clear.<br />
the "Sloppy" was always a bit .. imprecise.<br />
</pre><br />
<br />
==Example CVS PKGBUILD==<br />
<br />
Here is a PKGBUILD for bmp-cvs that utilizes some of the tips above<br />
<br />
<pre># Contributor: Lukas Sabota <punkrockguy318@comcast.net><br />
# Contributor: dibblethewrecker dibblethewrecker.at.jiwe.dot.org<br />
arch=(i686 x86_64)<br />
pkgname=bmp-cvs<br />
pkgver=20050728<br />
pkgrel=1<br />
pkgdesc="A multimedia player that uses the WinAmp 2.x UI, GTK2, and is based on XMMS. This will checkout and package the latest CVS version."<br />
url="http://beepmp.sourceforge.net/"<br />
license=<br />
depends=('gtk2' 'libvorbis' 'alsa-lib' 'audiofile' 'libglade' 'id3lib' 'x-server')<br />
provides=('bmp')<br />
conflicts=('bmp')<br />
makedepends=('cvs')<br />
install=$pkgname.install<br />
<br />
_cvsroot=":pserver:anonymous:@cvs.sourceforge.net:/cvsroot/beepmp"<br />
_cvsmod="bmp"<br />
<br />
build() {<br />
cd $startdir/src<br />
msg "Connecting to $_cvsmod.sourceforge.net CVS server...."<br />
if [ -d $_cvsmod/CVS ]; then<br />
cd $_cvsmod<br />
cvs -z3 update -d<br />
else<br />
cvs -z3 -d $_cvsroot co -D $pkgver -f $_cvsmod<br />
cd $_cvsmod<br />
fi<br />
./autogen.sh<br />
<br />
msg "CVS checkout done or server timeout"<br />
msg "Starting make..."<br />
<br />
cp -r ../$_cvsmod ../$_cvsmod-build<br />
cd ../$_cvsmod-build<br />
<br />
./configure --prefix=/usr<br />
make || return 1<br />
make DESTDIR=$startdir/pkg install || return 1<br />
<br />
mkdir -p $startdir/pkg/usr/share/xmms/Skins<br />
mv $startdir/pkg/usr/share/bmp/Skins/* $startdir/pkg/usr/share/xmms/Skins<br />
rmdir $startdir/pkg/usr/share/bmp/Skins<br />
<br />
rm -r $startdir/src/$_cvsmod-build<br />
}<br />
# vim:syntax=sh<br />
</pre><br />
<br />
==Example SVN PKGBUILD==<br />
<br />
If you use the <tt>source</tt> command on the PKGBUILD first it will store the _svntrunk and _svnmod variables. So if you run :<br />
source PKGBUILD<br />
svn info $_svntrunk<br />
you can get the revision number(Or,Last Changed Rev) which can be used in pkgver<br />
<br />
<pre><br />
# Contributor: Lukas Sabota <punkrockguy318@comcast.net><br />
# Contributor: dibblethewrecker dibblethewrecker.at.jiwe.dot.org<br />
arch=(i686 x86_64)<br />
pkgname=fluxbox-svn<br />
pkgver=4084<br />
pkgrel=1<br />
pkgdesc="Fluxbox-svn is the bleeding edge version of a lightweight yet \<br />
customizable windowmanager for X. This will checkout and package the latest SVN version."<br />
url="http://www.fluxbox.org"<br />
license=<br />
<br />
depends=('bash' 'x-server')<br />
makedepends=('subversion')<br />
conflicts=('blackbox' 'fluxbox' 'fluxbox-devel' 'fluxbox-cvs')<br />
provides=('fluxbox')<br />
<br />
source=()<br />
md5sums=()<br />
<br />
_svntrunk=svn://svn.berlios.de/fluxbox/trunk<br />
_svnmod=fluxbox<br />
<br />
build() {<br />
cd $startdir/src<br />
<br />
if [ -d $_svnmod/.svn ]; then<br />
(cd $_svnmod && svn up -r $pkgver)<br />
else<br />
svn co $_svntrunk --config-dir ./ -r $pkgver $_svnmod<br />
fi<br />
<br />
msg "SVN checkout done or server timeout"<br />
msg "Starting make..."<br />
<br />
cp -r $_svnmod $_svnmod-build<br />
cd $_svnmod-build<br />
<br />
./autogen.sh<br />
<br />
# fix for crap fb issue<br />
mkdir data<br />
cp ../$_svnmod/data/keys data/<br />
<br />
./configure --prefix=/usr --enable-xinerama --enable-imlib2 --enable-debug<br />
make || return 1<br />
make DESTDIR=$startdir/pkg/ install<br />
<br />
rm -rf $startdir/src/$_svnmod-build<br />
}<br />
# vim:syntax=sh</pre><br />
<br />
==Example GIT PKGBUILD==<br />
<br />
<pre><br />
arch=(i686 x86_64)<br />
pkgname=compiz-git<br />
pkgver=20060707<br />
pkgrel=1<br />
pkgdesc="Composite and window manager for Xgl"<br />
url="http://en.opensuse.org/Compiz"<br />
license=""<br />
depends=('xgl-cvs' 'mesa-xgl-cvs' 'cairo-devel' 'libxevie' \<br />
'startup-notification' 'libpng' 'libxdamage' \<br />
'libxrandr' 'libwnck-compiz' 'gnome-desktop' 'control-center' \<br />
'libsvg-cairo' 'libxcomposite')<br />
makedepends=('git')<br />
conflicts=()<br />
replaces=()<br />
backup=()<br />
install=compiz.install<br />
source=(compiz-intel-copy-pixel-issue-workaround-1.diff)<br />
md5sums=('10a157b86d528bca2be6731c5eaff7b3')<br />
<br />
_gitroot="git://anongit.freedesktop.org/git/xorg/app/compiz"<br />
_gitname="compiz"<br />
build() {<br />
export CFLAGS="$CFLAGS -I/opt/mesa-xgl-cvs/include"<br />
cd $startdir/src<br />
msg "Connecting to git.freedesktop.org GIT server...."<br />
<br />
if [ -d $startdir/src/$_gitname ] ; then<br />
cd $_gitname && git-pull origin<br />
msg "The local files are updated."<br />
else<br />
git clone $_gitroot<br />
fi<br />
<br />
msg "GIT checkout done or server timeout"<br />
msg "Starting make..."<br />
<br />
cp -r $startdir/src/$_gitname $startdir/src/$_gitname-build<br />
cd $startdir/src/$_gitname-build<br />
patch -Np0 -i ${startdir}/src/compiz-intel-copy-pixel-issue-workaround-1.diff<br />
<br />
ACLOCAL="aclocal -I /opt/gnome/share/aclocal" ./autogen.sh --host=${CHOST} \<br />
--prefix=/usr \<br />
--infodir=/usr/share/info \<br />
--mandir=/usr/man \<br />
--sysconfdir=/opt/gnome/etc \<br />
--enable-gnome \<br />
--enable-libsvg-cairo \<br />
--enable-gconf-dump \<br />
--disable-kde || return 1<br />
make || return 1<br />
make DESTDIR=$startdir/pkg install<br />
<br />
find $startdir/pkg -type f -name '*.la' -exec rm {} \;<br />
} <br />
</pre><br />
As you see, I use "-git" suffix in the pkgname, and two variables, _gitroot and _gitname for identify the repositories and the name of the package.<br />
I need to introduce an if condition: <br />
<pre><br />
if [ -d $startdir/src/$_gitname ] ; then<br />
cd $_gitname && git-pull origin<br />
msg "The local files are updated."<br />
else<br />
git clone $_gitroot<br />
fi<br />
</pre><br />
because we have two commands, one for updating source and one for getting it. I copy the source code in a "-build" directory ( the same thing that we do with -cvs and -svn program ).<br />
<br />
==Example darcs PKGBUILD==<br />
<pre><br />
pkgname=psi-darcs<br />
pkgver=20070404<br />
pkgrel=2<br />
pkgdesc="Psi - Jabber client (with SSL support) darcs version"<br />
makedepends=('darcs' 'qt4>=4.2')<br />
depends=('qt4>=4.2' 'openssl' 'libxss' 'cyrus-sasl' 'aspell') <br />
source=()<br />
conflicts=('psi')<br />
provides=('psi')<br />
url="http://psi-im.org/"<br />
md5sums=()<br />
<br />
_darcsmod="psi"<br />
_darcstrunk="http://dev.psi-im.org/darcs"<br />
<br />
build() {<br />
cd $startdir/src/<br />
# Erasing previous build<br />
msg "Checking for previous build"<br />
# get the sources<br />
if [[ -d $_darcsmod/_darcs ]]<br />
then<br />
msg "Retrieving missing patches"<br />
cd $_darcsmod<br />
darcs pull -a $_darcstrunk/$_darcsmod<br />
else<br />
msg "Retrieving complete sources"<br />
darcs get --partial --set-scripts-executable $_darcstrunk/$_darcsmod<br />
cd $_darcsmod<br />
fi<br />
<br />
. /etc/profile.d/qt4.sh<br />
export PATH=$QTDIR/bin:$PATH<br />
<br />
# building<br />
msg "Starting build"<br />
./configure --prefix=/usr --disable-xmms<br />
make || return 1<br />
make INSTALL_ROOT=$startdir/pkg install<br />
}<br />
</pre><br />
<br />
==rc-script PROTO==<br />
<pre><br />
#!/bin/bash<br />
<br />
daemon_name=DAEMON_NAME<br />
<br />
. /etc/rc.d/functions<br />
<br />
. /etc/conf.d/$daemon_name.conf<br />
<br />
. /etc/rc.conf<br />
<br />
get_pid() {<br />
pidof $daemon_name<br />
}<br />
<br />
case "$1" in<br />
start)<br />
stat_busy "Starting $daemon_name daemon"<br />
<br />
PID=`get_pid`<br />
if [ -z "$PID" ]; then<br />
[ -f /var/run/$daemon_name.pid ] && rm -f /var/run/$daemon_name.pid<br />
# RUN<br />
$daemon_name<br />
#<br />
if [ $? -gt 0 ]; then<br />
stat_fail<br />
exit 1<br />
else<br />
echo `get_pid` > /var/run/$daemon_name.pid<br />
add_daemon $daemon_name<br />
stat_done<br />
fi<br />
else<br />
stat_fail<br />
exit 1<br />
fi<br />
;;<br />
<br />
stop)<br />
stat_busy "Stopping $daemon_name daemon"<br />
PID=`get_pid`<br />
# KILL<br />
[ ! -z "$PID" ] && kill $PID &> /dev/null<br />
#<br />
if [ $? -gt 0 ]; then<br />
stat_fail<br />
exit 1<br />
else<br />
rm -f /var/run/$daemon_name.pid &> /dev/null<br />
rm_daemon $daemon_name<br />
stat_done<br />
fi<br />
;;<br />
<br />
restart)<br />
$0 stop<br />
sleep 3<br />
$0 start<br />
;;<br />
*)<br />
echo "usage: $0 {start|stop|restart}"<br />
esac<br />
exit 0<br />
</pre></div>Wide-eyehttps://wiki.archlinux.org/index.php?title=Custom_Kernel_Compilation_with_ABS&diff=43584Custom Kernel Compilation with ABS2008-06-23T21:14:57Z<p>Wide-eye: /* I want the Arch logo! */ - updated logo location, language cleanup.</p>
<hr />
<div>[[Category:Kernel (English)]]<br />
[[Category:HOWTOs (English)]]<br />
<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|Custom_Kernel_Compilation_with_ABS}}<br />
{{i18n_entry|简体中文|从ABS定制内核}}<br />
{{i18n_entry|Italiano|Custom_Kernel_Compilation_with_ABS_(Italiano)}}<br />
{{i18n_links_end}}<br />
<br />
=== Introduction ===<br />
You can choose to compile your custom kernel [[Kernel Compilation From Source|the traditional way]], or via [[Kernel Compilation with ABS|ABS]] (this guide). Some Arch users prefer [[Kernel Compilation From Source|the traditional way]], however using ABS is helpful for automating certain tasks. The choice is yours, neither way is inherently better than the other. <br />
<br />
This howto has been updated to provide a definitive PKGBUILD for the creation of custom kernel packages. It allows you to maintain multiple custom kernels with a unique naming scheme under pacman version control. It is ideal for ANY custom kernel build and can be easily adapted to fit many requirements. The PKGBUILD automatically accounts for the <code>EXTRAVERSION</code> and <code>LOCALVERSION</code> variables that are now fully supported in the kernel. <code>EXTRAVERSION</code> is frequently set by major patchsets such as -ck and -nitro. <code>EXTRAVERSION</code> is also used in the 2.6.x.y branch to carry the <code>.y</code> variable. <code>LOCALVERSION</code> can be set during the config stage and is the easiest and RECOMMENDED way to customize your kernel pkgnames. Simply setting <code>LOCALVERSION</code> to <code>-custom</code> or the date e.g. <code>-20050105</code> will suffice! A unique LOCALVERSION guarantees a unique pkg.<br />
<br />
=== Philosophy and Logic (how it works and why it works this way) ===<br />
* The Arch Way - Keep It Simple.<br />
* This PKGBUILD builds on the previous, widely accepted version.<br />
* This build provides kernel packages and components with a simple, logical and uncomplicated naming scheme that ONLY uses variables that are part of the ABS system and part of the kernel compilation process itself. Rationale:<br />
** The stock Arch kernel uses the <code>kernel26</code> base pkgname which is logically extended here under the 2.6.x and 2.6.x.y schemes e.g <code>kernel2611</code> and <code>kernel26117</code><br>These also provide the basis of <code>/boot</code> filenames e.g. <code>vmlinux26</code> and <code>vmlinuz26117</code><br />
** The ''kernel compilation process'' uses the kernel version (2.6.x), <code>EXTRAVERSION</code> from the <code>Makefile</code> and <code>CONFIG_LOCALVERSION</code> from the kernel config to create the name for the kernel's module directory, e.g.:<br />
<br />
<pre><br />
2.6.x$EXTRAVERSION$LOCALVERSION<br />
2.6.11-cko2-ARCH/<br />
</pre><br />
<br />
: This is beyond the control of the PKGBUILD so to provide a pkg with similarly named components the PKGBUILD uses the same scheme to create unique <code>/boot</code> files and a unique <code>/usr/src</code> directory by appending <code>-EXTRAVERSION-LOCALVERSION</code>, e.g.:<br />
<br />
<pre><br />
/boot/vmlinuz2611-cko2-ARCH<br />
/boot/System.map2611-cko2-ARCH<br />
/boot/kconfig2611-cko2-ARCH<br />
<br />
/usr/src/linux-2.6.11-cko2-ARCH/<br />
</pre><br />
<br />
* If you have the recommended knowledge of ABS you will see that the PKGBUILD is transparently constructed, self-explanatory and easily customized.<br />
* User input is almost identical to all ABS builds: simply set <code>pkgver</code>, <code>pkgrel</code> and <code>pkgdesc</code> and add additional sources, including patches, to the <code>source</code> array. Patch users should insert the appropriate patch commands where indicated. Aside from uncommenting the config method and choosing whether to <code>make clean</code> or not the rest of the build is automated.<br />
* Having created a custom pkg naming scheme during the build, the PKGBUILD automatically corrects/updates itself with the new <code>pkgname</code> variable allowing simple <code>gensync</code> operation.<br />
<br />
=== CAUTION ===<br />
# This PKGBUILD is only suited to builds of the 2.6 kernel branch - kernel 2.4 is no longer supported in Arch Linux ([http://www.archlinux.org/news/232/ news])<br />
# This is NOT an ABS howto - to successfully follow this HOWTO a working knowledge of building pkgs with ABS is ESSENTIAL - please read [[ABS - The Arch Build System]], [[The Arch package making HOW-TO - with guidelines]] and [[Patching in ABS]]<br><br />
I don't advise you build a kernel for your first ABS project. If you need guidelines on how to use <code>fakeroot</code> or set up a build directory read the other documents first.<br />
# Likewise it helps if you know how to configure a kernel! If this is your first effort building a kernel I strongly recommend you start from the default Arch config, this is detailed further below.<br />
<br />
=== Usage Notes ===<br />
<br />
* <code>pkgname</code> must be declared within 10 lines of the top of the PKGBUILD - so '''DO NOT''' move it - just leave it.<br><br />
If you miss this simple instruction don't worry, it won't screw up your build but your PKGBUILD file will not have the pkgname automatically updated at the end of the build. This is to allow you to use gensync correctly BUT you can edit the PKGBUILD file manually afterwards of course.<br />
<br />
* Until you have your own config that you are happy with it is easiest just to start with the default Arch config; you should also get the Arch <code>kernel26.install</code> file, make your own <code>kernel26.install</code> script or comment out the line <code>install=kernel26.install</code> from the PKGBUILD. The official Arch files are both in your ABS tree, normally under <code>/var/abs/kernels/kernel26</code>. To download the ABS tree to your system simply run <code>abs</code> as root. It doesn't take long, even on dialup. You should keep this updated by running <code>abs</code> as root on a regular basis.<br />
:NOTE: If you use Lilo or any other static bootloader you are adviced to use an install file to, at least, remember yourself to update your bootloader after the installation of your bootloader. This is an example <code>kernel26.install</code> for use with Lilo:<br />
<br />
# arg 1: the new package version<br />
# arg 2: the old package version<br />
<br />
# Script by Jouke Witteveen (j <dot> witteveen <at> gmail)<br />
# Revision: 4<br />
<br />
link () {<br />
dialog --backtitle &quot;$ba&quot; --title Linking --yesno<br />
&quot;\nDo you want to link /vmlinuz to the $ke kernel?\n(This can be useful for configuring your bootloader)&quot; 9 60 &&{<br />
[ -e /vmlinuz -o -h /vmlinuz ] &&\<br />
mv -f /vmlinuz /vmlinuz.old<br />
kern () {<br />
ls -t /boot/vmlinuz$1* 2> /dev/null | head -n 1<br />
}<br />
vm=`kern \`echo $1 | sed &quot;s|\.||g&quot;\``<br />
[ ! -e &quot;$vm&quot; ] &&\<br />
vm=`kern`<br />
ln -s $vm /vmlinuz<br />
}<br />
}<br />
<br />
exec () {<br />
dialog --backtitle &quot;$ba&quot; --title &quot;Bootloader execution&quot; --yesno<br />
&quot;\nDo you want to run Lilo to make the $ke kernel bootable?\n\n\<br />
Remember: If you choose 'No' now you will not be able to boot the $ke kernel until you manually update your bootloader!&quot; 12 60 &&\<br />
lilo &&\<br />
echo -e $1 # At least Lilo did not return an error<br />
}<br />
<br />
warn () {<br />
dialog --backtitle &quot;$ba&quot; --title Warning --msgbox<br />
&quot;\nYou will not be able to boot the $ke kernel until you manually update your bootloader.&quot; 9 60<br />
}<br />
<br />
<br />
post_install () {<br />
ba=&quot;Installing kernel $1&quot;<br />
ke=&quot;new&quot;<br />
link $1 &&\<br />
exec &quot;\nKernel $1 successfully installed!\n&quot; ||\<br />
warn<br />
}<br />
<br />
post_upgrade () {<br />
ba=&quot;Upgrading kernel $2 to kernel $1&quot;<br />
ke=&quot;upgraded&quot;<br />
link $1<br />
exec &quot;\nKernel $2 successfully upgraded to version $1!\n&quot; ||\<br />
warn<br />
}<br />
<br />
post_remove () {<br />
unli () {<br />
[ -h $1 -a ! -e $1 ] &&\<br />
unlink $1<br />
}<br />
unli /vmlinuz<br />
unli /vmlinuz.old<br />
[ -e /vmlinuz.old -a ! -e /vmlinuz ] &&{<br />
ba=&quot;Removing kernel $1&quot;<br />
ke=&quot;old&quot;<br />
mv /vmlinuz.old /vmlinuz<br />
exec &quot;\nThe old kernel was successfully restored\n&quot; ||\<br />
warn<br />
}<br />
}<br />
<br />
<br />
op=$1<br />
shift<br />
<br />
$op $*<br />
<br />
<br />
* To check if <code>EXTRAVERSION</code> is set by your patchset try doing<br />
<br />
grep +EXTRAVERSION= ./patchname<br />
<br />
: and it should return something like this:<br />
<br />
+EXTRAVERSION = -ck3<br />
<br />
: if it doesn't then <code>EXTRAVERSION</code> is '''probably not being set''' by your patchset and you should ensure you use LOCALVERSION to customize the pkgname.<br>Arch default kernels are set with the <code>-ARCH</code> <code>LOCALVERSION</code> variable - you can set anything you like e.g. <code>-custom</code> (note the need for the preceding dash <code>-</code>)<br>Because of these added variables there is no need to alter the pkgname manually at any point or use any other variables. The build process automatically updates the pkgname variable in the PKGBUILD file at the end of each build to reflect the final full kernel version naming scheme.<br />
<br />
* If used correctly this PKGBUILD '''should''' always provide a unique kernel build based on EXTRAVERSION and LOCALVERSION, and on the pkgver and pkgrel (as normal) - however it is up to the user to '''double check''' resulting pkgnames and contents '''before''' installation to prevent overwrites (see below for more details and examples).<br />
<br />
=== Configuring the PKGBUILD ===<br />
Copy the PKGBUILD below to your $startdir. The PKGBUILD can also be downloaded from [http://dtw.jiwe.org/share/kernel/PKGBUILDS/PKGBUILD.custom_kernel here]. Before building remember the following:<br />
# <code>pkgname</code> can be left as it is; it will automatically be set and correct itself.<br />
# Insert the <code>pkgver</code> for your kernel (for example: <code>2.6.9</code>).<br />
# Change the <code>pkgrel</code> for your current revision. You should increment this each time you make changes to the kernel config and want to build a REPLACEMENT pkg. If you don't want to replace the previous build but rather install in parallel you should use <code>LOCALVERSION</code> to create a unique pkg.<br />
# Change/expand the <code>pkgdesc</code> to describe any patches or special config options applied.<br />
# Change the source to use a closer mirror and if you are using a patchset, add the patches to the source array.<br />
# {OPTIONAL} Place the patch commands where indicated.<br />
# Choose a make method by leaving your preferred method uncommented - gconfig (gtk based) xconfig (qt based) menuconfig (ncurses based).<br />
# During the build you will be asked if you want to <code>make clean</code> - the default is <code>yes</code>, reply <code>NO</code> if you know what you are doing.<br />
<br />
<pre><br />
# Contributor: dibblethewrecker <dibblethewrecker.at.jiwe.org><br />
pkgname=kernel26<br />
pkgver=2.6.x.y<br />
pkgrel=1<br />
pkgdesc=&quot;The Linux Kernel 2.6.x.y and modules (IDE support)&quot;<br />
url=&quot;http://www.kernel.org&quot;<br />
depends=('module-init-tools')<br />
install=kernel26.install<br />
arch=(i686 x86_64)<br />
license=('GPL')<br />
<br />
##### add any patch sources to this section<br />
source=(config ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$pkgver.tar.bz2 )<br />
<br />
# Function to grab var from src<br />
getvar() {<br />
old=$(cat Makefile | grep &quot;^$1&quot;)<br />
echo $(echo ${old/&quot;$1 =&quot;/} | sed -e &quot;s/[ ]*\(.*\)[ ]*/\1/g&quot;)<br />
return 0<br />
}<br />
<br />
build() {<br />
cd $startdir/src/linux-$pkgver<br />
<br />
##### Uncomment and apply any patches here<br />
#patch -Np1 -i ../patchname || return 1<br />
<br />
# get rid of the 'i' in i686<br />
carch=`echo $CARCH | sed 's|i||'`<br />
cat ../config | sed &quot;s|#CARCH#|$carch|g&quot; >./.config<br />
<br />
##### Load config - uncomment your preferred config method<br />
#yes &quot;&quot; | make config<br />
#make oldconfig || return 1<br />
#make menuconfig<br />
#make xconfig<br />
make gconfig<br />
<br />
##### NO USER CHANGES BELOW HERE #####<br />
<br />
# save the current pkgname<br />
old_pkgname=$pkgname<br />
<br />
# set pkgname for build purposes - DO NOT alter!<br />
pkgname=kernel26<br />
<br />
# save the updated config to build with today's date<br />
cp ./.config $startdir/config-$(date +%b%d\-%Hh)<br />
<br />
# get EXTRAVERSION from Makefile to create a unique pkgname and /usr/src directory<br />
_kernextra=$(getvar &quot;EXTRAVERSION&quot;)<br />
# grab the 2.6.x.y version suffix from pkgver<br />
_y=&quot;`echo $pkgver | cut --delim &quot;.&quot; --fields 4`&quot;<br />
# remove .y version suffix from _kernextra<br />
_kernextra=&quot;`echo $_kernextra | sed &quot;s|\.$_y||g&quot;`&quot;<br />
<br />
# Read the full kernel version info from new config to use in pathnames and pkgname<br />
. ./.config<br />
<br />
# Kernel custom - to create a unique pkgname (see below)<br />
_kerncust=&quot;${_kernextra}${CONFIG_LOCALVERSION}&quot;<br />
# Kernel release - will be the same as Makefile<br />
_kernrel=&quot;${pkgver}${_kerncust}&quot;<br />
# Get the pkgver suffix for unique pkgname and /boot file suffices<br />
_pkgversuf=&quot;`echo $pkgver | sed &quot;s|2.6.||g&quot; | sed &quot;s|\.||g&quot;`&quot;<br />
# Set /boot file suffices from kernel release and pkgver suffix<br />
_kernboot=&quot;${_pkgversuf}${_kerncust}&quot;<br />
<br />
# Set a new pkgname from kernel release and pkgver suffix<br />
pkgname=&quot;${pkgname}${_pkgversuf}${_kerncust}&quot;<br />
<br />
# build!<br />
echo<br />
echo -n &quot;Do you want to make clean (default YES)? (YES/NO): &quot;<br />
read choice<br />
echo<br />
echo -n &quot;Press any key to start make or CTRL+C to quit&quot;<br />
read anykey<br />
<br />
if [ &quot;${choice}&quot; = &quot;NO&quot; ] ; then<br />
make bzImage modules || return 1<br />
else<br />
make clean bzImage modules || return 1<br />
fi<br />
<br />
mkdir -p $startdir/pkg/{lib/modules,boot}<br />
make INSTALL_MOD_PATH=$startdir/pkg modules_install || return 1<br />
cp System.map $startdir/pkg/boot/System.map26${_kernboot}<br />
cp arch/i386/boot/bzImage $startdir/pkg/boot/vmlinuz26${_kernboot}<br />
install -D -m644 Makefile \<br />
$startdir/pkg/usr/src/linux-${_kernrel}/Makefile<br />
install -D -m644 kernel/Makefile \<br />
$startdir/pkg/usr/src/linux-${_kernrel}/kernel/Makefile<br />
install -D -m644 .config \<br />
$startdir/pkg/usr/src/linux-${_kernrel}/.config<br />
install -D -m644 .kernelrelease \<br />
$startdir/pkg/usr/src/linux-${_kernrel}/.kernelrelease<br />
install -D -m644 .config $startdir/pkg/boot/kconfig26${_kernboot}<br />
mkdir -p $startdir/pkg/usr/src/linux-${_kernrel}/include<br />
mkdir -p $startdir/pkg/usr/src/linux-${_kernrel}/arch/i386/kernel<br />
for i in acpi asm-generic asm-i386 config linux math-emu media net pcmcia scsi sound video; do<br />
cp -a include/$i $startdir/pkg/usr/src/linux-${_kernrel}/include/<br />
done<br />
# copy files necessary for later builds, like nvidia and vmware<br />
cp Module.symvers $startdir/pkg/usr/src/linux-${_kernrel}<br />
cp -a scripts $startdir/pkg/usr/src/linux-${_kernrel}<br />
mkdir -p $startdir/pkg/usr/src/linux-${_kernrel}/.tmp_versions<br />
cp arch/i386/Makefile $startdir/pkg/usr/src/linux-${_kernrel}/arch/i386/<br />
cp arch/i386/Makefile.cpu $startdir/pkg/usr/src/linux-${_kernrel}/arch/i386/<br />
cp arch/i386/kernel/asm-offsets.s \<br />
$startdir/pkg/usr/src/linux-${_kernrel}/arch/i386/kernel/<br />
# copy in Kconfig files<br />
for i in `find . -name &quot;Kconfig*&quot;`; do<br />
mkdir -p $startdir/pkg/usr/src/linux-${_kernrel}/`echo $i | sed 's|/Kconfig.*||'`<br />
cp $i $startdir/pkg/usr/src/linux-${_kernrel}/$i<br />
done<br />
cd $startdir/pkg/usr/src/linux-${_kernrel}/include && ln -s asm-i386 asm<br />
chown -R root.root $startdir/pkg/usr/src/linux-${_kernrel}<br />
cd $startdir/pkg/lib/modules/${_kernrel} && \<br />
(rm -f source build; ln -sf /usr/src/linux-${_kernrel} build)<br />
<br />
# Correct the pkgname in our PKGBUILD - this allows correct gensync operation<br />
# NOTE: pkgname variable must be declared with first 10 lines of PKGBUILD!<br />
cd $startdir<br />
sed -i &quot;1,11 s|pkgname=$old_pkgname|pkgname=$pkgname|&quot; ./PKGBUILD<br />
}<br />
# vim:syntax=sh<br />
</pre><br />
<br />
* Install your new pkg as normal.<br />
<br />
=== Your <code>config</code> file ===<br />
PLEASE NOTE: during the build the '''final''' kernel config is stored in your <code>$startdir</code> as, for example, <code>config-Apr13-12h</code>. Your '''original''' config remains in the <code>$startdir</code> named <code>config</code>. If you wish to use the new config in another build make sure you copy the correct file!<br />
<br />
===Update Bootloader===<br />
* Remember to edit the [[LILO]] or [[GRUB]] configuration files to include an entry to the new kernel. The new kernel will install alongside any existing stock or custom kernels, so you may wish to keep a reference to your old kernel in the bootloader config file, at least until you know the new one is working. THIS IS STRONGLY RECOMMENDED!<br />
<br />
* If you use lilo remember to run <code>lilo</code> to update it.<br />
<br />
=== Other versions ===<br />
There are several variations on this PKGBUILD available, they all provide identical results but the mechanics are slightly different:<br />
* [http://dtw.jiwe.org/share/kernel/PKGBUILDS/PKGBUILD.custom_kernel_patch patch] - includes the old <code>patch=</code> variable.<br />
* [http://dtw.jiwe.org/share/kernel/PKGBUILDS/PKGBUILD.custom_kernel_verbose verbose] - provides Package Info (like that shown above) for review before starting the make process.<br />
* [http://dtw.jiwe.org/share/kernel/PKGBUILDS/PKGBUILD.custom_kernel_buildstats buildstats] - similar to verbose but writes more info, including build times, to a file called buildstats, which is stored in the $startdir. This can also be reviewed before starting the make process but also provides a permanent record.<br />
<br />
=== I want the Arch logo! ===<br />
Download the <code>logo_linux_clut224.ppm</code> to your <code>$startdir</code> from:<br />
<br />
[http://projects.archlinux.org/?p=linux-2.6-ARCH.git;a=tree;f=patches http://projects.archlinux.org/?p=linux-2.6-ARCH.git;a=tree;f=patches]<br />
<br />
Add the the file <code>logo_linux_clut224.ppm</code> to the source array, and add the copy command marked with (<code>>></code>) below into the PKGBUILD as indicated:<br />
<br />
<pre><br />
##### Uncomment and apply any patches here<br />
#patch -Np1 -i ../patchname || return 1<br />
<br />
>> ##### Arch logo - not compatible with gensplash!<br />
>> cp ../logo_linux_clut224.ppm drivers/video/logo/<br />
<br />
# get rid of the 'i' in i686<br />
carch=`echo $CARCH | sed 's|i||'`<br />
cat ../config | sed &quot;s|#CARCH#|$carch|g&quot; >./.config<br />
</pre><br />
<br />
The stock Arch config uses the following logo settings, ensure you set them at the config stage or use the stock config:<br />
<br />
<pre><br />
#<br />
# Logo configuration<br />
#<br />
CONFIG_LOGO=y<br />
CONFIG_LOGO_LINUX_MONO=y<br />
CONFIG_LOGO_LINUX_VGA16=y<br />
CONFIG_LOGO_LINUX_CLUT224=y<br />
</pre><br />
<br />
=== Customization and Advanced Use (normal people can stop here) ===<br />
Several people have successfully customized this PKGBUILD to their own needs, while others have derived a completely new approach from it. One customization recommended to people who make multiple builds of the same version for use in parallel is to add a sed command that automatically sets the <code>CONFIG_LOCALVERSION</code> variable in the config to a unique value before the config stage. This can be based on the date, your hostname, etc.<br />
For example:<br />
<pre><br />
# get rid of the 'i' in i686<br />
carch=`echo $CARCH | sed 's|i||'`<br />
cat ../config | sed &quot;s|#CARCH#|$carch|g&quot; >./.config<br />
<br />
>> # set LOCALVERSION to -date<br />
>> sed -i &quot;s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=-`date +%y%m%d`|g&quot; ./.config<br />
<br />
##### Load config - uncomment your preferred config method<br />
#yes &quot;&quot; | make config<br />
</pre><br />
<br />
or<br />
<br />
<pre><br />
# set LOCALVERSION to -date-hostname<br />
sed -i &quot;s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=-`date +%y%m%d`-`hostname`|g&quot; ./.config<br />
</pre><br />
<br />
For a truly unique <code>LOCALVERSION</code> you can set the date to seconds since <code>00:00:00 1970-01-01 UTC</code>!<br />
<br />
<pre><br />
sed -i &quot;s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=-`date +%s`|g&quot; ./.config<br />
</pre><br />
<br />
=== Problems ===<br />
<br />
If you have problems with wrong package names try using the [http://dtw.jiwe.org/share/kernel/PKGBUILDS/PKGBUILD.custom_kernel_verbose verbose] PKGBUILD described in [[Custom_Kernel_Compilation_with_ABS#Other_versions|Other Versions]] above to see what naming scheme is being created before you commit to the build - you can quit with ''ctrl+c'' at most points before the make starts.<br />
<br />
=== Using the nVIDIA video driver with your custom kernel ===<br />
<br />
To use the nvidia driver with your new custom kernel, see: [http://wiki.archlinux.org/index.php/NVIDIA#How_to_install_NVIDIA_Driver_with_custom_kernel How to install nVIDIA driver with custom kernel]<br />
<br />
=== Feedback ===<br />
If you have any questions/comments/suggestions about the above PKGBUILD feel free to join the discussion at: http://bbs.archlinux.org/viewtopic.php?t=9272<br />
<br />
Some suggestions have already been incorporated but please consider the Keep It Simple philosophy and remember the original goal. Kernel compilation is a very individual process and there are a HUGE variety of ways to go about it. This PKGBUILD does not even attempt to account for all eventualities, it would be fruitless to try but of course you are completely free to customize this build to your precise needs. Best of luck!<br />
<br />
''DibbleTheWrecker''</div>Wide-eyehttps://wiki.archlinux.org/index.php?title=Mkinitcpio&diff=34679Mkinitcpio2008-01-06T08:01:32Z<p>Wide-eye: added rootdalay option</p>
<hr />
<div>{{Article summary start}}<br />
{{Article summary text|mkinitcpio configuration manual}}<br />
{{Article summary heading|Available in languages}}<br />
{{i18n_entry|English|:Configuring_mkinitcpio}}<br />
{{i18n_entry|Русский|:Configuring_mkinitcpio(Russian)}}<br />
{{Article summary heading|Related articles}}<br />
{{Article summary end}}<br />
<br />
[[Category:Boot process (English)]]<br />
[[Category:Kernel (English)]]<br />
[[Category:HOWTOs (English)]]<br />
<br />
== About ==<br />
<br />
'''mkinitcpio''' is the next generation of '''initramfs creation'''. It has many advantages above the old '''mkinitrd''' and '''mkinitramfs''' scripts.<br />
<br />
* It uses '''klibc''' and '''kinit''' which are developed by Linux kernel devs to provide a small and lightweight base for early userspace.<br />
* It can use '''udev''' for hardware autodetection at runtime, thus prevents you from having tons of unnecessary modules loaded.<br />
* Its hook-based init script is easily extendable with custom hooks, which can easily be included in pacman packages without having to modifiy mkinitcpio itself.<br />
* It already supports '''lvm2''', '''dm-crypt''' for both legacy and luks volumes, '''raid''', '''swsusp''' and '''suspend2''' resuming and booting from '''usb mass storage''' devices.<br />
* Many features can be configured from the kernel command line without having to rebuild the image.<br />
* The '''mkinitcpio''' script makes it possible to include the image in a kernel, thus making a self-contained kernel image is possible.<br />
<br />
'''mkinitcpio''' has been developed by '''phrakture''' and '''tpowa''' with some help from the community.<br />
<br />
== Installing mkinitcpio ==<br />
=== From the [core] repository ===<br />
<br />
The '''mkinitcpio''' script can be found in the [core] repository. You can install with the command<br />
# pacman -Sy mkinitcpio<br />
<br />
=== From svn ===<br />
<br />
If you want the latest development version of '''mkinitcpio''', check out phrakture's svn repository using<br />
# svn co http://phraktured.net/initramfs<br />
The newest scripts are now in the '''initramfs/mkinitcpio''' directory.<br />
<br />
== Activation for >=2.6.17 kernels ==<br />
There will be 2 images created during kernel installation/upgrade:<br />
<br />
If you are using '''kernel26'''<br />
/boot/kernel26.img --> stripped down in size by autodetect<br />
/boot/kernel26-fallback.img --> contains all modules of subsystems<br />
If you are using '''kernel26beyond'''<br />
/boot/kernel26beyond.img --> stripped down in size by autodetect<br />
/boot/kernel26beyond-fallback.img --> contains all modules of subsystems<br />
Please change your bootloader to load the image you need.<br />
<br />
=== ATTENTION: ===<br />
==== => '''lvm2''', '''raid''' and '''encrypt''' are NOT enabled by default ====<br />
'''lvm2''', '''raid''' and '''encrypt''' are not! enabled by default.<br />
Please read this wiki carefully on how to setup those stuff, and configure it <br />
for your system.<br />
<br />
==== => Users with more than 1 hardware disk controller ====<br />
If you have more than one hardware disk controller which uses the same node names (like 2 SCSI/SATA or IDE controllers) and need different kernel modules to load them, please specify the correct order in MODULES="" in /etc/mkinitcpio.conf and in your fallback config file, else it could happen that your root device keeps on switching and you could run into random kernel panics.<br />
<br />
A more elegant alternative is to use [[Persistent block device naming]] to ensure that the right devices are mounted.<br />
<br />
==== Known modules that are not autoloaded during boot process ====<br />
If you need one of the following modules for your root device, consider to load them by MODULES="" in /etc/mkinitcpio.conf and in your fallback config file, else your kernel panics during boot.<br />
<br />
- '''SCSI CONTROLLERS''' (status stock kernel 2.6.18)<br />
scsi_transport_sas ultrastor qlogicfas eata BusLogic pas16 wd7000 sym53c416<br />
g_NCR5380_mmio fdomain u14-34f dtc initio in2000 imm t128 aha1542 aha152x<br />
atp870u g_NCR5380 NCR53c406a qlogicfas408 megaraid_mm advansys<br />
<br />
=== Customizing the Configuration Files ===<br />
<br />
=== '''Modifying main image''' ===<br />
To change the defaults for the main image edit the following file:<br />
<br />
/etc/mkinitcpio.conf<br />
<br />
mkinitcpio uses this file by default.<br />
<br />
=== '''Modifying fallback image''' ===<br />
To change the defaults for the fallback images, edit one of the following files:<br />
if you use kernel26, edit '''/etc/mkinitcpio.d/kernel26-fallback.conf'''<br />
if you use kernel26beyond, edit '''/etc/mkinitcpio.d/kernel26beyond-fallback.conf'''<br />
and set the file that you edited to '''NoUpgrade =''' in '/etc/pacman.conf'. Note that these should be sane unless you require a special setup such as lvm or raid.<br />
<br />
=== Configuring the HOOKS ===<br />
<br />
This is the most important part of mkinitcpio configuration. The HOOKS line contains the hooks that are executed on image creation and on runtime in the exact order they are executed. The format is like this:<br />
<br />
HOOKS="foo1 foo2 foo3 bar1 bar2"<br />
<br />
==== Available hooks ====<br />
<br />
{| border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border-style:solid; border-width:1px; border-collapse:collapse; empty-cells:show"<br />
|-<br />
! Hook || Installation || Runtime<br />
|-<br />
| '''base''' || Sets up all initial directories and installs base klibc utilities and libraries. Always add this hook unless you know what you are doing. || <br />
|-<br />
| '''udev''' || Adds udev to your image || Udev will be used to create your root device node and detect the needed modules for your root device. As it simplifies things, using the udev hook is recommended.<br />
|-<br />
| '''modload''' || || An alternative autodetecion method which is much slower than udev. Using this hook is discouraged. Use udev instead.<br />
|-<br />
| '''autodetect''' || Shrinks your initramfs to a smaller size by autodetecting your needed modules. Be sure to verify included modules are correct and none are missing. This hook must be run before other subsystem hooks in order to take advantage of auto-detection. Any hooks placed before 'autodetect' will be installed in full. || <br />
|-<br />
| '''ide''' || Adds IDE modules to the image. Use this if your root device is on a IDE disk. Also use the '''autodetect''' hook if you want to minimize your image size || Loads IDE modules. You will need the '''udev''' or '''modload''' hook unless you specify the needed modules manually (see MODULES section below).<br />
|-<br />
| '''pata''' || Adds IDE modules to the image. Use this if your root device is on a IDE disk. Also use the '''autodetect''' hook if you want to minimize your image size || Loads IDE modules. You will need the '''udev''' or '''modload''' hook unless you specify the needed modules manually (see MODULES section below). PATA is the kernel's new IDE driver. It will change your /dev/hd? to /dev/sd?. more info: http://archlinux.org/news/272/<br />
|-<br />
| '''sata''' || Adds serial ATA modules to the image. Use this if your root device is on a SATA disk. Also use the '''autodetect''' hook if you want to minimize your image size. || Loads SATA modules. You will need the '''udev''' or '''modload''' hook unless you specify the needed modules manually (see MODULES section below).<br />
|-<br />
| '''scsi''' || Adds SCSI modules to the image. Use this if your root device is on a SCSI disk. Also use the '''autodetect''' hook if you want to minimize your image size. || Loads SCSI modules. You will need the '''udev''' or '''modload''' hook unless you specify the needed modules manually (see MODULES section below).<br />
|-<br />
| '''usb''' || Adds USB modules to the image. Use this if your root device is on a USB mass storage device. || Loads USB modules. You will need the '''udev''' or '''modload''' hook unless you specify the needed modules manually (see MODULES section below).<br />
|-<br />
| '''usbinput''' || Adds USB HID modules to the image. Use this if you have an USB keyboard and need it in early userspace (either for entering encryption passphrases or for failsafe mode) || Loads USB HID modules. You will need the '''udev''' or '''modload''' hook unless you specify the needed modules manually (see MODULES section below).<br />
|-<br />
| '''fw''' || Adds Firewire modules to the image. Use this if your root device is on a FW mass storage device. || Loads FW modules. You will need the '''udev''' or '''modload''' hook unless you specify the needed modules manually (see MODULES section below).<br />
|-<br />
| '''net''' || Adds the necessary modules for a network device. For pcmcia net devices please add pcmcia hook too. || Loads network modules. You will need the '''udev''' or '''modload''' hook unless you specify the needed modules manually (see MODULES section below). See the section [[Configuring_mkinitcpio#Customizing_the_kernel_command_line|Customizing the kernel command line]] for further configuration.<br />
|-<br />
| '''pcmcia''' || Adds the necessary modules for pcmcia devices. You need to have pcmciautils installed to use this.|| Loads pcmcia modules. You will need the '''udev''' or '''modload''' hook unless you specify the needed modules manually (see MODULES section below).<br />
|-<br />
| '''dsdt''' || Loads a custom acpi dsdt file during boot. Place your custom dsdt file for inclusion at /lib/initcpio/custom.dsdt || The custom dsdt file is automatically used by the kernel if it is present in initramfs.<br />
|-<br />
| '''filesystems''' || This includes necessary filesystem modules into your image. This hook is necessary if you want to be able to boot || This will detect the filesystem type at runtime, load the module and pass it to kinit. NOTE: it will NOT detect reiser4, it must be added to modules list.<br />
|-<br />
| '''lvm2''' || Adds the device mapper kernel module and the lvm tool to the image. You need to have the lvm2 package installed to use this. || Enables all lvm2 volume groups. This is necessary if you have your root filesystem on lvm.<br />
|-<br />
| '''raid''' || Adds the modules and mdassamble for a software raid setup. You need to have mdadm installed to use this.|| Loads the necessary modules for software raid devices, and assembles the raid devices when run. See the section [[Configuring_mkinitcpio#Customizing_the_kernel_command_line|Customizing the kernel command line]] for further configuration.<br />
|-<br />
| '''encrypt''' || Adds the dm-crypt kernel module and the cryptsetup tool to the image. You need to have the cryptsetup package installed to use this. || Detects and unlocks an encrypted root partition. See the section [[Configuring_mkinitcpio#Customizing_the_kernel_command_line|Customizing the kernel command line]] for further configuration.<br />
|-<br />
| '''resume''' || || This tries to resume from "suspend to disk" state. Works with both swsusp and [[Suspend to Disk|suspend2]]. See the section [[Configuring_mkinitcpio#Customizing_the_kernel_command_line|Customizing the kernel command line]] for further configuration.<br />
|-<br />
| '''firmware''' || Adds /lib/firmware files. || Loads firmware. You will need the '''udev''' hook to get firmware loaded. <br />
|-<br />
| '''keymap''' || Adds keymap and consolefonts from rc.conf. || Loads the specified keymap and consolefont from rc.conf during early userspace.<br />
|}<br />
<br />
==== Examples ====<br />
<br />
This configuration will work for most users with a standard setup:<br />
<br />
HOOKS="base udev autodetect ide scsi sata filesystems"<br />
<br />
If you want to use the image on more than one machine, use this configuration:<br />
<br />
HOOKS="base udev ide scsi sata filesystems"<br />
<br />
You can use encrypted volumes on top of lvm2 volume groups:<br />
<br />
HOOKS="base udev autodetect ide scsi sata lvm2 encrypt filesystems"<br />
<br />
=== Configuring the MODULES ===<br />
<br />
You can use the MODULES in the configuration file to load a module before anything else is done. For example, if you don't want to use '''udev''' or '''modload''', you can add all necessary modules manually and make booting faster:<br />
<br />
MODULES="piix ide_disk reiserfs"<br />
HOOKS="base autodetect ide filesystems"<br />
<br />
NOTE: if you're using '''reiser4''', you MUST add it to the modules list.<br />
<br />
=== Configuring the BINARIES and FILES ===<br />
<br />
These options allow you to add files to the image. The only difference is that BINARIES checks binaries and libraries for dependencies, while FILES simply adds the file.<br />
<br />
Examples:<br />
<br />
FILES="/etc/modprobe.conf"<br />
<br />
BINARIES="/usr/bin/somefile"<br />
<br />
== Creating the image ==<br />
<br />
=== Regenerating predefined images / using presets ===<br />
<br />
If you want to regenerate your initramfs images for the Archlinux stock kernels, use the command<br />
# mkinitcpio -p kernel26<br />
This example is for the ''kernel26'' package, it works the same for the other kernel packages.<br />
<br />
If you want to change the settings for your images, edit the ''/etc/mkinitcpio.d/kernel26.preset'' file (again, just change the filename for the other kernel packages). '''These ''.preset'' files will be used on a kernel update, so don't break them.'''<br />
<br />
=== Manually ===<br />
<br />
Create the image with the following command:<br />
<br />
mkinitcpio -g /boot/kernel26.img<br />
<br />
This will generate the image for the currently running kernel and save it at '''/boot/kernel26.img''', which is the location for '''kernel26''' package. Users of '''kernel26beyond''' should use the following instead:<br />
<br />
mkinitcpio -g /boot/kernel26beyond.img<br />
<br />
If you are creating an image for a kernel other than the one you are currently running, add the kernel version to the command line:<br />
<br />
mkinitcpio -g /boot/kernel26.img -k 2.6.16-ARCH<br />
<br />
==== Regenerating the Fallback Image ====<br />
<br />
''NOTE:'' The following may confuse some people. It is only intended to help create fallback images for people already running the current kernel. To create images for any kernel that is not currently running, you MUST use the -k parameter.<br />
<br />
A fallback image should have been created when you installed '''kernel26''' or '''kernel26beyond''' but in case you want to re-generate it<br />
<br />
mkinitcpio -c /etc/mkinitcpio.d/kernel26-fallback.conf -g /boot/kernel26-fallback.img<br />
for beyond<br />
mkinitcpio -c /etc/mkinitcpio.d/kernel26beyond-fallback.conf -g /boot/kernel26beyond-fallback.img<br />
<br />
See '''mkinitcpio -h''' for more options.<br />
<br />
Don't forget to add a new bootloader entry. Just make a copy of your old one and change the initrd to your new image. As long as mkinitcpio is beta, please always leave the old one intact, so that you can boot it if something goes wrong. You can use mkinitcpio with any kernel, so kernel26 and kernel26-beyond users are encouraged to try it.<br />
<br />
== Customizing the kernel command line ==<br />
<br />
Just like without initramfs, some options need to be passed on the kernel command line to configure your kernel, like the root device. Some of the mkinitcpio hooks have special options. These are discussed below.<br />
<br />
If you don't know what a kernel command line is, please refer to the [[GRUB]] or [[Lilo]] documentation.<br />
<br />
=== Entering failsafe mode ===<br />
<br />
If you add the option<br />
break=y<br />
to the kernel command line, init stops after the setup is completed and you are left with a ''dash'' shell. This can be used to verify that everything went fine. If you logout, normal boot continues.<br />
<br />
=== Disabling hooks ===<br />
<br />
You can disable a hook at runtime by adding the ''disablehooks'' option to the kernel command line like this:<br />
<br />
disablehooks=hook1,hook2,hook2<br />
<br />
for example<br />
<br />
disablehooks=resume<br />
<br />
=== Blacklisting modules ===<br />
<br />
You can blacklist modules by adding the ''disablemodules'' option to the kernel command line like this:<br />
<br />
disablemodules=mod1,mod2,mod3<br />
<br />
for example<br />
<br />
disablemodules=ata_piix<br />
<br />
=== Using raid ===<br />
First add the raid hook to the HOOKS list in /etc/mkinitcpio.conf<br />
<br />
'''Kernel Parameters: '''<br />
Specify your md arrays with: md= parameter: (see below).<br />
Note that only adding the raid array you're booting from is enough.<br />
Example: md=0,/dev/sda3,/dev/sda4 md=1,/dev/hda1,/dev/hdb1<br />
<br />
Then add the following to the kernel line in '''grub/menu.lst''':<br />
Example: md=0,/dev/sda3,/dev/sda4 md=1,/dev/hda1,/dev/hdb1<br />
So that it looks like:<br />
kernel /vmlinuz26beyond root=/dev/md0 ro md=0,/dev/sda1,/dev/sdb1<br />
This will setup 2 md arrays with persistent superblocks<br />
<br />
'''Setup:'''<br />
- for old raid arrays without persistent superblocks:<br />
md=<md device no.>,<raid level>,<chunk size factor>,<fault level>,dev0,dev1<br />
- for raid arrays with persistent superblocks:<br />
md=<md device no.>,dev0,dev1,...,devn<br />
- for, to assemble a partitionable array:<br />
md=d<md device no.>,dev0,dev1,...,devn<br />
<br />
'''Parameters:'''<br />
- <md device no.> = the number of the md device: <br />
0 means md0, 1 means md1, ...<br />
- <raid level> = -1 linear mode, 0 striped mode<br />
other modes are only supported with persistent super block<br />
- <chunk size factor> = (raid-0 and raid-1 only):<br />
Set the chunk size as 4k << n.<br />
- <fault level> = totally ignored<br />
- <dev0-devn>: e.g. /dev/hda1,/dev/hdc1,/dev/sda1,/dev/sdb1<br />
<br />
=== Using net ===<br />
<br />
'''Kernel Parameters:''' <br />
<br />
'''ip=''' <br />
<br />
An interface spec can be either short form, which is just the name of<br />
an interface (eth0 or whatever), or long form. The long form consists<br />
of up to seven elements, separated by colons:<br />
<br />
ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf><br />
nfsaddrs= is an alias to ip= and can be used too.<br />
<br />
''Parameter explanation:''<br />
<client-ip> IP address of the client. If empty, the address will<br />
either be determined by RARP/BOOTP/DHCP. What protocol<br />
is used de- pends on the <autoconf> parameter. If this<br />
parameter is not empty, autoconf will be used.<br />
<br />
<server-ip> IP address of the NFS server. If RARP is used to<br />
determine the client address and this parameter is NOT<br />
empty only replies from the specified server are<br />
accepted. To use different RARP and NFS server,<br />
specify your RARP server here (or leave it blank), and<br />
specify your NFS server in the `nfsroot' parameter<br />
(see above). If this entry is blank the address of the<br />
server is used which answered the RARP/BOOTP/DHCP<br />
request.<br />
<br />
<gw-ip> IP address of a gateway if the server is on a different<br />
subnet. If this entry is empty no gateway is used and the<br />
server is assumed to be on the local network, unless a<br />
value has been received by BOOTP/DHCP.<br />
<br />
<netmask> Netmask for local network interface. If this is empty,<br />
the netmask is derived from the client IP address assuming<br />
classful addressing, unless overridden in BOOTP/DHCP reply.<br />
<br />
<hostname> Name of the client. If empty, the client IP address is<br />
used in ASCII notation, or the value received by<br />
BOOTP/DHCP.<br />
<br />
<device> Name of network device to use. If this is empty, all<br />
devices are used for RARP/BOOTP/DHCP requests, and the<br />
first one we receive a reply on is configured. If you<br />
have only one device, you can safely leave this blank.<br />
<br />
<autoconf> Method to use for autoconfiguration. If this is either<br />
'rarp', 'bootp', or 'dhcp' the specified protocol is<br />
used. If the value is 'both', 'all' or empty, all<br />
protocols are used. 'off', 'static' or 'none' means<br />
no autoconfiguration.<br />
''Examples:''<br />
ip=127.0.0.1:::::lo:none --> Enable the loopback interface.<br />
ip=192.168.1.1:::::eth2:none --> Enable static eth2 interface.<br />
ip=:::::eth0:dhcp --> Enable dhcp protocol for eth0 configuration.<br />
'''nfsroot='''<br />
<br />
If the 'nfsroot' parameter is NOT given on the command line, the default<br />
"/tftpboot/%s" will be used.<br />
<br />
nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]<br />
<br />
''Parameter explanation:''<br />
<br />
<server-ip> Specifies the IP address of the NFS server. If this field<br />
is not given, the default address as determined by the<br />
`ip' variable (see below) is used. One use of this<br />
parameter is for example to allow using different servers<br />
for RARP and NFS. Usually you can leave this blank.<br />
<br />
<root-dir> Name of the directory on the server to mount as root. If<br />
there is a "%s" token in the string, the token will be<br />
replaced by the ASCII-representation of the client's IP<br />
address.<br />
<br />
<nfs-options> Standard NFS options. All options are separated by commas.<br />
If the options field is not given, the following defaults<br />
will be used:<br />
port = as given by server portmap daemon<br />
rsize = 1024<br />
wsize = 1024<br />
timeo = 7<br />
retrans = 3<br />
acregmin = 3<br />
acregmax = 60<br />
acdirmin = 30<br />
acdirmax = 60<br />
flags = hard, nointr, noposix, cto, ac<br />
<br />
'''root=/dev/nfs'''<br />
If you don't use nfsroot= parameter you need to set root=/dev/nfs <br />
to boot from a nfs root by autoconfiguration.<br />
<br />
=== Using lvm ===<br />
<br />
If your root device is on lvm, you have to add the '''lvm2''' hook. You have to pass your root device on the kernel command line in the format<br />
<br />
root=/dev/mapper/<volume group name>-<logical volume name><br />
<br />
for example<br />
<br />
root=/dev/mapper/myvg-root<br />
<br />
=== Using encrypted root ===<br />
<br />
If your root volume is encrypted, you need to add the '''encrypt''' hook. Then specify your root device on the kernel command line, just as if it was unencrypted.<br />
<br />
For an encrypted partition on an sata or scsi disk:<br />
root=/dev/sda5<br />
<br />
For an encrypted lvm volume:<br />
root=/dev/mapper/myvg-root<br />
<br />
The root device will be automatically changed to ''/dev/mapper/root''.<br />
<br />
==== Using LUKS volumes ====<br />
<br />
If you use LUKS for hard disk encryption, the init script will detect the encryption automatically if the '''encrypt''' hook is enabled. It will then ask for a passphrase and try to unlock the volume.<br />
<br />
If this fails try to add you filesystem-module to the module list in /etc/mkinitcpio.conf if it's not compiled into your kernel.<br />
<br />
==== Using legacy cryptsetup volumes ====<br />
<br />
If you are using a legacy cryptsetup volume, you have to specify all cryptsetup options necessary to unlock it on the kernel command line. The option format is<br />
<br />
crypto=hash:cipher:keysize:offset:skip<br />
<br />
representing cryptsetup's --hash, --cipher, --keysize, --offset and --skip options. If you omit an option, cryptsetup's default value is used, so you can just specify<br />
<br />
crypto=::::<br />
<br />
if you created your volume with the default settings.<br />
<br />
'''NOTE:''' For technical reasons, it is not possible to verify the correctness of your passphrase with legacy cryptsetup volumes. If you typed it wrong, mounting will simply fail. It is recommended that you use LUKS instead.<br />
<br />
==== Using loop-aes volumes ====<br />
<br />
'''mkinitcpio''' does not support loop-aes yet.<br />
<br />
=== Add a Delay ===<br />
<br />
if you need to wait for a few seconds before mounting /. For example if you have a usb hard drive that takes a while to become ready. The example below will pause 8 seconds before continuing.<br />
<br />
rootdelay=8<br />
<br />
== Using Suspend to Disk ==<br />
<br />
If you want to use suspend to disk, you have to add the '''resume''' hook.<br />
<br />
==== swsusp ====<br />
<br />
''TODO''<br />
<br />
==== µswsusp ====<br />
<br />
µswsusp is not supported yet.<br />
<br />
==== suspend2 ====<br />
<br />
If you are using [[Suspend to Disk|suspend2]], you have to specify the ''resume2'' kernel commandline option. If you are using the swap writer, use<br />
<br />
resume2=swap:/dev/hda3<br />
<br />
where ''/dev/hda3'' is your swap partition. If you want to use the filewriter, use<br />
<br />
resume2=file:/dev/hda2:0x123456<br />
<br />
where ''/dev/hda2'' is the partition where the suspend2 image is stored (most likely the root partition) and ''0x123456'' is the file offset. You can get the exact value with the commands<br />
<br />
echo "/suspend2_file" > /proc/suspend2/filewriter_target<br />
cat /proc/suspend2/resume2<br />
<br />
where /suspend2_file is the path to your suspend image file. This - of course - works for lvm volumes as well. You can also use a suspend file on an encrypted root partition with the option<br />
<br />
resume2=file:/dev/mapper/root:0x123456<br />
<br />
where ''0x123456'' is the offset again. Resuming from an encrypted swap partition is not supported.<br />
<br />
=== Example bootloader configuration files ===<br />
<br />
If you use the beyond kernel, the filenames are ''kernel26beyond.img'' and ''kernel26beyond-fallback.img'' instead of ''kernel26.img'' and ''kernel26-fallback.img'', respectively. Also, change "vmlinuz26" to "vmlinuz26beyond". <br />
<br />
==== GRUB ====<br />
<br />
For those who have /boot on a separate partition:<br />
<br />
# (0) Arch Linux<br />
title Arch Linux<br />
root (hd0,3)<br />
kernel /vmlinuz26 root=/dev/hda4 vga=791 ro<br />
initrd /kernel26.img<br />
<br />
title Arch Linux Fallback<br />
root (hd0,3)<br />
kernel /vmlinuz26 root=/dev/hda4 vga=791 ro<br />
initrd /kernel26-fallback.img<br />
<br />
For those who do _not_ have /boot on a separate partition:<br />
<br />
# (0) Arch Linux<br />
title Arch Linux<br />
root (hd0,3)<br />
kernel /boot/vmlinuz26 root=/dev/hda4 vga=791 ro<br />
initrd /boot/kernel26.img<br />
<br />
title Arch Linux Fallback<br />
root (hd0,3)<br />
kernel /boot/vmlinuz26 root=/dev/hda4 vga=791 ro<br />
initrd /boot/kernel26-fallback.img<br />
<br />
==== LILO ====<br />
<br />
If you use LILO, it is recommended that you use ''append="root=/dev/XYZ"'' instead of ''root=/dev/XYZ''. If you already have a global ''append'' option, then use ''addappend''.<br />
<br />
boot=/dev/hdX <br />
default = ArchLinux<br />
timeout=50 <br />
vga=791<br />
lba32<br />
prompt<br />
<br />
# for the hardware-autodetecting image<br />
image=/boot/vmlinuz26<br />
label=ArchLinux<br />
append="root=/dev/hdXY"<br />
initrd=/boot/kernel26.img<br />
read-only<br />
<br />
# fallback image if the other doesnt work (Will most prob. never be used)<br />
image=/boot/vmlinuz26<br />
label=ArchLinuxFallBack<br />
append="root=/dev/hdXY"<br />
initrd=/boot/kernel26-fallback.img<br />
read-only<br />
<br />
== Troubleshooting ==<br />
=== piix ide controllers and beyond kernel ===<br />
==== Problem ====<br />
If you are having problems getting mkinitcpio to detect your hard drive giving errors akin to "Can't find device dev(0,0)" when switching to kinit, then this could be because of a conflict that the ata_piix and piix drivers have. The beyond kernel has some libata patches that cause ata_piix to *conflict* with piix.<br />
<br />
==== Solution ====<br />
Edit /etc/mkinitcpio.conf to only have ide or sata or scsi depending on what your system actually needs to boot.<br />
<br />
<br />
== Getting under the hood ==<br />
If you are curious about what is inside the initrd image you can extract it and poke at the files inside of it. it is a cpio archive but...<br />
=== Warning about cpio ===<br />
using cpio to extract an image is dangerous, as it likes to extract the image to /, rendering your system broken and unbootable. recovery involves reinstalling the packages that own the overwritten files with pacman.static. You MUST add --no-absolute-filenames option to your cpio command and make sure current directory is not "/".<br />
zcat /boot/kernel26.img | cpio -id --no-absolute-filenames<br />
A list of files can made with bsdtar -t -f kernel26.img<br />
=== using bsdtar to extract the image ===<br />
bsdtar is kind enough to extract to the current directory instead of hosing your system.<br />
<br />
bsdtar -x -f /boot/kernel26.img</div>Wide-eyehttps://wiki.archlinux.org/index.php?title=Talk:Mkinitcpio&diff=34676Talk:Mkinitcpio2008-01-06T04:37:27Z<p>Wide-eye: whywhywhy?</p>
<hr />
<div>wide-eye says: shouldn't the generic kernel options go into other pages? such as the "using net" "using lvm." also the copies of the grub/lilo pages should be elsewhere. they are just not part of the page subject. /me thinks a "Customizing the kernel command line" page is in order.</div>Wide-eyehttps://wiki.archlinux.org/index.php?title=Arch_IRC_channels&diff=33302Arch IRC channels2007-12-06T20:56:59Z<p>Wide-eye: /* Channel Statistics */ * poof * xtermin.us has been offline for a month now</p>
<hr />
<div>[[Category:About Arch (English)]]<br />
[[Category:General (English)]]<br />
<br />
The official Archlinux channel is '''#archlinux''' on '''[http://www.freenode.net/ irc.freenode.net]''' (what is [http://www.irchelp.org/ IRC]?).<br />
If you have questions that cannot be answered by [[Arch_Terminology/Jargon_for_newbies#RTFM|RTFM]], join '''#archlinux''' and ask there.<br />
<br />
If you like, stay some time to help others by answering some questions yourself. Or even stay permanently :-)<br />
<br />
Use the above shown connection data to join with any IRC-client like [http://www.irssi.org/ irssi], [http://www.xchat.org/ XChat],<br />
[http://www.pidgin.im/ Pidgin] or [http://www.hacksrus.com/~ginda/chatzilla/ ChatZilla]. We collect some fortunes on the [[Wall of Quotes]].<br />
<br />
== Channel Guidelines ==<br />
===after:===<br />
* When you've been served well, stay long & prosper to '''help others''' (in the channel and add to Wiki)!<br />
<br />
===before:===<br />
* Check '''google''', '''[http://bbs.archlinux.org the forums]''', '''[http://bugs.archlinux.org flyspray]''' and '''[[:Category:HowTos|The Wiki]]''' before you ask.<br />
* If you've '''already found''' the answers on your own by now, then '''tell us''' which docs helped you (not?).<br />
* Otherwise, if you want good & fast answers, ask '''[http://www.catb.org/~esr/faqs/smart-questions.html smart questions]'''<br />
** No mind-reading here, '''state most specifically''': expected result(s) first, the ones you get, and then '''all''' circumstantial info.<br />
** Quality of answer won't exceed quality of question, you decide how helpful you are to yourself.<br />
<br />
===while:===<br />
* This is an '''English language''' channel. If this does not suit you, there are a number of Arch channels available for other languages.<br />
* Just '''ask your stuff''', don't ask if we're "alive"!<br />
* '''Wait''' some time: eventually, someone will answer, don't count on instant reaction.<br />
* Be '''supportive''': we can't read minds, so be specific! See "smart-questions" above!<br />
** State your goal first, too, maybe you chose the wrong way.<br />
* Show '''commitment''': this is not a service hot-line, this is a do-it-yourself environment.<br />
** Look up references yourself, use existing docs, learn to help yourself.<br />
* Be '''patient''' (with yourself & fellows): answers are favors, not your right.<br />
** You are supposed to do the actual work, you get advice and pointers.<br />
<br />
* '''Don't flood''' the channel by pasting lots of lines (up to 4 lines is ok). If you have to paste a lot of lines:<br />
** use a '''nopaste'''-website and post the URL to '''#archlinux''' channel (eg. [http://pastebin.archlinux.org the archlinux pastebin]).<br />
** if you don't have X running, and got no cli browser installed, check out '''nopaste''' from the '''[community]''' repo.<br />
* Disable '''auto-away''' messages & '''nick-changes'''! Use the '''silent''' <tt>/away</tt> feature of your client manually, nothing else!<br />
* Last, but not least - keep it '''on topic'''. This is a support channel and nothing else!<br />
** This means: '''no flamewars''' and '''no distro-bashing'''. We respect our competition.<br />
<br />
As a bottom-line: if someone asks you to abide these rules, you better do it. Help to keep #archlinux a friendly and supportive place!<br />
<br />
== User Map ==<br />
<br />
* [[User:Brain0|Brain0]] maintains the [[ArchMap|ArchMap]] for Google Earth. Add yourself!<br />
<br />
== A typical #archlinux conversation?== <br />
To give you an example how a conversation should '''not''' be, have a look at the following. It depicts something that is actually happening. Do you want to be a part of ''this''? Wait, don't answer: it's a rhetorical question.<br />
<br />
benny> openbox <3<br />
wizzomafizzo> openbox <3<br />
wizzomafizzo> openbox > *<br />
benny> openbox > fluxbox > * > emacs<br />
wizzomafizzo> I HATE EMACS<br />
benny> emacs sucks<br />
benny> vim ftw<br />
benny> vim > nano > * > ed (HAHAHHAHA) > emacs<br />
wizzomafizzo> vim <3<br />
benny> ed is the standard editor.<br />
benny> emacs is a good OS<br />
benny> but it lacks a good text editor<br />
wizzomafizzo> I use nano for editing little config files and I only use vim for serious stuff, guys.<br />
benny> ruby ftw... perl sucks<br />
benny> cat /dev/urandom > test.pl; perl test.pl; echo $? => 0 hahahahhahaha<br />
wizzomafizzo> LOL<br />
benny> adobe photoshop cs3 > gimp<br />
wizzomafizzo> urxvt + irssi + screen + openbox + arch + kernel 2.6.22.21rc3 + X-svn ftw <3333333333333333333<br />
benny> does anyone have the latest wine-cvs, I need it for my business... I'm a lead webdeveloper for a big consultation company and I use photoshop cs3 on linux for optimal performance<br />
benny> irssi + screen <3<br />
wizzomafizzo> WTF WINE WAS RELEASED HALF AN HOUR AGO STILL NOT IN REPOS<br />
wizzomafizzo> WTF ARCH DEVS SUCK<br />
benny> WTF, when is kde4 in the repos?<br />
wizzomafizzo> omg arch so unstable they dont test packages!!!!!!!!!!!!<br />
wizzomafizzo> plz test pkgs more asrch<br />
benny> that pharmacist should STFU and drop kde so one wihht serious competence can take over<br />
wizzomafizzo> BBBBBBBBAAAAAAAAAAAAAAAAAAWWWWWWWWWWWWWWW<br />
benny> how do I update kernel?<br />
benny> WHY IS AUR NOT IN pacman!!!!<br />
benny> I packman -s motif-application and it says command not found: ARCH BROKEN, debian no problem! QUESTIONS!<br />
wizzomafizzo> I vote for yaourt and it never goes in community wtf??????<br />
wizzomafizzo> i'm using dpkg in arch so i don't waste all my debs<br />
benny> I install firefox, but I get bon echo. Arch bug, I demand fix immediately!<br />
wizzomafizzo> wtf i hate bon echo >_<<br />
benny> I can't browse with bon echo, what is this... some sort of joke?<br />
wizzomafizzo> i compile my own firefox<br />
benny> firefox <3, bon echo >3<br />
benny> why is swiftweasel not in the repos... I have optimal performance now!<br />
wizzomafizzo> guys i have legitimate problem with weechat<br />
wizzomafizzo> WEECHAT LOL<br />
wizzomafizzo> USE IRSSI</div>Wide-eyehttps://wiki.archlinux.org/index.php?title=Advanced_Linux_Sound_Architecture&diff=30532Advanced Linux Sound Architecture2007-10-10T23:05:08Z<p>Wide-eye: added "pops" powersave disabling section</p>
<hr />
<div>[[Category:Sound (English)]]<br />
[[Category:Audio/Video (English)]]<br />
[[Category:HOWTOs (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|ALSA Setup}}<br />
{{i18n_entry|Deutsch|ALSA Einrichten}}<br />
{{i18n_entry|Italiano|ALSA Setup (Italiano)}}<br />
{{i18n_entry|Nederlands|ALSA instellen}}<br />
{{i18n_entry|Русский|ALSA_(Russian)}}<br />
{{i18n_entry|Slovensky|Nastavenie ALSA}}<br />
{{i18n_entry|Česky|ALSA (Česky)}}<br />
{{i18n_entry|中文(简体)|设置ALSA}}<br />
{{i18n_entry|עברית|הגדרת ALSA}}<br />
{{i18n_entry|Рolski|ALSA Setup (Polski)}}<br />
{{i18n_entry|Português do Brasil|Instalação ALSA}}<br />
{{i18n_entry|ไทย|ALSA Setup (ไทย)}}<br />
{{i18n_links_end}}<br />
<br />
= Introduction =<br />
The Advanced Linux Sound Architecture (ALSA) is a Linux kernel component intended to replace the original Open Sound System ([[OSS]]) for providing device drivers for sound cards.<br />
<br />
This document tells how to get ALSA working with 2.6 kernels. Also see how to <br />
[[Allow_multiple_programs_to_play_sound_at_once|allow multiple programs to play sound at once]].<br />
<br />
=Installation=<br />
<br />
==Kernel drivers==<br />
<br />
ALSA has been included in the 2.6 kernels and is included in all arch '''kernel26*''' packages. If you build a custom kernel, do not forget to enable the correct ALSA driver.<br />
<br />
All necessary modules should be detected and loaded automatically by udev. No special configuration has to be done unless you use ISA cards. '''NEVER''' use alsaconf if you have a PCI or ISAPNP sound card, as the entries alsaconf adds to the modprobe.conf file might break udev's autodetection.<br />
<br />
==Userspace utilities==<br />
<br />
* Required for native ALSA programs and administration<br />
# pacman -Sy alsa-lib alsa-utils<br />
* Recommended if you want to use applications with OSS sound support in combination with dmix:<br />
# pacman -S alsa-oss<br />
<br />
All ALSA programs will most likely have alsa-lib as a dependency.<br />
<br />
=Configuration=<br />
<br />
==Making sure the sound modules are loaded==<br />
<br />
You can assume that udev will autodetect your sound properly, including the OSS compatibility modules. You can check this with the command<br />
<br />
$ lsmod|grep '^snd'<br />
snd_usb_audio 69696 0 <br />
snd_usb_lib 13504 1 snd_usb_audio<br />
snd_rawmidi 20064 1 snd_usb_lib<br />
snd_hwdep 7044 1 snd_usb_audio<br />
snd_seq_oss 29412 0 <br />
snd_seq_midi_event 6080 1 snd_seq_oss<br />
snd_seq 46220 4 snd_seq_oss,snd_seq_midi_event<br />
snd_seq_device 6796 3 snd_rawmidi,snd_seq_oss,snd_seq<br />
snd_pcm_oss 45216 0 <br />
snd_mixer_oss 15232 1 snd_pcm_oss<br />
snd_intel8x0 27932 0 <br />
snd_ac97_codec 87648 1 snd_intel8x0<br />
snd_ac97_bus 1792 1 snd_ac97_codec<br />
snd_pcm 76296 4 snd_usb_audio,snd_pcm_oss,snd_intel8x0,snd_ac97_codec<br />
snd_timer 19780 2 snd_seq,snd_pcm<br />
snd 43776 12 snd_usb_audio,snd_rawmidi,snd_hwdep,snd_seq_oss,snd_seq,snd_seq_device,snd_pcm_oss,snd_mixer_oss,snd_intel8x0,snd_ac97_codec,snd_pcm,snd_timer<br />
snd_page_alloc 7944 2 snd_intel8x0,snd_pcm<br />
<br />
If the output looks similar, your sound drivers have been successfully autodetected (note that in this case, snd_intel8x0 and snd_usb_audio are the drivers for the hardware devices). You might also want to check the directory '''/dev/snd''' for the right device files:<br />
<br />
$ ls -l /dev/snd/<br />
total 0<br />
crw-rw---- 1 root audio 116, 0 Apr 8 14:17 controlC0<br />
crw-rw---- 1 root audio 116, 32 Apr 8 14:17 controlC1<br />
crw-rw---- 1 root audio 116, 24 Apr 8 14:17 pcmC0D0c<br />
crw-rw---- 1 root audio 116, 16 Apr 8 14:17 pcmC0D0p<br />
crw-rw---- 1 root audio 116, 25 Apr 8 14:17 pcmC0D1c<br />
crw-rw---- 1 root audio 116, 56 Apr 8 14:17 pcmC1D0c<br />
crw-rw---- 1 root audio 116, 48 Apr 8 14:17 pcmC1D0p<br />
crw-rw---- 1 root audio 116, 1 Apr 8 14:17 seq<br />
crw-rw---- 1 root audio 116, 33 Apr 8 14:17 timer<br />
<br />
If you have at least the devices '''controlC0''' and '''pcmC0D0p''' or similar, then your sound modules have been detected and loaded properly.<br />
<br />
<br />
If this is not the case, your sound modules have not been detected properly. '''If you want any help on IRC or the forums, please post the output of the above commands.''' To solve this, you can try loading the modules manually:<br />
<br />
* Locate the module for your soundcard: http://www.alsa-project.org/alsa-doc/ The module will be prefixed with 'snd-' (for example: 'snd-via82xx').<br />
* Load modules:<br />
# modprobe snd-NAME-OF-MODULE<br />
# modprobe snd-pcm-oss<br />
* Check for the device files in '''/dev/snd''' (see above) and/or try if '''alsamixer''' or '''amixer''' have reasonable output.<br />
* Add '''snd-NAME-OF-MODULE''' and '''snd-pcm-oss''' to the list of MODULES in '''/etc/rc.conf''' to ensure they are loaded next time (make sure '''snd-NAME-OF-MODULE''' is before '''snd-pcm-oss''').<br />
<br />
==Unmuting the channels and testing the sound card==<br />
<br />
In this section, we assume that you are logged in as root. If you want to perform these steps as an unprivileged user, you have to skip to the next section ''Setup Permissions'' first.<br />
<br />
* Unmute Soundcard<br />
<br />
It is recommended to use 'alsamixer' to configure your mixer and unmute the channels.<br><br><br />
'''NOTE:''' When using '''amixer''', be sure to '''unmute''' as well as bring volumes up to a specific level in percent, i.e you need to use that % sign. '''amixer''' understands the percent sign (%), not numbers. If you use a number (say, 90) then '''amixer''' will take it as 100%, which can harm your speakers.<br />
<br />
# amixer set Master 90% unmute<br />
# amixer set PCM 85% unmute<br />
<br />
* Try to play a WAV file<br />
<br />
# aplay mywav.wav<br />
<br />
'''NOTE:''' Some cards (well, at least Soundblaster Audigy LS) needs to have digital output muted/turned off in order to hear analog sound.<br />
<br />
* [[Allow multiple programs to play sound at once]]<br />
<br />
==Setup Permissions==<br />
<br />
To be able to use the sound card as a user, follow these steps:<br />
<br />
* Add your user to the audio group:<br />
# gpasswd -a USERNAME audio<br />
<br />
* Log your user out and back in to ensure the audio group is loaded.<br />
<br />
==Restore ALSA Mixer settings at startup==<br />
<br />
* Run 'alsactl' once to create '/etc/asound.state'<br />
<br />
alsactl store<br />
<br />
* Edit '/etc/rc.conf' and add 'alsa' to the list of daemons to start on boot-up. This will store the mixer settings on every shutdown and restore them when you boot.<br />
<br />
==Getting SPDIF output==<br />
<br />
(from gralves from the Gentoo forums)<br />
* In GNOME Volume Control, under the Options tab, change the IEC958 to PCM. This option can be enabled in the preferences.<br />
* If you don't have GNOME Volume Control installed,<br />
** Edit /etc/asound.state. This file is where alsasound stores your mixer settings.<br />
** Find a line that says: 'IEC958 Playback Switch'. Near it you will find a line saying value:false. Change it to value:true.<br />
** Now find this line: 'IEC958 Playback AC97-SPSA'. Change its value to 0.<br />
** Restart ALSA.<br />
<br />
Alternative way to enable SPDIF output automatically on login (tested on SoundBlaster Audigy):<br />
* add following lines to /etc/rc.local:<br />
<br />
# Use COAX-digital output<br />
amixer set 'IEC958 Optical' 100 unmute<br />
amixer set 'Audigy Analog/Digital Output Jack' on<br />
<br />
You can see the name of your card's digital output with:<br />
<br />
amixer scontrols<br />
<br />
==KDE Settings==<br />
* Start up KDE:<br />
# startx<br />
<br />
* Set up the volumes as you want them for this user (each user has their own settings):<br />
# alsamixer<br />
<br />
* <b>KDE 3.3</b> Go to K Menu > Multimedia > KMix<br />
** Choose Settings > Configure KMix...<br />
** Uncheck the option "Restore volumes on logon"<br />
** Press OK, and you should be all set. Now your volumes will be the same from the command line or within KDE.<br />
<br />
=Troubleshooting=<br />
==Still Getting No Sound?==<br />
<br />
Even though your drivers are installed correctly, your volume is right, and nothing is muted, you might not hear anything! Adding the following line to <code>/etc/modprobe.conf</code> should fix this problem (with the <code>via82xx</code> driver, at least).<br />
<br />
options snd-NAME-OF-MODULE ac97_quirk=0<br />
<br />
==Poor Sound Quality?==<br />
<br />
If you experience poor sound quality, try setting the PCM volume (in alsamixer) to a level such that gain is 0.<br />
<br />
==Pops when Starting and Stopping Playback?==<br />
<br />
Some modules can power off your sound card when not in use. this can make an audible noise when powering down your sound card. If you find this annoying try "modinfo snd-MY-MODULE", and look for a module option that adjusts or disables this feature. <br />
<br />
for example: to disable the power saving mode using snd-hda-intel add "options snd-hda-intel power_save=0" in /etc/modprobe.conf. or try it with "modprobe snd-hda-intel power_save=0"</div>Wide-eyehttps://wiki.archlinux.org/index.php?title=Talk:Start_X_at_login&diff=26570Talk:Start X at login2007-07-04T22:48:10Z<p>Wide-eye: wide-eye's opionon</p>
<hr />
<div>Should this article be removed, with [[Adding_a_login_manager_(KDM,_GDM,_or_XDM)_to_automatically_boot_on_startup]] being placed in this article's name, and a redirect from there to here? That article is more complete, and I believe it includes this article, aswell as having one other i18n translation.<br />
<br />
<br />
this is not the same as enabling a login manager, it sends you directly to your desktop without loading anything besides bash. no passwords, no delays. The thing that i prefer about this method is that it is more kiss: my not needing the extra software as in {g,x}dm, slim. which is better for my single user computer. If you want to connect the pages, sure add an overview that links them both, perhaps containing the inittab background info common to both. But this is an alternative to what the page you linked to does. So please don't just remove it. - wide-eye</div>Wide-eyehttps://wiki.archlinux.org/index.php?title=Shutdown_Pressing_Power_Button&diff=26279Shutdown Pressing Power Button2007-07-01T09:52:29Z<p>Wide-eye: fixed path to xfsm-shutdown-helper</p>
<hr />
<div>[[Category:Customizing (English)]]<br />
[[Category:HOWTOs (English)]]<br />
<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|Shutting system down by pressing the power button}}<br />
{{i18n_entry|Русский|Выключение компьютера нажатием кнопки Power}}<br />
{{i18n_entry|Українська|Вимкнення_системи_кнопкою_Power}}<br />
{{i18n_links_end}}<br />
<br />
If you want to shutdown your system by simply pressing the power button, do the following:<br />
<br />
Install acpid package, add acpid to the DAEMONS array in rc.conf (and/or execute ''/etc/rc.d/acpid start'') and create a file in /etc/acpi/events/ with following content:<br />
<br />
<pre><br />
# /etc/acpi/events/power<br />
# This is called when the user presses the power button<br />
<br />
event=button/power (PWR.||PBTN)<br />
action=/sbin/poweroff<br />
</pre><br />
<br />
From now on pressing the power button (lightly, not for few seconds) should properly shutdown the system.<br />
Note that if you have '''hibernate''' configured and working you may want to change the last line with:<br />
<pre><br />
action=/usr/sbin/hibernate<br />
</pre><br />
<br />
However, if you're using more sophisticated WM, you should use its own shutdown call, so it'd save its session etc. <br />
<br />
To accomplish it in '''KDE''', simply change the action to: <br />
''action=/opt/kde/bin/dcop --all-users --all-sessions ksmserver ksmserver logout 0 2 0''<br />
<br />
Likewise for '''XFCE4.4''' change the action line to: <br />
''echo POWEROFF | /usr/lib/xfce4/xfsm-shutdown-helper''<br />
<br />
<br />
Note: For a more robust solution [If you are facing frequent WM crashes or working on a sacrificial PC for developing or testing your software...], you should take a look at "/usr/src/linux/Documentation/sysrq.txt", which is a kernel facility for yielding you [the user...] the CPU so that it could be used for any *rescue* work.</div>Wide-eyehttps://wiki.archlinux.org/index.php?title=Map_Custom_Device_Entries_with_udev&diff=25266Map Custom Device Entries with udev2007-06-04T09:39:48Z<p>Wide-eye: typo</p>
<hr />
<div>[[Category:Hardware detection and troubleshooting (English)]]<br />
[[Category:HOWTOs (English)]]<br />
<br />
This information is basically mirrored from the gentoo wiki with some additional hints. Recently it was updated to reflect changes in udev >= 98 syntax.<br />
<br />
This process allows you to always map a specific device to the same <code>/dev</code> node. This can then be used in <code>fstab</code> to ensure you can always mount the device same device in exactly the same place - which is great for desktop shortcuts!<br />
<br />
<br />
==Get the udev info for your USB device==<br />
<br />
Make sure one of your target devices is plugged in and then run the following as root:<br />
udevinfo -a -p `udevinfo -q path -n /dev/sda`<br />
<br />
This gets the udev device info for the device on <code>/dev/sda</code> - if your device is not mapped to <code>/dev/sda</code> then obviously use the correct mapping. :)<br />
<br />
You should get some output like this:<br />
<pre><br />
<br />
Udevinfo starts with the device specified by the devpath and then<br />
walks up the chain of parent devices. It prints for every device<br />
found, all possible attributes in the udev rules key format.<br />
A rule to match, can be composed by the attributes of the device<br />
and the attributes from one single parent device.<br />
<br />
looking at device '/block/sda':<br />
KERNEL=="sda"<br />
SUBSYSTEM=="block"<br />
DRIVER==""<br />
ATTR{stat}==" 19 111 137 160 0 0 0 0 0 152 160"<br />
ATTR{size}=="2007040"<br />
ATTR{removable}=="1"<br />
ATTR{range}=="16"<br />
ATTR{dev}=="8:0"<br />
<br />
looking at parent device '/devices/pci0000:00/0000:00:02.2/usb1/1-5/1-5:1.0/host5/target5:0:0/5:0:0:0':<br />
KERNELS=="5:0:0:0"<br />
SUBSYSTEMS=="scsi"<br />
DRIVERS=="sd"<br />
ATTRS{ioerr_cnt}=="0x0"<br />
ATTRS{iodone_cnt}=="0x1c"<br />
ATTRS{iorequest_cnt}=="0x1c"<br />
ATTRS{iocounterbits}=="32"<br />
ATTRS{timeout}=="30"<br />
ATTRS{state}=="running"<br />
ATTRS{rev}=="1.20"<br />
ATTRS{model}=="01GB Tiny "<br />
ATTRS{vendor}=="Pretec "<br />
ATTRS{scsi_level}=="3"<br />
ATTRS{type}=="0"<br />
ATTRS{queue_type}=="none"<br />
ATTRS{queue_depth}=="1"<br />
ATTRS{device_blocked}=="0"<br />
ATTRS{max_sectors}=="240"<br />
<br />
looking at parent device '/devices/pci0000:00/0000:00:02.2/usb1/1-5/1-5:1.0/host5/target5:0:0':<br />
KERNELS=="target5:0:0"<br />
SUBSYSTEMS==""<br />
DRIVERS==""<br />
<br />
looking at parent device '/devices/pci0000:00/0000:00:02.2/usb1/1-5/1-5:1.0/host5':<br />
KERNELS=="host5"<br />
SUBSYSTEMS==""<br />
DRIVERS==""<br />
<br />
looking at parent device '/devices/pci0000:00/0000:00:02.2/usb1/1-5/1-5:1.0':<br />
KERNELS=="1-5:1.0"<br />
SUBSYSTEMS=="usb"<br />
DRIVERS=="usb-storage"<br />
ATTRS{modalias}=="usb:v4146pBA01d0100dc00dsc00dp00ic08isc06ip50"<br />
ATTRS{bInterfaceProtocol}=="50"<br />
ATTRS{bInterfaceSubClass}=="06"<br />
ATTRS{bInterfaceClass}=="08"<br />
ATTRS{bNumEndpoints}=="03"<br />
ATTRS{bAlternateSetting}==" 0"<br />
ATTRS{bInterfaceNumber}=="00"<br />
<br />
looking at parent device '/devices/pci0000:00/0000:00:02.2/usb1/1-5':<br />
KERNELS=="1-5"<br />
SUBSYSTEMS=="usb"<br />
DRIVERS=="usb"<br />
ATTRS{configuration}==""<br />
ATTRS{serial}=="14AB0000000096"<br />
ATTRS{product}=="USB Mass Storage Device"<br />
ATTRS{maxchild}=="0"<br />
ATTRS{version}==" 2.00"<br />
ATTRS{devnum}=="7"<br />
ATTRS{speed}=="480"<br />
ATTRS{bMaxPacketSize0}=="64"<br />
ATTRS{bNumConfigurations}=="1"<br />
ATTRS{bDeviceProtocol}=="00"<br />
ATTRS{bDeviceSubClass}=="00"<br />
ATTRS{bDeviceClass}=="00"<br />
ATTRS{bcdDevice}=="0100"<br />
ATTRS{idProduct}=="ba01"<br />
ATTRS{idVendor}=="4146"<br />
ATTRS{bMaxPower}==" 98mA"<br />
ATTRS{bmAttributes}=="80"<br />
ATTRS{bConfigurationValue}=="1"<br />
ATTRS{bNumInterfaces}==" 1"<br />
<br />
looking at parent device '/devices/pci0000:00/0000:00:02.2/usb1':<br />
KERNELS=="usb1"<br />
SUBSYSTEMS=="usb"<br />
DRIVERS=="usb"<br />
ATTRS{configuration}==""<br />
ATTRS{serial}=="0000:00:02.2"<br />
ATTRS{product}=="EHCI Host Controller"<br />
ATTRS{manufacturer}=="Linux 2.6.18-ARCH ehci_hcd"<br />
ATTRS{maxchild}=="6"<br />
ATTRS{version}==" 2.00"<br />
ATTRS{devnum}=="1"<br />
ATTRS{speed}=="480"<br />
ATTRS{bMaxPacketSize0}=="64"<br />
ATTRS{bNumConfigurations}=="1"<br />
ATTRS{bDeviceProtocol}=="01"<br />
ATTRS{bDeviceSubClass}=="00"<br />
ATTRS{bDeviceClass}=="09"<br />
ATTRS{bcdDevice}=="0206"<br />
ATTRS{idProduct}=="0000"<br />
ATTRS{idVendor}=="0000"<br />
ATTRS{bMaxPower}==" 0mA"<br />
ATTRS{bmAttributes}=="e0"<br />
ATTRS{bConfigurationValue}=="1"<br />
ATTRS{bNumInterfaces}==" 1"<br />
<br />
looking at parent device '/devices/pci0000:00/0000:00:02.2':<br />
KERNELS=="0000:00:02.2"<br />
SUBSYSTEMS=="pci"<br />
DRIVERS=="ehci_hcd"<br />
ATTRS{broken_parity_status}=="0"<br />
ATTRS{enable}=="1"<br />
ATTRS{modalias}=="pci:v000010DEd00000068sv00001043sd00000C11bc0Csc03i20"<br />
ATTRS{local_cpus}=="f"<br />
ATTRS{irq}=="17"<br />
ATTRS{class}=="0x0c0320"<br />
ATTRS{subsystem_device}=="0x0c11"<br />
ATTRS{subsystem_vendor}=="0x1043"<br />
ATTRS{device}=="0x0068"<br />
ATTRS{vendor}=="0x10de"<br />
<br />
looking at parent device '/devices/pci0000:00':<br />
KERNELS=="pci0000:00"<br />
SUBSYSTEMS==""<br />
DRIVERS==""<br />
<br />
</pre><br />
<br />
Bit too much information! The only bit of this you actaully need is the <code>ATTRS<serial}</code> part - so now you know what the above command does just grep out the bit you want in future cases:<br />
<br />
udevinfo -a -p `udevinfo -q path -n /dev/sda` | grep ATTRS{serial}<br />
<br />
output:<br />
<br />
ATTRS{serial}=="14AB0000000096"<br />
ATTRS{serial}=="0000:00:02.2"<br />
<br />
Hmm, two serials. Which one to use?<br />
<br />
udevinfo -a -p `udevinfo -q path -n /dev/sda` | grep ATTRS{product}<br />
<br />
and we get<br />
<br />
ATTRS{product}=="USB Mass Storage Device"<br />
ATTRS{product}=="EHCI Host Controller"<br />
<br />
So, we need to use first serial.<br />
<br />
<br />
==Create a udev rule==<br />
<br />
You then use the <code>ATTRS{serial}</code> in a udev rule as follows:<br />
<br />
Note: The convention for Arch Linux is to place custom rules into <code>/etc/udev/rules.d/00.rules</code><br />
You may, however create a file with a different name. Just remember that udev processes these files in alphabetical order.<br />
<br />
BUS=="usb", ATTRS{serial}=="14AB0000000096", KERNEL=="sd?1", NAME="%k", SYMLINK+="usbdrive", GROUP="storage"<br />
<br />
<br />
==Create an fstab entry and mount point==<br />
<br />
Create a directory:<br />
<br />
mkdir /mnt/usbdrive<br />
<br />
In your <code>/etc/fstab</code>, create an entry like this:<br />
<br />
/dev/usbdrive /mnt/usbdrive vfat rw,noauto,flush,quiet,nodev,nosuid,noexec,noatime,dmask=000,fmask=111 0 0<br />
<br />
Additionally, depending on your locale preferences, add something like <code>codepage=866,iocharset=utf-8</code> to be able to see non-Latin filenames correctly.<br />
<br />
Now root or any user who belongs to the <code>storage</code> group can mount the USB stick by simply doing<br />
<br />
mount /mnt/usbdrive<br />
<br />
BTW, all the last 3 additional mount options are meant to increase your system's security, e.g. they will prevent you running an executable file directly from the USB drive.<br />
<br />
To allow non-root users to acces to USB stick do<br />
gpasswd -a user1 storage<br />
gpasswd -a user2 storage<br />
<br />
==Restart udev==<br />
<br />
to test your updated rules you can run:<br />
udevcontrol reload_rules<br />
<br />
Only if really needed, you may restart udev like this. As root, run those 3 commands:<br />
/etc/./start_udev<br />
mount /dev/pts<br />
mount /dev/shm<br />
<br />
==Examples==<br />
<br />
Here are some examples from my system. My devices sometimes mount on <code>sda</code> or <code>sda1</code> so I have two rules for each - this is a work around for device not found problems. The sda node is also needed for disk-level activities e.g. <code>fdisk /dev/sda</code>.<br />
<br />
This always maps my disgo USB pen to <code>/dev/usbpen</code> which I then map in fstab to mount on <code>/mnt/usbpen</code><br />
<br />
# Symlink USB pen<br />
SUBSYSTEMS=="usb", ATTRS{serial}=="1730C13B18000B84", KERNEL=="sd?", NAME="%k", SYMLINK+="usbpen", GROUP="storage"<br />
SUBSYSTEMS=="usb", ATTRS{serial}=="1730C13B18000B84", KERNEL=="sd?1", NAME="%k", SYMLINK+="usbpen", GROUP="storage"<br />
<br />
If you have a device with with multiple partitions, the following example maps the device to <code>/dev/usbdisk</code>, and partitions 1, 2, 3 etc. to <code>/dev/usbdisk1</code>, <code>/dev/usbdisk2</code>, <code>/dev/usbdisk3</code> etc.<br />
<br />
# Symlink multi-part device<br />
SUSSYSTEMS=="usb", ATTRS{serial}=="1730C13B18000B84", KERNEL=="sd?", NAME="%k", SYMLINK+="usbdisk", GROUP="storage"<br />
SUBSYSTEMS=="usb", ATTRS{serial}=="1730C13B18000B84", KERNEL=="sd?[1-9]", NAME="%k", SYMLINK+="usbdisk%n", GROUP="storage"<br />
<br />
These rules are equivalent to the following one:<br />
<br />
# Symlink multi-part device<br />
SUBSYSTEMS=="usb", ATTRS{serial}=="1730C13B18000B84", KERNEL=="sd*", NAME="%k", SYMLINK+="usbdisk%n", GROUP="storage"<br />
<br />
You can also omit the NAME and GROUP statements, so that the defaults from <code>udev.rules</code> are used. So the shortest and simplest solution would be adding this rule:<br />
<br />
# Symlink multi-part device<br />
SUBSYSTEMS=="usb", ATTRS{serial}=="1730C13B18000B84", KERNEL=="sd*", SYMLINK+="usbdisk%n"<br />
<br />
This always maps our Olympus digicam to <code>/dev/usbcam</code> which I then map in fstab to mount on <code>/mnt/usbcam</code><br />
<br />
# Symlink USB camera<br />
SUBSYSTEMS=="usb", ATTRS{serial}=="000207532049", KERNEL=="sd?", NAME="%k", SYMLINK+="usbcam", GROUP="storage"<br />
SUBSYSTEMS=="usb", ATTRS{serial}=="000207532049", KERNEL=="sd?1", NAME="%k", SYMLINK+="usbcam", GROUP="storage"<br />
<br />
And this maps my Packard Bell MP3 player to <code>/dev/mp3player</code><br />
<br />
# Symlink MP3 player<br />
SUBSYSTEMS=="usb", ATTRS{serial}=="0002F5CF72C9C691", KERNEL=="sd?", NAME="%k", SYMLINK+="mp3player", GROUP="storage"<br />
SUBSYSTEMS=="usb", ATTRS{serial}=="0002F5CF72C9C691", KERNEL=="sd?1", NAME="%k", SYMLINK+="mp3player", GROUP="storage"<br />
<br />
To map your own usb key to <code>/dev/mykey</code> and all of other keys to <code>/dev/otherkey</code><br />
<br />
# Symlink USB keys<br />
SUBSYSTEMS=="usb", ATTRS{serial}=="insert serial key", KERNEL=="sd?1", NAME="%k", SYMLINK+="mykey"<br />
SUBSYSTEMS=="usb", KERNEL=="sd?1", NAME="%k", SYMLINK+="otherkey"<br />
<br />
Note the order of the lines. Since all the usb keys should create the /dev/sd<a||b> node, udev will first check if it is your own usb key, defined with the serial number. But if you plug another key witch you don't know the serial number, it will create a node too, with a generic name "otherkey". That rule should be the last one your rules file.<br />
<br />
<br />
This is an example how to distinguish USB HDD drive and USB sticks:<br />
<br />
BUS=="usb", ATTRS{product}=="USB2.0 Storage Device", KERNEL=="sd?", NAME="%k", SYMLINK+="usbdisk", GROUP="storage"<br />
BUS=="usb", ATTRS{product}=="USB2.0 Storage Device", KERNEL=="sd?[1-9]", NAME="%k", SYMLINK+="usbdisk%n", GROUP="storage"<br />
BUS=="usb", ATTRS{product}=="USB Mass Storage Device", KERNEL=="sd?1", NAME="%k", SYMLINK+="usbflash", GROUP="storage"<br />
<br />
Note that this udev rule doesn't use serials at all.</div>Wide-eyehttps://wiki.archlinux.org/index.php?title=Map_Custom_Device_Entries_with_udev&diff=25265Map Custom Device Entries with udev2007-06-04T09:39:16Z<p>Wide-eye: added snippit on using udevcontrol</p>
<hr />
<div>[[Category:Hardware detection and troubleshooting (English)]]<br />
[[Category:HOWTOs (English)]]<br />
<br />
This information is basically mirrored from the gentoo wiki with some additional hints. Recently it was updated to reflect changes in udev >= 98 syntax.<br />
<br />
This process allows you to always map a specific device to the same <code>/dev</code> node. This can then be used in <code>fstab</code> to ensure you can always mount the device same device in exactly the same place - which is great for desktop shortcuts!<br />
<br />
<br />
==Get the udev info for your USB device==<br />
<br />
Make sure one of your target devices is plugged in and then run the following as root:<br />
udevinfo -a -p `udevinfo -q path -n /dev/sda`<br />
<br />
This gets the udev device info for the device on <code>/dev/sda</code> - if your device is not mapped to <code>/dev/sda</code> then obviously use the correct mapping. :)<br />
<br />
You should get some output like this:<br />
<pre><br />
<br />
Udevinfo starts with the device specified by the devpath and then<br />
walks up the chain of parent devices. It prints for every device<br />
found, all possible attributes in the udev rules key format.<br />
A rule to match, can be composed by the attributes of the device<br />
and the attributes from one single parent device.<br />
<br />
looking at device '/block/sda':<br />
KERNEL=="sda"<br />
SUBSYSTEM=="block"<br />
DRIVER==""<br />
ATTR{stat}==" 19 111 137 160 0 0 0 0 0 152 160"<br />
ATTR{size}=="2007040"<br />
ATTR{removable}=="1"<br />
ATTR{range}=="16"<br />
ATTR{dev}=="8:0"<br />
<br />
looking at parent device '/devices/pci0000:00/0000:00:02.2/usb1/1-5/1-5:1.0/host5/target5:0:0/5:0:0:0':<br />
KERNELS=="5:0:0:0"<br />
SUBSYSTEMS=="scsi"<br />
DRIVERS=="sd"<br />
ATTRS{ioerr_cnt}=="0x0"<br />
ATTRS{iodone_cnt}=="0x1c"<br />
ATTRS{iorequest_cnt}=="0x1c"<br />
ATTRS{iocounterbits}=="32"<br />
ATTRS{timeout}=="30"<br />
ATTRS{state}=="running"<br />
ATTRS{rev}=="1.20"<br />
ATTRS{model}=="01GB Tiny "<br />
ATTRS{vendor}=="Pretec "<br />
ATTRS{scsi_level}=="3"<br />
ATTRS{type}=="0"<br />
ATTRS{queue_type}=="none"<br />
ATTRS{queue_depth}=="1"<br />
ATTRS{device_blocked}=="0"<br />
ATTRS{max_sectors}=="240"<br />
<br />
looking at parent device '/devices/pci0000:00/0000:00:02.2/usb1/1-5/1-5:1.0/host5/target5:0:0':<br />
KERNELS=="target5:0:0"<br />
SUBSYSTEMS==""<br />
DRIVERS==""<br />
<br />
looking at parent device '/devices/pci0000:00/0000:00:02.2/usb1/1-5/1-5:1.0/host5':<br />
KERNELS=="host5"<br />
SUBSYSTEMS==""<br />
DRIVERS==""<br />
<br />
looking at parent device '/devices/pci0000:00/0000:00:02.2/usb1/1-5/1-5:1.0':<br />
KERNELS=="1-5:1.0"<br />
SUBSYSTEMS=="usb"<br />
DRIVERS=="usb-storage"<br />
ATTRS{modalias}=="usb:v4146pBA01d0100dc00dsc00dp00ic08isc06ip50"<br />
ATTRS{bInterfaceProtocol}=="50"<br />
ATTRS{bInterfaceSubClass}=="06"<br />
ATTRS{bInterfaceClass}=="08"<br />
ATTRS{bNumEndpoints}=="03"<br />
ATTRS{bAlternateSetting}==" 0"<br />
ATTRS{bInterfaceNumber}=="00"<br />
<br />
looking at parent device '/devices/pci0000:00/0000:00:02.2/usb1/1-5':<br />
KERNELS=="1-5"<br />
SUBSYSTEMS=="usb"<br />
DRIVERS=="usb"<br />
ATTRS{configuration}==""<br />
ATTRS{serial}=="14AB0000000096"<br />
ATTRS{product}=="USB Mass Storage Device"<br />
ATTRS{maxchild}=="0"<br />
ATTRS{version}==" 2.00"<br />
ATTRS{devnum}=="7"<br />
ATTRS{speed}=="480"<br />
ATTRS{bMaxPacketSize0}=="64"<br />
ATTRS{bNumConfigurations}=="1"<br />
ATTRS{bDeviceProtocol}=="00"<br />
ATTRS{bDeviceSubClass}=="00"<br />
ATTRS{bDeviceClass}=="00"<br />
ATTRS{bcdDevice}=="0100"<br />
ATTRS{idProduct}=="ba01"<br />
ATTRS{idVendor}=="4146"<br />
ATTRS{bMaxPower}==" 98mA"<br />
ATTRS{bmAttributes}=="80"<br />
ATTRS{bConfigurationValue}=="1"<br />
ATTRS{bNumInterfaces}==" 1"<br />
<br />
looking at parent device '/devices/pci0000:00/0000:00:02.2/usb1':<br />
KERNELS=="usb1"<br />
SUBSYSTEMS=="usb"<br />
DRIVERS=="usb"<br />
ATTRS{configuration}==""<br />
ATTRS{serial}=="0000:00:02.2"<br />
ATTRS{product}=="EHCI Host Controller"<br />
ATTRS{manufacturer}=="Linux 2.6.18-ARCH ehci_hcd"<br />
ATTRS{maxchild}=="6"<br />
ATTRS{version}==" 2.00"<br />
ATTRS{devnum}=="1"<br />
ATTRS{speed}=="480"<br />
ATTRS{bMaxPacketSize0}=="64"<br />
ATTRS{bNumConfigurations}=="1"<br />
ATTRS{bDeviceProtocol}=="01"<br />
ATTRS{bDeviceSubClass}=="00"<br />
ATTRS{bDeviceClass}=="09"<br />
ATTRS{bcdDevice}=="0206"<br />
ATTRS{idProduct}=="0000"<br />
ATTRS{idVendor}=="0000"<br />
ATTRS{bMaxPower}==" 0mA"<br />
ATTRS{bmAttributes}=="e0"<br />
ATTRS{bConfigurationValue}=="1"<br />
ATTRS{bNumInterfaces}==" 1"<br />
<br />
looking at parent device '/devices/pci0000:00/0000:00:02.2':<br />
KERNELS=="0000:00:02.2"<br />
SUBSYSTEMS=="pci"<br />
DRIVERS=="ehci_hcd"<br />
ATTRS{broken_parity_status}=="0"<br />
ATTRS{enable}=="1"<br />
ATTRS{modalias}=="pci:v000010DEd00000068sv00001043sd00000C11bc0Csc03i20"<br />
ATTRS{local_cpus}=="f"<br />
ATTRS{irq}=="17"<br />
ATTRS{class}=="0x0c0320"<br />
ATTRS{subsystem_device}=="0x0c11"<br />
ATTRS{subsystem_vendor}=="0x1043"<br />
ATTRS{device}=="0x0068"<br />
ATTRS{vendor}=="0x10de"<br />
<br />
looking at parent device '/devices/pci0000:00':<br />
KERNELS=="pci0000:00"<br />
SUBSYSTEMS==""<br />
DRIVERS==""<br />
<br />
</pre><br />
<br />
Bit too much information! The only bit of this you actaully need is the <code>ATTRS<serial}</code> part - so now you know what the above command does just grep out the bit you want in future cases:<br />
<br />
udevinfo -a -p `udevinfo -q path -n /dev/sda` | grep ATTRS{serial}<br />
<br />
output:<br />
<br />
ATTRS{serial}=="14AB0000000096"<br />
ATTRS{serial}=="0000:00:02.2"<br />
<br />
Hmm, two serials. Which one to use?<br />
<br />
udevinfo -a -p `udevinfo -q path -n /dev/sda` | grep ATTRS{product}<br />
<br />
and we get<br />
<br />
ATTRS{product}=="USB Mass Storage Device"<br />
ATTRS{product}=="EHCI Host Controller"<br />
<br />
So, we need to use first serial.<br />
<br />
<br />
==Create a udev rule==<br />
<br />
You then use the <code>ATTRS{serial}</code> in a udev rule as follows:<br />
<br />
Note: The convention for Arch Linux is to place custom rules into <code>/etc/udev/rules.d/00.rules</code><br />
You may, however create a file with a different name. Just remember that udev processes these files in alphabetical order.<br />
<br />
BUS=="usb", ATTRS{serial}=="14AB0000000096", KERNEL=="sd?1", NAME="%k", SYMLINK+="usbdrive", GROUP="storage"<br />
<br />
<br />
==Create an fstab entry and mount point==<br />
<br />
Create a directory:<br />
<br />
mkdir /mnt/usbdrive<br />
<br />
In your <code>/etc/fstab</code>, create an entry like this:<br />
<br />
/dev/usbdrive /mnt/usbdrive vfat rw,noauto,flush,quiet,nodev,nosuid,noexec,noatime,dmask=000,fmask=111 0 0<br />
<br />
Additionally, depending on your locale preferences, add something like <code>codepage=866,iocharset=utf-8</code> to be able to see non-Latin filenames correctly.<br />
<br />
Now root or any user who belongs to the <code>storage</code> group can mount the USB stick by simply doing<br />
<br />
mount /mnt/usbdrive<br />
<br />
BTW, all the last 3 additional mount options are meant to increase your system's security, e.g. they will prevent you running an executable file directly from the USB drive.<br />
<br />
To allow non-root users to acces to USB stick do<br />
gpasswd -a user1 storage<br />
gpasswd -a user2 storage<br />
<br />
==Restart udev==<br />
<br />
to test your updated rules you can run:<br />
udevcontrol reload_rules<br />
<br />
Only if really needed, you may restart udev like this. As root, run those 3 commands:<br />
/etc/./start_udev<br />
mount /dev/pts<br />
mount /dev/shm<br />
<br />
==Examples==<br />
<br />
Here are some examples from my system. My devices sometimes mount on <code>sda</code> or <code>sda1</code> so I have two rules for each - this is a work around for device not found problems. The sda node is also needed for disk-level activities e.g. <code>fdisk /dev/sda</code>.<br />
<br />
This always maps my disgo USB pen to <code>/dev/usbpen</code> which I then map in fstab to mount on <code>/mnt/usbpen</code><br />
<br />
# Symlink USB pen<br />
SUBSYSTEMS=="usb", ATTRS{serial}=="1730C13B18000B84", KERNEL=="sd?", NAME="%k", SYMLINK+="usbpen", GROUP="storage"<br />
SUBSYSTEMS=="usb", ATTRS{serial}=="1730C13B18000B84", KERNEL=="sd?1", NAME="%k", SYMLINK+="usbpen", GROUP="storage"<br />
<br />
If you have a device with with multiple partitions, the following example maps the device to <code>/dev/usbdisk</code>, and partitions 1, 2, 3 etc. to <code>/dev/usbdisk1</code>, <code>/dev/usbdisk2</code>, <code>/dev/usbdisk3</code> etc.<br />
<br />
# Symlink multi-part device<br />
SUSSYSTEMS=="usb", ATTRS{serial}=="1730C13B18000B84", KERNEL=="sd?", NAME="%k", SYMLINK+="usbdisk", GROUP="storage"<br />
SUBSYSTEMS=="usb", ATTRS{serial}=="1730C13B18000B84", KERNEL=="sd?[1-9]", NAME="%k", SYMLINK+="usbdisk%n", GROUP="storage"<br />
<br />
These rules are equivalent to the following one:<br />
<br />
# Symlink multi-part device<br />
SUBSYSTEMS=="usb", ATTRS{serial}=="1730C13B18000B84", KERNEL=="sd*", NAME="%k", SYMLINK+="usbdisk%n", GROUP="storage"<br />
<br />
You can also omit the NAME and GROUP statements, so that the defaults from <code>udev.rules</code> are used. So the shortest and simplest solution would be adding this rule:<br />
<br />
# Symlink multi-part device<br />
SUBSYSTEMS=="usb", ATTRS{serial}=="1730C13B18000B84", KERNEL=="sd*", SYMLINK+="usbdisk%n"<br />
<br />
This always maps our Olympus digicam to <code>/dev/usbcam</code> which I then map in fstab to mount on <code>/mnt/usbcam</code><br />
<br />
# Symlink USB camera<br />
SUBSYSTEMS=="usb", ATTRS{serial}=="000207532049", KERNEL=="sd?", NAME="%k", SYMLINK+="usbcam", GROUP="storage"<br />
SUBSYSTEMS=="usb", ATTRS{serial}=="000207532049", KERNEL=="sd?1", NAME="%k", SYMLINK+="usbcam", GROUP="storage"<br />
<br />
And this maps my Packard Bell MP3 player to <code>/dev/mp3player</code><br />
<br />
# Symlink MP3 player<br />
SUBSYSTEMS=="usb", ATTRS{serial}=="0002F5CF72C9C691", KERNEL=="sd?", NAME="%k", SYMLINK+="mp3player", GROUP="storage"<br />
SUBSYSTEMS=="usb", ATTRS{serial}=="0002F5CF72C9C691", KERNEL=="sd?1", NAME="%k", SYMLINK+="mp3player", GROUP="storage"<br />
<br />
To map your own usb key to <code>/dev/mykey</code> and all of other keys to <code>/dev/otherkey</code><br />
<br />
# Symlink USB keys<br />
SUBSYSTEMS=="usb", ATTRS{serial}=="insert serial key", KERNEL=="sd?1", NAME="%k", SYMLINK+="mykey"<br />
SUBSYSTEMS=="usb", KERNEL=="sd?1", NAME="%k", SYMLINK+="otherkey"<br />
<br />
Note the order of the lines. Since all the usb keys should create the /dev/sd<a||b> node, udev will first check if it is your own usb key, defined with the serial number. But if you plug another key witch you don't know the serial number, it will create a node too, with a generic name "otherkey". That rule should be the last one your rules file.<br />
<br />
<br />
This is an example how to distinguish USB HDD drive and USB sticks:<br />
<br />
BUS=="usb", ATTRS{product}=="USB2.0 Storage Device", KERNEL=="sd?", NAME="%k", SYMLINK+="usbdisk", GROUP="storage"<br />
BUS=="usb", ATTRS{product}=="USB2.0 Storage Device", KERNEL=="sd?[1-9]", NAME="%k", SYMLINK+="usbdisk%n", GROUP="storage"<br />
BUS=="usb", ATTRS{product}=="USB Mass Storage Device", KERNEL=="sd?1", NAME="%k", SYMLINK+="usbflash", GROUP="storage"<br />
<br />
Note that this udev rule doesn't use serials at all.</div>Wide-eyehttps://wiki.archlinux.org/index.php?title=MythTV&diff=25170MythTV2007-06-02T06:22:47Z<p>Wide-eye: /* Frontend setup */</p>
<hr />
<div>[[Category:Audio/Video (English)]]<br />
[[Category:HOWTOs (English)]]<br />
==Introduction==<br />
MythTV is an application suite designed to provide an amazing multimedia experience.<br />
It provides PVR functionality to a Linux based computer, and also supports other media types. <br />
Combined with a nice, quiet computer and a decent TV, it makes an excellent centerpiece to a home theater system.<br />
<br />
==Structure==<br />
The MythTV system is split into a backend and a frontend. Each component has its own functions:<br />
<br />
===mythbackend===<br />
*Schedule and record television programming<br />
*Stream video data to the frontend<br />
*Flag commercial breaks<br />
*Transcode videos from one format to another<br />
<br />
===mythfrontend===<br />
*Provide a pretty GUI<br />
*Play back recorded content<br />
*Provide an interface to schedule programs<br />
<br />
The frontend and backend may be on separate computers on a network, and there may also be multiple frontends. This architecture allows for a central media distribution system that can reach anywhere a network can. This is a remarkably flexible system, and it even allows very low power machines to act as perfectly usable frontends.<br />
<br />
==Requirements==<br />
MythTV is a very scalable system. With standard definition television and pure MPEG2 encoding and decoding with hardware acceleration, even a very modest system can act as both frontend and backend. How modest? Some people report being able to use fanless Via systems with Hauppauge PVR cards for both backend and frontend simultaneously. While the author does not condone the use of such a lightweight system, it has been done successfully.<br />
<br />
On the other end of the spectrum, high definition TV with MPEG4 transcoding and commercial flagging can require serious horsepower. Most people in the HD realm use high end Athlon XP's, midrange to high end Athlon 64's, and high end Pentium 4's for their backends. The frontend can get away with a somewhat more midrange processor if XvMC playback acceleration is used.<br />
<br />
All systems are going to need a tuner card. The Hauppauge PVR series of cards (150, 250, 350, and 500) are very popular for use with MythTV due to fairly decent linux support and low CPU usage. Other cards, like those based on the BT878 chipset are also used. Unlike the PVR series, BT878 based cards require significant amounts of CPU power to save the video, as these cards output raw frames and not compressed streams.<br />
<br />
The only combination of hardware the author can say works is an Athlon XP 1700+ frontend with 512MB of DDR, and a Pentium 4 2.8GHz backend with 512MB of DDR2.<br />
<br />
==Getting Started==<br />
In order to install MythTV on your system(s), you must have a working Linux installation. Since this is the Arch Linux website, this article will be geared towards that distribution. A simple base system [[:Category:Installation|Installation]] with no extras is a suggested starting point.<br />
<br />
For the backend, it is also good to have [[LAMP]] working properly so that anybody can use a web browser to schedule programming through MythWeb. While it is not necessary, it's a very handy feature.<br />
<br />
A working [[Install and configure xorg]](XWindow) environment is necessary.<br />
<br />
==Installing MythTV==<br />
<br />
There is a MythTV package in ''Extra''.<br />
<br />
* Install the MythTV package:<br />
<pre><br />
# pacman -S mythtv<br />
</pre><br />
<br />
* If you get a libXvMCW.so.1 shared library error, install the following:<br />
<pre><br />
# pacman -S libxvmc<br />
</pre><br />
<br />
At this point you have a generic MythTV installation. It must be refined into a backend, a frontend, or both.<br />
<br />
===Backend setup===<br />
Before setting up your backend, make sure you have a functioning video capture card or firewire input from an STB. Unfortunately, that part of setup is outside the scope of this article. It is also helpful to have an account with DataDirect from Zap2It labs. If you are in the United States, this service provides TV listings at a minimal cost. All you have to do is take a survey every three months, and you get (monetarily) free listings. Users outside the United States will need to use screen scrapers ([http://membled.com/work/apps/xmltv/ xmltv]) to do the same job.<br />
<br />
''Setting up the database:''<br />
* Install and run MySQL<br />
<pre><br />
# pacman -S mysql<br />
# /etc/rc.d/mysqld start<br />
</pre><br />
<br />
* Add this to the daemons line in rc.conf:<br />
<pre><br />
mysqld<br />
</pre><br />
<br />
* Import the database structure:<br />
<pre><br />
# mysql -u root -p < /usr/share/mythtv/mc.sql<br />
</pre><br />
<br />
''Setting up the master backend:''<br />
<br />
* Start up X, if you haven't already:<br />
<pre><br />
# startx<br />
</pre><br />
<br />
* Open up xterm, or the GUI console of your choice<br />
<br />
* Run the mythtv-setup program<br />
<pre><br />
# mythtv-setup<br />
</pre><br />
<br />
* '''Capture menu''' <br><br />
If this is your master backend, put its IP address in the first and fourth fields, identifying this computer as your master and giving its network IP address.<br><br />
On the next page, enter the paths where recordings and the live tv buffer will be stored. LVM or RAID solutions provide easily accessible large scale storage, but again, those are outside the scope of this article. Set the live tv buffer to a size you can handle, and leave everything else alone.<br><br />
On the next page, set the settings to your locale. NTSC is mostly used in North America, and be sure to set whether using cable or broadcast.<br><br />
On the next two pages, leave everything as is, unless you know for sure you want to change it.<br />
On the next page, if you have a fast backend that can handle recordings and flagging jobs simultaneously, it is recommended to set CPU usage to \"High\", maximum simultaneous jobs to 2, and to check the commercial flagging option.<br><br />
On the next page, set these options to taste. Automatic commercial flagging is highly recommended.<br />
Ignore the next page and finish.<br><br />
<br />
* '''Capture card menu''' <br><br />
Select your card type from the drop down list. Hauppauge PVR users will select the MPEG-2 encoder card option.<br><br />
Point mythtv-setup to the proper location, usually /dev/v4l/video0<br><br />
<br />
* '''Video sources menu''' <br><br />
This is where it gets important to have a source for TV listings. DataDirect users should create a new video source, name it, select the North America (DataDirect) option, and fill in their logon information. In order to verify that it is correct, go ahead and retrieve the listings.<br />
<br />
* '''Input connections menu''' <br><br />
This menu is rather self explanatory. All you need to do is pick an input on the capture card, and tell myth which video source it connects to. Most users will select their tuner and leave all the other inputs alone. Satellite users will select a video input, and on the next page provide the command to change channels on their STB using an external channel change program. This is also outside the scope of this article.<br />
<br />
* '''Channel editor menu''' <br><br />
This menu is safe to ignore<br />
<br />
* Exit the program (esc)<br />
<br />
* Run mythfilldatabase<br />
<pre><br />
# mythfilldatabase<br />
</pre><br />
This should populate your mysql database with TV listings for the next two weeks (or so).<br />
<br />
* Add mythbackend to the /etc/rc.conf daemons line.<br />
<br />
* Restart<br />
<pre><br />
# reboot<br />
</pre><br />
While it isn't absolutely necessary to restart at this point, it is a good idea, just to clean things up and make sure that all the necessary daemons start up automatically.<br />
<br />
==Frontend setup==<br />
<br />
Compared to the backend, getting a frontend running is trivially simple. Just make sure you are in an X environment as a normal user and run mythfrontend. It will pop up a menu asking about the IP address of the backend, and the local computer's name and IP. Fill in this information and your frontend should be functional. On the other hand, the frontend has has more options than a luxury car. All of those are an article on their own. There are a few notable options that should be set to ensure a good working setup. If you don't have an interlaced monitor (and almost nobody does), you will need to deinterlace your television output. Go into the TV playback menu and select kernel deinterlacing or bob2x deinterlacing. Try both and see which you like better. Also, in the general settings page, it is good to set up your [Alsa setup] settings, but those vary so greatly it isn't worth suggesting values here.<br />
<br />
One problem I encountered running mythfrontend 0.20.0.2007013 on fglrx was that the colors were mixed up. People were blue skinned etc. It turns out there is a hack for ati cards in the source, but it is not enabled. Uncomment #define USE_ATI_PROPRIETARY_DRIVER_XVIDEO_HACK in libs/libmythtv/videoout_xv.cpp and rebuild. (this will change names in svn and so future versions)<br />
<br />
==MythTV Plugins==<br />
There are a number of plugins available for MythTV in the AUR. They range from RSS readers to DVD players. Take a look at them. Simply installing the package on the frontend computer should impart the intended functionality. There is rarely any additional setup, and when there is, the install file will mention it.<br />
<br />
==Hints to a Happy Myth System==<br />
But not full articles (yet)<br />
*Run ntpd or openntpd on your backend to make sure it always has the right time<br />
*[[lirc|LIRC]] on your frontend allows you to use a remote control, which is wonderful in a living room<br />
*Use gdm, kdm, or xdm to automatically log in your frontend, and ~/.xinitrc to load mythfrontend on boot<br />
*Set the automatically run mythfilldatabase option on one of your frontends to make sure you always have listings<br />
*Don't forget to use the verbosity statements and log file location arguments to mythfrontend so you can see when things break<br />
<br />
==References==<br />
*http://www.mythtv.org<br />
*http://mythtv.info<br />
*http://wilsonet.com/mythtv/fcmyth.php<br />
*http://commwebworks.com/ski/mythtv.html [dead link - May 29, 2007]</div>Wide-eyehttps://wiki.archlinux.org/index.php?title=MythTV&diff=25040MythTV2007-05-29T22:24:22Z<p>Wide-eye: /* References */</p>
<hr />
<div>[[Category:Audio/Video (English)]]<br />
[[Category:HOWTOs (English)]]<br />
==Introduction==<br />
MythTV is an application suite designed to provide an amazing multimedia experience.<br />
It provides PVR functionality to a Linux based computer, and also supports other media types. <br />
Combined with a nice, quiet computer and a decent TV, it makes an excellent centerpiece to a home theater system.<br />
<br />
==Structure==<br />
The MythTV system is split into a backend and a frontend. Each component has its own functions:<br />
<br />
===mythbackend===<br />
*Schedule and record television programming<br />
*Stream video data to the frontend<br />
*Flag commercial breaks<br />
*Transcode videos from one format to another<br />
<br />
===mythfrontend===<br />
*Provide a pretty GUI<br />
*Play back recorded content<br />
*Provide an interface to schedule programs<br />
<br />
The frontend and backend may be on separate computers on a network, and there may also be multiple frontends. This architecture allows for a central media distribution system that can reach anywhere a network can. This is a remarkably flexible system, and it even allows very low power machines to act as perfectly usable frontends.<br />
<br />
==Requirements==<br />
MythTV is a very scalable system. With standard definition television and pure MPEG2 encoding and decoding with hardware acceleration, even a very modest system can act as both frontend and backend. How modest? Some people report being able to use fanless Via systems with Hauppauge PVR cards for both backend and frontend simultaneously. While the author does not condone the use of such a lightweight system, it has been done successfully.<br />
<br />
On the other end of the spectrum, high definition TV with MPEG4 transcoding and commercial flagging can require serious horsepower. Most people in the HD realm use high end Athlon XP's, midrange to high end Athlon 64's, and high end Pentium 4's for their backends. The frontend can get away with a somewhat more midrange processor if XvMC playback acceleration is used.<br />
<br />
All systems are going to need a tuner card. The Hauppauge PVR series of cards (150, 250, 350, and 500) are very popular for use with MythTV due to fairly decent linux support and low CPU usage. Other cards, like those based on the BT878 chipset are also used. Unlike the PVR series, BT878 based cards require significant amounts of CPU power to save the video, as these cards output raw frames and not compressed streams.<br />
<br />
The only combination of hardware the author can say works is an Athlon XP 1700+ frontend with 512MB of DDR, and a Pentium 4 2.8GHz backend with 512MB of DDR2.<br />
<br />
==Getting Started==<br />
In order to install MythTV on your system(s), you must have a working Linux installation. Since this is the Arch Linux website, this article will be geared towards that distribution. A simple base system [[:Category:Installation|Installation]] with no extras is a suggested starting point.<br />
<br />
For the backend, it is also good to have [[LAMP]] working properly so that anybody can use a web browser to schedule programming through MythWeb. While it is not necessary, it's a very handy feature.<br />
<br />
A working [[Install and configure xorg]](XWindow) environment is necessary.<br />
<br />
==Installing MythTV==<br />
<br />
There is a MythTV package in ''Extra''.<br />
<br />
* Install the MythTV package:<br />
<pre><br />
# pacman -S mythtv<br />
</pre><br />
<br />
* If you get a libXvMCW.so.1 shared library error, install the following:<br />
<pre><br />
# pacman -S libxvmc<br />
</pre><br />
<br />
At this point you have a generic MythTV installation. It must be refined into a backend, a frontend, or both.<br />
<br />
===Backend setup===<br />
Before setting up your backend, make sure you have a functioning video capture card or firewire input from an STB. Unfortunately, that part of setup is outside the scope of this article. It is also helpful to have an account with DataDirect from Zap2It labs. If you are in the United States, this service provides TV listings at a minimal cost. All you have to do is take a survey every three months, and you get (monetarily) free listings. Users outside the United States will need to use screen scrapers ([http://membled.com/work/apps/xmltv/ xmltv]) to do the same job.<br />
<br />
''Setting up the database:''<br />
* Install and run MySQL<br />
<pre><br />
# pacman -S mysql<br />
# /etc/rc.d/mysqld start<br />
</pre><br />
<br />
* Add this to the daemons line in rc.conf:<br />
<pre><br />
mysqld<br />
</pre><br />
<br />
* Import the database structure:<br />
<pre><br />
# mysql -u root -p < /usr/share/mythtv/mc.sql<br />
</pre><br />
<br />
''Setting up the master backend:''<br />
<br />
* Start up X, if you haven't already:<br />
<pre><br />
# startx<br />
</pre><br />
<br />
* Open up xterm, or the GUI console of your choice<br />
<br />
* Run the mythtv-setup program<br />
<pre><br />
# mythtv-setup<br />
</pre><br />
<br />
* '''Capture menu''' <br><br />
If this is your master backend, put its IP address in the first and fourth fields, identifying this computer as your master and giving its network IP address.<br><br />
On the next page, enter the paths where recordings and the live tv buffer will be stored. LVM or RAID solutions provide easily accessible large scale storage, but again, those are outside the scope of this article. Set the live tv buffer to a size you can handle, and leave everything else alone.<br><br />
On the next page, set the settings to your locale. NTSC is mostly used in North America, and be sure to set whether using cable or broadcast.<br><br />
On the next two pages, leave everything as is, unless you know for sure you want to change it.<br />
On the next page, if you have a fast backend that can handle recordings and flagging jobs simultaneously, it is recommended to set CPU usage to \"High\", maximum simultaneous jobs to 2, and to check the commercial flagging option.<br><br />
On the next page, set these options to taste. Automatic commercial flagging is highly recommended.<br />
Ignore the next page and finish.<br><br />
<br />
* '''Capture card menu''' <br><br />
Select your card type from the drop down list. Hauppauge PVR users will select the MPEG-2 encoder card option.<br><br />
Point mythtv-setup to the proper location, usually /dev/v4l/video0<br><br />
<br />
* '''Video sources menu''' <br><br />
This is where it gets important to have a source for TV listings. DataDirect users should create a new video source, name it, select the North America (DataDirect) option, and fill in their logon information. In order to verify that it is correct, go ahead and retrieve the listings.<br />
<br />
* '''Input connections menu''' <br><br />
This menu is rather self explanatory. All you need to do is pick an input on the capture card, and tell myth which video source it connects to. Most users will select their tuner and leave all the other inputs alone. Satellite users will select a video input, and on the next page provide the command to change channels on their STB using an external channel change program. This is also outside the scope of this article.<br />
<br />
* '''Channel editor menu''' <br><br />
This menu is safe to ignore<br />
<br />
* Exit the program (esc)<br />
<br />
* Run mythfilldatabase<br />
<pre><br />
# mythfilldatabase<br />
</pre><br />
This should populate your mysql database with TV listings for the next two weeks (or so).<br />
<br />
* Add mythbackend to the /etc/rc.conf daemons line.<br />
<br />
* Restart<br />
<pre><br />
# reboot<br />
</pre><br />
While it isn't absolutely necessary to restart at this point, it is a good idea, just to clean things up and make sure that all the necessary daemons start up automatically.<br />
<br />
==Frontend setup==<br />
<br />
Compared to the backend, getting a frontend running is trivially simple. Just make sure you are in an X environment as a normal user and run mythfrontend. It will pop up a menu asking about the IP address of the backend, and the local computer's name and IP. Fill in this information and your frontend should be functional. On the other hand, the frontend has has more options than a luxury car. All of those are an article on their own. There are a few notable options that should be set to ensure a good working setup. If you don't have an interlaced monitor (and almost nobody does), you will need to deinterlace your television output. Go into the TV playback menu and select kernel deinterlacing or bob2x deinterlacing. Try both and see which you like better. Also, in the general settings page, it is good to set up your [Alsa setup] settings, but those vary so greatly it isn't worth suggesting values here.<br />
<br />
==MythTV Plugins==<br />
There are a number of plugins available for MythTV in the AUR. They range from RSS readers to DVD players. Take a look at them. Simply installing the package on the frontend computer should impart the intended functionality. There is rarely any additional setup, and when there is, the install file will mention it.<br />
<br />
==Hints to a Happy Myth System==<br />
But not full articles (yet)<br />
*Run ntpd or openntpd on your backend to make sure it always has the right time<br />
*[[lirc|LIRC]] on your frontend allows you to use a remote control, which is wonderful in a living room<br />
*Use gdm, kdm, or xdm to automatically log in your frontend, and ~/.xinitrc to load mythfrontend on boot<br />
*Set the automatically run mythfilldatabase option on one of your frontends to make sure you always have listings<br />
*Don't forget to use the verbosity statements and log file location arguments to mythfrontend so you can see when things break<br />
<br />
==References==<br />
*http://www.mythtv.org<br />
*http://mythtv.info<br />
*http://wilsonet.com/mythtv/fcmyth.php<br />
*http://commwebworks.com/ski/mythtv.html [dead link - May 29, 2007]</div>Wide-eyehttps://wiki.archlinux.org/index.php?title=Mkinitcpio&diff=23831Mkinitcpio2007-05-07T08:20:26Z<p>Wide-eye: added image exctraction section</p>
<hr />
<div>[[Category:Boot process (English)]]<br />
[[Category:Arch kernels (English)]]<br />
[[Category:Tutorials (English)]]<br />
<br />
== About ==<br />
<br />
'''mkinitcpio''' is the next generation of '''initramfs creation'''. It has many advantages above the old '''mkinitrd''' and '''mkinitramfs''' scripts.<br />
<br />
* It uses '''klibc''' and '''kinit''' which are developed by Linux kernel devs to provide a small and lightweight base for early userspace.<br />
* It can use '''udev''' for hardware autodetection at runtime, thus prevents you from having tons of unnecessary modules loaded.<br />
* Its hook-based init script is easily extendable with custom hooks, which can easily be included in pacman packages without having to modifiy mkinitcpio itself.<br />
* It already supports '''lvm2''', '''dm-crypt''' for both legacy and luks volumes, '''raid''', '''swsusp''' and '''suspend2''' resuming and booting from '''usb mass storage''' devices.<br />
* Many features can be configured from the kernel command line without having to rebuild the image.<br />
* The '''mkinitcpio''' script makes it possible to include the image in a kernel, thus making a self-contained kernel image is possible.<br />
<br />
'''mkinitcpio''' has been developed by '''phrakture''' and '''tpowa''' with some help from the community.<br />
<br />
== Installing mkinitcpio ==<br />
=== From the current repository ===<br />
<br />
The '''mkinitcpio''' script has made its move to the current repository. You can install with the command<br />
# pacman -Sy mkinitcpio<br />
<br />
=== From svn ===<br />
<br />
If you want the latest development version of '''mkinitcpio''', check out phrakture's svn repository using<br />
# svn co http://phraktured.net/initramfs<br />
The newest scripts are now in the '''initramfs/mkinitcpio''' directory.<br />
<br />
== Activation for >=2.6.17 kernels ==<br />
There will be 2 images created during kernel installation/upgrade:<br />
<br />
If you are using '''kernel26'''<br />
/boot/kernel26.img --> stripped down in size by autodetect<br />
/boot/kernel26-fallback.img --> contains all modules of subsystems<br />
If you are using '''kernel26beyond'''<br />
/boot/kernel26beyond.img --> stripped down in size by autodetect<br />
/boot/kernel26beyond-fallback.img --> contains all modules of subsystems<br />
Please change your bootloader to load the image you need.<br />
<br />
=== ATTENTION: ===<br />
==== => '''lvm2''', '''raid''' and '''encrypt''' are NOT enabled by default ====<br />
'''lvm2''', '''raid''' and '''encrypt''' are not! enabled by default.<br />
Please read this wiki carefully on how to setup those stuff, and configure it <br />
for your system.<br />
<br />
==== => Users with more than 1 hardware disk controller ====<br />
If you have more than one hardware disk controller which uses the same node names (like 2 SCSI/SATA or IDE controllers) and need different kernel modules to load them, please specify the correct order in MODULES="" in /etc/mkinitcpio.conf and in your fallback config file, else it could happen that your root device keeps on switching and you could run into random kernel panics.<br />
<br />
A more elegant alternative is to use [[Persistent block device naming]] to ensure that the right devices are mounted.<br />
<br />
==== Known modules that are not autoloaded during boot process ====<br />
If you need one of the following modules for your root device, consider to load them by MODULES="" in /etc/mkinitcpio.conf and in your fallback config file, else your kernel panics during boot.<br />
<br />
- '''SCSI CONTROLLERS''' (status stock kernel 2.6.18)<br />
scsi_transport_sas ultrastor qlogicfas eata BusLogic pas16 wd7000 sym53c416<br />
g_NCR5380_mmio fdomain u14-34f dtc initio in2000 imm t128 aha1542 aha152x<br />
atp870u g_NCR5380 NCR53c406a qlogicfas408 megaraid_mm advansys<br />
<br />
=== Customizing the Configuration Files ===<br />
<br />
=== '''Modifying main image''' ===<br />
To change the defaults for the main image edit the following file:<br />
<br />
/etc/mkinitcpio.conf<br />
<br />
mkinitcpio uses this file by default.<br />
<br />
=== '''Modifying fallback image''' ===<br />
To change the defaults for the fallback images, edit one of the following files:<br />
if you use kernel26, edit '''/boot/mkinitcpio.d/kernel26-fallback.conf'''<br />
if you use kernel26beyond, edit '''/boot/mkinitcpio.d/kernel26beyond-fallback.conf'''<br />
and set the file that you edited to '''NoUpgrade =''' in '/etc/pacman.conf'. Note that these should be sane unless you require a special setup such as lvm or raid.<br />
<br />
=== Configuring the HOOKS ===<br />
<br />
This is the most important part of mkinitcpio configuration. The HOOKS line contains the hooks that are executed on image creation and on runtime in the exact order they are executed. The format is like this:<br />
<br />
HOOKS="foo1 foo2 foo3 bar1 bar2"<br />
<br />
==== Available hooks ====<br />
<br />
{| border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border-style:solid; border-width:1px; border-collapse:collapse; empty-cells:show"<br />
|-<br />
! Hook || Installation || Runtime<br />
|-<br />
| '''base''' || Sets up all initial directories and installs base klibc utilities and libraries. Always add this hook unless you know what you are doing. || <br />
|-<br />
| '''udev''' || Adds udev to your image || Udev will be used to create your root device node and detect the needed modules for your root device. As it simplifies things, using the udev hook is recommended.<br />
|-<br />
| '''modload''' || || An alternative autodetecion method which is much slower than udev. Using this hook is discouraged. Use udev instead.<br />
|-<br />
| '''autodetect''' || Shrinks your initramfs to a smaller size by autodetecting your needed modules. Be sure to verify included modules are correct and none are missing. This hook must be run before other subsystem hooks in order to take advantage of auto-detection. Any hooks placed before 'autodetect' will be installed in full. || <br />
|-<br />
| '''ide''' || Adds IDE modules to the image. Use this if your root device is on a IDE disk. Also use the '''autodetect''' hook if you want to minimize your image size || Loads IDE modules. You will need the '''udev''' or '''modload''' hook unless you specify the needed modules manually (see MODULES section below).<br />
|-<br />
| '''pata''' || Adds IDE modules to the image. Use this if your root device is on a IDE disk. Also use the '''autodetect''' hook if you want to minimize your image size || Loads IDE modules. You will need the '''udev''' or '''modload''' hook unless you specify the needed modules manually (see MODULES section below). PATA is the kernel's new IDE driver. It will change your /dev/hd? to /dev/sd?. more info: http://archlinux.org/news/272/<br />
|-<br />
| '''sata''' || Adds serial ATA modules to the image. Use this if your root device is on a SATA disk. Also use the '''autodetect''' hook if you want to minimize your image size. || Loads SATA modules. You will need the '''udev''' or '''modload''' hook unless you specify the needed modules manually (see MODULES section below).<br />
|-<br />
| '''scsi''' || Adds SCSI modules to the image. Use this if your root device is on a SCSI disk. Also use the '''autodetect''' hook if you want to minimize your image size. || Loads SCSI modules. You will need the '''udev''' or '''modload''' hook unless you specify the needed modules manually (see MODULES section below).<br />
|-<br />
| '''usb''' || Adds USB modules to the image. Use this if your root device is on a USB mass storage device. || Loads USB modules. You will need the '''udev''' or '''modload''' hook unless you specify the needed modules manually (see MODULES section below).<br />
|-<br />
| '''usbinput''' || Adds USB HID modules to the image. Use this if you have an USB keyboard and need it in early userspace (either for entering encryption passphrases or for failsafe mode) || Loads USB HID modules. You will need the '''udev''' or '''modload''' hook unless you specify the needed modules manually (see MODULES section below).<br />
|-<br />
| '''fw''' || Adds Firewire modules to the image. Use this if your root device is on a FW mass storage device. || Loads FW modules. You will need the '''udev''' or '''modload''' hook unless you specify the needed modules manually (see MODULES section below).<br />
|-<br />
| '''net''' || Adds the necessary modules for a network device. For pcmcia net devices please add pcmcia hook too. || Loads network modules. You will need the '''udev''' or '''modload''' hook unless you specify the needed modules manually (see MODULES section below). See the section [[Configuring_mkinitcpio#Customizing_the_kernel_command_line|Customizing the kernel command line]] for further configuration.<br />
|-<br />
| '''pcmcia''' || Adds the necessary modules for pcmcia devices. You need to have pcmciautils installed to use this.|| Loads pcmcia modules. You will need the '''udev''' or '''modload''' hook unless you specify the needed modules manually (see MODULES section below).<br />
|-<br />
| '''dsdt''' || Loads a custom acpi dsdt file during boot. Place your custom dsdt file for inclusion at /lib/initcpio/custom.dsdt || The custom dsdt file is automatically used by the kernel if it is present in initramfs.<br />
|-<br />
| '''filesystems''' || This includes necessary filesystem modules into your image. This hook is necessary if you want to be able to boot || This will detect the filesystem type at runtime, load the module and pass it to kinit. NOTE: it will NOT detect reiser4, it must be added to modules list.<br />
|-<br />
| '''lvm2''' || Adds the device mapper kernel module and the lvm tool to the image. You need to have the lvm2 package installed to use this. || Enables all lvm2 volume groups. This is necessary if you have your root filesystem on lvm.<br />
|-<br />
| '''raid''' || Adds the modules and mdassamble for a software raid setup. You need to have mdadm installed to use this.|| Loads the necessary modules for software raid devices, and assembles the raid devices when run. See the section [[Configuring_mkinitcpio#Customizing_the_kernel_command_line|Customizing the kernel command line]] for further configuration.<br />
|-<br />
| '''encrypt''' || Adds the dm-crypt kernel module and the cryptsetup tool to the image. You need to have the cryptsetup package installed to use this. || Detects and unlocks an encrypted root partition. See the section [[Configuring_mkinitcpio#Customizing_the_kernel_command_line|Customizing the kernel command line]] for further configuration.<br />
|-<br />
| '''resume''' || || This tries to resume from "suspend to disk" state. Works with both swsusp and [[Suspend to Disk|suspend2]]. See the section [[Configuring_mkinitcpio#Customizing_the_kernel_command_line|Customizing the kernel command line]] for further configuration.<br />
|-<br />
| '''firmware''' || Adds /lib/firmware files. || Loads firmware. You will need the '''udev''' hook to get firmware loaded. <br />
|-<br />
| '''keymap''' || Adds keymap and consolefonts from rc.conf. || Loads the specified keymap and consolefont from rc.conf during early userspace.<br />
|}<br />
<br />
==== Examples ====<br />
<br />
This configuration will work for most users with a standard setup:<br />
<br />
HOOKS="base udev autodetect ide scsi sata filesystems"<br />
<br />
If you want to use the image on more than one machine, use this configuration:<br />
<br />
HOOKS="base udev ide scsi sata filesystems"<br />
<br />
You can use encrypted volumes on top of lvm2 volume groups:<br />
<br />
HOOKS="base udev autodetect ide scsi sata lvm2 encrypt filesystems"<br />
<br />
=== Configuring the MODULES ===<br />
<br />
You can use the MODULES in the configuration file to load a module before anything else is done. For example, if you don't want to use '''udev''' or '''modload''', you can add all necessary modules manually and make booting faster:<br />
<br />
MODULES="piix ide_disk reiserfs"<br />
HOOKS="base autodetect ide filesystems"<br />
<br />
NOTE: if you're using '''reiser4''', you MUST add it to the modules list.<br />
<br />
=== Configuring the BINARIES and FILES ===<br />
<br />
These options allow you to add files to the image. The only difference is that BINARIES checks binaries and libraries for dependencies, while FILES simply adds the file.<br />
<br />
Examples:<br />
<br />
FILES="/etc/modprobe.conf"<br />
<br />
BINARIES="/usr/bin/somefile"<br />
<br />
== Creating the image ==<br />
<br />
=== Regenerating predefined images / using presets ===<br />
<br />
If you want to regenerate your initramfs images for the Archlinux stock kernels, use the command<br />
# mkinitcpio -p kernel26<br />
This example is for the ''kernel26'' package, it works the same for the other kernel packages.<br />
<br />
If you want to change the settings for your images, edit the ''/etc/mkinitcpio.d/kernel26.preset'' file (again, just change the filename for the other kernel packages). '''These ''.preset'' files will be used on a kernel update, so don't break them.'''<br />
<br />
=== Manually ===<br />
<br />
Create the image with the following command:<br />
<br />
mkinitcpio -g /boot/kernel26.img<br />
<br />
This will generate the image for the currently running kernel and save it at '''/boot/kernel26.img''', which is the location for '''kernel26''' package. Users of '''kernel26beyond''' should use the following instead:<br />
<br />
mkinitcpio -g /boot/kernel26beyond.img<br />
<br />
If you are creating an image for a kernel other than the one you are currently running, add the kernel version to the command line:<br />
<br />
mkinitcpio -g /boot/kernel26.img -k 2.6.16-ARCH<br />
<br />
==== Regenerating the Fallback Image ====<br />
<br />
''NOTE:'' The following may confuse some people. It is only intended to help create fallback images for people already running the current kernel. To create images for any kernel that is not currently running, you MUST use the -k parameter.<br />
<br />
A fallback image should have been created when you installed '''kernel26''' or '''kernel26beyond''' but in case you want to re-generate it<br />
<br />
mkinitcpio -c /boot/mkinitcpio.d/kernel26-fallback.conf -g /boot/kernel26.img<br />
for beyond<br />
mkinitcpio -c /boot/mkinitcpio.d/kernel26beyond-fallback.conf -g /boot/kernel26beyond.img<br />
<br />
See '''mkinitcpio -h''' for more options.<br />
<br />
Don't forget to add a new bootloader entry. Just make a copy of your old one and change the initrd to your new image. As long as mkinitcpio is beta, please always leave the old one intact, so that you can boot it if something goes wrong. You can use mkinitcpio with any kernel, so kernel26 and kernel26-beyond users are encouraged to try it.<br />
<br />
== Customizing the kernel command line ==<br />
<br />
Just like without initramfs, some options need to be passed on the kernel command line to configure your kernel, like the root device. Some of the mkinitcpio hooks have special options. These are discussed below.<br />
<br />
If you don't know what a kernel command line is, please refer to the [[GRUB]] or [[Lilo]] documentation.<br />
<br />
=== Entering failsafe mode ===<br />
<br />
If you add the option<br />
break=y<br />
to the kernel command line, init stops after the setup is completed and you are left with a ''dash'' shell. This can be used to verify that everything went fine. If you logout, normal boot continues.<br />
<br />
=== Disabling hooks ===<br />
<br />
You can disable a hook at runtime by adding the ''disablehooks'' option to the kernel command line like this:<br />
<br />
disablehooks=hook1,hook2,hook2<br />
<br />
for example<br />
<br />
disablehooks=resume<br />
<br />
=== Blacklisting modules ===<br />
<br />
You can blacklist modules by adding the ''disablemodules'' option to the kernel command line like this:<br />
<br />
disablemodules=mod1,mod2,mod3<br />
<br />
for example<br />
<br />
disablemodules=ata_piix<br />
<br />
=== Using raid ===<br />
First add the raid hook to the HOOKS list in /etc/mkinitcpio.conf<br />
<br />
'''Kernel Parameters: '''<br />
Specify your md arrays with: md= parameter: (see below).<br />
Note that only adding the raid array you're booting from is enough.<br />
Example: md=0,/dev/sda3,/dev/sda4 md=1,/dev/hda1,/dev/hdb1<br />
<br />
Then add the following to the kernel line in '''grub/menu.lst''':<br />
Example: md=0,/dev/sda3,/dev/sda4 md=1,/dev/hda1,/dev/hdb1<br />
So that it looks like:<br />
kernel /vmlinuz26beyond root=/dev/md0 ro md=0,/dev/sda1,/dev/sdb1<br />
This will setup 2 md arrays with persistent superblocks<br />
<br />
'''Setup:'''<br />
- for old raid arrays without persistent superblocks:<br />
md=<md device no.>,<raid level>,<chunk size factor>,<fault level>,dev0,dev1<br />
- for raid arrays with persistent superblocks:<br />
md=<md device no.>,dev0,dev1,...,devn<br />
- for, to assemble a partitionable array:<br />
md=d<md device no.>,dev0,dev1,...,devn<br />
<br />
'''Parameters:'''<br />
- <md device no.> = the number of the md device: <br />
0 means md0, 1 means md1, ...<br />
- <raid level> = -1 linear mode, 0 striped mode<br />
other modes are only supported with persistent super block<br />
- <chunk size factor> = (raid-0 and raid-1 only):<br />
Set the chunk size as 4k << n.<br />
- <fault level> = totally ignored<br />
- <dev0-devn>: e.g. /dev/hda1,/dev/hdc1,/dev/sda1,/dev/sdb1<br />
<br />
=== Using net ===<br />
<br />
'''Kernel Parameters:''' <br />
<br />
'''ip=''' <br />
<br />
An interface spec can be either short form, which is just the name of<br />
an interface (eth0 or whatever), or long form. The long form consists<br />
of up to seven elements, separated by colons:<br />
<br />
ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf><br />
nfsaddrs= is an alias to ip= and can be used too.<br />
<br />
''Parameter explanation:''<br />
<client-ip> IP address of the client. If empty, the address will<br />
either be determined by RARP/BOOTP/DHCP. What protocol<br />
is used de- pends on the <autoconf> parameter. If this<br />
parameter is not empty, autoconf will be used.<br />
<br />
<server-ip> IP address of the NFS server. If RARP is used to<br />
determine the client address and this parameter is NOT<br />
empty only replies from the specified server are<br />
accepted. To use different RARP and NFS server,<br />
specify your RARP server here (or leave it blank), and<br />
specify your NFS server in the `nfsroot' parameter<br />
(see above). If this entry is blank the address of the<br />
server is used which answered the RARP/BOOTP/DHCP<br />
request.<br />
<br />
<gw-ip> IP address of a gateway if the server is on a different<br />
subnet. If this entry is empty no gateway is used and the<br />
server is assumed to be on the local network, unless a<br />
value has been received by BOOTP/DHCP.<br />
<br />
<netmask> Netmask for local network interface. If this is empty,<br />
the netmask is derived from the client IP address assuming<br />
classful addressing, unless overridden in BOOTP/DHCP reply.<br />
<br />
<hostname> Name of the client. If empty, the client IP address is<br />
used in ASCII notation, or the value received by<br />
BOOTP/DHCP.<br />
<br />
<device> Name of network device to use. If this is empty, all<br />
devices are used for RARP/BOOTP/DHCP requests, and the<br />
first one we receive a reply on is configured. If you<br />
have only one device, you can safely leave this blank.<br />
<br />
<autoconf> Method to use for autoconfiguration. If this is either<br />
'rarp', 'bootp', or 'dhcp' the specified protocol is<br />
used. If the value is 'both', 'all' or empty, all<br />
protocols are used. 'off', 'static' or 'none' means<br />
no autoconfiguration.<br />
''Examples:''<br />
ip=127.0.0.1:::::lo:none --> Enable the loopback interface.<br />
ip=192.168.1.1:::::eth2:none --> Enable static eth2 interface.<br />
ip=:::::eth0:dhcp --> Enable dhcp protcol for eth0 configuration.<br />
'''nfsroot='''<br />
<br />
If the 'nfsroot' parameter is NOT given on the command line, the default<br />
"/tftpboot/%s" will be used.<br />
<br />
nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]<br />
<br />
''Parameter explanation:''<br />
<br />
<server-ip> Specifies the IP address of the NFS server. If this field<br />
is not given, the default address as determined by the<br />
`ip' variable (see below) is used. One use of this<br />
parameter is for example to allow using different servers<br />
for RARP and NFS. Usually you can leave this blank.<br />
<br />
<root-dir> Name of the directory on the server to mount as root. If<br />
there is a "%s" token in the string, the token will be<br />
replaced by the ASCII-representation of the client's IP<br />
address.<br />
<br />
<nfs-options> Standard NFS options. All options are separated by commas.<br />
If the options field is not given, the following defaults<br />
will be used:<br />
port = as given by server portmap daemon<br />
rsize = 1024<br />
wsize = 1024<br />
timeo = 7<br />
retrans = 3<br />
acregmin = 3<br />
acregmax = 60<br />
acdirmin = 30<br />
acdirmax = 60<br />
flags = hard, nointr, noposix, cto, ac<br />
<br />
'''root=/dev/nfs'''<br />
If you don't use nfsroot= parameter you need to set root=/dev/nfs <br />
to boot from a nfs root by autoconfiguration.<br />
<br />
=== Using lvm ===<br />
<br />
If your root device is on lvm, you have to add the '''lvm2''' hook. You have to pass your root device on the kernel command line in the format<br />
<br />
root=/dev/mapper/<volume group name>-<logical volume name><br />
<br />
for example<br />
<br />
root=/dev/mapper/myvg-root<br />
<br />
=== Using encrypted root ===<br />
<br />
If your root volume is encrypted, you need to add the '''encrypt''' hook. Then specify your root device on the kernel command line, just as if it was unencrypted.<br />
<br />
For an encrypted partition on an sata or scsi disk:<br />
root=/dev/sda5<br />
<br />
For an encrypted lvm volume:<br />
root=/dev/mapper/myvg-root<br />
<br />
The root device will be automatically changed to ''/dev/mapper/root''.<br />
<br />
==== Using LUKS volumes ====<br />
<br />
If you use LUKS for hard disk encryption, the init script will detect the encryption automatically if the '''encrypt''' hook is enabled. It will then ask for a passphrase and try to unlock the volume.<br />
<br />
If this fails try to add you filesystem-module to the module list in /etc/mkinitcpio.conf if it's not compiled into your kernel.<br />
<br />
==== Using legacy cryptsetup volumes ====<br />
<br />
If you are using a legacy cryptsetup volume, you have to specify all cryptsetup options necessary to unlock it on the kernel command line. The option format is<br />
<br />
crypto=hash:cipher:keysize:offset:skip<br />
<br />
representing cryptsetup's --hash, --cipher, --keysize, --offset and --skip options. If you omit an option, cryptsetup's default value is used, so you can just specify<br />
<br />
crypto=::::<br />
<br />
if you created your volume with the default settings.<br />
<br />
'''NOTE:''' For technical reasons, it is not possible to verify the correctness of your passphrase with legacy cryptsetup volumes. If you typed it wrong, mounting will simply fail. It is recommended that you use LUKS instead.<br />
<br />
==== Using loop-aes volumes ====<br />
<br />
'''mkinitcpio''' does not support loop-aes yet.<br />
<br />
== Using Suspend to Disk ==<br />
<br />
If you want to use suspend to disk, you have to add the '''resume''' hook.<br />
<br />
==== swsusp ====<br />
<br />
''TODO''<br />
<br />
==== µswsusp ====<br />
<br />
µswsusp is not supported yet.<br />
<br />
==== suspend2 ====<br />
<br />
If you are using [[Suspend to Disk|suspend2]], you have to specify the ''resume2'' kernel commandline option. If you are using the swap writer, use<br />
<br />
resume2=swap:/dev/hda3<br />
<br />
where ''/dev/hda3'' is your swap partition. If you want to use the filewriter, use<br />
<br />
resume2=file:/dev/hda2:0x123456<br />
<br />
where ''/dev/hda2'' is the partition where the suspend2 image is stored (most likely the root partition) and ''0x123456'' is the file offset. You can get the exact value with the commands<br />
<br />
echo "/suspend2_file" > /proc/suspend2/filewriter_target<br />
cat /proc/suspend2/resume2<br />
<br />
where /suspend2_file is the path to your suspend image file. This - of course - works for lvm volumes as well. You can also use a suspend file on an encrypted root partition with the option<br />
<br />
resume2=file:/dev/mapper/root:0x123456<br />
<br />
where ''0x123456'' is the offset again. Resuming from an encrypted swap partition is not supported.<br />
<br />
=== Example bootloader configuration files ===<br />
<br />
If you use the beyond kernel, the filenames are ''kernel26beyond.img'' and ''kernel26beyond-fallback.img'' instead of ''kernel26.img'' and ''kernel26-fallback.img'', respectively. Also, change "vmlinuz26" to "vmlinuz26beyond". <br />
<br />
==== GRUB ====<br />
<br />
For those who have /boot on a separate partition:<br />
<br />
# (0) Arch Linux<br />
title Arch Linux<br />
root (hd0,3)<br />
kernel /vmlinuz26 root=/dev/hda4 vga=791 ro<br />
initrd /kernel26.img<br />
<br />
title Arch Linux Fallback<br />
root (hd0,3)<br />
kernel /vmlinuz26 root=/dev/hda4 vga=791 ro<br />
initrd /kernel26-fallback.img<br />
<br />
For those who do _not_ have /boot on a separate partition:<br />
<br />
# (0) Arch Linux<br />
title Arch Linux<br />
root (hd0,3)<br />
kernel /boot/vmlinuz26 root=/dev/hda4 vga=791 ro<br />
initrd /boot/kernel26.img<br />
<br />
title Arch Linux Fallback<br />
root (hd0,3)<br />
kernel /boot/vmlinuz26 root=/dev/hda4 vga=791 ro<br />
initrd /boot/kernel26-fallback.img<br />
<br />
==== LILO ====<br />
<br />
If you use LILO, it is recommended that you use ''append="root=/dev/XYZ"'' instead of ''root=/dev/XYZ''. If you already have a global ''append'' option, then use ''addappend''.<br />
<br />
boot=/dev/hdX <br />
default = ArchLinux<br />
timeout=50 <br />
vga=791<br />
lba32<br />
prompt<br />
<br />
# for the hardware-autodetecting image<br />
image=/boot/vmlinuz26<br />
label=ArchLinux<br />
append="root=/dev/hdXY"<br />
initrd=/boot/kernel26.img<br />
read-only<br />
<br />
# fallback image if the other doesnt work (Will most prob. never be used)<br />
image=/boot/vmlinuz26<br />
label=ArchLinuxFallBack<br />
append="root=/dev/hdXY"<br />
initrd=/boot/kernel26-fallback.img<br />
read-only<br />
<br />
== Troubleshooting ==<br />
=== piix ide controllers and beyond kernel ===<br />
==== Problem ====<br />
If you are having problems getting mkinitcpio to detect your hard drive giving errors akin to "Can't find device dev(0,0)" when switching to kinit, then this could be because of a conflict that the ata_piix and piix drivers have. The beyond kernel has some libata patches that cause ata_piix to *conflict* with piix.<br />
<br />
==== Solution ====<br />
Edit /etc/mkinitcpio.conf to only have ide or sata or scsi depending on what your system actually needs to boot.<br />
<br />
<br />
== Getting under the hood ==<br />
If you are curious about what is inside the initrd image you can extract it and poke at the files inside of it. it is a cpio archive but...<br />
=== Warning about cpio ===<br />
using cpio to extract an image is dangerous, as it likes to extract the image to /, rendering your system broken and unbootable. recovery involves reinstalling the packages that own the overwritten files with pacman.static. A list of files can made with bsdtar -t -f kernel26.img<br />
=== using bsdtar to extract the image ===<br />
bsdtar is kind enough to extract to the current directory instead of hosing your system.<br />
<br />
bsdtar -x -f /boot/kernel26.img</div>Wide-eyehttps://wiki.archlinux.org/index.php?title=Mkinitcpio&diff=23830Mkinitcpio2007-05-07T08:03:07Z<p>Wide-eye: </p>
<hr />
<div>[[Category:Boot process (English)]]<br />
[[Category:Arch kernels (English)]]<br />
[[Category:Tutorials (English)]]<br />
<br />
== About ==<br />
<br />
'''mkinitcpio''' is the next generation of '''initramfs creation'''. It has many advantages above the old '''mkinitrd''' and '''mkinitramfs''' scripts.<br />
<br />
* It uses '''klibc''' and '''kinit''' which are developed by Linux kernel devs to provide a small and lightweight base for early userspace.<br />
* It can use '''udev''' for hardware autodetection at runtime, thus prevents you from having tons of unnecessary modules loaded.<br />
* Its hook-based init script is easily extendable with custom hooks, which can easily be included in pacman packages without having to modifiy mkinitcpio itself.<br />
* It already supports '''lvm2''', '''dm-crypt''' for both legacy and luks volumes, '''raid''', '''swsusp''' and '''suspend2''' resuming and booting from '''usb mass storage''' devices.<br />
* Many features can be configured from the kernel command line without having to rebuild the image.<br />
* The '''mkinitcpio''' script makes it possible to include the image in a kernel, thus making a self-contained kernel image is possible.<br />
<br />
'''mkinitcpio''' has been developed by '''phrakture''' and '''tpowa''' with some help from the community.<br />
<br />
== Installing mkinitcpio ==<br />
=== From the current repository ===<br />
<br />
The '''mkinitcpio''' script has made its move to the current repository. You can install with the command<br />
# pacman -Sy mkinitcpio<br />
<br />
=== From svn ===<br />
<br />
If you want the latest development version of '''mkinitcpio''', check out phrakture's svn repository using<br />
# svn co http://phraktured.net/initramfs<br />
The newest scripts are now in the '''initramfs/mkinitcpio''' directory.<br />
<br />
== Activation for >=2.6.17 kernels ==<br />
There will be 2 images created during kernel installation/upgrade:<br />
<br />
If you are using '''kernel26'''<br />
/boot/kernel26.img --> stripped down in size by autodetect<br />
/boot/kernel26-fallback.img --> contains all modules of subsystems<br />
If you are using '''kernel26beyond'''<br />
/boot/kernel26beyond.img --> stripped down in size by autodetect<br />
/boot/kernel26beyond-fallback.img --> contains all modules of subsystems<br />
Please change your bootloader to load the image you need.<br />
<br />
=== ATTENTION: ===<br />
==== => '''lvm2''', '''raid''' and '''encrypt''' are NOT enabled by default ====<br />
'''lvm2''', '''raid''' and '''encrypt''' are not! enabled by default.<br />
Please read this wiki carefully on how to setup those stuff, and configure it <br />
for your system.<br />
<br />
==== => Users with more than 1 hardware disk controller ====<br />
If you have more than one hardware disk controller which uses the same node names (like 2 SCSI/SATA or IDE controllers) and need different kernel modules to load them, please specify the correct order in MODULES="" in /etc/mkinitcpio.conf and in your fallback config file, else it could happen that your root device keeps on switching and you could run into random kernel panics.<br />
<br />
A more elegant alternative is to use [[Persistent block device naming]] to ensure that the right devices are mounted.<br />
<br />
==== Known modules that are not autoloaded during boot process ====<br />
If you need one of the following modules for your root device, consider to load them by MODULES="" in /etc/mkinitcpio.conf and in your fallback config file, else your kernel panics during boot.<br />
<br />
- '''SCSI CONTROLLERS''' (status stock kernel 2.6.18)<br />
scsi_transport_sas ultrastor qlogicfas eata BusLogic pas16 wd7000 sym53c416<br />
g_NCR5380_mmio fdomain u14-34f dtc initio in2000 imm t128 aha1542 aha152x<br />
atp870u g_NCR5380 NCR53c406a qlogicfas408 megaraid_mm advansys<br />
<br />
=== Customizing the Configuration Files ===<br />
<br />
=== '''Modifying main image''' ===<br />
To change the defaults for the main image edit the following file:<br />
<br />
/etc/mkinitcpio.conf<br />
<br />
mkinitcpio uses this file by default.<br />
<br />
=== '''Modifying fallback image''' ===<br />
To change the defaults for the fallback images, edit one of the following files:<br />
if you use kernel26, edit '''/boot/mkinitcpio.d/kernel26-fallback.conf'''<br />
if you use kernel26beyond, edit '''/boot/mkinitcpio.d/kernel26beyond-fallback.conf'''<br />
and set the file that you edited to '''NoUpgrade =''' in '/etc/pacman.conf'. Note that these should be sane unless you require a special setup such as lvm or raid.<br />
<br />
=== Configuring the HOOKS ===<br />
<br />
This is the most important part of mkinitcpio configuration. The HOOKS line contains the hooks that are executed on image creation and on runtime in the exact order they are executed. The format is like this:<br />
<br />
HOOKS="foo1 foo2 foo3 bar1 bar2"<br />
<br />
==== Available hooks ====<br />
<br />
{| border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border-style:solid; border-width:1px; border-collapse:collapse; empty-cells:show"<br />
|-<br />
! Hook || Installation || Runtime<br />
|-<br />
| '''base''' || Sets up all initial directories and installs base klibc utilities and libraries. Always add this hook unless you know what you are doing. || <br />
|-<br />
| '''udev''' || Adds udev to your image || Udev will be used to create your root device node and detect the needed modules for your root device. As it simplifies things, using the udev hook is recommended.<br />
|-<br />
| '''modload''' || || An alternative autodetecion method which is much slower than udev. Using this hook is discouraged. Use udev instead.<br />
|-<br />
| '''autodetect''' || Shrinks your initramfs to a smaller size by autodetecting your needed modules. Be sure to verify included modules are correct and none are missing. This hook must be run before other subsystem hooks in order to take advantage of auto-detection. Any hooks placed before 'autodetect' will be installed in full. || <br />
|-<br />
| '''ide''' || Adds IDE modules to the image. Use this if your root device is on a IDE disk. Also use the '''autodetect''' hook if you want to minimize your image size || Loads IDE modules. You will need the '''udev''' or '''modload''' hook unless you specify the needed modules manually (see MODULES section below).<br />
|-<br />
| '''pata''' || Adds IDE modules to the image. Use this if your root device is on a IDE disk. Also use the '''autodetect''' hook if you want to minimize your image size || Loads IDE modules. You will need the '''udev''' or '''modload''' hook unless you specify the needed modules manually (see MODULES section below). PATA is the kernel's new IDE driver. It will change your /dev/hd? to /dev/sd?. more info: http://archlinux.org/news/272/<br />
|-<br />
| '''sata''' || Adds serial ATA modules to the image. Use this if your root device is on a SATA disk. Also use the '''autodetect''' hook if you want to minimize your image size. || Loads SATA modules. You will need the '''udev''' or '''modload''' hook unless you specify the needed modules manually (see MODULES section below).<br />
|-<br />
| '''scsi''' || Adds SCSI modules to the image. Use this if your root device is on a SCSI disk. Also use the '''autodetect''' hook if you want to minimize your image size. || Loads SCSI modules. You will need the '''udev''' or '''modload''' hook unless you specify the needed modules manually (see MODULES section below).<br />
|-<br />
| '''usb''' || Adds USB modules to the image. Use this if your root device is on a USB mass storage device. || Loads USB modules. You will need the '''udev''' or '''modload''' hook unless you specify the needed modules manually (see MODULES section below).<br />
|-<br />
| '''usbinput''' || Adds USB HID modules to the image. Use this if you have an USB keyboard and need it in early userspace (either for entering encryption passphrases or for failsafe mode) || Loads USB HID modules. You will need the '''udev''' or '''modload''' hook unless you specify the needed modules manually (see MODULES section below).<br />
|-<br />
| '''fw''' || Adds Firewire modules to the image. Use this if your root device is on a FW mass storage device. || Loads FW modules. You will need the '''udev''' or '''modload''' hook unless you specify the needed modules manually (see MODULES section below).<br />
|-<br />
| '''net''' || Adds the necessary modules for a network device. For pcmcia net devices please add pcmcia hook too. || Loads network modules. You will need the '''udev''' or '''modload''' hook unless you specify the needed modules manually (see MODULES section below). See the section [[Configuring_mkinitcpio#Customizing_the_kernel_command_line|Customizing the kernel command line]] for further configuration.<br />
|-<br />
| '''pcmcia''' || Adds the necessary modules for pcmcia devices. You need to have pcmciautils installed to use this.|| Loads pcmcia modules. You will need the '''udev''' or '''modload''' hook unless you specify the needed modules manually (see MODULES section below).<br />
|-<br />
| '''dsdt''' || Loads a custom acpi dsdt file during boot. Place your custom dsdt file for inclusion at /lib/initcpio/custom.dsdt || The custom dsdt file is automatically used by the kernel if it is present in initramfs.<br />
|-<br />
| '''filesystems''' || This includes necessary filesystem modules into your image. This hook is necessary if you want to be able to boot || This will detect the filesystem type at runtime, load the module and pass it to kinit. NOTE: it will NOT detect reiser4, it must be added to modules list.<br />
|-<br />
| '''lvm2''' || Adds the device mapper kernel module and the lvm tool to the image. You need to have the lvm2 package installed to use this. || Enables all lvm2 volume groups. This is necessary if you have your root filesystem on lvm.<br />
|-<br />
| '''raid''' || Adds the modules and mdassamble for a software raid setup. You need to have mdadm installed to use this.|| Loads the necessary modules for software raid devices, and assembles the raid devices when run. See the section [[Configuring_mkinitcpio#Customizing_the_kernel_command_line|Customizing the kernel command line]] for further configuration.<br />
|-<br />
| '''encrypt''' || Adds the dm-crypt kernel module and the cryptsetup tool to the image. You need to have the cryptsetup package installed to use this. || Detects and unlocks an encrypted root partition. See the section [[Configuring_mkinitcpio#Customizing_the_kernel_command_line|Customizing the kernel command line]] for further configuration.<br />
|-<br />
| '''resume''' || || This tries to resume from "suspend to disk" state. Works with both swsusp and [[Suspend to Disk|suspend2]]. See the section [[Configuring_mkinitcpio#Customizing_the_kernel_command_line|Customizing the kernel command line]] for further configuration.<br />
|-<br />
| '''firmware''' || Adds /lib/firmware files. || Loads firmware. You will need the '''udev''' hook to get firmware loaded. <br />
|-<br />
| '''keymap''' || Adds keymap and consolefonts from rc.conf. || Loads the specified keymap and consolefont from rc.conf during early userspace.<br />
|}<br />
<br />
==== Examples ====<br />
<br />
This configuration will work for most users with a standard setup:<br />
<br />
HOOKS="base udev autodetect ide scsi sata filesystems"<br />
<br />
If you want to use the image on more than one machine, use this configuration:<br />
<br />
HOOKS="base udev ide scsi sata filesystems"<br />
<br />
You can use encrypted volumes on top of lvm2 volume groups:<br />
<br />
HOOKS="base udev autodetect ide scsi sata lvm2 encrypt filesystems"<br />
<br />
=== Configuring the MODULES ===<br />
<br />
You can use the MODULES in the configuration file to load a module before anything else is done. For example, if you don't want to use '''udev''' or '''modload''', you can add all necessary modules manually and make booting faster:<br />
<br />
MODULES="piix ide_disk reiserfs"<br />
HOOKS="base autodetect ide filesystems"<br />
<br />
NOTE: if you're using '''reiser4''', you MUST add it to the modules list.<br />
<br />
=== Configuring the BINARIES and FILES ===<br />
<br />
These options allow you to add files to the image. The only difference is that BINARIES checks binaries and libraries for dependencies, while FILES simply adds the file.<br />
<br />
Examples:<br />
<br />
FILES="/etc/modprobe.conf"<br />
<br />
BINARIES="/usr/bin/somefile"<br />
<br />
== Creating the image ==<br />
<br />
=== Regenerating predefined images / using presets ===<br />
<br />
If you want to regenerate your initramfs images for the Archlinux stock kernels, use the command<br />
# mkinitcpio -p kernel26<br />
This example is for the ''kernel26'' package, it works the same for the other kernel packages.<br />
<br />
If you want to change the settings for your images, edit the ''/etc/mkinitcpio.d/kernel26.preset'' file (again, just change the filename for the other kernel packages). '''These ''.preset'' files will be used on a kernel update, so don't break them.'''<br />
<br />
=== Manually ===<br />
<br />
Create the image with the following command:<br />
<br />
mkinitcpio -g /boot/kernel26.img<br />
<br />
This will generate the image for the currently running kernel and save it at '''/boot/kernel26.img''', which is the location for '''kernel26''' package. Users of '''kernel26beyond''' should use the following instead:<br />
<br />
mkinitcpio -g /boot/kernel26beyond.img<br />
<br />
If you are creating an image for a kernel other than the one you are currently running, add the kernel version to the command line:<br />
<br />
mkinitcpio -g /boot/kernel26.img -k 2.6.16-ARCH<br />
<br />
==== Regenerating the Fallback Image ====<br />
<br />
''NOTE:'' The following may confuse some people. It is only intended to help create fallback images for people already running the current kernel. To create images for any kernel that is not currently running, you MUST use the -k parameter.<br />
<br />
A fallback image should have been created when you installed '''kernel26''' or '''kernel26beyond''' but in case you want to re-generate it<br />
<br />
mkinitcpio -c /boot/mkinitcpio.d/kernel26-fallback.conf -g /boot/kernel26.img<br />
for beyond<br />
mkinitcpio -c /boot/mkinitcpio.d/kernel26beyond-fallback.conf -g /boot/kernel26beyond.img<br />
<br />
See '''mkinitcpio -h''' for more options.<br />
<br />
Don't forget to add a new bootloader entry. Just make a copy of your old one and change the initrd to your new image. As long as mkinitcpio is beta, please always leave the old one intact, so that you can boot it if something goes wrong. You can use mkinitcpio with any kernel, so kernel26 and kernel26-beyond users are encouraged to try it.<br />
<br />
== Customizing the kernel command line ==<br />
<br />
Just like without initramfs, some options need to be passed on the kernel command line to configure your kernel, like the root device. Some of the mkinitcpio hooks have special options. These are discussed below.<br />
<br />
If you don't know what a kernel command line is, please refer to the [[GRUB]] or [[Lilo]] documentation.<br />
<br />
=== Entering failsafe mode ===<br />
<br />
If you add the option<br />
break=y<br />
to the kernel command line, init stops after the setup is completed and you are left with a ''dash'' shell. This can be used to verify that everything went fine. If you logout, normal boot continues.<br />
<br />
=== Disabling hooks ===<br />
<br />
You can disable a hook at runtime by adding the ''disablehooks'' option to the kernel command line like this:<br />
<br />
disablehooks=hook1,hook2,hook2<br />
<br />
for example<br />
<br />
disablehooks=resume<br />
<br />
=== Blacklisting modules ===<br />
<br />
You can blacklist modules by adding the ''disablemodules'' option to the kernel command line like this:<br />
<br />
disablemodules=mod1,mod2,mod3<br />
<br />
for example<br />
<br />
disablemodules=ata_piix<br />
<br />
=== Using raid ===<br />
First add the raid hook to the HOOKS list in /etc/mkinitcpio.conf<br />
<br />
'''Kernel Parameters: '''<br />
Specify your md arrays with: md= parameter: (see below).<br />
Note that only adding the raid array you're booting from is enough.<br />
Example: md=0,/dev/sda3,/dev/sda4 md=1,/dev/hda1,/dev/hdb1<br />
<br />
Then add the following to the kernel line in '''grub/menu.lst''':<br />
Example: md=0,/dev/sda3,/dev/sda4 md=1,/dev/hda1,/dev/hdb1<br />
So that it looks like:<br />
kernel /vmlinuz26beyond root=/dev/md0 ro md=0,/dev/sda1,/dev/sdb1<br />
This will setup 2 md arrays with persistent superblocks<br />
<br />
'''Setup:'''<br />
- for old raid arrays without persistent superblocks:<br />
md=<md device no.>,<raid level>,<chunk size factor>,<fault level>,dev0,dev1<br />
- for raid arrays with persistent superblocks:<br />
md=<md device no.>,dev0,dev1,...,devn<br />
- for, to assemble a partitionable array:<br />
md=d<md device no.>,dev0,dev1,...,devn<br />
<br />
'''Parameters:'''<br />
- <md device no.> = the number of the md device: <br />
0 means md0, 1 means md1, ...<br />
- <raid level> = -1 linear mode, 0 striped mode<br />
other modes are only supported with persistent super block<br />
- <chunk size factor> = (raid-0 and raid-1 only):<br />
Set the chunk size as 4k << n.<br />
- <fault level> = totally ignored<br />
- <dev0-devn>: e.g. /dev/hda1,/dev/hdc1,/dev/sda1,/dev/sdb1<br />
<br />
=== Using net ===<br />
<br />
'''Kernel Parameters:''' <br />
<br />
'''ip=''' <br />
<br />
An interface spec can be either short form, which is just the name of<br />
an interface (eth0 or whatever), or long form. The long form consists<br />
of up to seven elements, separated by colons:<br />
<br />
ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf><br />
nfsaddrs= is an alias to ip= and can be used too.<br />
<br />
''Parameter explanation:''<br />
<client-ip> IP address of the client. If empty, the address will<br />
either be determined by RARP/BOOTP/DHCP. What protocol<br />
is used de- pends on the <autoconf> parameter. If this<br />
parameter is not empty, autoconf will be used.<br />
<br />
<server-ip> IP address of the NFS server. If RARP is used to<br />
determine the client address and this parameter is NOT<br />
empty only replies from the specified server are<br />
accepted. To use different RARP and NFS server,<br />
specify your RARP server here (or leave it blank), and<br />
specify your NFS server in the `nfsroot' parameter<br />
(see above). If this entry is blank the address of the<br />
server is used which answered the RARP/BOOTP/DHCP<br />
request.<br />
<br />
<gw-ip> IP address of a gateway if the server is on a different<br />
subnet. If this entry is empty no gateway is used and the<br />
server is assumed to be on the local network, unless a<br />
value has been received by BOOTP/DHCP.<br />
<br />
<netmask> Netmask for local network interface. If this is empty,<br />
the netmask is derived from the client IP address assuming<br />
classful addressing, unless overridden in BOOTP/DHCP reply.<br />
<br />
<hostname> Name of the client. If empty, the client IP address is<br />
used in ASCII notation, or the value received by<br />
BOOTP/DHCP.<br />
<br />
<device> Name of network device to use. If this is empty, all<br />
devices are used for RARP/BOOTP/DHCP requests, and the<br />
first one we receive a reply on is configured. If you<br />
have only one device, you can safely leave this blank.<br />
<br />
<autoconf> Method to use for autoconfiguration. If this is either<br />
'rarp', 'bootp', or 'dhcp' the specified protocol is<br />
used. If the value is 'both', 'all' or empty, all<br />
protocols are used. 'off', 'static' or 'none' means<br />
no autoconfiguration.<br />
''Examples:''<br />
ip=127.0.0.1:::::lo:none --> Enable the loopback interface.<br />
ip=192.168.1.1:::::eth2:none --> Enable static eth2 interface.<br />
ip=:::::eth0:dhcp --> Enable dhcp protcol for eth0 configuration.<br />
'''nfsroot='''<br />
<br />
If the 'nfsroot' parameter is NOT given on the command line, the default<br />
"/tftpboot/%s" will be used.<br />
<br />
nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]<br />
<br />
''Parameter explanation:''<br />
<br />
<server-ip> Specifies the IP address of the NFS server. If this field<br />
is not given, the default address as determined by the<br />
`ip' variable (see below) is used. One use of this<br />
parameter is for example to allow using different servers<br />
for RARP and NFS. Usually you can leave this blank.<br />
<br />
<root-dir> Name of the directory on the server to mount as root. If<br />
there is a "%s" token in the string, the token will be<br />
replaced by the ASCII-representation of the client's IP<br />
address.<br />
<br />
<nfs-options> Standard NFS options. All options are separated by commas.<br />
If the options field is not given, the following defaults<br />
will be used:<br />
port = as given by server portmap daemon<br />
rsize = 1024<br />
wsize = 1024<br />
timeo = 7<br />
retrans = 3<br />
acregmin = 3<br />
acregmax = 60<br />
acdirmin = 30<br />
acdirmax = 60<br />
flags = hard, nointr, noposix, cto, ac<br />
<br />
'''root=/dev/nfs'''<br />
If you don't use nfsroot= parameter you need to set root=/dev/nfs <br />
to boot from a nfs root by autoconfiguration.<br />
<br />
=== Using lvm ===<br />
<br />
If your root device is on lvm, you have to add the '''lvm2''' hook. You have to pass your root device on the kernel command line in the format<br />
<br />
root=/dev/mapper/<volume group name>-<logical volume name><br />
<br />
for example<br />
<br />
root=/dev/mapper/myvg-root<br />
<br />
=== Using encrypted root ===<br />
<br />
If your root volume is encrypted, you need to add the '''encrypt''' hook. Then specify your root device on the kernel command line, just as if it was unencrypted.<br />
<br />
For an encrypted partition on an sata or scsi disk:<br />
root=/dev/sda5<br />
<br />
For an encrypted lvm volume:<br />
root=/dev/mapper/myvg-root<br />
<br />
The root device will be automatically changed to ''/dev/mapper/root''.<br />
<br />
==== Using LUKS volumes ====<br />
<br />
If you use LUKS for hard disk encryption, the init script will detect the encryption automatically if the '''encrypt''' hook is enabled. It will then ask for a passphrase and try to unlock the volume.<br />
<br />
If this fails try to add you filesystem-module to the module list in /etc/mkinitcpio.conf if it's not compiled into your kernel.<br />
<br />
==== Using legacy cryptsetup volumes ====<br />
<br />
If you are using a legacy cryptsetup volume, you have to specify all cryptsetup options necessary to unlock it on the kernel command line. The option format is<br />
<br />
crypto=hash:cipher:keysize:offset:skip<br />
<br />
representing cryptsetup's --hash, --cipher, --keysize, --offset and --skip options. If you omit an option, cryptsetup's default value is used, so you can just specify<br />
<br />
crypto=::::<br />
<br />
if you created your volume with the default settings.<br />
<br />
'''NOTE:''' For technical reasons, it is not possible to verify the correctness of your passphrase with legacy cryptsetup volumes. If you typed it wrong, mounting will simply fail. It is recommended that you use LUKS instead.<br />
<br />
==== Using loop-aes volumes ====<br />
<br />
'''mkinitcpio''' does not support loop-aes yet.<br />
<br />
== Using Suspend to Disk ==<br />
<br />
If you want to use suspend to disk, you have to add the '''resume''' hook.<br />
<br />
==== swsusp ====<br />
<br />
''TODO''<br />
<br />
==== µswsusp ====<br />
<br />
µswsusp is not supported yet.<br />
<br />
==== suspend2 ====<br />
<br />
If you are using [[Suspend to Disk|suspend2]], you have to specify the ''resume2'' kernel commandline option. If you are using the swap writer, use<br />
<br />
resume2=swap:/dev/hda3<br />
<br />
where ''/dev/hda3'' is your swap partition. If you want to use the filewriter, use<br />
<br />
resume2=file:/dev/hda2:0x123456<br />
<br />
where ''/dev/hda2'' is the partition where the suspend2 image is stored (most likely the root partition) and ''0x123456'' is the file offset. You can get the exact value with the commands<br />
<br />
echo "/suspend2_file" > /proc/suspend2/filewriter_target<br />
cat /proc/suspend2/resume2<br />
<br />
where /suspend2_file is the path to your suspend image file. This - of course - works for lvm volumes as well. You can also use a suspend file on an encrypted root partition with the option<br />
<br />
resume2=file:/dev/mapper/root:0x123456<br />
<br />
where ''0x123456'' is the offset again. Resuming from an encrypted swap partition is not supported.<br />
<br />
=== Example bootloader configuration files ===<br />
<br />
If you use the beyond kernel, the filenames are ''kernel26beyond.img'' and ''kernel26beyond-fallback.img'' instead of ''kernel26.img'' and ''kernel26-fallback.img'', respectively. Also, change "vmlinuz26" to "vmlinuz26beyond". <br />
<br />
==== GRUB ====<br />
<br />
For those who have /boot on a separate partition:<br />
<br />
# (0) Arch Linux<br />
title Arch Linux<br />
root (hd0,3)<br />
kernel /vmlinuz26 root=/dev/hda4 vga=791 ro<br />
initrd /kernel26.img<br />
<br />
title Arch Linux Fallback<br />
root (hd0,3)<br />
kernel /vmlinuz26 root=/dev/hda4 vga=791 ro<br />
initrd /kernel26-fallback.img<br />
<br />
For those who do _not_ have /boot on a separate partition:<br />
<br />
# (0) Arch Linux<br />
title Arch Linux<br />
root (hd0,3)<br />
kernel /boot/vmlinuz26 root=/dev/hda4 vga=791 ro<br />
initrd /boot/kernel26.img<br />
<br />
title Arch Linux Fallback<br />
root (hd0,3)<br />
kernel /boot/vmlinuz26 root=/dev/hda4 vga=791 ro<br />
initrd /boot/kernel26-fallback.img<br />
<br />
==== LILO ====<br />
<br />
If you use LILO, it is recommended that you use ''append="root=/dev/XYZ"'' instead of ''root=/dev/XYZ''. If you already have a global ''append'' option, then use ''addappend''.<br />
<br />
boot=/dev/hdX <br />
default = ArchLinux<br />
timeout=50 <br />
vga=791<br />
lba32<br />
prompt<br />
<br />
# for the hardware-autodetecting image<br />
image=/boot/vmlinuz26<br />
label=ArchLinux<br />
append="root=/dev/hdXY"<br />
initrd=/boot/kernel26.img<br />
read-only<br />
<br />
# fallback image if the other doesnt work (Will most prob. never be used)<br />
image=/boot/vmlinuz26<br />
label=ArchLinuxFallBack<br />
append="root=/dev/hdXY"<br />
initrd=/boot/kernel26-fallback.img<br />
read-only<br />
<br />
== Troubleshooting ==<br />
=== piix ide controllers and beyond kernel ===<br />
==== Problem ====<br />
If you are having problems getting mkinitcpio to detect your hard drive giving errors akin to "Can't find device dev(0,0)" when switching to kinit, then this could be because of a conflict that the ata_piix and piix drivers have. The beyond kernel has some libata patches that cause ata_piix to *conflict* with piix.<br />
<br />
==== Solution ====<br />
Edit /etc/mkinitcpio.conf to only have ide or sata or scsi depending on what your system actually needs to boot.<br />
<br />
<br />
== Getting under the hood ==<br />
If you are curious about what is inside the initrd image you can extract it and poke around the files inside of it. but...<br />
=== Warning ===<br />
using cpio to extract an image is dangerous, as it likes to extract over your existing system, rendering it broken and unbootable.<br />
=== using bsdtar ===</div>Wide-eyehttps://wiki.archlinux.org/index.php?title=Hibernate-script&diff=22143Hibernate-script2007-03-24T16:50:09Z<p>Wide-eye: alternate method to find the offset</p>
<hr />
<div>[[Category:Power management (English)]]<br />
[[Category:Laptops (English)]]<br />
[[Category:Tutorials (English)]]<br />
<br />
This article will describe how to Suspend a computer (usually a laptop) to Disk. This means that all programs in use will be saved to the hard drive and power will completely shut down. This article uses suspend2 software and does not cover all options within suspend2. See the [http://www.suspend2.net/ Suspend2 website] for complete documentation.<br />
<br />
=Obtaining Suspend2=<br />
Suspend2 is a kernel patch and set of scripts and UI components. They are available as part of the [http://bbs.archlinux.org/viewtopic.php?t=20199 -beyond kernel patchset] conveniently available through pacman. You will also need the hibernate scripts.<br />
<br />
# pacman -S kernel26beyond hibernate-script<br />
<br />
As an alternative, there is also a suspend2 kernel in community. Use this if you don't want/need the numerous other patches that are included in the beyond kernel.<br />
<br />
# pacman -S kernel26suspend2 hibernate-script<br />
<br />
Note that if you are not currently using the beyond or suspend2 kernel you may need to also download the -beyond or -suspend2 version of certain drivers, particularly wireless card and video drivers. If you have custom compiled modules, you will need to recompile them. You can search for all precompiled -beyond or -suspend2 modules with:<br />
<br />
# pacman -Ss beyond<br />
# pacman -Ss suspend2<br />
<br />
I suggest that you make sure all your hardware is working properly before configuring Suspend2.<br />
<br />
=Configuring Suspend2=<br />
In order to use Suspend2, you need to do three things<br />
# Edit your Bootloader configuration (/boot/grub/menu.lst)<br />
# Configure the hibernate script<br />
# Edit your /etc/mkinitcpio.conf file and regenerate your initramfs image<br />
<br />
==Editing the Grub menu.lst==<br />
Before your can use the suspend function, you need to boot your computer with the "resume2" parameter.<br />
<br />
'''menu.lst: Boot with this option before trying to Suspend for the first time!'''<br />
<br />
# suspend2 with the beyond kernel<br />
title ArchLinux Beyond<br />
kernel /boot/vmlinuz26beyond root=/dev/hda2 resume2=swap:/dev/hda3<br />
initrd /boot/kernel26beyond.img<br />
<br />
or<br />
<br />
# suspend2 with the suspend2 kernel<br />
title ArchLinux Suspend2<br />
kernel /boot/vmlinuz26suspend2 root=/dev/hda2 resume2=swap:/dev/hda3<br />
initrd /boot/kernel26suspend2.img<br />
<br />
This assumes that you installed Archlinux onto the second hard drive partition, and that your swap partition is the third. If you have a separate /boot partition, the /boot at the kernel and initrd lines has to be omitted.<br />
<br />
If you use lilo instead of grub, refer to the lilo documentation and make the proper changes in ''/etc/lilo.conf''.<br />
<br />
==Configuring the hibernate script==<br />
<br />
This is a brief overview of the hibernate script. If you want to tweak it further, examine the ''common.conf'' and ''suspend2.conf'' files further and read ''hibernate --help''.<br />
<br />
===Editing /etc/hibernate/hibernate.conf===<br />
<br />
Make sure ''hibernate'' uses suspend2. (''hibernate'' can also be used with ACPI S3 (suspend to ram) or linux swsusp, but this is not part of this HOWTO)<br />
<br />
TryMethod suspend2.conf<br />
#TryMethod disk.conf<br />
#TryMethod ram.conf<br />
<br />
===Editing /etc/hibernate/suspend2.conf===<br />
<br />
Make sure the following lines are uncommented and appropriately configured<br />
UseSuspend2 yes<br />
Reboot no<br />
EnableEscape yes<br />
DefaultConsoleLevel 1<br />
Compressor lzf<br />
Encryptor none<br />
<br />
===Editing /etc/hibernate/common.conf===<br />
<br />
Uncomment the lines for any filesystems that have the potential to change while your computer is suspended (for example shared partitions with windows like vfat or ntfs ones). Resume will then remount them when you resume. Failure to follow this could result in filesystem corruption.<br />
### filesystems<br />
# Unmount /nfsshare /windows /mnt/sambaserver<br />
# UnmountFSTypes smbfs nfs<br />
# UnmountGraceTime 1<br />
# Mount /windows<br />
<br />
Do not uncomment the Grub lines below, as it will work once or twice, but after two or three suspend/resumes it will hang on resuming and corrupt your menu.lst file causing you to have to try and remember how to boot from a "grub>" prompt--not fun.<br />
<br />
### grub<br />
#ChangeGrubMenu yes<br />
#GrubMenuFile /boot/grub/menu.lst<br />
#AlternateGrubMenuFile /boot/grub/menu-suspended.lst<br />
#BackupGrubMenuFile /boot/grub/menu.lst.hibernate.bak<br />
<br />
You can have Suspend2 unload problematic modules. The blacklisted modules list is found in the /etc/hibernate directory. It has a list of modules known to be broken with suspend2. Most people don't have to change the settings here or in the blacklisted modules.<br />
<br />
### modules<br />
# UnloadModules snd_via82cxxx usb-ohci<br />
# UnloadAllModules yes<br />
UnloadBlacklistedModules yes<br />
LoadModules auto<br />
# LoadModulesFromFile /etc/modules<br />
<br />
If you suspend from X, you most likely need the ''SwitchToTextMode'' option. If it doesn't work, try changing these.<br />
<br />
### xhacks<br />
SwitchToTextMode yes<br />
# UseDummyXServer yes<br />
<br />
These settings can be used to customize your hibernation and resume messages.<br />
<br />
### xstatus<br />
## This can be set to gnome, kde or x:<br />
# XStatus gnome<br />
# XSuspendText Preparing to suspend...<br />
# XResumeText Resuming from suspend...<br />
## When using XStatus x, and you have xosd installed:<br />
# XosdSettings --font -misc-fixed-medium-r-semicondensed--*-120-*-*-c-*-*-* --colour=Green --shadow 1 --pos bottom --align center --offset 50<br />
<br />
===/etc/rc.d/hibernate-cleanup script===<br />
It's optional. It clears out old resume images from swap and filewriter<br />
locations on boot (in case they are present, but you haven't used them<br />
to resume). It is not required if you only boot a suspend2 capable kernel.<br />
<br />
So add it to the DAEMONS list in rc.conf if you wish.<br />
<br />
==Editing /etc/mkinitcpio.conf==<br />
<br />
Arch Linux uses initcpio, you have to add ''resume'' hook to ''/etc/mkinitcpio.conf'' to resume. If you use the ''udev'' hook (which most people do), make sure you put ''resume'' after ''udev'' in order to let the kernel load all of the modules for your harddisks before resuming, otherwise you'll get a "BIG FAT WARNING!! Failed to translate the device name into a device id." error.<br />
<br />
The HOOKS in ''/etc/mkinitcpio.conf'' should look something like<br />
<br />
HOOKS="base udev autodetect ide resume filesystems"<br />
<br />
Then do "mkinitcpio" to rebuild the initcpio image (if you decided to use kernel26suspend2, change the line accordingly).<br />
<br />
# mkinitcpio -p kernel26beyond<br />
<br />
==swapwriter and filewriter==<br />
<br />
Suspend2 can either write the image to your swapspace or to a file on a partition.<br />
<br />
===Using the swapwriter===<br />
<br />
If you want to use the swapwriter, just add your swap partition to the resume2 kernel command line option. For example, if ''/dev/hda3'' is your swap partition, it would look like this:<br />
<br />
resume2=swap:/dev/hda3<br />
<br />
You don't need to change the default hibernate configuration. (NOTE: This configuration is also used in the examples above)<br />
<br />
===Using the filewriter===<br />
<br />
If you want to use the filewriter. Choose a partition which enough space on it, like for example your root partition. To create a 256MB suspend file in ''/root/suspend_file'', change ''/etc/hibernate/suspend2.conf'' like this:<br />
<br />
## For filewriter:<br />
FilewriterLocation /root/suspend_file 256<br />
VerifyFilewriterResume2 no<br />
<br />
Then call the command<br />
<br />
# hibernate --no-suspend<br />
<br />
Then find out the offset for the resume2 option:<br />
<br />
# cat /sys/power/suspend2/resume2 <br />
file:/dev/hda2:0x1a2b3<br />
<br />
Add this as the resume2 option to your kernel commandline:<br />
<br />
resume2=file:/dev/hda2:0x1a2b3<br />
<br />
After that, change ''/etc/hibernate/suspend2.conf'' like this:<br />
<br />
## For filewriter:<br />
FilewriterLocation /root/suspend_file 256<br />
VerifyFilewriterResume2 yes<br />
<br />
and reboot. (NOTE: In some more complicated setups, you may have to let the ''VerifyFilewriterResume2'' option be set to ''no''. Setting it to yes is just a precaution)<br />
<br />
<br />
An alternate method to find the offset if you can't get the above to work:<br />
echo "Suspend2" > /root/suspend_file<br />
dd if=/dev/zero bs=1M count=256 >> /root/suspend_file <br />
echo /root/suspend_file > /proc/suspend2/filewriter_target<br />
cat /proc/suspend2/resume2<br />
<br />
=Using userui - a user interface for suspend2=<br />
<br />
Optionally, you can use a text or fbsplash interface with a progress bar with suspend2. To do this, install the ''userui'' package:<br />
<br />
# pacman -S userui<br />
<br />
In ''/etc/hibernate/suspend2.conf'', configure the user interface:<br />
<br />
## Specify a userui like this:<br />
# text interface<br />
ProcSetting user_interface/program /usr/sbin/suspend2ui_text<br />
<br />
or<br />
<br />
## Specify a userui like this:<br />
# fbsplash interface interface<br />
ProcSetting user_interface/program /usr/sbin/suspend2ui_fbsplash<br />
<br />
The ''fbsplash'' interface also needs a fbsplash theme in ''/etc/splash/suspend2/''.<br />
<br />
The text interface may be good for debugging suspend2, as it displays some messages. Both interfaces allow aborting a suspend cycle if you press the escape key.<br />
<br />
You won't see a user interface for the first few seconds of the resume process unless you add the ''userui'' hook to your mkinitcpio configuration, but this is also optional.<br />
<br />
=Suspending and Resuming=<br />
<br />
Now that you've installed the necessary software and edited the configuration files, you need to reboot once using the resume2 enabled boot option from your Grub menu. You can then try hibernating with the hibernate script.<br />
<br />
# hibernate<br />
<br />
If all goes well, you should be able to resume using the same Grub menu selection. If you make that option the default for Grub, you will always default to resuming if a resume image is available. '''Do never use a different kernel to resume than you used to suspend! If pacman updates your kernel, don't suspend before you have rebooted properly.''' It is recommended that you test the suspend/hibernate from a text console first and then once you have confirmed that it works try it from within X.<br />
<br />
Once you've done your testing, you will want to make it so that regular users can use the hibernate script. You can either use sudo or you can use desktop specific functions such as making a menu item with the command "kdesu hibernate" (KDE only). Unfortunately, using kdesu still requires the root password (that issue has been fixed in kde 3.5.5, i think), so it's probably better to go with sudo.<br />
<br />
=Combining suspend to disk with suspend to RAM=<br />
<br />
If your motherboard or laptop supports ACPI S3 (suspend to RAM), you can combine it with suspend2. This will result in the following behaviour:<br />
<br />
* When you call hibernate, your system will suspend to disk and after that suspend to RAM instead of powering down.<br />
* When you turn your system back on, it will resume directly from RAM (which only takes a few seconds)<br />
* If your battery fails in the meantime (and the image in your memory is therefore lost), suspend2 resumes from your harddisk.<br />
<br />
This setting could be described as suspend to RAM with fallback. To use it, change ''/etc/hibernate/suspend2.conf'':<br />
<br />
## Powerdown method - 3 for suspend-to-RAM, 4 for ACPI S4 sleep, 5 for poweroff<br />
PowerdownMethod 3<br />
<br />
For this to work, your computer must be able to use suspend to RAM. On many machines, this is more problematic than suspend to disk and requires some extra tweaks to the hibernate script.<br />
<br />
=Miscellaneous hibernate tweaks=<br />
<br />
== Restore volume levels when resuming ==<br />
<br />
If you don't explicitly restore the volume levels, ALSA will have the sound channels muted after resuming. To account for that, look for<br />
<br />
### services<br />
<br />
in /etc/hibernate/common.conf and change the line just below to<br />
<br />
RestartServices alsa<br />
<br />
== Eject all PcCards ==<br />
<br />
If you want to eject all PcCards before suspending and reinsert them after resuming, change the ''EjectCards'' setting in ''common.conf'':<br />
<br />
### pcmcia<br />
EjectCards yes<br />
<br />
This is necessary on some laptops, if the PcCards stop working after resume.<br />
<br />
== NVidia specific settings ==<br />
<br />
If you have an NVidia graphics card and are using the binary driver by NVidia with an AGP card, you have to add the following line to your /etc/X11/xorg.conf:<br />
<br />
Option "NvAGP" "1"<br />
<br />
Maybe this is not necessary because the alternative AGP driver is not even enabled in the -beyond kernel. NVidia also suggests to add<br />
<br />
ProcSetting extra_pages_allowance 0<br />
<br />
to the file /etc/hibernate/suspend2.conf. This setting also seems to help with the binary ATI driver. At last, you need to uncomment the nvidia module in /etc/hibernate/blacklisted-modules. Using those settings I can successfully hibernate and resume from within an X environment, GNOME in my case.<br />
<br />
== Dropping Disk Caches ==<br />
<br />
As a way to speed up suspending, you can free the memory used for disk caches. so there will be less to write to the disk. The downside is there is a risk of crashing your system. but I have had no trouble with it so far, while reducing the size of the suspended image by half. Just run this before hibernating:<br />
<br />
sync; echo 3 > /proc/sys/vm/drop_caches<br />
[http://linux.inet.hr/proc_sys_vm_drop_caches.html drop_caches introduction]<br />
<br />
== Other ==<br />
<br />
*There is a good [http://gentoo-wiki.com/HOWTO_Software_Suspend_v2 Gentoo wiki article] that covers a lot of the same material.</div>Wide-eyehttps://wiki.archlinux.org/index.php?title=Hibernate-script&diff=21285Hibernate-script2007-02-25T05:43:45Z<p>Wide-eye: added drop_cache tip</p>
<hr />
<div>[[Category:Power management (English)]]<br />
[[Category:Laptops (English)]]<br />
[[Category:Tutorials (English)]]<br />
<br />
This article will describe how to Suspend a computer (usually a laptop) to Disk. This means that all programs in use will be saved to the hard drive and power will completely shut down. This article uses suspend2 software and does not cover all options within suspend2. See the [http://www.suspend2.net/ Suspend2 website] for complete documentation.<br />
<br />
=Obtaining Suspend2=<br />
Suspend2 is a kernel patch and set of scripts and UI components. They are available as part of the [http://bbs.archlinux.org/viewtopic.php?t=20199 -beyond kernel patchset] conveniently available through pacman. You will also need the hibernate scripts.<br />
<br />
# pacman -S kernel26beyond hibernate-script<br />
<br />
As an alternative, there is also a suspend2 kernel in community. Use this if you don't want/need the numerous other patches that are included in the beyond kernel.<br />
<br />
# pacman -S kernel26suspend2 hibernate-script<br />
<br />
Note that if you are not currently using the beyond or suspend2 kernel you may need to also download the -beyond or -suspend2 version of certain drivers, particularly wireless card and video drivers. If you have custom compiled modules, you will need to recompile them. You can search for all precompiled -beyond or -suspend2 modules with:<br />
<br />
# pacman -Ss beyond<br />
# pacman -Ss suspend2<br />
<br />
I suggest that you make sure all your hardware is working properly before configuring Suspend2.<br />
<br />
=Configuring Suspend2=<br />
In order to use Suspend2, you need to do three things<br />
# Edit your Bootloader configuration (/boot/grub/menu.lst)<br />
# Configure the hibernate script<br />
# Edit your /etc/mkinitcpio.conf file and regenerate your initramfs image<br />
<br />
==Editing the Grub menu.lst==<br />
Before your can use the suspend function, you need to boot your computer with the "resume2" parameter.<br />
<br />
'''menu.lst: Boot with this option before trying to Suspend for the first time!'''<br />
<br />
# suspend2 with the beyond kernel<br />
title ArchLinux Beyond<br />
kernel /boot/vmlinuz26beyond root=/dev/hda2 resume2=swap:/dev/hda3<br />
initrd /boot/kernel26beyond.img<br />
<br />
or<br />
<br />
# suspend2 with the suspend2 kernel<br />
title ArchLinux Suspend2<br />
kernel /boot/vmlinuz26suspend2 root=/dev/hda2 resume2=swap:/dev/hda3<br />
initrd /boot/kernel26suspend2.img<br />
<br />
This assumes that you installed Archlinux onto the second hard drive partition, and that your swap partition is the third. If you have a separate /boot partition, the /boot at the kernel and initrd lines has to be omitted.<br />
<br />
If you use lilo instead of grub, refer to the lilo documentation and make the proper changes in ''/etc/lilo.conf''.<br />
<br />
==Configuring the hibernate script==<br />
<br />
This is a brief overview of the hibernate script. If you want to tweak it further, examine the ''common.conf'' and ''suspend2.conf'' files further and read ''hibernate --help''.<br />
<br />
===Editing /etc/hibernate/hibernate.conf===<br />
<br />
Make sure ''hibernate'' uses suspend2. (''hibernate'' can also be used with ACPI S3 (suspend to ram) or linux swsusp, but this is not part of this HOWTO)<br />
<br />
TryMethod suspend2.conf<br />
#TryMethod disk.conf<br />
#TryMethod ram.conf<br />
<br />
===Editing /etc/hibernate/suspend2.conf===<br />
<br />
Make sure the following lines are uncommented and appropriately configured<br />
UseSuspend2 yes<br />
Reboot no<br />
EnableEscape yes<br />
DefaultConsoleLevel 1<br />
Compressor lzf<br />
Encryptor none<br />
<br />
===Editing /etc/hibernate/common.conf===<br />
<br />
Uncomment the lines for any filesystems that have the potential to change while your computer is suspended (for example shared partitions with windows like vfat or ntfs ones). Resume will then remount them when you resume. Failure to follow this could result in filesystem corruption.<br />
### filesystems<br />
# Unmount /nfsshare /windows /mnt/sambaserver<br />
# UnmountFSTypes smbfs nfs<br />
# UnmountGraceTime 1<br />
# Mount /windows<br />
<br />
Do not uncomment the Grub lines below, as it will work once or twice, but after two or three suspend/resumes it will hang on resuming and corrupt your menu.lst file causing you to have to try and remember how to boot from a "grub>" prompt--not fun.<br />
<br />
### grub<br />
#ChangeGrubMenu yes<br />
#GrubMenuFile /boot/grub/menu.lst<br />
#AlternateGrubMenuFile /boot/grub/menu-suspended.lst<br />
#BackupGrubMenuFile /boot/grub/menu.lst.hibernate.bak<br />
<br />
You can have Suspend2 unload problematic modules. The blacklisted modules list is found in the /etc/hibernate directory. It has a list of modules known to be broken with suspend2. Most people don't have to change the settings here or in the blacklisted modules.<br />
<br />
### modules<br />
# UnloadModules snd_via82cxxx usb-ohci<br />
# UnloadAllModules yes<br />
UnloadBlacklistedModules yes<br />
LoadModules auto<br />
# LoadModulesFromFile /etc/modules<br />
<br />
If you suspend from X, you most likely need the ''SwitchToTextMode'' option. If it doesn't work, try changing these.<br />
<br />
### xhacks<br />
SwitchToTextMode yes<br />
# UseDummyXServer yes<br />
<br />
These settings can be used to customize your hibernation and resume messages.<br />
<br />
### xstatus<br />
## This can be set to gnome, kde or x:<br />
# XStatus gnome<br />
# XSuspendText Preparing to suspend...<br />
# XResumeText Resuming from suspend...<br />
## When using XStatus x, and you have xosd installed:<br />
# XosdSettings --font -misc-fixed-medium-r-semicondensed--*-120-*-*-c-*-*-* --colour=Green --shadow 1 --pos bottom --align center --offset 50<br />
<br />
===/etc/rc.d/hibernate-cleanup script===<br />
It's optional. It clears out old resume images from swap and filewriter<br />
locations on boot (in case they are present, but you haven't used them<br />
to resume). It is not required if you only boot a suspend2 capable kernel.<br />
<br />
So add it to the DAEMONS list in rc.conf if you wish.<br />
<br />
==Editing /etc/mkinitcpio.conf==<br />
<br />
Arch Linux uses initcpio, you have to add ''resume'' hook to ''/etc/mkinitcpio.conf'' to resume. If you use the ''udev'' hook (which most people do), make sure you put ''resume'' after ''udev'' in order to let the kernel load all of the modules for your harddisks before resuming, otherwise you'll get a "BIG FAT WARNING!! Failed to translate the device name into a device id." error.<br />
<br />
The HOOKS in ''/etc/mkinitcpio.conf'' should look something like<br />
<br />
HOOKS="base udev autodetect ide resume filesystems"<br />
<br />
Then do "mkinitcpio" to rebuild the initcpio image (if you decided to use kernel26suspend2, change the line accordingly).<br />
<br />
# mkinitcpio -p kernel26beyond<br />
<br />
==swapwriter and filewriter==<br />
<br />
Suspend2 can either write the image to your swapspace or to a file on a partition.<br />
<br />
===Using the swapwriter===<br />
<br />
If you want to use the swapwriter, just add your swap partition to the resume2 kernel command line option. For example, if ''/dev/hda3'' is your swap partition, it would look like this:<br />
<br />
resume2=swap:/dev/hda3<br />
<br />
You don't need to change the default hibernate configuration. (NOTE: This configuration is also used in the examples above)<br />
<br />
===Using the filewriter===<br />
<br />
If you want to use the filewriter. Choose a partition which enough space on it, like for example your root partition. To create a 256MB suspend file in ''/root/suspend_file'', change ''/etc/hibernate/suspend2.conf'' like this:<br />
<br />
## For filewriter:<br />
FilewriterLocation /root/suspend_file 256<br />
VerifyFilewriterResume2 no<br />
<br />
Then call the command<br />
<br />
# hibernate --no-suspend<br />
<br />
Then find out the offset for the resume2 option:<br />
<br />
# cat /sys/power/suspend2/resume2 <br />
file:/dev/hda2:0x1a2b3<br />
<br />
Add this as the resume2 option to your kernel commandline:<br />
<br />
resume2=file:/dev/hda2:0x1a2b3<br />
<br />
After that, change ''/etc/hibernate/suspend2.conf'' like this:<br />
<br />
## For filewriter:<br />
FilewriterLocation /root/suspend_file 256<br />
VerifyFilewriterResume2 yes<br />
<br />
and reboot. (NOTE: In some more complicated setups, you may have to let the ''VerifyFilewriterResume2'' option be set to ''no''. Setting it to yes is just a precaution)<br />
<br />
=Using userui - a user interface for suspend2=<br />
<br />
Optionally, you can use a text or fbsplash interface with a progress bar with suspend2. To do this, install the ''userui'' package:<br />
<br />
# pacman -S userui<br />
<br />
In ''/etc/hibernate/suspend2.conf'', configure the user interface:<br />
<br />
## Specify a userui like this:<br />
# text interface<br />
ProcSetting user_interface/program /usr/sbin/suspend2ui_text<br />
<br />
or<br />
<br />
## Specify a userui like this:<br />
# fbsplash interface interface<br />
ProcSetting user_interface/program /usr/sbin/suspend2ui_fbsplash<br />
<br />
The ''fbsplash'' interface also needs a fbsplash theme in ''/etc/splash/suspend2/''.<br />
<br />
The text interface may be good for debugging suspend2, as it displays some messages. Both interfaces allow aborting a suspend cycle if you press the escape key.<br />
<br />
You won't see a user interface for the first few seconds of the resume process unless you add the ''userui'' hook to your mkinitcpio configuration, but this is also optional.<br />
<br />
=Suspending and Resuming=<br />
<br />
Now that you've installed the necessary software and edited the configuration files, you need to reboot once using the resume2 enabled boot option from your Grub menu. You can then try hibernating with the hibernate script.<br />
<br />
# hibernate<br />
<br />
If all goes well, you should be able to resume using the same Grub menu selection. If you make that option the default for Grub, you will always default to resuming if a resume image is available. '''Do never use a different kernel to resume than you used to suspend! If pacman updates your kernel, don't suspend before you have rebooted properly.''' It is recommended that you test the suspend/hibernate from a text console first and then once you have confirmed that it works try it from within X.<br />
<br />
Once you've done your testing, you will want to make it so that regular users can use the hibernate script. You can either use sudo or you can use desktop specific functions such as making a menu item with the command "kdesu hibernate" (KDE only). Unfortunately, using kdesu still requires the root password (that issue has been fixed in kde 3.5.5, i think), so it's probably better to go with sudo.<br />
<br />
=Combining suspend to disk with suspend to RAM=<br />
<br />
If your motherboard or laptop supports ACPI S3 (suspend to RAM), you can combine it with suspend2. This will result in the following behaviour:<br />
<br />
* When you call hibernate, your system will suspend to disk and after that suspend to RAM instead of powering down.<br />
* When you turn your system back on, it will resume directly from RAM (which only takes a few seconds)<br />
* If your battery fails in the meantime (and the image in your memory is therefore lost), suspend2 resumes from your harddisk.<br />
<br />
This setting could be described as suspend to RAM with fallback. To use it, change ''/etc/hibernate/suspend2.conf'':<br />
<br />
## Powerdown method - 3 for suspend-to-RAM, 4 for ACPI S4 sleep, 5 for poweroff<br />
PowerdownMethod 3<br />
<br />
For this to work, your computer must be able to use suspend to RAM. On many machines, this is more problematic than suspend to disk and requires some extra tweaks to the hibernate script.<br />
<br />
=Miscellaneous hibernate tweaks=<br />
<br />
== Restore volume levels when resuming ==<br />
<br />
If you don't explicitly restore the volume levels, ALSA will have the sound channels muted after resuming. To account for that, look for<br />
<br />
### services<br />
<br />
in /etc/hibernate/common.conf and change the line just below to<br />
<br />
RestartServices alsa<br />
<br />
== Eject all PcCards ==<br />
<br />
If you want to eject all PcCards before suspending and reinsert them after resuming, change the ''EjectCards'' setting in ''common.conf'':<br />
<br />
### pcmcia<br />
EjectCards yes<br />
<br />
This is necessary on some laptops, if the PcCards stop working after resume.<br />
<br />
== NVidia specific settings ==<br />
<br />
If you have an NVidia graphics card and are using the binary driver by NVidia with an AGP card, you have to add the following line to your /etc/X11/xorg.conf:<br />
<br />
Option "NvAGP" "1"<br />
<br />
Maybe this is not necessary because the alternative AGP driver is not even enabled in the -beyond kernel. NVidia also suggests to add<br />
<br />
ProcSetting extra_pages_allowance 0<br />
<br />
to the file /etc/hibernate/suspend2.conf. This setting also seems to help with the binary ATI driver. At last, you need to uncomment the nvidia module in /etc/hibernate/blacklisted-modules. Using those settings I can successfully hibernate and resume from within an X environment, GNOME in my case.<br />
<br />
== Dropping Disk Caches ==<br />
<br />
As a way to speed up suspending, you can free the memory used for disk caches. so there will be less to write to the disk. The downside is there is a risk of crashing your system. but I have had no trouble with it so far, while reducing the size of the suspended image by half. Just run this before hibernating:<br />
<br />
sync; echo 3 > /proc/sys/vm/drop_caches<br />
[http://linux.inet.hr/proc_sys_vm_drop_caches.html drop_caches introduction]<br />
<br />
== Other ==<br />
<br />
*There is a good [http://gentoo-wiki.com/HOWTO_Software_Suspend_v2 Gentoo wiki article] that covers a lot of the same material.</div>Wide-eye