https://wiki.archlinux.org/api.php?action=feedcontributions&user=Xrchz&feedformat=atomArchWiki - User contributions [en]2024-03-28T20:47:56ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Unofficial_user_repositories/ArchHaskell&diff=372922Unofficial user repositories/ArchHaskell2015-05-08T02:52:43Z<p>Xrchz: /* [haskell-happstack] */ remove unnecessary spaces in code blocks</p>
<hr />
<div>[[Category:Package development]]<br />
The ArchHaskell group works on providing [[Haskell]] packages to the wider Arch Linux community. The goal is to provide all of [http://hackage.haskell.org Hackage] as binary packages for easy installation.<br />
<br />
== Resources ==<br />
<br />
The main resources for the [[ArchHaskell]] community to interact and discuss are:<br />
<br />
* #archlinux-haskell IRC channel @ freenode.org<br />
* arch-haskell@haskell.org [http://haskell.org/mailman/listinfo/arch-haskell mailing list] and [http://www.haskell.org/pipermail/arch-haskell archives]<br />
* [https://github.com/archhaskell ArchHaskell group] on GitHub<br />
<br />
== Membership ==<br />
<br />
Membership is not required at all in order to contribute. Just fork the relevant repository, make some changes, and file a pull request.<br />
<br />
There are currently two people with commit rights to the ArchHaskell repository at GitHub:<br />
<br />
* Magnus Therning<br />
* Leif Warner<br />
<br />
== Available repositories ==<br />
<br />
=== [haskell-core] ===<br />
<br />
The [haskell-core] repository is the base repository of packages maintained by the ArchHaskell team.<br />
[haskell-core] can be accessed by adding the following entry to {{ic|/etc/pacman.conf}} (above [extra]):<br />
<br />
[haskell-core]<br />
<nowiki>Server = http://xsounds.org/~haskell/core/$arch</nowiki><br />
<br />
or a mirror (updated daily):<br />
<br />
[haskell-core]<br />
<nowiki>Server = http://orbitalfox.com/haskell/core/$arch</nowiki><br />
<br />
The set of packages in the [haskell-core] repository is derived from the '''habs''' tree officially located [https://github.com/archhaskell/habs here]. A tool called [https://github.com/magthe/cblrepo cblrepo] is used to keep the '''habs''' tree synchronized with the official Haskell packages from [http://hackage.haskell.org/packages/hackage.html Hackage].<br />
<br />
{{Warning|Placing [haskell-core] above [extra] will cause packages from [haskell-core] to take precedence, and avoid dependency conflicts in case of duplicate packages. Overriding [[official repositories]] is however '''not''' supported.}}<br />
<br />
The repositories provide both file listings (by using {{ic|repo-add --files}}), package deltas ({{ic|repo-add --delta}}), and both packages and the database are signed. The fingerprint of the key used for signing is:<br />
<br />
pub 2048D/4209170B 2012-12-26<br />
Key fingerprint = F310 4992 EBF2 4EB8 72B9 7B9C 32B0 B453 4209 170B<br />
uid ArchHaskell (Magnus Therning) <magnus@therning.org><br />
sub 2048D/A418C0FE 2012-12-26<br />
<br />
If you use {{ic|SigLevel &#61; Required TrustedOnly}} in {{ic|/etc/pacman.conf}} for [haskell-core], then you need to do the following to add Magnus Therning's key:<br />
<br />
# pacman-key -r 4209170B<br />
# pacman-key --lsign-key 4209170B<br />
<br />
Force a refresh of all package lists:<br />
<br />
# pacman -Syy<br />
<br />
=== [haskell-happstack] ===<br />
<br />
The [haskell-happstack] repository contains packages for web development based on the [http://happstack.com/ Happstack] framework. It requires [[Haskell_Package_Guidelines#.5Bhaskell-core.5D|[haskell-core]]], and includes most of the Happstack packages in [http://hackage.haskell.org/ HackageDB], plus [http://gitit.net/ Gitit] (package name {{ic|haskell-gitit}}) and [http://clckwrks.com/ clckwrks], all their dependencies not in [haskell-core] and some other not web related packages. To enable the repository, add the following entry to {{ic|/etc/pacman.conf}}:<br />
<br />
[haskell-happstack]<br />
<nowiki>Server = http://noaxiom.org/$repo/$arch</nowiki><br />
<br />
Add and sign the maintainer's key:<br />
<br />
# pacman-key -r B0544167<br />
# pacman-key --lsign-key B0544167<br />
<br />
Bug reports and feature requests in [https://github.com/tensor5/haskell-happstack/issues GitHub].<br />
<br />
=== [haskell-web] ===<br />
<br />
{{Note|The [haskell-web] repository is not maintained anymore. If you wish to help, please send a mail to the list or use the IRC channel.}}<br />
The repository was built on [haskell-core], providing several more packages, especially those useful for web applications.<br />
<br />
[haskell-web]<br />
<nowiki>Server = http://archhaskell.mynerdside.com/$repo/$arch</nowiki><br />
<br />
== Improving ArchHaskell ==<br />
<br />
=== Community ===<br />
<br />
See the [[ArchHaskell]] community page and get in touch via the mailing list or the IRC channel.<br />
<br />
=== Overview ===<br />
<br />
The plan is to have one user-facing repository, [haskell], which merges the packages available in various satellite repositories (like [haskell-web]), thereby distributing the maintenance load.<br />
One satellite repo is special, the [haskell-core] repository, which provides packages that are dependencies of all the other satellites.<br />
<br />
=== [haskell-core] maintenance ===<br />
<br />
Ensure:<br />
* [haskell-core] is an Arch repo hosted at kiwilight and xsounds.<br />
* [haskell-core] is in sync with the [https://github.com/archhaskell/habs habs] cblrepo database.<br />
<br />
=== Other repo maintenance ===<br />
<br />
For example, for haskell-foo, ensure:<br />
* haskell-foo is a cblrepo database, possibly using packages from [haskell-core] as DistroPkgs.<br />
* Whenever [haskell-core] is updated, haskell-foo's database is updated to match within a reasonable time.<br />
<br />
=== Creating another repo ===<br />
<br />
=== List of satellite repos ===<br />
<br />
== Troubleshooting ==<br />
<br />
=== Switching to ArchHaskell repository ===<br />
<br />
There can be some problems switching to [[#ArchHaskell repository|ArchHaskell repository]] when some Haskell packages are already installed from [[official repositories]]. The surest way is to remove all Haskell related packages, synchronize the [[pacman]] packages database, and reinstall all the needed packages. Also for Xmonad users, be sure to install {{ic|haskell-xmonad}} package instead of {{Pkg|xmonad}}.</div>Xrchzhttps://wiki.archlinux.org/index.php?title=Haskell_package_guidelines&diff=241099Haskell package guidelines2012-12-21T07:58:14Z<p>Xrchz: /* Improving ArchHaskell */ start documenting processes for distributed archhaskell</p>
<hr />
<div>[[Category:Package development]]<br />
[[it:Haskell Package Guidelines]]<br />
{{Package Guidelines}}<br />
<br />
[[Wikipedia:Haskell|Haskell]] is well supported on Arch Linux.<br />
GHC and a few core packages are available in the [[Official Repositories|official repositories]].<br />
For more serious Haskellers, the [[ArchHaskell]] community project provides many packages from [http://hackage.haskell.org Hackage], and the number is growing.<br />
<br />
See the [[ArchHaskell]] community page for contact details and ways to help.<br />
<br />
== Haskell Packages ==<br />
To use Haskell on Arch Linux, you have two mutually exclusive options:<br />
# Use packages from the official Arch Linux repositories. These are a well maintained small subset of all Haskell packages. Just install them the way you would install anything else on Arch Linux. Examples of what is available: in the [https://www.archlinux.org/packages/?arch=x86_64&repo=Extra&q=haskell&last_update=&limit=50 extra] and [https://www.archlinux.org/packages/?arch=x86_64&repo=Community&q=haskell&last_update=&limit=50 community] repositories. The packages here should satisfy people who just want to use the Haskell Platform. You may also combine this option with other packages from unofficial sources like the AUR.<br />
# Use the ArchHaskell project's unofficial repositories. These contain a much larger subset of what's available on Hackage. As a community effort, we often need volunteers to help maintain and add more packages to these repositories. Read on for information about using them.<br />
<br />
=== [haskell] ===<br />
The [haskell] repository is the base repository of packages maintained by the ArchHaskell team.<br />
[haskell] can be accessed by adding the following entry to {{ic|/etc/pacman.conf}} (above [extra]):<br />
<br />
[haskell]<br />
Server = http://xsounds.org/~haskell/$arch<br />
<br />
The set of packages in the [haskell] repository is derived from the '''habs''' tree officially located [https://github.com/archhaskell/habs here]. A tool called [https://github.com/magthe/cblrepo cblrepo] is used to keep the '''habs''' tree synchronized with the official Haskell packages from [http://hackage.haskell.org/packages/hackage.html Hackage].<br />
<br />
Putting [haskell] above [extra] will ensure that the packages from [haskell] take precedence, in case of duplicate packages in the two repositories.<br />
<br />
=== [haskell-web] ===<br />
The [haskell-web] repository builds on [haskell], providing several more packages, especially those useful for web applications.<br />
<br />
[haskell-web]<br />
Server = http://archhaskell.mynerdside.com/$repo/$arch<br />
<br />
Add it after [haskell].<br />
<br />
=== Last resorts ===<br />
* [https://aur.archlinux.org/packages.php?O=0&K=haskell- Haskell packages in the AUR]<br />
* cabal-install directly<br />
<br />
Unfortunately, many of the packages in the AUR are outdated due to a lack of resources.<br />
If you have the time, it is recommended to use cblrepo and create something like [haskell-web], which can then be added to the collection of haskell-providing repositories.<br />
<br />
== Improving ArchHaskell ==<br />
<br />
=== Community ===<br />
See the [[ArchHaskell]] community page and get in touch via the mailing list or the IRC channel.<br />
<br />
=== Overview ===<br />
The plan is to have one user-facing repository, [haskell], which merges the packages available in various satellite repositories (like [haskell-web]), thereby distributing the maintenance load.<br />
One satellite repo is special, the [haskell-core] repository, which provides packages that are dependencies of all the other satellites.<br />
<br />
=== [haskell-core] maintenance ===<br />
Ensure:<br />
* [haskell-core] is an Arch repo hosted at (xsounds?).<br />
* [haskell-core] is in sync with the [https://github.com/archhaskell/habs habs] cblrepo database.<br />
<br />
=== [haskell] maintenance ===<br />
Ensure:<br />
* [haskell] is an Arch repo hosted at (unknown).<br />
* Whenever all satellite repositories' databases are in sync with [haskell-core]'s, packages from all of them are put into [haskell].<br />
<br />
=== Other repo maintenance ===<br />
For example, for haskell-foo, ensure:<br />
* haskell-foo is a cblrepo database, possibly using packages from [haskell-core] as DistroPkgs.<br />
* Whenever [haskell-core] is updated, haskell-foo's database is updated to match within a reasonable time.<br />
<br />
=== Creating another repo ===<br />
<br />
=== List of satellite repos ===</div>Xrchzhttps://wiki.archlinux.org/index.php?title=Unofficial_user_repositories/ArchHaskell&diff=240375Unofficial user repositories/ArchHaskell2012-12-15T09:07:54Z<p>Xrchz: clean up</p>
<hr />
<div>[[Category:Package development]]<br />
The ArchHaskell group works on providing Haskell packages to the wider Arch Linux community. The goal is to provide all of [http://hackage.haskell.org Hackage] as binary packages for easy installation.<br />
<br />
See also [[Haskell package guidelines]].<br />
<br />
== Resources ==<br />
<br />
The main resources for the [[ArchHaskell]] community to interact and discuss are:<br />
<br />
* #archlinux-haskell IRC channel @ freenode.org<br />
* arch-haskell@haskell.org [http://haskell.org/mailman/listinfo/arch-haskell mailing list] and [http://www.haskell.org/pipermail/arch-haskell archives]<br />
* [https://github.com/archhaskell ArchHaskell group] on GitHub<br />
<br />
== Membership ==<br />
<br />
Membership is not required at all in order to contribute. Just fork the relevant repository, make some changes, and file a pull request.<br />
<br />
There are currently two people with commit rights to the ArchHaskell repository at GitHub:<br />
<br />
* Magnus Therning<br />
* Leif Warner</div>Xrchzhttps://wiki.archlinux.org/index.php?title=Haskell_package_guidelines&diff=240374Haskell package guidelines2012-12-15T09:01:08Z<p>Xrchz: remove outdated stuff and rewrite more clearly</p>
<hr />
<div>[[Category:Package development]]<br />
[[it:Haskell Package Guidelines]]<br />
{{Package Guidelines}}<br />
<br />
[[Wikipedia:Haskell|Haskell]] is well supported on Arch Linux.<br />
GHC and a few core packages are available in the [[Official Repositories|official repositories]].<br />
For more serious Haskellers, the [[ArchHaskell]] community project provides many packages from [http://hackage.haskell.org Hackage], and the number is growing.<br />
<br />
See the [[ArchHaskell]] community page for contact details and ways to help.<br />
<br />
== Haskell Packages ==<br />
To use Haskell on Arch Linux, you have two mutually exclusive options:<br />
# Use packages from the official Arch Linux repositories. These are a well maintained small subset of all Haskell packages. Just install them the way you would install anything else on Arch Linux. Examples of what is available: in the [https://www.archlinux.org/packages/?arch=x86_64&repo=Extra&q=haskell&last_update=&limit=50 extra] and [https://www.archlinux.org/packages/?arch=x86_64&repo=Community&q=haskell&last_update=&limit=50 community] repositories. The packages here should satisfy people who just want to use the Haskell Platform. You may also combine this option with other packages from unofficial sources like the AUR.<br />
# Use the ArchHaskell project's unofficial repositories. These contain a much larger subset of what's available on Hackage. As a community effort, we often need volunteers to help maintain and add more packages to these repositories. Read on for information about using them.<br />
<br />
=== [haskell] ===<br />
The [haskell] repository is the base repository of packages maintained by the ArchHaskell team.<br />
[haskell] can be accessed by adding the following entry to {{ic|/etc/pacman.conf}} (above [extra]):<br />
<br />
[haskell]<br />
Server = http://xsounds.org/~haskell/$arch<br />
<br />
The set of packages in the [haskell] repository is derived from the '''habs''' tree officially located [https://github.com/archhaskell/habs here]. A tool called [https://github.com/magthe/cblrepo cblrepo] is used to keep the '''habs''' tree synchronized with the official Haskell packages from [http://hackage.haskell.org/packages/hackage.html Hackage].<br />
<br />
Putting [haskell] above [extra] will ensure that the packages from [haskell] take precedence, in case of duplicate packages in the two repositories.<br />
<br />
=== [haskell-web] ===<br />
The [haskell-web] repository builds on [haskell], providing several more packages, especially those useful for web applications.<br />
<br />
[haskell-web]<br />
Server = http://archhaskell.mynerdside.com/$repo/$arch<br />
<br />
Add it after [haskell].<br />
<br />
=== Last resorts ===<br />
* [https://aur.archlinux.org/packages.php?O=0&K=haskell- Haskell packages in the AUR]<br />
* cabal-install directly<br />
<br />
Unfortunately, many of the packages in the AUR are outdated due to a lack of resources.<br />
If you have the time, it is recommended to use cblrepo and create something like [haskell-web], which can then be added to the collection of haskell-providing repositories.<br />
<br />
== Improving ArchHaskell ==<br />
<br />
See the [[ArchHaskell]] community page and get in touch via the mailing list or the IRC channel.<br />
We are working on developing and documenting a workflow by which more repos like [haskell-web] can be added and maintained in a distributed fashion, with all of their packages collected in one user-facing repo.</div>Xrchzhttps://wiki.archlinux.org/index.php?title=Haskell_package_guidelines&diff=239849Haskell package guidelines2012-12-11T01:11:31Z<p>Xrchz: rewrite the options for using haskell on arch linux</p>
<hr />
<div>[[Category:Package development]]<br />
[[it:Haskell Package Guidelines]]<br />
{{Package Guidelines}}<br />
<br />
[[Wikipedia:Haskell|Haskell]] is well supported on Arch Linux, with GHC and other key tools available via the [[Official Repositories|official repositories]], a growing number of packages made available by the ArchHaskell group, and a large part of [http://hackage.haskell.org hackage.haskell.org]'s library database [https://aur.archlinux.org/packages.php?O=0&K=haskell- available in the AUR].<br />
The AUR packages, especially those owned by archhaskell, are deprecated. It is better to use and contribute to the [haskell] repository.<br />
<br />
The community around Haskell on Arch is dying but in the process of revival, so your help is especially welcome!<br />
<br />
== Community ==<br />
All the details on the [[ArchHaskell]] group is available on its own page.<br />
<br />
== Haskell Packages ==<br />
To use Haskell on Arch Linux, you have two mutually exclusive options:<br />
# Use packages from the official Arch Linux repositories. These are a well maintained small subset of all Haskell packages. Just install them the way you would install anything else on Arch Linux. Examples of what is available: in the [https://www.archlinux.org/packages/?arch=x86_64&repo=Extra&q=haskell&last_update=&limit=50 extra] and [https://www.archlinux.org/packages/?arch=x86_64&repo=Community&q=haskell&last_update=&limit=50 community] repositories. The packages here should satisfy people who just want to use the Haskell Platform. You may also combine this option with other packages from unofficial sources like the AUR.<br />
# Use the Arch-Haskell project's unofficial repositories. These contain a much larger subset of what's available on Hackage. As a community effort, we often need volunteers to help maintain and add more packages to these repositories. Read on for information about using them.<br />
<br />
=== [haskell] ===<br />
The [haskell] repository is the main repository of packages maintained by the ArchHaskell team. This repository represents the last tier of stability, before resorting to the packages in the AUR, or perhaps building packages yourself with cabal2arch. [haskell] can be accessed by adding the following entry to {{ic|/etc/pacman.conf}}:<br />
<br />
[haskell]<br />
Server = http://xsounds.org/~haskell/$arch<br />
<br />
The set of packages in the [haskell] repository is derived from the '''habs''' tree officially located [https://github.com/archhaskell/habs here]. A tool called [https://github.com/magthe/cblrepo cblrepo] is used to keep the '''habs''' tree synchronized with the official Haskell packages from [http://hackage.haskell.org/packages/hackage.html Hackage].<br />
<br />
Putting [haskell] above [extra] will ensure that the packages from [haskell] take precedence, in case of duplicate packages in the two repositories.<br />
<br />
=== [haskell-web] ===<br />
We are moving towards the possibility of distributing the desired contents of [haskell] (that is, all of Hackage) over several repositories (that is, distributing maintenance), while still collecting them all in a single repository.<br />
The first test towards this was [https://github.com/EffeErre/habs-extra habs-extra]. [haskell-extra] is now deprecated.<br />
The new version is [haskell-web], introduced [http://www.haskell.org/pipermail/arch-haskell/2012-October/002214.html here]:<br />
<br />
[haskell-web]<br />
Server = http://archhaskell.mynerdside.com/$repo/$arch<br />
<br />
This should currently be used in conjunction with [haskell], because it provides additional packages while re-using those already provided by [haskell].<br />
<br />
=== AUR and other places ===<br />
* [https://aur.archlinux.org/packages.php?O=0&K=haskell- Haskell packages in the AUR]<br />
<br />
A huge number (almost 2000) packages built from http://hackage.haskell.org.<br />
<br />
These generally improve on installing directly from Hackage as they resolve required C libraries. They can be installed like regular [[Arch User Repository|AUR]] packages.<br />
<br />
Anything not found here can be installed via {{pkg|cabal-install}} directly from Hackage.<br />
<br />
Unfortunately, many of the packages in the AUR are outdated due to a lack of resources.<br />
In practice, one could use the cabal2arch program to create [[PKGBUILD]]s directly from Hackage.<br />
But now it is recommended to use cblrepo and create something like [haskell-extra], which can then be added to the collection of haskell-providing repositories.<br />
<br />
== Guidelines ==<br />
<br />
{{out of date|this and remaining sections may be out of date given the move to distributed repositories}}<br />
<br />
In almost all cases, cabalised Haskell packages can be automatically translated into Arch packages, via the cabal2arch tool. It is strongly recommended that you use the latest released version of this tool, as it implements the packaging policy for Haskell packages. You can get it in several ways:<br />
<br />
* Add the [haskell] repository to {{ic|/etc/pacman.conf}} and use [[pacman]] to install the latest release.<br />
* Download and build the {{AUR|cabal2arch}} package from the [[Arch User Repository|AUR]].<br />
* Install directly from Hackage using {{ic|cabal install cabal2arch}}.<br />
<br />
===cabal2arch: an example===<br />
This example illustrates how to create a new package with cabal2arch. We will make a new package for the document formatter Pandoc:<br />
<br />
First, set the name and email address to be used in the generated PKGBUILD:<br />
<br />
export ARCH_HASKELL='My Name <my.name@domain.org>'<br />
<br />
Second, find [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/pandoc the hackage page for Pandoc], then identify the link to the .cabal file. Use this link as an argument to cabal2arch:<br />
<br />
{{bc|<nowiki><br />
% cd /tmp<br />
% cabal2arch http://hackage.haskell.org/packages/archive/pandoc/1.6.0.1/pandoc.cabal<br />
Using /tmp/tmp.D7HAJJx2js/pandoc.cabal<br />
Feeding the PKGBUILD to `makepkg -g`...<br />
==> Retrieving Sources...<br />
-> Downloading pandoc-1.6.0.1.tar.gz...<br />
--2011-05-14 07:25:39-- http://hackage.haskell.org/packages/archive/pandoc/1.6.0.1/pandoc-1.6.0.1.tar.gz<br />
Resolving hackage.haskell.org... 69.30.63.204<br />
Connecting to hackage.haskell.org|69.30.63.204|:80... connected.<br />
HTTP request sent, awaiting response... 200 OK<br />
Length: 355477 (347K) [application/x-tar]<br />
Saving to: “pandoc-1.6.0.1.tar.gz.part”<br />
<br />
0K .......... .......... .......... .......... .......... 14% 210K 1s<br />
50K .......... .......... .......... .......... .......... 28% 393K 1s<br />
100K .......... .......... .......... .......... .......... 43% 338K 1s<br />
150K .......... .......... .......... .......... .......... 57% 419K 0s<br />
200K .......... .......... .......... .......... .......... 72% 404K 0s<br />
250K .......... .......... .......... .......... .......... 86% 554K 0s<br />
300K .......... .......... .......... .......... ....... 100% 506K=0.9s<br />
<br />
2011-05-14 07:25:40 (369 KB/s) - “pandoc-1.6.0.1.tar.gz.part” saved [355477/355477]<br />
<br />
==> Generating checksums for source files...<br />
</nowiki>}}<br />
<br />
Checking what was created:<br />
<br />
% ls<br />
haskell-pandoc<br />
% cd haskell-pandoc<br />
% ls<br />
haskell-pandoc.install PKGBUILD<br />
<br />
You can now inspect the PKGBUILD and install script for the library:<br />
<br />
{{bc|<nowiki><br />
# Maintainer: <br />
_hkgname=pandoc<br />
pkgname=haskell-pandoc<br />
pkgver=1.6.0.1<br />
pkgrel=1<br />
pkgdesc="Conversion between markup formats"<br />
url="http://hackage.haskell.org/package/${_hkgname}"<br />
license=('GPL')<br />
arch=('i686' 'x86_64')<br />
makedepends=()<br />
depends=('ghc' 'haskell-http=4000.1.1' 'haskell-bytestring=0.9.1.10' 'haskell-containers=0.4.0.0' 'haskell-directory=1.1.0.0' 'haskell-extensible-exceptions=0.1.1.2' 'haskell-filepath=1.2.0.0' 'haskell-mtl=2.0.1.0' 'haskell-network=2.3.0.2' 'haskell-old-time=1.0.0.6' 'haskell-parsec=3.1.1' 'haskell-pretty=1.0.1.2' 'haskell-process=1.0.1.5' 'haskell-random=1.0.0.3' 'haskell-syb=0.3' 'haskell-texmath<0.5' 'haskell-utf8-string>=0.3' 'haskell-xhtml=3000.2.0.1' 'haskell-xml<1.4' 'haskell-zip-archive<0.2')<br />
options=('strip')<br />
source=(http://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz)<br />
install=${pkgname}.install<br />
md5sums=('d19a630462595941b3100dff6f839aa3')<br />
build() {<br />
cd ${srcdir}/${_hkgname}-${pkgver}<br />
runhaskell Setup configure -O ${PKGBUILD_HASKELL_ENABLE_PROFILING:+-p } --enable-split-objs --enable-shared \<br />
--prefix=/usr --docdir=/usr/share/doc/${pkgname} --libsubdir=\$compiler/site-local/\$pkgid<br />
runhaskell Setup build<br />
runhaskell Setup haddock<br />
runhaskell Setup register --gen-script<br />
runhaskell Setup unregister --gen-script<br />
sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh<br />
}<br />
package() {<br />
cd ${srcdir}/${_hkgname}-${pkgver}<br />
install -D -m744 register.sh ${pkgdir}/usr/share/haskell/${pkgname}/register.sh<br />
install -m744 unregister.sh ${pkgdir}/usr/share/haskell/${pkgname}/unregister.sh<br />
install -d -m755 ${pkgdir}/usr/share/doc/ghc/html/libraries<br />
ln -s /usr/share/doc/${pkgname}/html ${pkgdir}/usr/share/doc/ghc/html/libraries/${_hkgname}<br />
runhaskell Setup copy --destdir=${pkgdir}<br />
}<br />
</nowiki>}}<br />
<br />
It follows the conventions for Haskell packages:<br />
<br />
* Libraries are prefixed with {{ic|haskell-}}<br />
* All libraries that the package depend on are listed (libraries shipped with GHC are dealt with by having the {{pkg|ghc}} package provide them)<br />
* It uses cabal to generate a post-install register/unregister script, with a standard name.<br />
* We use haddock to build the documentation.<br />
<br />
All Haskell libraries should follow these naming conventions, and using the latest release of cabal2arch will ensure this is the case.<br />
<br />
{{Note|Beginning with {{AUR|cabal2arch}} 1.1-2, a new environment variable, {{ic|PKGBUILD_HASKELL_ENABLE_PROFILING}}, is generated into the PKGBUILD. If this variable is of non-zero length, such as "1" or "true", then profiling builds will occur. Thus, if a user desires profiling, then it is advised to export this environment variable in a file such as {{ic|~/.bashrc}} or {{ic|~/.zshrc}}.}}<br />
<br />
===Guidelines for Libraries===<br />
In general, each .cabal file should map to one PKGBUILD. The following conventions hold:<br />
<br />
* libraries have their cabal names prefixed with {{ic|haskell-}}<br />
* all libraries have a dependency on {{pkg|ghc}}<br />
* all libraries that are depended on must be listed in the {{ic|depends}} array in the PKGBUILD<br />
* be careful about dependencies from gtk2hs: cairo, svg, glib, gtk. These are all provided by the {{pkg|gtk2hs}} package, not , e.g. "haskell-cairo"<br />
<br />
Registering Haskell libraries is done via a register hook, see above.<br />
<br />
===Guidelines for Programs ===<br />
* Have their normal name. Examples: hmp3, xmonad, ghc, cabal-install<br />
<br />
* Be careful about dynamically linked run-time dependencies on C. For example, all GHC-produced binaries have a run-time dependency on 'gmp'. OpenGL or GtT-based binaries will have additional 'depends'. cabal2arch will attempt to work out the C dependencies, but there may be others implied by Haskell dependencies that are missed.<br />
<br />
* Use executable stripping, {{ic|--enable-executable-stripping}}. cabal2arch will do this automatically.<br />
<br />
== Haskell Build Order ==<br />
* haskell-x11 update: haskell-x11-xft -> xmonad -> xmonad-contrib</div>Xrchzhttps://wiki.archlinux.org/index.php?title=Haskell_package_guidelines&diff=239376Haskell package guidelines2012-12-07T20:35:15Z<p>Xrchz: /* [haskell-extra] and [haskell-web] */</p>
<hr />
<div>[[Category:Package development]]<br />
[[it:Haskell Package Guidelines]]<br />
{{Package Guidelines}}<br />
<br />
[[Wikipedia:Haskell|Haskell]] is well supported on Arch Linux, with GHC and other key tools available via the [[Official Repositories|official repositories]], a growing number of packages made available by the ArchHaskell group, and a large part of [http://hackage.haskell.org hackage.haskell.org]'s library database [https://aur.archlinux.org/packages.php?O=0&K=haskell- available in the AUR].<br />
The AUR packages, especially those owned by archhaskell, are deprecated. It is better to use and contribute to the [haskell] repository.<br />
<br />
The community around Haskell on Arch is dying but in the process of revival, so your help is especially welcome!<br />
<br />
== Community ==<br />
All the details on the [[ArchHaskell]] group is available on its own page.<br />
<br />
== Haskell Packages ==<br />
The core Haskell tools are available in the core system (extra):<br />
<br />
=== [extra] ===<br />
* [https://www.archlinux.org/packages/?arch=x86_64&repo=Extra&q=haskell&last_update=&limit=50 Haskell packages in the core system]<br />
<br />
Our policy for [extra] is to provide the Haskell platform, and popular Haskell applications.<br />
<br />
=== [community] ===<br />
* [https://www.archlinux.org/packages/?arch=x86_64&repo=Community&q=haskell&last_update=&limit=50 other popular Haskell packages]<br />
<br />
[community] provides additional packages that are popular and not part of the Haskell platform, such as [[xmonad]].<br />
These packages are also provided by the [haskell] repo below.<br />
So, if you just want to use a few popular packages, you can just use what is provided by the official Arch repos.<br />
But if you want to use Haskell more seriously, read on.<br />
<br />
=== [haskell] ===<br />
The [haskell] repository is the official repository of packages maintained by the ArchHaskell team. This repository represents the last tier of stability, before resorting to the packages in the AUR, or perhaps building packages yourself with cabal2arch. [haskell] can be accessed by adding the following entry to {{ic|/etc/pacman.conf}}:<br />
<br />
[haskell]<br />
Server = http://xsounds.org/~haskell/$arch<br />
<br />
The set of packages in the [haskell] repository is derived from the '''habs''' tree officially located [https://github.com/archhaskell/habs here]. A tool called [https://github.com/magthe/cblrepo cblrepo] is used to keep the '''habs''' tree synchronized with the official Haskell packages from [http://hackage.haskell.org/packages/hackage.html Hackage].<br />
<br />
Putting [haskell] above [extra] will ensure that the packages from [haskell] take precedence, in case of duplicate packages in the two repositories.<br />
<br />
=== [haskell-web] ===<br />
We are moving towards the possibility of distributing the desired contents of [haskell] (that is, all of Hackage) over several repositories (that is, distributing maintenance), while still collecting them all in a single repository.<br />
The first test towards this was [https://github.com/EffeErre/habs-extra habs-extra]. [haskell-extra] is now deprecated.<br />
The new version is [haskell-web], introduced [http://www.haskell.org/pipermail/arch-haskell/2012-October/002214.html here]:<br />
<br />
[haskell-web]<br />
Server = http://archhaskell.mynerdside.com/$repo/$arch<br />
<br />
This should currently be used in conjunction with [haskell], because it provides additional packages while re-using those already provided by [haskell].<br />
<br />
=== AUR ===<br />
* [https://aur.archlinux.org/packages.php?O=0&K=haskell- Haskell packages in the AUR]<br />
<br />
A huge number (almost 2000) packages built from http://hackage.haskell.org.<br />
<br />
These generally improve on installing directly from Hackage as they resolve required C libraries. They can be installed like regular [[Arch User Repository|AUR]] packages.<br />
<br />
Anything not found here can be installed via {{pkg|cabal-install}} directly from Hackage.<br />
<br />
Unfortunately, many of the packages in the AUR are outdated due to a lack of resources.<br />
In practice, one could use the cabal2arch program to create [[PKGBUILD]]s directly from Hackage.<br />
But now it is recommended to use cblrepo and create something like [haskell-extra], which can then be added to the collection of haskell-providing repositories.<br />
<br />
== Guidelines ==<br />
<br />
{{out of date|this and remaining sections may be out of date given the move to distributed repositories}}<br />
<br />
In almost all cases, cabalised Haskell packages can be automatically translated into Arch packages, via the cabal2arch tool. It is strongly recommended that you use the latest released version of this tool, as it implements the packaging policy for Haskell packages. You can get it in several ways:<br />
<br />
* Add the [haskell] repository to {{ic|/etc/pacman.conf}} and use [[pacman]] to install the latest release.<br />
* Download and build the {{AUR|cabal2arch}} package from the [[Arch User Repository|AUR]].<br />
* Install directly from Hackage using {{ic|cabal install cabal2arch}}.<br />
<br />
===cabal2arch: an example===<br />
This example illustrates how to create a new package with cabal2arch. We will make a new package for the document formatter Pandoc:<br />
<br />
First, set the name and email address to be used in the generated PKGBUILD:<br />
<br />
export ARCH_HASKELL='My Name <my.name@domain.org>'<br />
<br />
Second, find [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/pandoc the hackage page for Pandoc], then identify the link to the .cabal file. Use this link as an argument to cabal2arch:<br />
<br />
{{bc|<nowiki><br />
% cd /tmp<br />
% cabal2arch http://hackage.haskell.org/packages/archive/pandoc/1.6.0.1/pandoc.cabal<br />
Using /tmp/tmp.D7HAJJx2js/pandoc.cabal<br />
Feeding the PKGBUILD to `makepkg -g`...<br />
==> Retrieving Sources...<br />
-> Downloading pandoc-1.6.0.1.tar.gz...<br />
--2011-05-14 07:25:39-- http://hackage.haskell.org/packages/archive/pandoc/1.6.0.1/pandoc-1.6.0.1.tar.gz<br />
Resolving hackage.haskell.org... 69.30.63.204<br />
Connecting to hackage.haskell.org|69.30.63.204|:80... connected.<br />
HTTP request sent, awaiting response... 200 OK<br />
Length: 355477 (347K) [application/x-tar]<br />
Saving to: “pandoc-1.6.0.1.tar.gz.part”<br />
<br />
0K .......... .......... .......... .......... .......... 14% 210K 1s<br />
50K .......... .......... .......... .......... .......... 28% 393K 1s<br />
100K .......... .......... .......... .......... .......... 43% 338K 1s<br />
150K .......... .......... .......... .......... .......... 57% 419K 0s<br />
200K .......... .......... .......... .......... .......... 72% 404K 0s<br />
250K .......... .......... .......... .......... .......... 86% 554K 0s<br />
300K .......... .......... .......... .......... ....... 100% 506K=0.9s<br />
<br />
2011-05-14 07:25:40 (369 KB/s) - “pandoc-1.6.0.1.tar.gz.part” saved [355477/355477]<br />
<br />
==> Generating checksums for source files...<br />
</nowiki>}}<br />
<br />
Checking what was created:<br />
<br />
% ls<br />
haskell-pandoc<br />
% cd haskell-pandoc<br />
% ls<br />
haskell-pandoc.install PKGBUILD<br />
<br />
You can now inspect the PKGBUILD and install script for the library:<br />
<br />
{{bc|<nowiki><br />
# Maintainer: <br />
_hkgname=pandoc<br />
pkgname=haskell-pandoc<br />
pkgver=1.6.0.1<br />
pkgrel=1<br />
pkgdesc="Conversion between markup formats"<br />
url="http://hackage.haskell.org/package/${_hkgname}"<br />
license=('GPL')<br />
arch=('i686' 'x86_64')<br />
makedepends=()<br />
depends=('ghc' 'haskell-http=4000.1.1' 'haskell-bytestring=0.9.1.10' 'haskell-containers=0.4.0.0' 'haskell-directory=1.1.0.0' 'haskell-extensible-exceptions=0.1.1.2' 'haskell-filepath=1.2.0.0' 'haskell-mtl=2.0.1.0' 'haskell-network=2.3.0.2' 'haskell-old-time=1.0.0.6' 'haskell-parsec=3.1.1' 'haskell-pretty=1.0.1.2' 'haskell-process=1.0.1.5' 'haskell-random=1.0.0.3' 'haskell-syb=0.3' 'haskell-texmath<0.5' 'haskell-utf8-string>=0.3' 'haskell-xhtml=3000.2.0.1' 'haskell-xml<1.4' 'haskell-zip-archive<0.2')<br />
options=('strip')<br />
source=(http://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz)<br />
install=${pkgname}.install<br />
md5sums=('d19a630462595941b3100dff6f839aa3')<br />
build() {<br />
cd ${srcdir}/${_hkgname}-${pkgver}<br />
runhaskell Setup configure -O ${PKGBUILD_HASKELL_ENABLE_PROFILING:+-p } --enable-split-objs --enable-shared \<br />
--prefix=/usr --docdir=/usr/share/doc/${pkgname} --libsubdir=\$compiler/site-local/\$pkgid<br />
runhaskell Setup build<br />
runhaskell Setup haddock<br />
runhaskell Setup register --gen-script<br />
runhaskell Setup unregister --gen-script<br />
sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh<br />
}<br />
package() {<br />
cd ${srcdir}/${_hkgname}-${pkgver}<br />
install -D -m744 register.sh ${pkgdir}/usr/share/haskell/${pkgname}/register.sh<br />
install -m744 unregister.sh ${pkgdir}/usr/share/haskell/${pkgname}/unregister.sh<br />
install -d -m755 ${pkgdir}/usr/share/doc/ghc/html/libraries<br />
ln -s /usr/share/doc/${pkgname}/html ${pkgdir}/usr/share/doc/ghc/html/libraries/${_hkgname}<br />
runhaskell Setup copy --destdir=${pkgdir}<br />
}<br />
</nowiki>}}<br />
<br />
It follows the conventions for Haskell packages:<br />
<br />
* Libraries are prefixed with {{ic|haskell-}}<br />
* All libraries that the package depend on are listed (libraries shipped with GHC are dealt with by having the {{pkg|ghc}} package provide them)<br />
* It uses cabal to generate a post-install register/unregister script, with a standard name.<br />
* We use haddock to build the documentation.<br />
<br />
All Haskell libraries should follow these naming conventions, and using the latest release of cabal2arch will ensure this is the case.<br />
<br />
{{Note|Beginning with {{AUR|cabal2arch}} 1.1-2, a new environment variable, {{ic|PKGBUILD_HASKELL_ENABLE_PROFILING}}, is generated into the PKGBUILD. If this variable is of non-zero length, such as "1" or "true", then profiling builds will occur. Thus, if a user desires profiling, then it is advised to export this environment variable in a file such as {{ic|~/.bashrc}} or {{ic|~/.zshrc}}.}}<br />
<br />
===Guidelines for Libraries===<br />
In general, each .cabal file should map to one PKGBUILD. The following conventions hold:<br />
<br />
* libraries have their cabal names prefixed with {{ic|haskell-}}<br />
* all libraries have a dependency on {{pkg|ghc}}<br />
* all libraries that are depended on must be listed in the {{ic|depends}} array in the PKGBUILD<br />
* be careful about dependencies from gtk2hs: cairo, svg, glib, gtk. These are all provided by the {{pkg|gtk2hs}} package, not , e.g. "haskell-cairo"<br />
<br />
Registering Haskell libraries is done via a register hook, see above.<br />
<br />
===Guidelines for Programs ===<br />
* Have their normal name. Examples: hmp3, xmonad, ghc, cabal-install<br />
<br />
* Be careful about dynamically linked run-time dependencies on C. For example, all GHC-produced binaries have a run-time dependency on 'gmp'. OpenGL or GtT-based binaries will have additional 'depends'. cabal2arch will attempt to work out the C dependencies, but there may be others implied by Haskell dependencies that are missed.<br />
<br />
* Use executable stripping, {{ic|--enable-executable-stripping}}. cabal2arch will do this automatically.<br />
<br />
== Haskell Build Order ==<br />
* haskell-x11 update: haskell-x11-xft -> xmonad -> xmonad-contrib</div>Xrchzhttps://wiki.archlinux.org/index.php?title=Unofficial_user_repositories/ArchHaskell&diff=235998Unofficial user repositories/ArchHaskell2012-11-19T18:59:13Z<p>Xrchz: /* Resources */</p>
<hr />
<div>[[Category:Package development]]<br />
The ArchHaskell group works on providing Haskell packages to the wider Arch Linux community. The ultimate goal is to provide all of [http://hackage.haskell.org Hackage] as binary packages for easy installation. We are still a long way away :-)<br />
<br />
See also [[Haskell package guidelines]].<br />
<br />
== Resources ==<br />
<br />
The main resources for the [[ArchHaskell]] community to interact and discuss are:<br />
<br />
* [http://www.gogloom.com/FreeNode/archlinux-haskell <nowiki>#archlinux-haskell</nowiki>] IRC channel @ freenode.org<br />
** Good for quick discussion and planning<br />
** Currently severely underpopulated<br />
* [http://haskell.org/mailman/listinfo/arch-haskell arch-haskell@haskell.org] mailing list<br />
** Broader announcements, and automated updates<br />
** Currently very low traffic, but responses do come.<br />
** Also, check the archives.<br />
* [https://github.com/archhaskell ArchHaskell group] on GitHub<br />
** Repositories for tools as well as the source for the binary packages (HABS).<br />
<br />
== Membership ==<br />
<br />
Due to using GitHub for the source repositories, membership is not required at all in order to contribute. Just fork the relevant repository, make some changes, and file a pull request.<br />
<br />
There are currently two people with commit rights to the ArchHaskell repository at GitHub:<br />
<br />
* Magnus Therning<br />
* Leif Warner</div>Xrchzhttps://wiki.archlinux.org/index.php?title=Haskell_package_guidelines&diff=230671Haskell package guidelines2012-10-22T14:59:59Z<p>Xrchz: /* [haskell-extra] */ mention haskell-web</p>
<hr />
<div>[[Category:Package development]]<br />
[[it:Haskell Package Guidelines]]<br />
{{Package Guidelines}}<br />
<br />
[[Wikipedia:Haskell|Haskell]] is well supported on Arch Linux, with GHC and other key tools available via the [[Official Repositories|official repositories]], a growing number of packages made available by the ArchHaskell group, and a large part of [http://hackage.haskell.org hackage.haskell.org]'s library database [https://aur.archlinux.org/packages.php?O=0&K=haskell- available in the AUR].<br />
The AUR packages, especially those owned by archhaskell, are deprecated. It is better to use and contribute to the [haskell] repository.<br />
<br />
The community around Haskell on Arch is dying but in the process of revival, so your help is especially welcome!<br />
<br />
== Community ==<br />
All the details on the [[ArchHaskell]] group is available on its own page.<br />
<br />
== Haskell Packages ==<br />
The core Haskell tools are available in the core system (extra):<br />
<br />
=== [extra] ===<br />
* [https://www.archlinux.org/packages/?arch=x86_64&repo=Extra&q=haskell&last_update=&limit=50 Haskell packages in the core system]<br />
<br />
Our policy for [extra] is to provide the Haskell platform, and popular Haskell applications.<br />
<br />
=== [community] ===<br />
* [https://www.archlinux.org/packages/?arch=x86_64&repo=Community&q=haskell&last_update=&limit=50 other popular Haskell packages]<br />
<br />
[community] provides additional packages that are popular and not part of the Haskell platform, such as [[xmonad]].<br />
These packages are also provided by the [haskell] repo below.<br />
So, if you just want to use a few popular packages, you can just use what is provided by the official Arch repos.<br />
But if you want to use Haskell more seriously, read on.<br />
<br />
=== [haskell] ===<br />
The [haskell] repository is the official repository of packages maintained by the ArchHaskell team. This repository represents the last tier of stability, before resorting to the packages in the AUR, or perhaps building packages yourself with cabal2arch. [haskell] can be accessed by adding the following entry to {{ic|/etc/pacman.conf}}:<br />
<br />
[haskell]<br />
Server = http://xsounds.org/~haskell/$arch<br />
<br />
The set of packages in the [haskell] repository is derived from the '''habs''' tree officially located [https://github.com/archhaskell/habs here]. A tool called [https://github.com/magthe/cblrepo cblrepo] is used to keep the '''habs''' tree synchronized with the official Haskell packages from [http://hackage.haskell.org/packages/hackage.html Hackage].<br />
<br />
Putting [haskell] above [extra] will ensure that the packages from [haskell] take precedence, in case of duplicate packages in the two repositories.<br />
<br />
=== [haskell-extra] and [haskell-web] ===<br />
We are moving towards the possibility of distributing the desired contents of [haskell] (that is, all of Hackage) over several repositories (that is, distributing maintenance), while still collecting them all in a single repository.<br />
The first test towards this is [https://github.com/EffeErre/habs-extra habs-extra], which is also provided as a repository to be added to {{ic|/etc/pacman.conf}}:<br />
<br />
[haskell-extra]<br />
Server = http://archhaskell.mynerdside.com/$repo/$arch<br />
<br />
This should currently be used in conjunction with [haskell], because it provides additional packages while re-using those already provided by [haskell].<br />
More details are available in this [http://www.haskell.org/pipermail/arch-haskell/2012-September/002147.html message], and in the README on github.<br />
<br />
There is also [haskell-web], as mentioned [http://www.haskell.org/pipermail/arch-haskell/2012-October/002214.html here].<br />
<br />
=== AUR ===<br />
* [https://aur.archlinux.org/packages.php?O=0&K=haskell- Haskell packages in the AUR]<br />
<br />
A huge number (almost 2000) packages built from http://hackage.haskell.org.<br />
<br />
These generally improve on installing directly from Hackage as they resolve required C libraries. They can be installed as, for example:<br />
<br />
# paktahn -S haskell-csv<br />
<br />
Anything not found here can be installed via {{pkg|cabal-install}} directly from Hackage.<br />
<br />
Unfortunately, many of the packages in the AUR are outdated due to a lack of resources.<br />
In practice, one could use the cabal2arch program to create [[PKGBUILD]]s directly from Hackage.<br />
But now it is recommended to use cblrepo and create something like [haskell-extra], which can then be added to the collection of haskell-providing repositories.<br />
<br />
== Guidelines ==<br />
<br />
{{out of date|this and remaining sections may be out of date given the move to distributed repositories}}<br />
<br />
In almost all cases, cabalised Haskell packages can be automatically translated into Arch packages, via the cabal2arch tool. It is strongly recommended that you use the latest released version of this tool, as it implements the packaging policy for Haskell packages. You can get it in several ways:<br />
<br />
* Add the [haskell] repository to {{ic|/etc/pacman.conf}} and use [[pacman]] to install the latest release.<br />
* Download and build the {{AUR|cabal2arch}} package from the [[Arch User Repository|AUR]].<br />
* Install directly from Hackage using {{ic|cabal install cabal2arch}}.<br />
<br />
===cabal2arch: an example===<br />
This example illustrates how to create a new package with cabal2arch. We will make a new package for the document formatter Pandoc:<br />
<br />
First, set the name and email address to be used in the generated PKGBUILD:<br />
<br />
export ARCH_HASKELL='My Name <my.name@domain.org>'<br />
<br />
Second, find [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/pandoc the hackage page for Pandoc], then identify the link to the .cabal file. Use this link as an argument to cabal2arch:<br />
<br />
{{bc|<nowiki><br />
% cd /tmp<br />
% cabal2arch http://hackage.haskell.org/packages/archive/pandoc/1.6.0.1/pandoc.cabal<br />
Using /tmp/tmp.D7HAJJx2js/pandoc.cabal<br />
Feeding the PKGBUILD to `makepkg -g`...<br />
==> Retrieving Sources...<br />
-> Downloading pandoc-1.6.0.1.tar.gz...<br />
--2011-05-14 07:25:39-- http://hackage.haskell.org/packages/archive/pandoc/1.6.0.1/pandoc-1.6.0.1.tar.gz<br />
Resolving hackage.haskell.org... 69.30.63.204<br />
Connecting to hackage.haskell.org|69.30.63.204|:80... connected.<br />
HTTP request sent, awaiting response... 200 OK<br />
Length: 355477 (347K) [application/x-tar]<br />
Saving to: “pandoc-1.6.0.1.tar.gz.part”<br />
<br />
0K .......... .......... .......... .......... .......... 14% 210K 1s<br />
50K .......... .......... .......... .......... .......... 28% 393K 1s<br />
100K .......... .......... .......... .......... .......... 43% 338K 1s<br />
150K .......... .......... .......... .......... .......... 57% 419K 0s<br />
200K .......... .......... .......... .......... .......... 72% 404K 0s<br />
250K .......... .......... .......... .......... .......... 86% 554K 0s<br />
300K .......... .......... .......... .......... ....... 100% 506K=0.9s<br />
<br />
2011-05-14 07:25:40 (369 KB/s) - “pandoc-1.6.0.1.tar.gz.part” saved [355477/355477]<br />
<br />
==> Generating checksums for source files...<br />
</nowiki>}}<br />
<br />
Checking what was created:<br />
<br />
% ls<br />
haskell-pandoc<br />
% cd haskell-pandoc<br />
% ls<br />
haskell-pandoc.install PKGBUILD<br />
<br />
You can now inspect the PKGBUILD and install script for the library:<br />
<br />
{{bc|<nowiki><br />
# Maintainer: <br />
_hkgname=pandoc<br />
pkgname=haskell-pandoc<br />
pkgver=1.6.0.1<br />
pkgrel=1<br />
pkgdesc="Conversion between markup formats"<br />
url="http://hackage.haskell.org/package/${_hkgname}"<br />
license=('GPL')<br />
arch=('i686' 'x86_64')<br />
makedepends=()<br />
depends=('ghc' 'haskell-http=4000.1.1' 'haskell-bytestring=0.9.1.10' 'haskell-containers=0.4.0.0' 'haskell-directory=1.1.0.0' 'haskell-extensible-exceptions=0.1.1.2' 'haskell-filepath=1.2.0.0' 'haskell-mtl=2.0.1.0' 'haskell-network=2.3.0.2' 'haskell-old-time=1.0.0.6' 'haskell-parsec=3.1.1' 'haskell-pretty=1.0.1.2' 'haskell-process=1.0.1.5' 'haskell-random=1.0.0.3' 'haskell-syb=0.3' 'haskell-texmath<0.5' 'haskell-utf8-string>=0.3' 'haskell-xhtml=3000.2.0.1' 'haskell-xml<1.4' 'haskell-zip-archive<0.2')<br />
options=('strip')<br />
source=(http://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz)<br />
install=${pkgname}.install<br />
md5sums=('d19a630462595941b3100dff6f839aa3')<br />
build() {<br />
cd ${srcdir}/${_hkgname}-${pkgver}<br />
runhaskell Setup configure -O ${PKGBUILD_HASKELL_ENABLE_PROFILING:+-p } --enable-split-objs --enable-shared \<br />
--prefix=/usr --docdir=/usr/share/doc/${pkgname} --libsubdir=\$compiler/site-local/\$pkgid<br />
runhaskell Setup build<br />
runhaskell Setup haddock<br />
runhaskell Setup register --gen-script<br />
runhaskell Setup unregister --gen-script<br />
sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh<br />
}<br />
package() {<br />
cd ${srcdir}/${_hkgname}-${pkgver}<br />
install -D -m744 register.sh ${pkgdir}/usr/share/haskell/${pkgname}/register.sh<br />
install -m744 unregister.sh ${pkgdir}/usr/share/haskell/${pkgname}/unregister.sh<br />
install -d -m755 ${pkgdir}/usr/share/doc/ghc/html/libraries<br />
ln -s /usr/share/doc/${pkgname}/html ${pkgdir}/usr/share/doc/ghc/html/libraries/${_hkgname}<br />
runhaskell Setup copy --destdir=${pkgdir}<br />
}<br />
</nowiki>}}<br />
<br />
It follows the conventions for Haskell packages:<br />
<br />
* Libraries are prefixed with {{ic|haskell-}}<br />
* All libraries that the package depend on are listed (libraries shipped with GHC are dealt with by having the {{pkg|ghc}} package provide them)<br />
* It uses cabal to generate a post-install register/unregister script, with a standard name.<br />
* We use haddock to build the documentation.<br />
<br />
All Haskell libraries should follow these naming conventions, and using the latest release of cabal2arch will ensure this is the case.<br />
<br />
{{Note|Beginning with {{AUR|cabal2arch}} 1.1-2, a new environment variable, {{ic|PKGBUILD_HASKELL_ENABLE_PROFILING}}, is generated into the PKGBUILD. If this variable is of non-zero length, such as "1" or "true", then profiling builds will occur. Thus, if a user desires profiling, then it is advised to export this environment variable in a file such as {{ic|~/.bashrc}} or {{ic|~/.zshrc}}.}}<br />
<br />
===Guidelines for Libraries===<br />
In general, each .cabal file should map to one PKGBUILD. The following conventions hold:<br />
<br />
* libraries have their cabal names prefixed with {{ic|haskell-}}<br />
* all libraries have a dependency on {{pkg|ghc}}<br />
* all libraries that are depended on must be listed in the {{ic|depends}} array in the PKGBUILD<br />
* be careful about dependencies from gtk2hs: cairo, svg, glib, gtk. These are all provided by the {{pkg|gtk2hs}} package, not , e.g. "haskell-cairo"<br />
<br />
Registering Haskell libraries is done via a register hook, see above.<br />
<br />
===Guidelines for Programs ===<br />
* Have their normal name. Examples: hmp3, xmonad, ghc, cabal-install<br />
<br />
* Be careful about dynamically linked run-time dependencies on C. For example, all GHC-produced binaries have a run-time dependency on 'gmp'. OpenGL or GtT-based binaries will have additional 'depends'. cabal2arch will attempt to work out the C dependencies, but there may be others implied by Haskell dependencies that are missed.<br />
<br />
* Use executable stripping, {{ic|--enable-executable-stripping}}. cabal2arch will do this automatically.<br />
<br />
== Haskell Build Order ==<br />
* haskell-x11 update: haskell-x11-xft -> xmonad -> xmonad-contrib</div>Xrchzhttps://wiki.archlinux.org/index.php?title=Haskell_package_guidelines&diff=227615Haskell package guidelines2012-10-08T14:48:30Z<p>Xrchz: /* Haskell Packages */ remove mention of haskell-testing, since it's being merged back to haskell now</p>
<hr />
<div>[[Category:Package development]]<br />
[[it:Haskell Package Guidelines]]<br />
{{Package Guidelines}}<br />
<br />
[[Wikipedia:Haskell|Haskell]] is well supported on Arch Linux, with GHC and other key tools available via the [[Official Repositories|official repositories]], a growing number of packages made available by the ArchHaskell group, and a large part of [http://hackage.haskell.org hackage.haskell.org]'s library database [https://aur.archlinux.org/packages.php?O=0&K=haskell- available in the AUR].<br />
The AUR packages, especially those owned by archhaskell, are deprecated. It is better to use and contribute to the [haskell] repository.<br />
<br />
The community around Haskell on Arch is dying but in the processo of revival, so your help is especially welcome!<br />
<br />
== Community ==<br />
All the details on the [[ArchHaskell]] group is available on its own page.<br />
<br />
== Haskell Packages ==<br />
The core Haskell tools are available in the core system (extra):<br />
<br />
=== [extra] ===<br />
* [https://www.archlinux.org/packages/?arch=x86_64&repo=Extra&q=haskell&last_update=&limit=50 Haskell packages in the core system]<br />
<br />
Our policy for [extra] is to provide the Haskell platform, and popular Haskell applications.<br />
<br />
=== [community] ===<br />
* [https://www.archlinux.org/packages/?arch=x86_64&repo=Community&q=haskell&last_update=&limit=50 other popular Haskell packages]<br />
<br />
[community] provides additional packages that are popular and not part of the Haskell platform, such as [[xmonad]].<br />
These packages are also provided by the [haskell] repo below.<br />
So, if you just want to use a few popular packages, you can just use what is provided by the official Arch repos.<br />
But if you want to use Haskell more seriously, read on.<br />
<br />
=== [haskell] ===<br />
The [haskell] repository is the official repository of packages maintained by the ArchHaskell team. This repository represents the last tier of stability, before resorting to the packages in the AUR, or perhaps building packages yourself with cabal2arch. [haskell] can be accessed by adding the following entry to {{ic|/etc/pacman.conf}}:<br />
<br />
[haskell]<br />
Server = http://xsounds.org/~haskell/$arch<br />
<br />
The set of packages in the [haskell] repository is derived from the '''habs''' tree officially located [https://github.com/archhaskell/habs here]. A tool called [https://github.com/magthe/cblrepo cblrepo] is used to keep the '''habs''' tree synchronized with the official Haskell packages from [http://hackage.haskell.org/packages/hackage.html Hackage].<br />
<br />
Putting [haskell] above [extra] will ensure that the packages from [haskell] take precedence, in case of duplicate packages in the two repositories.<br />
<br />
=== [haskell-extra] ===<br />
We are moving towards the possibility of distributing the desired contents of [haskell] (that is, all of Hackage) over several repositories (that is, distributing maintenance), while still collecting them all in a single repository.<br />
The first test towards this is [https://github.com/EffeErre/habs-extra habs-extra], which is also provided as a repository to be added to {{ic|/etc/pacman.conf}}:<br />
<br />
[haskell-extra]<br />
Server = http://archhaskell.mynerdside.com/$repo/$arch<br />
<br />
This should currently be used in conjunction with [haskell], because it provides additional packages while re-using those already provided by [haskell].<br />
More details are available in this [http://www.haskell.org/pipermail/arch-haskell/2012-September/002147.html message], and in the README on github.<br />
<br />
=== AUR ===<br />
* [https://aur.archlinux.org/packages.php?O=0&K=haskell- Haskell packages in the AUR]<br />
<br />
A huge number (almost 2000) packages built from http://hackage.haskell.org.<br />
<br />
These generally improve on installing directly from Hackage as they resolve required C libraries. They can be installed as, for example:<br />
<br />
# paktahn -S haskell-csv<br />
<br />
Anything not found here can be installed via {{pkg|cabal-install}} directly from Hackage.<br />
<br />
Unfortunately, many of the packages in the AUR are outdated due to a lack of resources.<br />
In practice, one could use the cabal2arch program to create [[PKGBUILD]]s directly from Hackage.<br />
But now it is recommended to use cblrepo and create something like [haskell-extra], which can then be added to the collection of haskell-providing repositories.<br />
<br />
== Guidelines ==<br />
<br />
{{out of date|this and remaining sections may be out of date given the move to distributed repositories}}<br />
<br />
In almost all cases, cabalised Haskell packages can be automatically translated into Arch packages, via the cabal2arch tool. It is strongly recommended that you use the latest released version of this tool, as it implements the packaging policy for Haskell packages. You can get it in several ways:<br />
<br />
* Add the [haskell] repository to {{ic|/etc/pacman.conf}} and use [[pacman]] to install the latest release.<br />
* Download and build the {{AUR|cabal2arch}} package from the [[Arch User Repository|AUR]].<br />
* Install directly from Hackage using {{ic|cabal install cabal2arch}}.<br />
<br />
===cabal2arch: an example===<br />
This example illustrates how to create a new package with cabal2arch. We will make a new package for the document formatter Pandoc:<br />
<br />
First, set the name and email address to be used in the generated PKGBUILD:<br />
<br />
export ARCH_HASKELL='My Name <my.name@domain.org>'<br />
<br />
Second, find [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/pandoc the hackage page for Pandoc], then identify the link to the .cabal file. Use this link as an argument to cabal2arch:<br />
<br />
{{bc|<nowiki><br />
% cd /tmp<br />
% cabal2arch http://hackage.haskell.org/packages/archive/pandoc/1.6.0.1/pandoc.cabal<br />
Using /tmp/tmp.D7HAJJx2js/pandoc.cabal<br />
Feeding the PKGBUILD to `makepkg -g`...<br />
==> Retrieving Sources...<br />
-> Downloading pandoc-1.6.0.1.tar.gz...<br />
--2011-05-14 07:25:39-- http://hackage.haskell.org/packages/archive/pandoc/1.6.0.1/pandoc-1.6.0.1.tar.gz<br />
Resolving hackage.haskell.org... 69.30.63.204<br />
Connecting to hackage.haskell.org|69.30.63.204|:80... connected.<br />
HTTP request sent, awaiting response... 200 OK<br />
Length: 355477 (347K) [application/x-tar]<br />
Saving to: “pandoc-1.6.0.1.tar.gz.part”<br />
<br />
0K .......... .......... .......... .......... .......... 14% 210K 1s<br />
50K .......... .......... .......... .......... .......... 28% 393K 1s<br />
100K .......... .......... .......... .......... .......... 43% 338K 1s<br />
150K .......... .......... .......... .......... .......... 57% 419K 0s<br />
200K .......... .......... .......... .......... .......... 72% 404K 0s<br />
250K .......... .......... .......... .......... .......... 86% 554K 0s<br />
300K .......... .......... .......... .......... ....... 100% 506K=0.9s<br />
<br />
2011-05-14 07:25:40 (369 KB/s) - “pandoc-1.6.0.1.tar.gz.part” saved [355477/355477]<br />
<br />
==> Generating checksums for source files...<br />
</nowiki>}}<br />
<br />
Checking what was created:<br />
<br />
% ls<br />
haskell-pandoc<br />
% cd haskell-pandoc<br />
% ls<br />
haskell-pandoc.install PKGBUILD<br />
<br />
You can now inspect the PKGBUILD and install script for the library:<br />
<br />
{{bc|<nowiki><br />
# Maintainer: <br />
_hkgname=pandoc<br />
pkgname=haskell-pandoc<br />
pkgver=1.6.0.1<br />
pkgrel=1<br />
pkgdesc="Conversion between markup formats"<br />
url="http://hackage.haskell.org/package/${_hkgname}"<br />
license=('GPL')<br />
arch=('i686' 'x86_64')<br />
makedepends=()<br />
depends=('ghc' 'haskell-http=4000.1.1' 'haskell-bytestring=0.9.1.10' 'haskell-containers=0.4.0.0' 'haskell-directory=1.1.0.0' 'haskell-extensible-exceptions=0.1.1.2' 'haskell-filepath=1.2.0.0' 'haskell-mtl=2.0.1.0' 'haskell-network=2.3.0.2' 'haskell-old-time=1.0.0.6' 'haskell-parsec=3.1.1' 'haskell-pretty=1.0.1.2' 'haskell-process=1.0.1.5' 'haskell-random=1.0.0.3' 'haskell-syb=0.3' 'haskell-texmath<0.5' 'haskell-utf8-string>=0.3' 'haskell-xhtml=3000.2.0.1' 'haskell-xml<1.4' 'haskell-zip-archive<0.2')<br />
options=('strip')<br />
source=(http://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz)<br />
install=${pkgname}.install<br />
md5sums=('d19a630462595941b3100dff6f839aa3')<br />
build() {<br />
cd ${srcdir}/${_hkgname}-${pkgver}<br />
runhaskell Setup configure -O ${PKGBUILD_HASKELL_ENABLE_PROFILING:+-p } --enable-split-objs --enable-shared \<br />
--prefix=/usr --docdir=/usr/share/doc/${pkgname} --libsubdir=\$compiler/site-local/\$pkgid<br />
runhaskell Setup build<br />
runhaskell Setup haddock<br />
runhaskell Setup register --gen-script<br />
runhaskell Setup unregister --gen-script<br />
sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh<br />
}<br />
package() {<br />
cd ${srcdir}/${_hkgname}-${pkgver}<br />
install -D -m744 register.sh ${pkgdir}/usr/share/haskell/${pkgname}/register.sh<br />
install -m744 unregister.sh ${pkgdir}/usr/share/haskell/${pkgname}/unregister.sh<br />
install -d -m755 ${pkgdir}/usr/share/doc/ghc/html/libraries<br />
ln -s /usr/share/doc/${pkgname}/html ${pkgdir}/usr/share/doc/ghc/html/libraries/${_hkgname}<br />
runhaskell Setup copy --destdir=${pkgdir}<br />
}<br />
</nowiki>}}<br />
<br />
It follows the conventions for Haskell packages:<br />
<br />
* Libraries are prefixed with {{ic|haskell-}}<br />
* All libraries that the package depend on are listed (libraries shipped with GHC are dealt with by having the {{pkg|ghc}} package provide them)<br />
* It uses cabal to generate a post-install register/unregister script, with a standard name.<br />
* We use haddock to build the documentation.<br />
<br />
All Haskell libraries should follow these naming conventions, and using the latest release of cabal2arch will ensure this is the case.<br />
<br />
{{Note|Beginning with {{AUR|cabal2arch}} 1.1-2, a new environment variable, {{ic|PKGBUILD_HASKELL_ENABLE_PROFILING}}, is generated into the PKGBUILD. If this variable is of non-zero length, such as "1" or "true", then profiling builds will occur. Thus, if a user desires profiling, then it is advised to export this environment variable in a file such as {{ic|~/.bashrc}} or {{ic|~/.zshrc}}.}}<br />
<br />
===Guidelines for Libraries===<br />
In general, each .cabal file should map to one PKGBUILD. The following conventions hold:<br />
<br />
* libraries have their cabal names prefixed with {{ic|haskell-}}<br />
* all libraries have a dependency on {{pkg|ghc}}<br />
* all libraries that are depended on must be listed in the {{ic|depends}} array in the PKGBUILD<br />
* be careful about dependencies from gtk2hs: cairo, svg, glib, gtk. These are all provided by the {{pkg|gtk2hs}} package, not , e.g. "haskell-cairo"<br />
<br />
Registering Haskell libraries is done via a register hook, see above.<br />
<br />
===Guidelines for Programs ===<br />
* Have their normal name. Examples: hmp3, xmonad, ghc, cabal-install<br />
<br />
* Be careful about dynamically linked run-time dependencies on C. For example, all GHC-produced binaries have a run-time dependency on 'gmp'. OpenGL or GtT-based binaries will have additional 'depends'. cabal2arch will attempt to work out the C dependencies, but there may be others implied by Haskell dependencies that are missed.<br />
<br />
* Use executable stripping, {{ic|--enable-executable-stripping}}. cabal2arch will do this automatically.<br />
<br />
== Haskell Build Order ==<br />
* haskell-x11 update: haskell-x11-xft -> xmonad -> xmonad-contrib</div>Xrchzhttps://wiki.archlinux.org/index.php?title=Haskell_package_guidelines&diff=226320Haskell package guidelines2012-09-30T20:45:16Z<p>Xrchz: /* Haskell Packages */</p>
<hr />
<div>[[Category:Package development]]<br />
[[it:Haskell Package Guidelines]]<br />
{{Package Guidelines}}<br />
<br />
[[Wikipedia:Haskell|Haskell]] is well supported on Arch Linux, with GHC and other key tools available via the [[Official Repositories|official repositories]], a growing number of packages made available by the ArchHaskell group, and a large part of [http://hackage.haskell.org hackage.haskell.org]'s library database [https://aur.archlinux.org/packages.php?O=0&K=haskell- available in the AUR].<br />
The AUR packages, especially those owned by archhaskell, are deprecated. It is better to use and contribute to the [haskell] repository.<br />
<br />
The community around Haskell on Arch is dying but in the processo of revival, so your help is especially welcome!<br />
<br />
== Community ==<br />
All the details on the [[ArchHaskell]] group is available on its own page.<br />
<br />
== Haskell Packages ==<br />
The core Haskell tools are available in the core system (extra):<br />
<br />
=== [extra] ===<br />
* [https://www.archlinux.org/packages/?arch=x86_64&repo=Extra&q=haskell&last_update=&limit=50 Haskell packages in the core system]<br />
<br />
Our policy for [extra] is to provide the Haskell platform, and popular Haskell applications.<br />
<br />
=== [community] ===<br />
* [https://www.archlinux.org/packages/?arch=x86_64&repo=Community&q=haskell&last_update=&limit=50 other popular Haskell packages]<br />
<br />
[community] provides additional packages that are popular and not part of the Haskell platform, such as [[xmonad]].<br />
These packages are also provided by the [haskell] repo below.<br />
So, if you just want to use a few popular packages, you can just use what is provided by the official Arch repos.<br />
But if you want to use Haskell more seriously, read on.<br />
<br />
=== [haskell] ===<br />
The [haskell] repository is the official repository of packages maintained by the ArchHaskell team. This repository represents the last tier of stability, before resorting to the packages in the AUR, or perhaps building packages yourself with cabal2arch. [haskell] can be accessed by adding the following entry to {{ic|/etc/pacman.conf}}:<br />
<br />
[haskell]<br />
Server = http://xsounds.org/~haskell/$arch<br />
<br />
The set of packages in the [haskell] repository is derived from the '''habs''' tree officially located [https://github.com/archhaskell/habs here]. A tool called [https://github.com/magthe/cblrepo cblrepo] is used to keep the '''habs''' tree synchronized with the official Haskell packages from [http://hackage.haskell.org/packages/hackage.html Hackage].<br />
<br />
Putting [haskell] above [extra] will ensure that the packages from [haskell] take precedence, in case of duplicate packages in the two repositories.<br />
<br />
There is currently also a [haskell-testing] repo for GHC 7.6. <br />
<br />
[haskell-testing]<br />
Server = http://www.kiwilight.com/haskell/testing/$arch <br />
<br />
=== [haskell-extra] ===<br />
We are moving towards the possibility of distributing the desired contents of [haskell] (that is, all of Hackage) over several repositories (that is, distributing maintenance), while still collecting them all in a single repository.<br />
The first test towards this is [https://github.com/EffeErre/habs-extra habs-extra], which is also provided as a repository to be added to {{ic|/etc/pacman.conf}}:<br />
<br />
[haskell-extra]<br />
Server = http://archhaskell.mynerdside.com/$repo/$arch<br />
<br />
This should currently be used in conjunction with [haskell], because it provides additional packages while re-using those already provided by [haskell].<br />
More details are available in this [http://www.haskell.org/pipermail/arch-haskell/2012-September/002147.html message], and in the README on github.<br />
<br />
=== AUR ===<br />
* [https://aur.archlinux.org/packages.php?O=0&K=haskell- Haskell packages in the AUR]<br />
<br />
A huge number (almost 2000) packages built from http://hackage.haskell.org.<br />
<br />
These generally improve on installing directly from Hackage as they resolve required C libraries. They can be installed as, for example:<br />
<br />
# paktahn -S haskell-csv<br />
<br />
Anything not found here can be installed via {{pkg|cabal-install}} directly from Hackage.<br />
<br />
Unfortunately, many of the packages in the AUR are outdated due to a lack of resources.<br />
In practice, one could use the cabal2arch program to create [[PKGBUILD]]s directly from Hackage.<br />
But now it is recommended to use cblrepo and create something like [haskell-extra], which can then be added to the collection of haskell-providing repositories.<br />
<br />
== Guidelines ==<br />
<br />
{{out of date|this and remaining sections may be out of date given the move to distributed repositories}}<br />
<br />
In almost all cases, cabalised Haskell packages can be automatically translated into Arch packages, via the cabal2arch tool. It is strongly recommended that you use the latest released version of this tool, as it implements the packaging policy for Haskell packages. You can get it in several ways:<br />
<br />
* Add the [haskell] repository to {{ic|/etc/pacman.conf}} and use [[pacman]] to install the latest release.<br />
* Download and build the {{AUR|cabal2arch}} package from the [[Arch User Repository|AUR]].<br />
* Install directly from Hackage using {{ic|cabal install cabal2arch}}.<br />
<br />
===cabal2arch: an example===<br />
This example illustrates how to create a new package with cabal2arch. We will make a new package for the document formatter Pandoc:<br />
<br />
First, set the name and email address to be used in the generated PKGBUILD:<br />
<br />
export ARCH_HASKELL='My Name <my.name@domain.org>'<br />
<br />
Second, find [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/pandoc the hackage page for Pandoc], then identify the link to the .cabal file. Use this link as an argument to cabal2arch:<br />
<br />
{{bc|<nowiki><br />
% cd /tmp<br />
% cabal2arch http://hackage.haskell.org/packages/archive/pandoc/1.6.0.1/pandoc.cabal<br />
Using /tmp/tmp.D7HAJJx2js/pandoc.cabal<br />
Feeding the PKGBUILD to `makepkg -g`...<br />
==> Retrieving Sources...<br />
-> Downloading pandoc-1.6.0.1.tar.gz...<br />
--2011-05-14 07:25:39-- http://hackage.haskell.org/packages/archive/pandoc/1.6.0.1/pandoc-1.6.0.1.tar.gz<br />
Resolving hackage.haskell.org... 69.30.63.204<br />
Connecting to hackage.haskell.org|69.30.63.204|:80... connected.<br />
HTTP request sent, awaiting response... 200 OK<br />
Length: 355477 (347K) [application/x-tar]<br />
Saving to: “pandoc-1.6.0.1.tar.gz.part”<br />
<br />
0K .......... .......... .......... .......... .......... 14% 210K 1s<br />
50K .......... .......... .......... .......... .......... 28% 393K 1s<br />
100K .......... .......... .......... .......... .......... 43% 338K 1s<br />
150K .......... .......... .......... .......... .......... 57% 419K 0s<br />
200K .......... .......... .......... .......... .......... 72% 404K 0s<br />
250K .......... .......... .......... .......... .......... 86% 554K 0s<br />
300K .......... .......... .......... .......... ....... 100% 506K=0.9s<br />
<br />
2011-05-14 07:25:40 (369 KB/s) - “pandoc-1.6.0.1.tar.gz.part” saved [355477/355477]<br />
<br />
==> Generating checksums for source files...<br />
</nowiki>}}<br />
<br />
Checking what was created:<br />
<br />
% ls<br />
haskell-pandoc<br />
% cd haskell-pandoc<br />
% ls<br />
haskell-pandoc.install PKGBUILD<br />
<br />
You can now inspect the PKGBUILD and install script for the library:<br />
<br />
{{bc|<nowiki><br />
# Maintainer: <br />
_hkgname=pandoc<br />
pkgname=haskell-pandoc<br />
pkgver=1.6.0.1<br />
pkgrel=1<br />
pkgdesc="Conversion between markup formats"<br />
url="http://hackage.haskell.org/package/${_hkgname}"<br />
license=('GPL')<br />
arch=('i686' 'x86_64')<br />
makedepends=()<br />
depends=('ghc' 'haskell-http=4000.1.1' 'haskell-bytestring=0.9.1.10' 'haskell-containers=0.4.0.0' 'haskell-directory=1.1.0.0' 'haskell-extensible-exceptions=0.1.1.2' 'haskell-filepath=1.2.0.0' 'haskell-mtl=2.0.1.0' 'haskell-network=2.3.0.2' 'haskell-old-time=1.0.0.6' 'haskell-parsec=3.1.1' 'haskell-pretty=1.0.1.2' 'haskell-process=1.0.1.5' 'haskell-random=1.0.0.3' 'haskell-syb=0.3' 'haskell-texmath<0.5' 'haskell-utf8-string>=0.3' 'haskell-xhtml=3000.2.0.1' 'haskell-xml<1.4' 'haskell-zip-archive<0.2')<br />
options=('strip')<br />
source=(http://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz)<br />
install=${pkgname}.install<br />
md5sums=('d19a630462595941b3100dff6f839aa3')<br />
build() {<br />
cd ${srcdir}/${_hkgname}-${pkgver}<br />
runhaskell Setup configure -O ${PKGBUILD_HASKELL_ENABLE_PROFILING:+-p } --enable-split-objs --enable-shared \<br />
--prefix=/usr --docdir=/usr/share/doc/${pkgname} --libsubdir=\$compiler/site-local/\$pkgid<br />
runhaskell Setup build<br />
runhaskell Setup haddock<br />
runhaskell Setup register --gen-script<br />
runhaskell Setup unregister --gen-script<br />
sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh<br />
}<br />
package() {<br />
cd ${srcdir}/${_hkgname}-${pkgver}<br />
install -D -m744 register.sh ${pkgdir}/usr/share/haskell/${pkgname}/register.sh<br />
install -m744 unregister.sh ${pkgdir}/usr/share/haskell/${pkgname}/unregister.sh<br />
install -d -m755 ${pkgdir}/usr/share/doc/ghc/html/libraries<br />
ln -s /usr/share/doc/${pkgname}/html ${pkgdir}/usr/share/doc/ghc/html/libraries/${_hkgname}<br />
runhaskell Setup copy --destdir=${pkgdir}<br />
}<br />
</nowiki>}}<br />
<br />
It follows the conventions for Haskell packages:<br />
<br />
* Libraries are prefixed with {{ic|haskell-}}<br />
* All libraries that the package depend on are listed (libraries shipped with GHC are dealt with by having the {{pkg|ghc}} package provide them)<br />
* It uses cabal to generate a post-install register/unregister script, with a standard name.<br />
* We use haddock to build the documentation.<br />
<br />
All Haskell libraries should follow these naming conventions, and using the latest release of cabal2arch will ensure this is the case.<br />
<br />
{{Note|Beginning with {{AUR|cabal2arch}} 1.1-2, a new environment variable, {{ic|PKGBUILD_HASKELL_ENABLE_PROFILING}}, is generated into the PKGBUILD. If this variable is of non-zero length, such as "1" or "true", then profiling builds will occur. Thus, if a user desires profiling, then it is advised to export this environment variable in a file such as {{ic|~/.bashrc}} or {{ic|~/.zshrc}}.}}<br />
<br />
===Guidelines for Libraries===<br />
In general, each .cabal file should map to one PKGBUILD. The following conventions hold:<br />
<br />
* libraries have their cabal names prefixed with {{ic|haskell-}}<br />
* all libraries have a dependency on {{pkg|ghc}}<br />
* all libraries that are depended on must be listed in the {{ic|depends}} array in the PKGBUILD<br />
* be careful about dependencies from gtk2hs: cairo, svg, glib, gtk. These are all provided by the {{pkg|gtk2hs}} package, not , e.g. "haskell-cairo"<br />
<br />
Registering Haskell libraries is done via a register hook, see above.<br />
<br />
===Guidelines for Programs ===<br />
* Have their normal name. Examples: hmp3, xmonad, ghc, cabal-install<br />
<br />
* Be careful about dynamically linked run-time dependencies on C. For example, all GHC-produced binaries have a run-time dependency on 'gmp'. OpenGL or GtT-based binaries will have additional 'depends'. cabal2arch will attempt to work out the C dependencies, but there may be others implied by Haskell dependencies that are missed.<br />
<br />
* Use executable stripping, {{ic|--enable-executable-stripping}}. cabal2arch will do this automatically.<br />
<br />
== Haskell Build Order ==<br />
* haskell-x11 update: haskell-x11-xft -> xmonad -> xmonad-contrib</div>Xrchzhttps://wiki.archlinux.org/index.php?title=Systemd/Services&diff=226199Systemd/Services2012-09-29T18:30:07Z<p>Xrchz: add foldingathome-smp service file</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Daemons and system services]]<br />
[[Category:Boot process]]<br />
{{Article summary start}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Systemd}}<br />
{{Article summary end}}<br />
<br />
This page is useful to publish [[systemd]] service files that are missing in the appropriate package in the repositories. These files can be copied from other distributions or created by yourself.<br />
<br />
== atd ==<br />
{{hc|/etc/systemd/system/atd.service|<nowiki><br />
<br />
[Unit]<br />
Description=Execution Queue Daemon<br />
<br />
[Service]<br />
ExecStart=/usr/sbin/atd -f<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
== BOINC Daemon ==<br />
{{hc|/etc/systemd/system/boinc.service|<nowiki><br />
[Unit]<br />
Description=BOINC Daemon<br />
<br />
[Service]<br />
User=boinc<br />
Nice=19<br />
ExecStart=/usr/bin/boinc_client --dir /var/lib/boinc --redirectio<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
== CouchDB ==<br />
{{hc|/etc/systemd/system/couchdb.service|<nowiki><br />
[Unit]<br />
Description=CouchDB Server<br />
<br />
[Service]<br />
User=couchdb<br />
Type=forking<br />
PermissionsStartOnly=true<br />
ExecStartPre=/bin/mkdir -p /var/run/couchdb ; /bin/chown -R couchdb /var/run/couchdb<br />
ExecStart=/usr/bin/couchdb -b -o /dev/null -e /dev/null<br />
ExecStop=/usr/bin/couchdb -d<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
== Courier-IMAP ==<br />
{{hc|/etc/systemd/system/authdaemond.service|<nowiki><br />
[Unit]<br />
Description=Courier Authentification Daemon<br />
<br />
[Service]<br />
Type=forking<br />
ExecStart=/usr/sbin/authdaemond start<br />
ExecStop=/usr/sbin/authdaemon stop<br />
PIDFile=/run/authdaemon/pid<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
{{hc|/etc/systemd/system/courier-imapd.service|<nowiki><br />
[Unit]<br />
Description=Courier IMAP Daemon<br />
Requires=authdaemond.service<br />
After=authdaemond.service<br />
<br />
[Service]<br />
Type=forking<br />
EnvironmentFile=/etc/courier-imap/imapd<br />
ExecStart=/usr/lib/courier-imap/imapd.rc start<br />
ExecStop=/usr/lib/courier-imap/imapd.rc stop<br />
PIDFile=/var/run/courier/imapd.pid<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
{{hc|/etc/systemd/system/courier-imapd-ssl.service|<nowiki><br />
[Unit]<br />
Description=Courier IMAP Daemon<br />
Requires=authdaemond.service<br />
After=authdaemond.service<br />
<br />
[Service]<br />
Type=forking<br />
EnvironmentFile=/etc/courier-imap/imapd<br />
ExecStart=/usr/lib/courier-imap/imapd-ssl.rc start<br />
ExecStop=/usr/lib/courier-imap/imapd-ssl.rc stop<br />
PIDFile=/var/run/courier/imapd-ssl.pid<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
{{hc|/usr/lib/tmpfiles.d/authdaemond.conf|<nowiki><br />
D /run/authdaemon 0755 courier courier<br />
</nowiki>}}<br />
<br />
{{hc|/usr/lib/tmpfiles.d/courier-imapd.conf|<nowiki><br />
D /run/courier 0755 courier courier<br />
</nowiki>}}<br />
<br />
{{Note|Taken from Gentoo and modified for Arch. You could replace the files in tmpfiles.d with appropriate ExecStartPre calls as well. Service files for pop3d and pop3d-ssl are still missing, but are probably very similar to the imapd files!}}<br />
<br />
== dropbear ==<br />
{{hc|/etc/systemd/system/dropbear.service|<br />
<nowiki><br />
[Unit]<br />
Description=Dropbear SSH server<br />
<br />
[Service]<br />
Type=oneshot<br />
ExecStart=/usr/sbin/dropbear -p 22 -d /etc/dropbear/dropbear_dss_host_key -w -P /var/run/dropbear.pid<br />
RemainAfterExit=yes<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
<br />
</nowiki>}}<br />
<br />
== Folding@home SMP ==<br />
See the comment on the [https://aur.archlinux.org/packages.php?ID=11964 AUR package].<br />
The unit file is copied below for convenience.<br />
{{hc|/etc/systemd/system/foldingathome-smp.service|<br />
<nowiki><br />
[Unit]<br />
Description=Folding@home distributed computing client<br />
After=network.target<br />
<br />
[Service]<br />
Type=simple<br />
WorkingDirectory=/opt/fah-smp<br />
ExecStart=/opt/fah-smp/fah6 -smp -verbosity 9 -forceasm<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
== IPv6 (Hurricane Electric) ==<br />
{{hc|/etc/systemd/system/he-ipv6.service|<nowiki><br />
<br />
[Unit]<br />
Description=he.net IPv6 tunnel<br />
After=network.target<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
ExecStart=/sbin/ip tunnel add he-ipv6 mode sit remote 209.51.161.14 local <local IPv4> ttl 255<br />
ExecStart=/sbin/ip link set he-ipv6 up mtu 1480<br />
ExecStart=/sbin/ip addr add <local IPv6>/64 dev he-ipv6<br />
ExecStart=/sbin/ip -6 route add ::/0 dev he-ipv6<br />
ExecStart=/sbin/ip addr add <public IPv6>/64 dev he-ipv6<br />
ExecStop=/sbin/ip -6 route del ::/0 dev he-ipv6<br />
ExecStop=/sbin/ip link set he-ipv6 down<br />
ExecStop=/sbin/ip tunnel del he-ipv6<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
<br />
</nowiki>}}<br />
<br />
== Logmein Hamachi ==<br />
{{hc|/etc/systemd/system/hamachi.service|<nowiki><br />
[Unit]<br />
Description=Hamachi Daemon<br />
After=network.target<br />
<br />
[Service]<br />
Type=forking<br />
ExecStart=/opt/logmein-hamachi/bin/hamachid<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
== Noip ==<br />
{{hc|/etc/systemd/system/noip2.service|<nowiki><br />
[Unit]<br />
Description=No-IP Dynamic DNS Update Client<br />
After=network.target<br />
<br />
[Service]<br />
Type=forking<br />
ExecStart=/usr/bin/noip2<br />
<br />
[Install]<br />
WantedBy=multi-user.target</nowiki>}}<br />
<br />
== pcscd ==<br />
{{hc|/etc/systemd/system/pcscd.service|<nowiki><br />
[Unit]<br />
Description=PC/SC Smart Card Daemon<br />
Requires=pcscd.socket<br />
<br />
[Service]<br />
ExecStart=/usr/sbin/pcscd --foreground --auto-exit<br />
ExecReload=/usr/sbin/pcscd --hotplug<br />
StandardOutput=syslog<br />
<br />
[Install]<br />
Also=pcscd.socket<br />
</nowiki>}}<br />
<br />
{{hc|/etc/systemd/system/pcscd.socket|<nowiki><br />
[Unit]<br />
Description=PC/SC Smart Card Daemon Activation Socket<br />
<br />
[Socket]<br />
ListenStream=/var/run/pcscd/pcscd.comm<br />
<br />
[Install]<br />
WantedBy=sockets.target<br />
</nowiki>}}<br />
Reference:<br />
* http://ludovicrousseau.blogspot.de/2011/11/pcscd-auto-start-using-systemd.html<br />
<br />
== rc.local ==<br />
{{hc|/etc/systemd/system/rc-local.service|<nowiki><br />
[Unit]<br />
Description=/etc/rc.local Compatibility<br />
<br />
[Service]<br />
Type=oneshot<br />
ExecStart=/etc/rc.local<br />
TimeoutSec=0<br />
StandardInput=tty<br />
RemainAfterExit=yes<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
{{Tip|You can replace your rc.local with native systemd units in {{ic|/etc/systemd/system/}}.}}<br />
{{Note|Also available in {{Pkg|initscripts}} (see: [[Systemd#Arch_integration]]).}}<br />
{{Note|1=StandardInput=tty may give strange behaviour:<br />
https://bbs.archlinux.org/viewtopic.php?id=147790}}<br />
<br />
== Remote filesystem mounts ==<br />
''See: [[Systemd#Remote_filesystem_mounts]]''<br />
<br />
== Static Ethernet network ==<br />
This is a custom service file for static Ethernet configurations. For other configurations, see [[Systemd#Network]]<br />
{{hc|/etc/conf.d/network|<nowiki><br />
interface=eth0<br />
address=192.168.0.1<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.254</nowiki>}}<br />
<br />
{{hc|/etc/systemd/system/network.service|<nowiki><br />
[Unit]<br />
Description=Network Connectivity<br />
Wants=network.target<br />
Before=network.target<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network<br />
ExecStart=/sbin/ip link set dev ${interface} up<br />
ExecStart=/sbin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev ${interface}<br />
ExecStart=/sbin/ip route add default via ${gateway}<br />
ExecStop=/sbin/ip addr flush dev ${interface}<br />
ExecStop=/sbin/ip link set dev ${interface} down<br />
<br />
[Install]<br />
WantedBy=multi-user.target</nowiki>}}<br />
<br />
== tpfand ==<br />
{{hc|/etc/systemd/system/tpfand.service|<nowiki><br />
[Unit]<br />
Description=ThinkPad Fan Control<br />
<br />
[Service]<br />
Type=forking<br />
PIDFile=/var/run/tpfand.pid<br />
ExecStart=/usr/sbin/tpfand<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
== verynice ==<br />
{{hc|/etc/systemd/system/verynice.service|<nowiki><br />
[Unit]<br />
Description=A tool for dynamically adjusting the nice-level of processes<br />
<br />
[Service]<br />
Type=forking<br />
PIDFile=/var/run/verynice.pid<br />
ExecStart=/usr/sbin/verynice -d /var/run/verynice.pid<br />
ExecStop=/bin/kill -15 $MAINPID<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
== VideoLAN 2.0 ==<br />
Change the '''User''' parameter.<br />
<br />
{{hc|/etc/systemd/system/vlc.service|<nowiki><br />
[Unit]<br />
Description=VideoOnLAN Service<br />
After=network.target<br />
<br />
[Service]<br />
Type=forking<br />
User=nobody<br />
ExecStart=/usr/bin/cvlc --intf=lua --lua-intf=http --daemon --http-port 8090<br />
Restart=on-abort<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
== See also ==<br />
<br />
* [[systemd]]<br />
* [http://en.gentoo-wiki.com/wiki/Systemd systemd at gentoo wiki]</div>Xrchzhttps://wiki.archlinux.org/index.php?title=Haskell_package_guidelines&diff=225006Haskell package guidelines2012-09-25T09:33:41Z<p>Xrchz: </p>
<hr />
<div>[[Category:Package development]]<br />
[[it:Haskell Package Guidelines]]<br />
{{Package Guidelines}}<br />
<br />
[[Wikipedia:Haskell|Haskell]] is well supported on Arch Linux, with GHC and other key tools available via the [[Official Repositories|official repositories]], a growing number of packages made available by the ArchHaskell group, and a large part of [http://hackage.haskell.org hackage.haskell.org]'s library database [https://aur.archlinux.org/packages.php?O=0&K=haskell- available in the AUR].<br />
The AUR packages, especially those owned by archhaskell, are deprecated. It is better to use and contribute to the [haskell] repository.<br />
<br />
The community around Haskell on Arch is dying but in the processo of revival, so your help is especially welcome!<br />
<br />
== Community ==<br />
All the details on the [[ArchHaskell]] group is available on its own page.<br />
<br />
== Haskell Packages ==<br />
The core Haskell tools are available in the core system (extra):<br />
<br />
=== [extra] ===<br />
* [https://www.archlinux.org/packages/?arch=x86_64&repo=Extra&q=haskell&last_update=&limit=50 Haskell packages in the core system]<br />
<br />
Our policy for [extra] is to provide the Haskell platform, and popular Haskell applications.<br />
<br />
=== [community] ===<br />
* [https://www.archlinux.org/packages/?arch=x86_64&repo=Community&q=haskell&last_update=&limit=50 other popular Haskell packages]<br />
<br />
[community] provides additional packages that are popular and not part of the Haskell platform, such as [[xmonad]].<br />
These packages are also provided by the [haskell] repo below.<br />
So, if you just want to use a few popular packages, you can just use what is provided by the official Arch repos.<br />
But if you want to use Haskell more seriously, read on.<br />
<br />
=== [haskell] ===<br />
The [haskell] repository is the official repository of packages maintained by the ArchHaskell team. This repository represents the last tier of stability, before resorting to the packages in the AUR, or perhaps building packages yourself with cabal2arch. [haskell] can be accessed by adding the following entry to {{ic|/etc/pacman.conf}}:<br />
<br />
[haskell]<br />
Server = http://xsounds.org/~haskell/$arch<br />
<br />
The set of packages in the [haskell] repository is derived from the '''habs''' tree officially located [https://github.com/archhaskell/habs here]. A tool called [https://github.com/magthe/cblrepo cblrepo] is used to keep the '''habs''' tree synchronized with the official Haskell packages from [http://hackage.haskell.org/packages/hackage.html Hackage].<br />
<br />
Putting [haskell] above [extra] will ensure that the packages from [haskell] take precedence, in case of duplicate packages in the two repositories.<br />
<br />
=== [haskell-extra] ===<br />
We are moving towards the possibility of distributing the desired contents of [haskell] (that is, all of Hackage) over several repositories (that is, distributing maintenance), while still collecting them all in a single repository.<br />
The first test towards this is [https://github.com/EffeErre/habs-extra habs-extra], which is also provided as a repository to be added to {{ic|/etc/pacman.conf}}:<br />
<br />
[haskell-extra]<br />
Server = http://archhaskell.mynerdside.com/$repo/$arch<br />
<br />
This should currently be used in conjunction with [haskell], because it provides additional packages while re-using those already provided by [haskell].<br />
More details are available in this [http://www.haskell.org/pipermail/arch-haskell/2012-September/002147.html message], and in the README on github.<br />
<br />
=== AUR ===<br />
* [https://aur.archlinux.org/packages.php?O=0&K=haskell- Haskell packages in the AUR]<br />
<br />
A huge number (almost 2000) packages built from http://hackage.haskell.org.<br />
<br />
These generally improve on installing directly from Hackage as they resolve required C libraries. They can be installed as, for example:<br />
<br />
# paktahn -S haskell-csv<br />
<br />
Anything not found here can be installed via {{pkg|cabal-install}} directly from Hackage.<br />
<br />
Unfortunately, many of the packages in the AUR are outdated due to a lack of resources.<br />
In practice, one could use the cabal2arch program to create [[PKGBUILD]]s directly from Hackage.<br />
But now it is recommended to use cblrepo and create something like [haskell-extra], which can then be added to the collection of haskell-providing repositories.<br />
<br />
== Guidelines ==<br />
<br />
{{out of date|this and remaining sections may be out of date given the move to distributed repositories}}<br />
<br />
In almost all cases, cabalised Haskell packages can be automatically translated into Arch packages, via the cabal2arch tool. It is strongly recommended that you use the latest released version of this tool, as it implements the packaging policy for Haskell packages. You can get it in several ways:<br />
<br />
* Add the [haskell] repository to {{ic|/etc/pacman.conf}} and use [[pacman]] to install the latest release.<br />
* Download and build the {{AUR|cabal2arch}} package from the [[Arch User Repository|AUR]].<br />
* Install directly from Hackage using {{ic|cabal install cabal2arch}}.<br />
<br />
===cabal2arch: an example===<br />
This example illustrates how to create a new package with cabal2arch. We will make a new package for the document formatter Pandoc:<br />
<br />
First, set the name and email address to be used in the generated PKGBUILD:<br />
<br />
export ARCH_HASKELL='My Name <my.name@domain.org>'<br />
<br />
Second, find [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/pandoc the hackage page for Pandoc], then identify the link to the .cabal file. Use this link as an argument to cabal2arch:<br />
<br />
{{bc|<nowiki><br />
% cd /tmp<br />
% cabal2arch http://hackage.haskell.org/packages/archive/pandoc/1.6.0.1/pandoc.cabal<br />
Using /tmp/tmp.D7HAJJx2js/pandoc.cabal<br />
Feeding the PKGBUILD to `makepkg -g`...<br />
==> Retrieving Sources...<br />
-> Downloading pandoc-1.6.0.1.tar.gz...<br />
--2011-05-14 07:25:39-- http://hackage.haskell.org/packages/archive/pandoc/1.6.0.1/pandoc-1.6.0.1.tar.gz<br />
Resolving hackage.haskell.org... 69.30.63.204<br />
Connecting to hackage.haskell.org|69.30.63.204|:80... connected.<br />
HTTP request sent, awaiting response... 200 OK<br />
Length: 355477 (347K) [application/x-tar]<br />
Saving to: “pandoc-1.6.0.1.tar.gz.part”<br />
<br />
0K .......... .......... .......... .......... .......... 14% 210K 1s<br />
50K .......... .......... .......... .......... .......... 28% 393K 1s<br />
100K .......... .......... .......... .......... .......... 43% 338K 1s<br />
150K .......... .......... .......... .......... .......... 57% 419K 0s<br />
200K .......... .......... .......... .......... .......... 72% 404K 0s<br />
250K .......... .......... .......... .......... .......... 86% 554K 0s<br />
300K .......... .......... .......... .......... ....... 100% 506K=0.9s<br />
<br />
2011-05-14 07:25:40 (369 KB/s) - “pandoc-1.6.0.1.tar.gz.part” saved [355477/355477]<br />
<br />
==> Generating checksums for source files...<br />
</nowiki>}}<br />
<br />
Checking what was created:<br />
<br />
% ls<br />
haskell-pandoc<br />
% cd haskell-pandoc<br />
% ls<br />
haskell-pandoc.install PKGBUILD<br />
<br />
You can now inspect the PKGBUILD and install script for the library:<br />
<br />
{{bc|<nowiki><br />
# Maintainer: <br />
_hkgname=pandoc<br />
pkgname=haskell-pandoc<br />
pkgver=1.6.0.1<br />
pkgrel=1<br />
pkgdesc="Conversion between markup formats"<br />
url="http://hackage.haskell.org/package/${_hkgname}"<br />
license=('GPL')<br />
arch=('i686' 'x86_64')<br />
makedepends=()<br />
depends=('ghc' 'haskell-http=4000.1.1' 'haskell-bytestring=0.9.1.10' 'haskell-containers=0.4.0.0' 'haskell-directory=1.1.0.0' 'haskell-extensible-exceptions=0.1.1.2' 'haskell-filepath=1.2.0.0' 'haskell-mtl=2.0.1.0' 'haskell-network=2.3.0.2' 'haskell-old-time=1.0.0.6' 'haskell-parsec=3.1.1' 'haskell-pretty=1.0.1.2' 'haskell-process=1.0.1.5' 'haskell-random=1.0.0.3' 'haskell-syb=0.3' 'haskell-texmath<0.5' 'haskell-utf8-string>=0.3' 'haskell-xhtml=3000.2.0.1' 'haskell-xml<1.4' 'haskell-zip-archive<0.2')<br />
options=('strip')<br />
source=(http://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz)<br />
install=${pkgname}.install<br />
md5sums=('d19a630462595941b3100dff6f839aa3')<br />
build() {<br />
cd ${srcdir}/${_hkgname}-${pkgver}<br />
runhaskell Setup configure -O ${PKGBUILD_HASKELL_ENABLE_PROFILING:+-p } --enable-split-objs --enable-shared \<br />
--prefix=/usr --docdir=/usr/share/doc/${pkgname} --libsubdir=\$compiler/site-local/\$pkgid<br />
runhaskell Setup build<br />
runhaskell Setup haddock<br />
runhaskell Setup register --gen-script<br />
runhaskell Setup unregister --gen-script<br />
sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh<br />
}<br />
package() {<br />
cd ${srcdir}/${_hkgname}-${pkgver}<br />
install -D -m744 register.sh ${pkgdir}/usr/share/haskell/${pkgname}/register.sh<br />
install -m744 unregister.sh ${pkgdir}/usr/share/haskell/${pkgname}/unregister.sh<br />
install -d -m755 ${pkgdir}/usr/share/doc/ghc/html/libraries<br />
ln -s /usr/share/doc/${pkgname}/html ${pkgdir}/usr/share/doc/ghc/html/libraries/${_hkgname}<br />
runhaskell Setup copy --destdir=${pkgdir}<br />
}<br />
</nowiki>}}<br />
<br />
It follows the conventions for Haskell packages:<br />
<br />
* Libraries are prefixed with {{ic|haskell-}}<br />
* All libraries that the package depend on are listed (libraries shipped with GHC are dealt with by having the {{pkg|ghc}} package provide them)<br />
* It uses cabal to generate a post-install register/unregister script, with a standard name.<br />
* We use haddock to build the documentation.<br />
<br />
All Haskell libraries should follow these naming conventions, and using the latest release of cabal2arch will ensure this is the case.<br />
<br />
{{Note|Beginning with {{AUR|cabal2arch}} 1.1-2, a new environment variable, {{ic|PKGBUILD_HASKELL_ENABLE_PROFILING}}, is generated into the PKGBUILD. If this variable is of non-zero length, such as "1" or "true", then profiling builds will occur. Thus, if a user desires profiling, then it is advised to export this environment variable in a file such as {{ic|~/.bashrc}} or {{ic|~/.zshrc}}.}}<br />
<br />
===Guidelines for Libraries===<br />
In general, each .cabal file should map to one PKGBUILD. The following conventions hold:<br />
<br />
* libraries have their cabal names prefixed with {{ic|haskell-}}<br />
* all libraries have a dependency on {{pkg|ghc}}<br />
* all libraries that are depended on must be listed in the {{ic|depends}} array in the PKGBUILD<br />
* be careful about dependencies from gtk2hs: cairo, svg, glib, gtk. These are all provided by the {{pkg|gtk2hs}} package, not , e.g. "haskell-cairo"<br />
<br />
Registering Haskell libraries is done via a register hook, see above.<br />
<br />
===Guidelines for Programs ===<br />
* Have their normal name. Examples: hmp3, xmonad, ghc, cabal-install<br />
<br />
* Be careful about dynamically linked run-time dependencies on C. For example, all GHC-produced binaries have a run-time dependency on 'gmp'. OpenGL or GtT-based binaries will have additional 'depends'. cabal2arch will attempt to work out the C dependencies, but there may be others implied by Haskell dependencies that are missed.<br />
<br />
* Use executable stripping, {{ic|--enable-executable-stripping}}. cabal2arch will do this automatically.<br />
<br />
== Haskell Build Order ==<br />
* haskell-x11 update: haskell-x11-xft -> xmonad -> xmonad-contrib</div>Xrchzhttps://wiki.archlinux.org/index.php?title=Unofficial_user_repositories/ArchHaskell&diff=225002Unofficial user repositories/ArchHaskell2012-09-25T09:22:43Z<p>Xrchz: </p>
<hr />
<div>[[Category:Package development]]<br />
The ArchHaskell group works on providing Haskell packages to the wider Arch Linux community. The ultimate goal is to provide all of [http://hackage.haskell.org Hackage] as binary packages for easy installation. We are still a long way away :-)<br />
<br />
See also [[Haskell package guidelines]].<br />
<br />
== Resources ==<br />
<br />
The main resources for the [[ArchHaskell]] community to interact and discuss are:<br />
<br />
* [http://www.gogloom.com/FreeNode/arch-haskell <nowiki>#arch-haskell</nowiki>] IRC channel @ freenode.org<br />
** Good for quick discussion and planning<br />
** Currently severely underpopulated<br />
* [http://haskell.org/mailman/listinfo/arch-haskell arch-haskell@haskell.org] mailing list<br />
** Broader announcements, and automated updates<br />
** Currently very low traffic, but responses do come.<br />
** Also, check the archives.<br />
* [https://github.com/archhaskell ArchHaskell group] on GitHub<br />
** Repositories for tools as well as the source for the binary packages (HABS).<br />
<br />
== Membership ==<br />
<br />
Due to using GitHub for the source repositories, membership is not required at all in order to contribute. Just fork the relevant repository, make some changes, and file a pull request.<br />
<br />
There are currently three people with commit rights to the ArchHaskell repository at GitHub:<br />
<br />
* Peter Simons<br />
* Rémy Oudompheng<br />
* Leif Warner</div>Xrchzhttps://wiki.archlinux.org/index.php?title=Unofficial_user_repositories/ArchHaskell&diff=225001Unofficial user repositories/ArchHaskell2012-09-25T09:21:45Z<p>Xrchz: </p>
<hr />
<div>[[Category:Package development]]<br />
The ArchHaskell group works on providing Haskell packages to the wider Arch Linux community. The ultimate goal is to provide all of [http://hackage.haskell.org Hackage] as binary packages for easy installation. We are still a long way away :-)<br />
<br />
== Resources ==<br />
<br />
The main resources for the [[ArchHaskell]] community to interact and discuss are:<br />
<br />
* [http://www.gogloom.com/FreeNode/arch-haskell <nowiki>#arch-haskell</nowiki>] IRC channel @ freenode.org<br />
** Good for quick discussion and planning<br />
** Currently severely underpopulated<br />
* [http://haskell.org/mailman/listinfo/arch-haskell arch-haskell@haskell.org] mailing list<br />
** Broader announcements, and automated updates<br />
** Currently very low traffic, but responses do come.<br />
** Also, check the archives.<br />
* [https://github.com/archhaskell ArchHaskell group] on GitHub<br />
** Repositories for tools as well as the source for the binary packages (HABS).<br />
<br />
== Membership ==<br />
<br />
Due to using GitHub for the source repositories, membership is not required at all in order to contribute. Just fork the relevant repository, make some changes, and file a pull request.<br />
<br />
There are currently three people with commit rights to the ArchHaskell repository at GitHub:<br />
<br />
* Peter Simons<br />
* Rémy Oudompheng<br />
* Leif Warner</div>Xrchzhttps://wiki.archlinux.org/index.php?title=Arch_Linux_on_a_VPS&diff=217365Arch Linux on a VPS2012-08-10T08:35:22Z<p>Xrchz: /* Providers that offer Arch Linux */ update linode image</p>
<hr />
<div>[[Category:Getting and installing Arch]]<br />
[[Category:Virtualization]]<br />
{{Article summary start}}<br />
{{Article summary text|This article discusses the use of Arch Linux on Virtual Private Servers, and includes some fixes and installation instructions specific to VPSes.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Comprehensive Server Guide}}<br />
{{Article summary end}}<br />
From [[Wikipedia:Virtual private server]]:<br />
<br />
:''Virtual private server (VPS) is a term used by Internet hosting services to refer to a virtual machine. The term is used for emphasizing that the virtual machine, although running in software on the same physical computer as other customers' virtual machines, is in many respects functionally equivalent to a separate physical computer, is dedicated to the individual customer's needs, has the privacy of a separate physical computer, and can be configured to run server software.''<br />
<br />
==Providers that offer Arch Linux==<br />
<br />
{{Warning|We cannot vouch for the honesty or quality of any provider. Please conduct due diligence before ordering.}}<br />
{{Note|This list is for providers with a convenient Arch Linux image. Using Arch on other providers is probably possible, but would require loading custom ISOs or disk images or [[Installation Chroot|installing under chroot]].}}<br />
<br />
{| border="1"<br />
! Provider !! Arch Release !! Virtualization !! Locations !! Notes<br />
|-<br />
| [http://alienvps.com/ AlienVPS] || 2010.05 || Xen, KVM || Los Angeles, New York ||<br />
|-<br />
| [https://www.clodo.ru/ Clodo.ru] || ? || Xen || Moscow || Can pay per hour.<br />
|-<br />
| [http://en.edis.at/ Edis] || 2011.08 i686/x86_64 || vServer, KVM || Austria, Switzerland, Germany, UK, Italy, USA, Sweden, France, Poland, Iceland, Hong Kong ||<br />
|-<br />
| [http://eoreality.net/ EOReality] || (?) i686/x86_64 || OpenVZ || Chicago || Need to use special glibc-vps repo for this provider . See [[Virtual_Private_Server#OpenVZ:_kernel_too_old_for_glibc|OpenVZ troubleshooting]] for instructions. You will also need to remove heimdal.<br />
|-<br />
| [http://fanaticalvps.com/ FanaticalVPS] || 2010.05 i686/x86_64 || OpenVZ || Nuremburg ||<br />
|-<br />
| [https://www.gigatux.com/virtual.php GigaTux] || 2011.08 x86_64 || Xen || Chicago, Frankfurt, Israel, London, San Jose ||<br />
|-<br />
| [http://www.vr.org/ Host Virtual] || 2011.08 || Xen || Amsterdam, Chennai (Madras), Chicago, Dallas, Hong Kong, London, Los Angeles, New York, Paris, Reston, San Jose ||<br />
|-<br />
| [https://hostigation.com/ Hostigation] || 2010.05 i686 || OpenVZ, KVM || Charlotte, Los Angeles || You can [[Migrating Between Architectures Without Reinstalling|migrate to x86_64]].<br />
|-<br />
| [http://www.intovps.com IntoVPS] || 2012.05 i686/x86_64 || OpenVZ || Amsterdam, Bucharest, Dallas, Fremont, London ||<br />
|-<br />
| [https://www.linode.com Linode.com] || 2012.07 || Xen || Atlanta, Dallas, Fremont, London, Newark, Tokyo || Uses a custom kernel; do not install the ''linux'' package.<br />
|-<br />
| [http://lylix.net/home Lylix] || 2007.08 || ? || ? ||<br />
|-<br />
| [http://openvz.ca/ OpenVZ.ca] || 2010.05 i686/x86_64 || OpenVZ || Canada ||<br />
|-<br />
| [http://www.rackspace.com/cloud/cloud_hosting_products/servers/ Rackspace Cloud] || 2011.10 || Xen || Chicago, Dallas, London, Hong Kong || Can pay per hour.<br />
|-<br />
| [http://www.ramhost.us RamHost.us] || 2009.10 || OpenVZ, KVM || Atlanta, England, Germany, Los Angeles ||<br />
|-<br />
| [http://www.tilaa.nl/ Tilaa] || 2011.08 i686/x86_64 || KVM || Amsterdam ||<br />
|-<br />
| [https://www.transip.nl/ TransIP] || 2011.08 || KVM || Amsterdam ||<br />
|-<br />
| [http://www.xenvz.co.uk/ XenVZ] || 2009.12 x86_64 || OpenVZ, Xen || UK? ||<br />
|-<br />
| [http://www.virpus.com/ Virpus] || 2010.05 x86_64 || OpenVZ, Xen || Kansas City ||<br />
|-<br />
| [http://vpslink.com/ VPSLink] || 0.8 || OpenVZ, Xen || Boston ||<br />
|-<br />
| [http://www.uk2.net/ UK2.net] || 2010.05 i686/x86_64 || Xen || United Kingdom || Appears to use a custom kernel; do not install the linux package.<br />
|}<br />
<br />
==Installation==<br />
<br />
===KVM===<br />
{{Expansion|Are there instructions specific to VPSes?}}<br />
See [[KVM#Preparing an (Arch) Linux guest]].<br />
<br />
===OpenVZ===<br />
{{Expansion|Move some of the [[#Troubleshooting]] instructions here.}}<br />
<br />
===Xen===<br />
{{Expansion|Are there instructions specific to VPSes?}}<br />
See [[Xen#Arch as Xen guest (PVHVM mode)]] and/or [[Xen#Arch as Xen guest (PV mode)]].<br />
<br />
==Troubleshooting==<br />
===OpenVZ: kernel too old for glibc===<br />
Are you on a virtual private server (VPS) with an old kernel & broke your system? Are you using OpenVZ?<br />
<br />
Arch Template Used: http://dev.archlinux.org/~ibiru/openvz/2010.05/arch-2010.05-i686-minimal.tar.gz<br />
<br />
Try doing the following to fix it:<br />
<br />
1) Edit {{ic|/etc/pacman.conf}} and add the following repository '''ABOVE [core]''':<br />
<br />
for 32-bit:<br />
<br />
{{bc|<nowiki>[glibc-vps]<br />
Server = http://dev.archlinux.org/~ibiru/openvz/glibc-vps/i686</nowiki>}}<br />
<br />
for 64-bit:<br />
<br />
{{bc|<nowiki>[glibc-vps]<br />
Server = http://dev.archlinux.org/~ibiru/openvz/glibc-vps/x86_64</nowiki>}}<br />
<br />
2) Then run {{ic|pacman -Syy}} followed by {{ic|pacman -Syu}}. You will be notified to upgrade pacman first.<br />
<br />
3) Upgrade the [[pacman]] database by running {{ic|pacman-db-upgrade}} as root.<br />
<br />
4) Edit {{ic|/etc/pacman.conf.pacnew}} (new pacman config file) and add the following repository '''ABOVE [core]''':<br />
<br />
{{bc|<nowiki>[glibc-vps]<br />
Server = http://dev.archlinux.org/~ibiru/openvz/glibc-vps/$arch</nowiki>}}<br />
<br />
5) Replace {{ic|/etc/pacman.conf}} with {{ic|/etc/pacman.conf.pacnew}} (run as root):<br />
<br />
{{bc|mv /etc/pacman.conf.pacnew /etc/pacman.conf}}<br />
<br />
6) Upgrade your whole system with new packages again {{ic|pacman -Syu}}<br />
<br />
If you get the following or similar error:<br />
{{bc|initscripts: /etc/profile.d/locale.sh exists in filesystem}}<br />
<br />
Simply delete that file (e.g., {{ic|rm -f /etc/profile.d/locale.sh}}), then run {{ic|pacman -Syu}} again.<br />
<br />
<br />
If you get the following or similar error:<br />
{{bc|filesystem: /etc/mtab exists in filesystem}}<br />
<br />
Run {{ic|pacman -S filesystem --force}}<br />
<br />
<br />
If you get the following or similar error:<br />
{{bc|libusb-compat: /usr/bin/libusb-config exists in filesystem}}<br />
<br />
Run {{ic|pacman -S libusb}} and then {{ic|pacman -S libusb-compat}}<br />
<br />
7) Before rebooting, you need to [[pacman|install]] the {{Pkg|makedev}} package by running {{ic|pacman -S makedev}}.<br />
<br />
8) Add MAKEDEV to {{ic|/etc/rc.local}}:<br />
<br />
{{bc|/usr/sbin/MAKEDEV tty<br />
/usr/sbin/MAKEDEV pty}}<br />
<br />
9) Edit {{ic|/etc/inittab}}, comment out the following lines (otherwise you will see errors in {{ic|/var/log/errors.log}}):<br />
<br />
{{bc|#c1:2345:respawn:/sbin/agetty -8 -s 38400 tty1 linux<br />
#c2:2345:respawn:/sbin/agetty -8 -s 38400 tty2 linux<br />
#c3:2345:respawn:/sbin/agetty -8 -s 38400 tty3 linux<br />
#c4:2345:respawn:/sbin/agetty -8 -s 38400 tty4 linux<br />
#c5:2345:respawn:/sbin/agetty -8 -s 38400 tty5 linux<br />
#c6:2345:respawn:/sbin/agetty -8 -s 38400 tty6 linux}}<br />
<br />
10) To enable the use of the {{ic|hostname}} command, [[pacman|install]] the package {{Pkg|inetutils}} from the [[Official Repositories|official repositories]]. <br />
<br />
11) Save and reboot.<br />
<br />
Enjoy & thank ioni if you happen to be in #archlinux<br />
<br />
===SSH fails: PTY allocation request failed on channel 0===<br />
<br />
Some VPSes have an outdated {{ic|rc.sysinit}}. You may be able to login via serial console or with<br />
<br />
{{bc|> ssh root@broken.server '/bin/bash -i'}}<br />
<br />
Then run the following:<br />
<br />
{{bc|# mv /etc/rc.sysinit.pacnew /etc/rc.sysinit<br />
# reboot}}<br />
<br />
Once it’s working, you should be able to comment out the {{ic|udevd_modprobe}} line in {{ic|rc.sysinit}} to save a bit of RAM the next time you reboot.<br />
<br />
If the above doesn’t work, take a look at<br />
http://fsk141.com/fix-pty-allocation-request-failed-on-channel-0.</div>Xrchzhttps://wiki.archlinux.org/index.php?title=Pacman/Pacnew_and_Pacsave&diff=215779Pacman/Pacnew and Pacsave2012-07-31T14:08:16Z<p>Xrchz: /* Managing .pacnew Files */ pacnews is now in AUR</p>
<hr />
<div>[[Category:Package management]]<br />
[[cs:Pacnew and Pacsave Files]]<br />
[[es:Pacnew and Pacsave Files]]<br />
[[fr:Gestion des fichiers de configurations]]<br />
[[it:Pacnew and Pacsave Files]]<br />
== Getting Started ==<br />
<br />
During package upgrades or removal [[Pacman]] will inform you of files (usually configurations in {{ic|/etc}}) that are being installed with a {{ic|.pacnew}} extension or backed up with a {{ic|.pacsave}} extension.<br />
<br />
A {{ic|.pacnew}} file may be created during a package upgrade ({{Ic|pacman -Syu}}, {{Ic|pacman -Su}} or {{Ic|pacman -U}}) to avoid overwriting a file which already exists and was previously modified by the user. When this happens a message like the following will appear in the output of pacman:<br />
<br />
warning: /etc/pam.d/usermod installed as /etc/pam.d/usermod.pacnew<br />
<br />
A {{ic|.pacsave}} file may be created during a package removal ({{Ic|pacman -R}}), or by a package upgrade (the package must be removed first). When the pacman database has record that a certain file owned by the package should be backed up it will create a {{ic|.pacsave}} file. When this happens pacman outputs a message like the following:<br />
<br />
warning: /etc/pam.d/usermod saved as /etc/pam.d/usermod.pacsave<br />
<br />
These files require manual intervention from the user and it is good practice to handle them right after every package upgrade or removal. If left unhandled, improper configurations can result in improper function of the software, or the software being unable to run altogether.<br />
<br />
== Package backup files ==<br />
<br />
A package's {{ic|PKGBUILD}} file specifies which files should be preserved or backed up when the package is upgraded or removed. For example, the {{ic|PKGBUILD}} for {{ic|pulseaudio}} contains the following line:<br />
<br />
backup=('etc/pulse/client.conf' 'etc/pulse/daemon.conf' 'etc/pulse/default.pa')<br />
<br />
== Types Explained ==<br />
<br />
The different types of *.pac* files.<br />
<br />
===.pacnew===<br />
<br />
For each {{ic|backup}} file in a package being upgraded, pacman cross-compares three [http://en.wikipedia.org/wiki/Md5sum md5sums] generated from the file's contents: one sum for the version originally installed by the package, one for the version currently in the filesystem, and one for the version in the new package. If the version of the file currently in the filesystem has been modified from the version originally installed by the package, pacman cannot know how to merge those changes with the new version of the file. Therefore, instead of overwriting the modified file when upgrading, pacman saves the new version with a {{ic|.pacnew}} extension and leaves the modified version untouched.<br />
<br />
Going into further detail, the 3-way MD5 sum comparison results in one of the following outcomes:<br />
<br />
; original = ''X'', current = ''X'', new = ''X'' : All three versions of the file have identical contents, so overwriting is not a problem. Overwrite the current version with the new version and do not notify the user. (Although the file contents are the same, this overwrite will update the filesystem's information regarding the file's installed, modified, and accessed times, as well as ensure that any file permission changes are applied.)<br />
<br />
; original = ''X'', current = ''X'', new = ''Y'' : The current version's contents are identical to the original's, but the new version is different. Since the user has not modified the current version and the new version may contain improvements or bugfixes, overwrite the current version with the new version and do not notify the user. This is the only auto-merging of new changes that pacman is capable of performing.<br />
<br />
; original = ''X'', current = ''Y'', new = ''X'' : The original package and the new package both contain exactly the same version of the file, but the version currently in the filesystem has been modified. Leave the current version in place and discard the new version without notifying the user.<br />
<br />
; original = ''X'', current = ''Y'', new = ''Y'' : The new version is identical to the current version. Overwrite the current version with the new version and do not notify the user. (Although the file contents are the same, this overwrite will update the filesystem's information regarding the file's installed, modified, and accessed times, as well as ensure that any file permission changes are applied.)<br />
<br />
; original = ''X'', current = ''Y'', new = ''Z'' : All three versions are different, so leave the current version in place, install the new version with a {{ic|.pacnew}} extension and warn the user about the new version. The user will be expected to manually merge any changes necessary from the new version into the current version.<br />
<br />
===.pacsave===<br />
<br />
If the user has modified one of the files specified in {{ic|backup}} then that file will be renamed with a {{ic|.pacsave}} extension and will remain in the filesystem after the rest of the package is removed.<br />
<br />
{{Box Note | Use of the {{ic|-n}} option with {{ic|pacman -R}} will result in complete removal of ''all'' files in the specified package, therefore no {{ic|.pacsave}} files will be created.}}<br />
<br />
===.pacorig===<br />
<br />
When a file (usually a configuration found in {{ic|/etc}}) is encountered during package installation or upgrade that does not belong to any installed package but is listed in {{ic|backup}} for the package in the current operation, it will be saved with a {{ic|'''.pacorig'''}} extension and replaced with the version of the file from the package. Usually this happens when a configuration file has been moved from one package to another. If such a file were not listed in {{ic|backup}}, pacman would abort with a file conflict error.<br />
<br />
{{Box Note | Because {{ic|.pacorig}} files tend to be created for special circumstances, there is no universal method for handling them. It may be helpful to consult the [http://www.archlinux.org/news/ Arch News] for handling instructions if it is a known case.}}<br />
<br />
== Locating .pac* Files==<br />
<br />
Arch Linux does not provide official utilities for {{ic|.pacnew}} files. You'll need to maintain these yourself; a few tools are presented in the next section. To do this manually, first you will need to locate them. When upgrading or removing a large number of packages, updated *.pac* files may be missed. To discover whether any {{ic|*.pac*}} files have been installed:<br />
<br />
To just search where most global configurations are stored:<br />
<br />
$ find /etc -name "*.pac*"<br />
<br />
or the entire disk:<br />
<br />
$ find / -name "*.pac*"<br />
<br />
Or use [[locate]] if you have installed it. First re-index the database:<br />
<br />
# updatedb<br />
<br />
Then:<br />
<br />
$ locate -e --regex "\.pac(new|orig|save)$"<br />
<br />
Or use pacman's log to find them:<br />
<br />
$ egrep "pac(new|orig|save)" /var/log/pacman.log<br />
<br />
Note that the log does not keep track of which files are currently in the filesystem nor of which files have already been removed.<br />
<br />
== Managing .pacnew Files==<br />
<br />
Once all existing {{ic|.pacnew}} files have been located, the user may handle them manually using common merge tools such as [[Vim#Merging_Files_.28Vimdiff.29|vimdiff]], ediff (part of [[Emacs|emacs]]), {{Pkg|meld}} (a Gnome GUI tool), sdiff (part of {{Pkg|diffutils}}, or {{Pkg|Kompare}} (a KDE GUI tool), then deleting the {{ic|.pacnew}} files afterwards.<br />
<br />
A few third-party utilities providing various levels of automation for these tasks are available from the [[AUR_User_Guidelines#.5Bcommunity.5D|community repository]] and the [[Arch User Repository|AUR]].<br />
<br />
*{{AUR|pacmerge-git}} - CLI interactive merge program<br />
*[[Dotpac]] - Basic interactive script with ncurses-based text interface and helpful walkthrough. No merging or auto-merging features.<br />
*pacdiff - Very minimal and undocumented CLI script. Part of the {{Pkg|pacman-contrib}} package in the {{ic|community}} repo.<br />
*pacdiffviewer - Full-featured interactive CLI script with auto-merging capability. Part of the {{AUR|yaourt}} package.<br />
*{{AUR|diffpac}} - Standalone pacdiffviewer replacement<br />
*[[Yaourt]] - A package manager that supports the AUR repository. Use {{ic|yaourt -C}} to compare, replace and merge configuration files..<br />
*{{AUR|etc-update}} - Arch port of [http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=3&chap=4#doc_chap2 Gentoo's etc-update] utility, providing a simple CLI to view changes, interactively edit and merge changes, and automatically merge trivial changes (e.g. comments.) Unlike some others above, this uses your preferred text editor rather than forcing you to learn a new one.<br />
*{{AUR|pacnews-git}} is a simple script aimed at finding all {{ic|.pacnew}} files, then editing with {{ic|vimdiff}}. It differs from the below script using {{ic|meld}}.<br />
<br />
<br />
=== A quick roundup of vimdiff ===<br />
{{Merge|Vim|There is no need to duplicate Vim command information here.}}<br />
[[Vim#Merging_Files_.28Vimdiff.29|vimdiff]] is part of the [[vim|vim]] package. The command will open colored windows each showing the content of the file with colored highlights of differences, line by line.<br />
# vimdiff file file.pacnew<br />
You are left with two modes: the insert one, which let you edit the file, and the screen mode, which let you move around windows and lines.<br />
*press '''i''' to enter insert mode. {{ic|--INSERT--}} will then appear on the bottom line.<br />
*press '''Esc''' to leave the insert mode.<br />
*press '''Ctrl+ww''' to move from one window to another one<br />
*press '''yy''' to copy a line<br />
*press '''p''' to paste a line<br />
*press ''']c''' to jump to the next change<br />
*press '''[c''' to jump to the previous change<br />
*press '''do''' when cursor is on a highlighted difference and changes from other window will move into the current one.<br />
*press '''dp''' is same as '''do''' but will put the changes from current windows into the other one. <br />
*press ''':wq''' to exit and save current window<br />
*press ''':wa''' to exit and save both windows<br />
*press ''':q!''' to exit without saving<br />
<br />
<br />
Once your file has been correctly edited taking account changes in file.pacnew<br />
# mv file file.bck<br />
# mv file.pacnew file<br />
Check if your new file is correct, then remove your backup<br />
# rm file.bck<br />
<br />
=== Using Meld to Update Differences ===<br />
<br />
Using meld in a loop can be used to update configuration files. This script will loop through the files one by one then prompt to delete the {{Ic|.pacnew}} file. <br />
<br />
{{hc|pacnew|<pre>#!/bin/bash<br />
# Merge new *.pacnew configuration files with their originals<br />
<br />
pacnew=$(find /etc -type f -name "*.pacnew")<br />
<br />
# Check if any .pacnew configurations are found<br />
if [[ -z "$pacnew" ]]; then<br />
echo " No configurations to update"<br />
fi<br />
<br />
for config in $pacnew; do<br />
# Diff original and new configuration to merge<br />
gksudo meld ${config%\.*} $config &<br />
wait<br />
# Remove .pacnew file?<br />
while true; do<br />
read -p " Delete \""$config"\"? (Y/n): " Yn<br />
case $Yn in<br />
[Yy]* ) sudo rm "$config" && \<br />
echo " Deleted \""$config"\"."<br />
break ;;<br />
[Nn]* ) break ;;<br />
* ) echo " Answer (Y)es or (n)o." ;;<br />
esac<br />
done<br />
done</pre>}}<br />
<br />
The above script uses GNOME's {{Ic|gksudo}} for graphical sudo permissions. Use {{Ic|kdesu}} for KDE.<br />
<br />
== Resources ==<br />
<br />
*Arch Linux Forums: [http://bbs.archlinux.org/viewtopic.php?id=53532 Dealing With .pacnew Files]</div>Xrchzhttps://wiki.archlinux.org/index.php?title=Talk:PKGBUILD&diff=210303Talk:PKGBUILD2012-06-19T08:00:00Z<p>Xrchz: /* makedepends should not include base? */ new section</p>
<hr />
<div>This needs to be updated for split packages. [[User:Daenyth|Daenyth]] 22:55, 4 December 2009 (EST)<br />
<br />
== Variables/noextract about zip? ==<br />
<br />
Isn't this information outdated? It seems bsdtar can now perfectly handle zip-files.<br />
<br />
--[[User:Paolo|Paolo]] 11:03, 8 September 2010 (EDT)<br />
<br />
== Installing the package ==<br />
<br />
It might be helpful for beginners to know how to install the package after building it. <br />
Maybe it should be explicity mentioned that one can install it with '''sudo pacman -U yourpackage.pkg.tar.??'''<br />
<br />
where ?? can be xz, gz or something else.<br />
<br />
[[User:Slopjong|Slopjong]] 12:00, June 9th 2010 (CET)<br />
::1. It's a package - you install it as any other package. The introduction clearly states that ''The resulting package contains binary files and installation instructions; readily installed with pacman.'' and a link to the pacman article.<br />
::2. pacman can install uncompressed <tt>.pkg.tar</tt> archives too.<br />
::3. 'makepkg -i' will install the compiled package.<br />
::-- [[User:Karol|Karol]] 06:52, 9 June 2011 (EDT)<br />
<br />
== External links ==<br />
<br />
One of the two links is redundant, is the same mentioned here<br />
Tip: A prototype .install is provided at /usr/share/pacman/proto.install.<br />
the second one should be added to proto installed by pacman package.<br />
<br />
== check / checkdepends ==<br />
<br />
the default ''PKGBUILD'' in ''/usr/share/pacman'' now contains a ''check'' function and a ''checkdepends'' array. Some explanation would be nice.<br />
--[[User:Oal|Oal]] 15:41, 26 July 2011 (EDT)<br />
:Some quick references: [https://bugs.archlinux.org/task/15145], [http://mailman.archlinux.org/pipermail/pacman-dev/2010-December/012131.html]. -- [[User:Kynikos|Kynikos]] 04:23, 27 July 2011 (EDT)<br />
<br />
:: Have you seen [https://www.archlinux.org/pacman/PKGBUILD.5.html man PKGBUILD]?. [[User:Vadmium|Vadmium]] 04:54, 27 July 2011 (EDT).<br />
<br />
== epoch ==<br />
<br />
There is an epoch variable in the PKGBUILD.proto and an explanation here in the wiki, but for me at least the explanation doesn't cut it, I'd have no idea how to use it. I'm not sure that something that seems to be only meant for very special cases should be in the proto (which is meant for new packages, as I see it).<br />
[[User:Hollunder|hollunder]] 12:20, 11 September 2011 (EDT)<br />
<br />
== package compression ==<br />
Please add some info about PKGEXT variable, eg. for disable compression<br />
<pre><br />
PKGEXT='.pkg.tar'<br />
</pre><br />
Compression is IMO useless for game's package and almost nobody from aur is using this variable... And they are looking usually for info in archwiki ;)<br />
:See [https://bbs.archlinux.org/viewtopic.php?id=127894] for a couple ways to skin this cat. -- [[User:Karol|Karol]] 05:55, 12 December 2011 (EST)<br />
<br />
== makedepends should not include base? ==<br />
<br />
There is a warning not to include base-devel packages in makedepends, but should it also be said not to include base pacakges in makedepends (or even in depends)?</div>Xrchzhttps://wiki.archlinux.org/index.php?title=OpenSSH&diff=119226OpenSSH2010-10-14T19:21:36Z<p>Xrchz: /* Tips and Tricks */</p>
<hr />
<div>[[Category:Daemons and system services (English)]]<br />
{{i18n|SSH}}<br />
<br />
Secure Shell or SSH is a network protocol that allows data to be exchanged over a secure channel between two computers. Encryption provides confidentiality and integrity of data. SSH uses public-key cryptography to authenticate the remote computer and allow the remote computer to authenticate the user, if necessary.<br />
<br />
SSH is typically used to log into a remote machine and execute commands, but it also supports tunneling, forwarding arbitrary TCP ports and X11 connections; file transfer can be accomplished using the associated SFTP or SCP protocols.<br />
<br />
An SSH server, by default, listens on the standard TCP port 22. An SSH client program is typically used for establishing connections to an ''sshd'' daemon accepting remote connections. Both are commonly present on most modern operating systems, including Mac OS X, GNU/Linux, Solaris and OpenVMS. Proprietary, freeware and open source versions of various levels of complexity and completeness exist.<br />
<br />
(Source: [[Wikipedia:Secure Shell]])<br />
<br />
= OpenSSH =<br />
<br />
OpenSSH (OpenBSD Secure Shell) is a set of computer programs providing encrypted communication sessions over a computer network using the ssh protocol. It was created as an open source alternative to the proprietary Secure Shell software suite offered by SSH Communications Security. OpenSSH is developed as part of the OpenBSD project, which is led by Theo de Raadt.<br />
<br />
OpenSSH is occasionally confused with the similarly-named OpenSSL; however, the projects have different purposes and are developed by different teams, the similar name is drawn only from similar goals.<br />
<br />
== Installing OpenSSH ==<br />
# pacman -S openssh<br />
<br />
== Configuring SSH ==<br />
===Client===<br />
The SSH client configuration file can be found and edited in {{Filename|/etc/ssh/ssh_config}}.<br />
<br />
An example configuration: <br />
<br />
{{File|name=/etc/ssh/ssh_config|content=<br />
<br />
# $OpenBSD: ssh_config,v 1.25 2009/02/17 01:28:32 djm Exp $<br />
<br />
# This is the ssh client system-wide configuration file. See<br />
# ssh_config(5) for more information. This file provides defaults for<br />
# users, and the values can be changed in per-user configuration files<br />
# or on the command line.<br />
<br />
# Configuration data is parsed as follows:<br />
# 1. command line options<br />
# 2. user-specific file<br />
# 3. system-wide file<br />
# Any configuration value is only changed the first time it is set.<br />
# Thus, host-specific definitions should be at the beginning of the<br />
# configuration file, and defaults at the end.<br />
<br />
# Site-wide defaults for some commonly used options. For a comprehensive<br />
# list of available options, their meanings and defaults, please see the<br />
# ssh_config(5) man page.<br />
<br />
Host *<br />
# ForwardAgent no<br />
# ForwardX11 no<br />
# RhostsRSAAuthentication no<br />
# RSAAuthentication yes<br />
# PasswordAuthentication yes<br />
# HostbasedAuthentication no<br />
# GSSAPIAuthentication no<br />
# GSSAPIDelegateCredentials no<br />
# BatchMode no<br />
# CheckHostIP yes<br />
# AddressFamily any<br />
# ConnectTimeout 0<br />
# StrictHostKeyChecking ask<br />
# IdentityFile ~/.ssh/identity<br />
# IdentityFile ~/.ssh/id_rsa<br />
# IdentityFile ~/.ssh/id_dsa<br />
# Port 22<br />
# Protocol 2,1<br />
# Cipher 3des<br />
# Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc<br />
# MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160<br />
# EscapeChar ~<br />
# Tunnel no<br />
# TunnelDevice any:any<br />
# PermitLocalCommand no<br />
# VisualHostKey no<br />
HashKnownHosts yes<br />
StrictHostKeyChecking ask}}<br />
<br />
It is recommended to change the Protocol line into this:<br />
Protocol 2<br />
<br />
That means that only Protocol 2 will be used, since Protocol 1 is considered somewhat insecure.<br />
<br />
===Daemon===<br />
The SSH daemon configuration file can be found and edited in {{Filename|/etc/ssh/ssh'''d'''_config}}.<br />
<br />
An example configuration: <br />
<br />
{{File|name=/etc/ssh/sshd_config|content=<br />
<br />
# $OpenBSD: sshd_config,v 1.75 2007/03/19 01:01:29 djm Exp $<br />
<br />
# This is the sshd server system-wide configuration file. See<br />
# sshd_config(5) for more information.<br />
<br />
# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin<br />
<br />
# The strategy used for options in the default sshd_config shipped with<br />
# OpenSSH is to specify options with their default value where<br />
# possible, but leave them commented. Uncommented options change a<br />
# default value.<br />
<br />
#Port 22<br />
#Protocol 2,1<br />
ListenAddress 0.0.0.0<br />
#ListenAddress ::<br />
<br />
# HostKey for protocol version 1<br />
#HostKey /etc/ssh/ssh''host''key<br />
# HostKeys for protocol version 2<br />
#HostKey /etc/ssh/ssh''host''rsa_key<br />
#HostKey /etc/ssh/ssh''host''dsa_key<br />
<br />
# Lifetime and size of ephemeral version 1 server key<br />
#KeyRegenerationInterval 1h<br />
#ServerKeyBits 768<br />
<br />
# Logging<br />
#obsoletes ~QuietMode and ~FascistLogging<br />
#SyslogFacility AUTH<br />
#LogLevel INFO<br />
<br />
# Authentication:<br />
<br />
#LoginGraceTime 2m<br />
#PermitRootLogin yes<br />
#StrictModes yes<br />
#MaxAuthTries 6<br />
<br />
#RSAAuthentication yes<br />
#PubkeyAuthentication yes<br />
#AuthorizedKeysFile .ssh/authorized_keys<br />
<br />
# For this to work you will also need host keys in /etc/ssh/ssh''known''hosts<br />
#RhostsRSAAuthentication no<br />
# similar for protocol version 2<br />
#HostbasedAuthentication no<br />
# Change to yes if you don't trust ~/.ssh/known_hosts for<br />
# RhostsRSAAuthentication and HostbasedAuthentication<br />
#IgnoreUserKnownHosts no<br />
# Don't read the user's ~/.rhosts and ~/.shosts files<br />
#IgnoreRhosts yes<br />
<br />
# To disable tunneled clear text passwords, change to no here!<br />
#PasswordAuthentication yes<br />
#PermitEmptyPasswords no<br />
<br />
# Change to no to disable s/key passwords<br />
#ChallengeResponseAuthentication yes<br />
<br />
# Kerberos options<br />
#KerberosAuthentication no<br />
#KerberosOrLocalPasswd yes<br />
#KerberosTicketCleanup yes<br />
#KerberosGetAFSToken no<br />
<br />
# GSSAPI options<br />
#GSSAPIAuthentication no<br />
#GSSAPICleanupCredentials yes<br />
<br />
# Set this to 'yes' to enable PAM authentication, account processing,<br />
# and session processing. If this is enabled, PAM authentication will<br />
# be allowed through the ~ChallengeResponseAuthentication mechanism.<br />
# Depending on your PAM configuration, this may bypass the setting of<br />
# PasswordAuthentication, ~PermitEmptyPasswords, and<br />
# "PermitRootLogin without-password". If you just want the PAM account and<br />
# session checks to run without PAM authentication, then enable this but set<br />
# ChallengeResponseAuthentication=no<br />
#UsePAM no<br />
<br />
#AllowTcpForwarding yes<br />
#GatewayPorts no<br />
#X11Forwarding no<br />
#X11DisplayOffset 10<br />
#X11UseLocalhost yes<br />
#PrintMotd yes<br />
#PrintLastLog yes<br />
#TCPKeepAlive yes<br />
#UseLogin no<br />
#UsePrivilegeSeparation yes<br />
#PermitUserEnvironment no<br />
#Compression yes<br />
#ClientAliveInterval 0<br />
#ClientAliveCountMax 3<br />
#UseDNS yes<br />
#PidFile /var/run/sshd.pid<br />
#MaxStartups 10<br />
<br />
# no default banner path<br />
#Banner /some/path<br />
<br />
# override default of no subsystems<br />
Subsystem sftp /usr/lib/ssh/sftp-server}}<br />
<br />
<br />
To allow access only for some users add this line:<br />
AllowUsers user1 user2<br />
<br />
You might want to change some lines so that they look as following:<br />
<pre><br />
Protocol 2<br />
.<br />
.<br />
.<br />
LoginGraceTime 120<br />
.<br />
.<br />
.<br />
PermitRootLogin no # (put yes here if you want root login)<br />
</pre><br />
<br />
You could also uncomment the BANNER option and edit {{Filename|/etc/issue}} for a nice welcome message.<br />
<br />
{{Tip| You may want to change the default port from 22 to any higher port (see [http://en.wikipedia.org/wiki/Security_through_obscurity security through obscurity]).}} <br />
<br />
Even though the port ssh is running on could be detected by using a port-scanner like nmap, changing it will reduce the number of log entries caused by automated authentication attempts.<br />
<br />
{{Tip| Disabling password logins entirely may also increase security, since each user with access to the server will need to create ssh keys. (see [http://wiki.archlinux.org/index.php/Using_SSH_Keys Using SSH Keys]).}}<br />
<br />
{{File|name=/etc/ssh/sshd_config|content=<br />
PasswordAuthentication no<br />
ChallengeResponseAuthentication no}}<br />
<br />
===Allowing others in===<br />
{{Box Note | You have to adjust this file to remotely connect to your machine since the file is empty by default}}<br />
<br />
To let other people ssh to your machine you need to adjust {{Filename|/etc/hosts.allow}}, add the following:<br />
<br />
<pre><br />
# let everyone connect to you<br />
sshd: ALL<br />
<br />
# OR you can restrict it to a certain ip<br />
sshd: 192.168.0.1<br />
<br />
# OR restrict for an IP range<br />
sshd: 10.0.0.0/255.255.255.0<br />
<br />
# OR restrict for an IP match<br />
sshd: 192.168.1.<br />
</pre><br />
<br />
Now you should check your {{Filename|/etc/hosts.deny}} for the following line and make sure it looks like this:<br />
ALL: ALL: DENY<br />
<br />
That's it. You can SSH out and others should be able to SSH in :).<br />
<br />
To start using the new configuration, restart the daemon (as root):<br />
# /etc/rc.d/sshd restart<br />
<br />
== Managing SSHD Daemon ==<br />
Just add sshd to the "DAEMONS" section of your {{Filename|/etc/[[rc.conf]]}}:<br />
DAEMONS=(... ... '''sshd''' ... ...)<br />
<br />
To start/restart/stop the daemon, use the following:<br />
# /etc/rc.d/sshd {start|stop|restart}<br />
<br />
==Connecting to the server==<br />
To connect to a server, run:<br />
$ ssh -p port user@server-address<br />
<br />
= Tips and Tricks =<br />
<br />
== Encrypted Socks Tunnel ==<br />
This is highly useful for laptop users connected to various unsafe wireless connections. The only thing you need is an SSH server running at a somewhat secure location, like your home or at work. It might be useful to use a dynamic DNS service like [http://www.dyndns.org/ DynDNS] so you don't have to remember your IP-address.<br />
<br />
=== Step 1: Start the Connection ===<br />
You only have to execute this single command in your favorite terminal to start the connection:<br />
$ ssh -ND 4711 user@host<br />
where {{Codeline|"user"}} is your username at the SSH server running at the {{Codeline|"host"}}. It will ask for your password, and then you're connected! The {{Codeline|"N"}} flag disables the interactive prompt, and the {{Codeline|"D"}} flag specifies the local port on which to listen on (you can choose any port number if you want).<br />
<br />
One way to make this easier is to put an alias line in your {{Filename|~/.bashrc}} file as following:<br />
alias sshtunnel="ssh -ND 4711 -v user@host"<br />
It's nice to add the verbose {{Codeline|"-v"}} flag, because then you can verify that it's actually connected from that output. Now you just have to execute the {{Codeline|"sshtunnel"}} command :)<br />
<br />
=== Step 2: Configure your Browser (or other programs) ===<br />
<br />
The above step is completely useless if you don't configure your web browser (or other programs) to use this newly created socks tunnel. <br />
<br />
* For Firefox: ''Edit &rarr; Preferences &rarr; Advanced &rarr; Network &rarr; Connection &rarr; Setting'':<br />
: Check the ''"Manual proxy configuration"'' radio button, and enter "localhost" in the ''"SOCKS host"'' text field, and then enter your port number in the next text field (I used 4711 above).<br />
<br />
: Make sure you select SOCKS4 as the protocol to use. This procedure will not work for SOCKS5.<br />
<br />
Enjoy your secure tunnel!<br />
<br />
== X11 Forwarding ==<br />
<br />
To run graphical programs through a SSH connection you can enable X11 forwarding. An option needs to be set in the configuration files on the server and client (here "client" means your (desktop) machine your X11 Server runs on, and you will run X applications on the "server").<br />
<br />
Install xorg-xauth on the server:<br />
# pacman -S xorg-xauth<br />
<br />
* Enable the '''AllowTcpForwarding''' option in {{Filename|sshd_config}} on the '''server'''.<br />
* Enable the '''X11Forwarding''' option in {{Filename|sshd_config}} on the '''server'''.<br />
* Set the '''X11DisplayOffset''' option in {{Filename|sshd_config}} on the '''server''' to 10.<br />
* Enable the '''X11UseLocalhost''' option in {{Filename|sshd_config}} on the '''server'''.<br />
<br />
<br />
* Enable the '''ForwardX11''' option in {{Filename|ssh_config}} on the '''client'''.<br />
<br />
To use the forwarding, log on to your server through ssh:<br />
# ssh -X -p port user@server-address<br />
If you receive errors trying to run graphical applications try trusted forwarding instead:<br />
# ssh -Y -p port user@server-address<br />
You can now start any X program on the remote server, the output will be forwarded to your local session:<br />
# xclock<br />
<br />
== Speed up SSH ==<br />
Changing the ciphers used by SSH to less cpu-demanding ones can improve speed. In this aspect, the best choices are arcfour and blowfish-cbc. To use them, run SSH with the {{Codeline|"c"}} flag, like this:<br />
# ssh -c arcfour,blowfish-cbc user@server-address<br />
To use them permanently, add this line under the proper host in {{Filename|/etc/ssh/ssh_config}}:<br />
Ciphers arcfour,blowfish-cbc<br />
Another option to improve speed is to enable compression with the {{Codeline|"C"}} flag. A permanent solution is to add this line under the proper host in {{Filename|/etc/ssh/ssh_config}}:<br />
Compression yes<br />
Login time can be shorten by using the {{Codeline|"4"}} flag, which bypasses IPv6 lookup. This can be made permanent by adding this line under the proper host in {{Filename|/etc/ssh/ssh_config}}:<br />
AddressFamily inet<br />
Another way of making these changes permanent is to create an alias in {{Filename|~/.bashrc}}:<br />
alias ssh='ssh -C4c arcfour,blowfish-cbc'<br />
Finally, you can make all sessions to the same host use a single connection, which will greatly speed up subsequent logins, by adding those line under the proper host in {{Filename|/etc/ssh/ssh_config}}:<br />
ControlMaster auto<br />
ControlPath ~/.ssh/socket-%r@%h:%p<br />
<br />
=== Trouble Shooting ===<br />
<br />
make sure your DISPLAY string is resolveable on the remote end:<br />
<br />
ssh -X user@server-address<br />
server$ echo $DISPLAY<br />
localhost:10.0<br />
server$ telnet localhost 6010<br />
localhost/6010: lookup failure: Temporary failure in name resolution <br />
<br />
can be fixed by adding localhost to {{Filename|/etc/hosts}}.<br />
<br />
== Mounting a Remote Filesystem with SSHFS ==<br />
<br />
Install sshfs<br />
# pacman -S sshfs<br />
<br />
Load the Fuse module<br />
# modprobe fuse<br />
Add fuse to the ''modules'' array in {{Filename|/etc/rc.conf}} to load it on each system boot.<br />
<br />
Mount the remote folder using sshfs<br />
# mkdir ~/remote_folder<br />
# sshfs USER@remote_server:/tmp ~/remote_folder<br />
<br />
The command above will cause the folder /tmp on the remote server to be mounted as ~/remote_folder on the local machine. Copying any file to this folder will result in transparent copying over the network using SFTP. Same concerns direct file editing, creating or removing.<br />
<br />
When we’re done working with the remote filesystem, we can unmount the remote folder by issuing:<br />
# fusermount -u ~/remote_folder<br />
<br />
If we work on this folder on a daily basis, it is wise to add it to the {{Filename|/etc/fstab}} table. This way is can be automatically mounted upon system boot or mounted manually (if {{Codeline|noauto}} option is chosen) without the need to specify the remote location each time. Here is a sample entry in the table:<br />
sshfs#USER@remote_server:/tmp /full/path/to/directory fuse defaults,auto,allow_other 0 0<br />
<br />
== Keep Alive ==<br />
<br />
Your ssh session will automatically log out if it is idle. To keep the connection active (alive) add this to {{Filename|~/.ssh/config}} or to {{Filename|/etc/ssh/ssh_config}} on the client.<br />
<br />
ServerAliveInterval 120<br />
<br />
This will send a "keep alive" signal to the server every 120 seconds.<br />
<br />
Conversely, to keep incoming connections alive, you can set<br />
<br />
ClientAliveInterval 120<br />
<br />
(or some other number greater than 0) in {{Filename|/etc/ssh/sshd_config}} on the server.<br />
<br />
== Save connection data in .ssh/config ==<br />
<br />
Whenever you want to connect to a server, you usually have to type at least its address and your username. To save that typing work for servers you regularly connect to, you can use the {{Filename|$HOME/.ssh/config}} file as shown in the following example:<br />
<br />
{{File|name=$HOME/.ssh/config|content=<br />
<br />
Host myserver<br />
HostName 123.123.123.123<br />
Port 12345<br />
User bob<br />
Host other_server<br />
HostName test.something.org<br />
User alice<br />
CheckHostIP no<br />
Cipher blowfish<br />
}}<br />
<br />
Now you can simply connect to the server by using the name you specified:<br />
<br />
$ ssh myserver<br />
<br />
To see a complete list of the possible options, check out ssh_config's manpage on your system or the [http://www.openbsd.org/cgi-bin/man.cgi?query=ssh_config ssh_config documentation] on the official website.<br />
<br />
= See Also =<br />
*[[Using SSH Keys]]<br />
<br />
= Links & References =<br />
*[http://www.soloport.com/iptables.html A Cure for the Common SSH Login Attack]<br />
*[http://webssh.cz.cc Using your browser as SSH client]<br />
*[http://www.la-samhna.de/library/brutessh.html Defending against brute force ssh attacks]</div>Xrchzhttps://wiki.archlinux.org/index.php?title=Advanced_Linux_Sound_Architecture&diff=118924Advanced Linux Sound Architecture2010-10-09T15:22:01Z<p>Xrchz: /* No Headphone Sound with Onboard Intel Sound Card */</p>
<hr />
<div>[[Category:Audio/Video (English)]]<br />
[[Category:HOWTOs (English)]]<br />
{{i18n|ALSA|Advanced Linux Sound Architecture}}<br />
<br />
The Advanced Linux Sound Architecture (ALSA) is a Linux kernel component intended to provide device drivers for sound cards. <br />
<br />
Also see how to [[Allow_multiple_programs_to_play_sound_at_once|allow multiple programs to play sound at once]]<br />
<br />
{{Note|For an alternative sound environment, see the [[Open Sound System]] page.}}<br />
<br />
==Installation==<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 is required unless an ISA card is being used. '''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 -S 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, pacman will handle this automatically.<br />
<br />
==Configuration==<br />
===Set the default sound card===<br />
<br />
====In Kernel Space====<br />
<br />
''Note: snd-pcsp is no longer in the kernel from at least 2.6.35; the only related module is then pcspkr.''<br />
<br />
Telephony-capable modems and snd-pcsp (the internal PC speaker ALSA module) can conflict with the sound card for the default sound card slot. (pcspkr is another, non-ALSA PC speaker module. It will not conflict with ALSA sound cards.) To prevent this, discover your sound card model name with [http://linux.die.net/man/8/lspci lspci(8)] and your ALSA driver module names with ls(1):<br />
<br />
$ ls -l /sys/module/snd/holders<br />
total 0<br />
lrwxrwxrwx 1 root root 0 2009-06-02 23:49 snd_ac97_codec -> ../../snd_ac97_codec<br />
lrwxrwxrwx 1 root root 0 2009-06-02 23:49 snd_intel8x0 -> ../../snd_intel8x0<br />
lrwxrwxrwx 1 root root 0 2009-06-02 23:49 snd_intel8x0m -> ../../snd_intel8x0m<br />
lrwxrwxrwx 1 root root 0 2009-06-02 23:49 snd_pcm -> ../../snd_pcm<br />
lrwxrwxrwx 1 root root 0 2009-06-02 23:53 snd_pcsp -> ../../snd_pcsp<br />
lrwxrwxrwx 1 root root 0 2009-06-02 23:49 snd_timer -> ../../snd_timer<br />
<br />
Then add the names of your sound card modules to:<br />
<br />
{{file |name=/etc/modprobe.d/modprobe.conf (prior to module-init-tools 3.8, use /etc/modprobe.conf) |content=<br />
options snd-intel8x0 index=0<br />
options snd-pcsp index=1<br />
}}<br />
<br />
These entries ensure that the Intel 82801DB-ICH4 sound card will become card 0 and the PC speaker will become card 1.<br />
NB: Some modules do not support indexing options eg. snd-hda-intel. If you experience problems on reboot edit /etc/modprobe.d/modprobe.conf to just have the modules.<br />
<br />
If you do not want snd-pcsp to load at all you can add the following to:<br />
<br />
{{file |name=/etc/rc.conf |content=MODULES=(... !snd-pcsp)<br />
}}<br />
<br />
If you want the PC speaker completely disabled, you can additionally add the following to:<br />
<br />
{{file |name=/etc/rc.conf |content=MODULES=(... !pcspkr)<br />
}}<br />
<br />
<br />
{{Note| You will need to unload all your sound modules and reload them for the changes to take effect. It might be easier to reboot. Your choice. }}<br />
<br />
====In User Space====pcsp<br />
<br />
This method does not require root permissions, is on a per-user basis, and takes effect as soon as any software has been restarted (like your media player, for example).<br />
<br />
Located in {{Filename|/usr/share/alsa/alsa.conf}} is a list of defaults that alsa uses out of the box. These can be overridden in a {{Filename|~/.asoundrc}} file.<br />
{{File|name=~/.asoundrc|content=<br />
defaults.ctl.card 1<br />
defaults.pcm.card 1<br />
defaults.pcm.device 1}}<br />
The 'pcm' options affect which card and device will be used for audio playback. However it is the 'ctl' option affects which card is used by control utilities like alsamixer, amixer, and the like.<br />
<br />
To find out which numbers correspond to what audio device, use {{Codeline|aplay -l}}.<br />
$ aplay -l<br />
**** List of PLAYBACK Hardware Devices ****<br />
card 0: Intel [HDA Intel], device 0: CONEXANT Analog [CONEXANT Analog]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 0: Intel [HDA Intel], device 1: Conexant Digital [Conexant Digital]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 1: JamLab [JamLab], device 0: USB Audio [USB Audio]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 2: Audio [Altec Lansing XT1 - USB Audio], device 0: USB Audio [USB Audio]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<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' | column -t<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,<br />
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 />
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/main/index.php/Matrix:Main ALSA Soundcard Matrix] 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 {{Filename|/etc/rc.conf}} to ensure they are loaded next time (make sure '''snd-NAME-OF-MODULE''' is before '''snd-pcm-oss''').<br />
<br />
===Unmute the channels and test===<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 />
The current version of ALSA installs with all channels '''muted by default''', so even if installation completes successfully and all devices are working properly you will hear no sound. You will need to unmute the channels manually. It is recommended to use {{Codeline|alsamixer}} to accomplish this. From the alsamixer text ui, the label "MM" below a channel indicates that the channel is muted, and "00" indicates that it is open. Press the 'm' key to toggle MM/00. Use arrow-keys left and right to navigate through the channels and the arrow-keys up and down to adjust the volume. Such things as Master and PCM and possibly Speaker will need to unmuted for your sound to work.<br />
<br />
{{Note | When using '''{{Codeline|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. '''{{Codeline|amixer}}''' understands the percent sign (%), not numbers. If you use a number (say, 90) then '''{{Codeline|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 />
* Now run a test<br />
<br />
# speaker-test -c 2<br />
<br />
{{Note | Some cards need to have digital output muted/turned off in order to hear analog sound. For the Soundblaster Audigy LS mute the IEC958 channel.}}<br />
<br />
If you cannot hear anything, double check your mixer settings, being sure to unmute PCM, MASTER (and some machines such as the IBM Thinkpad have an additional 'SPEAKER' channel) and try the alsaconf utility as root:<br />
# alsaconf<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 if it is not already available:<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 {{Codeline|alsactl store}} once to create {{Filename|/etc/asound.state}}.<br />
<br />
# alsactl store<br />
<br />
* Edit {{Filename|/etc/[[rc.conf]]}} and add {{Codeline|"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 />
* If the mixer settings are not loaded on boot-up, add the following line to {{Filename|/etc/rc.local}}:<br />
<br />
# alsactl restore<br />
<br />
* These methods still may not work, or you may prefer to have audio settings for individual users. In this case, run {{Codeline|alsactl store -f ~/.asoundrc}} as a normal user. This will save and restore volume settings on a per user basis. To automate this process, add the respective commands to {{Filename|~/.bash_login}} and {{Filename|~/.bash_logout}}, or the correct locations for the shell of your choice.<br />
<br />
For zsh, use {{Filename|~/.zlogin}} and {{Filename|~/.zlogout}}.<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 />
<br />
* add following lines to {{Filename|/etc/rc.local}}:<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 />
$ amixer scontrols<br />
<br />
===System-Wide Equalizer===<br />
====Using AlsaEqual (provides UI)====<br />
<br />
Install [http://aur.archlinux.org/packages.php?ID=27066 alsaequal] from the [[AUR]].<br />
<br />
{{Note | If you have a x86_64-system and are using a 32bit-flashplugin the sound in flash will not work. Either you have to disable alsaequal or build alsaequal for 32bit.}}<br />
<br />
After installing package Insert the following into your ALSA configuration file ({{Filename|~/.asoundrc}} or {{Filename|/etc/asound.conf}}):<br />
<br />
ctl.equal {<br />
type equal;<br />
}<br />
<br />
pcm.plugequal {<br />
type equal;<br />
# Modify the line below if you don't<br />
# want to use sound card 0.<br />
#slave.pcm "plughw:0,0";<br />
#by default we want to play from more sources at time:<br />
slave.pcm "plug:dmix";<br />
}<br />
<br />
#pcm.equal {<br />
# Or if you want the equalizer to be your<br />
# default soundcard uncomment the following<br />
# line and comment the above line.<br />
pcm.!default {<br />
type plug;<br />
slave.pcm plugequal;<br />
}<br />
<br />
<br />
Then Reload your alsa settings (as root).<br />
# /etc/rc.d/alsa restart<br />
not sure if this is really needed - more important is to shut down all applications using ALSA...<br />
<br />
And you are ready to change your equalizer using command<br />
$ alsamixer -D equal<br />
<br />
Note that configuration file is different for each user (until not specified else) it's saved in '''$HOME/.alsaequal.bin'''.<br />
so if you want to use AlsaEqual with [[mpd]] or another software running under different user, you can configure it using<br />
# su mpd -c 'alsamixer -D equal'<br />
or eg. you can make symlink to your '''.alsaequal.bin''' in his home...<br />
<br />
====Using mbeq====<br />
{{Note | This method requires the use of a ladspa plugin which might use quite a bit of CPU when sound plays. In addition, this was made with stereophonic sound (e.g. headphones) in mind.}}<br />
<br />
* You will need, in addition to the aforementioned userspace utilities, alsa-plugins.<br />
# pacman -S alsa-plugins<br />
* Get the ladspa and swh-plugins packages too if you don't already have them.<br />
# pacman -S ladspa swh-plugins<br />
* If you haven't already created either an {{Filename|~/.asoundrc}} or a {{Filename|/etc/asound.conf}} file, then create either one<br />
$ vim ~/.asoundrc<br />
* Insert the following into your ALSA configuration file ({{Filename|~/.asoundrc}} or {{Filename|/etc/asound.conf}}):<br />
<br />
{{file |name=/etc/asound.conf |content=pcm.eq {<br />
type ladspa<br><br />
# The output from the EQ can either go direct to a hardware device<br />
# (if you have a hardware mixer, e.g. SBLive/Audigy) or it can go<br />
# to the software mixer shown here.<br />
#slave.pcm "plughw:0,0"<br />
slave.pcm "plug:dmix"<br><br />
# Sometimes you may need to specify the path to the plugins,<br />
# especially if you've just installed them. Once you've logged<br />
# out/restarted this shouldn't be necessary, but if you get errors<br />
# about being unable to find plugins, try uncommenting this.<br />
#path "/usr/lib/ladspa"<br><br />
plugins [<br />
{<br />
label mbeq<br />
id 1197<br />
input {<br />
#this setting is here by example, edit to your own taste<br />
#bands: 50hz, 100hz, 156hz, 220hz, 311hz, 440hz, 622hz, 880hz, 1250hz, 1750hz, 25000hz,<br />
#50000hz, 10000hz, 20000hz<br />
controls [ -5 -5 -5 -5 -5 -10 -20 -15 -10 -10 -10 -10 -10 -3 -2 ]<br />
}<br />
}<br />
]<br />
}<br><br />
# Redirect the default device to go via the EQ - you may want to do<br />
# this last, once you're sure everything is working. Otherwise all<br />
# your audio programs will break/crash if something has gone wrong.<br><br />
pcm.!default {<br />
type plug<br />
slave.pcm "eq"<br />
}<br><br />
# Redirect the OSS emulation through the EQ too (when programs are running through "aoss")<br><br />
pcm.dsp0 {<br />
type plug<br />
slave.pcm "eq"<br />
}<br />
}}<br />
<br />
*Reload your alsa settings (as root).<br />
# /etc/rc.d/alsa restart<br />
<br />
*You should be good to go (if not, ask in the forum).<br />
<br />
==Troubleshooting==<br />
===Model Settings===<br />
<br />
Although Alsa detects your soundcard through the BIOS at times Alsa may not be able to recognize your [http://www.kernel.org/doc/Documentation/sound/alsa/HD-Audio-Models.txt model type]. The soundcard chip can be found in <code>alsamixer</code> (e.g. ALC662) and the model can be set in {{Filename|/etc/modprobe.d/modprobe.conf}} or {{Filename|/etc/modprobe.d/sound.conf}}. For example:<br />
<br />
options snd-hda-intel model=MODEL<br />
<br />
There are other model settings too. For most cases Alsa defaults will do. If you want to look at more specific settings for your soundcard take a look at the [http://bugtrack.alsa-project.org/main/index.php/Matrix:Main Alsa Soundcard List] find your model, then Details, then look at the "Setting up modprobe..." section. Enter these values in {{Filename|/etc/modprobe.d/modprobe.conf}}. For example, for an Intel AC97 audio:<br />
<br />
<pre># ALSA portion<br />
alias char-major-116 snd<br />
alias snd-card-0 snd-intel8x0<br />
# module options should go here<br />
<br />
# OSS/Free portion<br />
alias char-major-14 soundcore<br />
alias sound-slot-0 snd-card-0<br />
<br />
# card #1<br />
alias sound-service-0-0 snd-mixer-oss<br />
alias sound-service-0-1 snd-seq-oss<br />
alias sound-service-0-3 snd-pcm-oss<br />
alias sound-service-0-8 snd-seq-oss<br />
alias sound-service-0-12 snd-pcm-oss</pre><br />
<br />
===Conflicting PC Speaker===<br />
<br />
Remember, ALSA installs with all channels '''muted by default''' (see previous section, [[Advanced Linux Sound Architecture#Unmute the channels and test|unmuting your soundcard]]).<br />
<br />
However, if you're sure nothing is muted, that your drivers are installed correctly, and that your volume is right, but you still do not hear anything, then try blacklisting snd-pcsp (kernels < 2.6.35) or pcspkr from your modules array in rc.conf:<br />
<br />
MODULES=(!snd-pcsp ... )<br />
<br />
Note that this will disable your PC's internal speaker.<br />
If that doesn't work, then try adding the following line to <code>/etc/modprobe.d/modprobe.conf</code>:<br />
<br />
options snd-NAME-OF-MODULE ac97_quirk=0<br />
<br />
The above fix has been observed to work with <code>via82xx</code><br />
options snd-NAME-OF-MODULE ac97_quirk=1<br />
The above fix has been reported to work with <code>snd_intel8x0</code><br />
<br />
===No Microphone Input===<br />
Make sure that all the volume levels are up under recording in alsamixer, and that CAPTURE is active on the microphone (in alsamixer, select it and press space). You may also need to enable and increase the volume of Line-in in the Playback section.<br />
<br />
To test the microphone, run these commands:<br />
arecord -d 5 test-mic.wav<br />
aplay test-mic.wav<br />
<br />
You may want to see arecord's man page to play with it a little bit. Anyway, if you are unable to hear anything, your microphone may be broken or in the wrong hole.<br />
<br />
Some programs use try to use OSS as the main input software. Add the following line to <code>/etc/rc.conf</code> to prevent OSS modules from being loaded:<br />
<br />
MODULES=(!snd_pcm_oss !snd_mixer_oss !snd_seq_oss ... )<br />
<br />
===Setting the default Microphone/Capture Device===<br />
Some applications (Pidgin, Adobe Flash) do not provide an option to change the capture device. It becomes an issue if your microphone is on a separate device (i.e. USB webcam or microphone) than your internal sound card. To change only the default capture device, leaving the default playback device as is, you can modify your ~/.asoundrc file to include the following:<br />
<br />
pcm.usb<br />
{<br />
type hw<br />
card U0x46d0x81d<br />
}<br />
<br />
pcm.!default<br />
{<br />
type asym<br />
playback.pcm<br />
{<br />
type plug<br />
slave.pcm "dmix"<br />
}<br />
capture.pcm <br />
{<br />
type plug<br />
slave.pcm "usb"<br />
}<br />
}<br />
<br />
<br />
Replace "U0x46d0x81d" with your capture device's card name in ALSA. You can use 'arecord -L' to list all the capture devices detected by ALSA.<br />
<br />
===Internal Microphone not working===<br />
<br />
First make sure all the volume levels are up under recording in alsamixer. In my case adding the following option to /etc/sound.conf and reloading the snd-* module produced a new volume setting called Capture which was capturing for the internal mic. For eg, for snd-hda-intel add <br />
<br />
options snd-hda-intel enable_msi=1<br />
<br />
Then reload the module (as below), up the recording volume of Capture and then test.<br />
<br />
rmmod snd-hda-intel<br />
modprobe snd-hda-intel<br />
<br />
===No Sound with Onboard Intel Sound Card===<br />
<br />
There may be an issue with two conflicting modules loaded, namely <code>snd_intel8x0</code> and <code>snd_intel8x0m</code>. In this case, edit <code>rc.conf</code> and in the MODULES array blacklist the latter one so that it reads <code>!snd_intel8x0m</code> afterwards.<br />
<br />
''Muting'' the "External Amplifier" in <code>alsamixer</code> or <code>amixer</code> may also help. See [http://alsa.opensrc.org/index.php/Intel8x0#Dell_Inspiron_8600_.28and_probably_others.29 the ALSA wiki].<br />
<br />
===No Headphone Sound with Onboard Intel Sound Card===<br />
With '''Intel Corporation 82801 I (ICH9 Family) HD Audio Controller''' on laptop, you may need to add this line to modprobe or sound.conf:<br />
<br />
options snd-hda-intel model=$model<br />
<br />
Where $model is any one of the following (in order of possibility to work, but not merit):<br />
<br />
* dell-vostro<br />
* olpc-xo-1_5<br />
* laptop<br />
<br />
Note: It may be necessary to put this "options" line below (after) any "alias" lines about your card.<br />
<br />
You can see all the available models in the kernel documentation. For example [http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.35.y.git;a=blob;f=Documentation/sound/alsa/HD-Audio-Models.txt;h=dc25bb84b83b49665a7ed850e7bf5423d50cd3ba;hb=HEAD here], but check that it's the correct version of that document for your kernel version.<br />
<br />
Note that there is a high chance none of the input devices (all internal and external mics) will work if you choose to do this, so it's either your headphones or your mic. Please report to ALSA if you are affected by this bug.<br />
<br />
And also, if you have problems getting beeps to work (pcspkr):<br />
<br />
options snd-hda-intel model=$model enable=1 index=0<br />
<br />
===No sound when S/PDIF video card is installed===<br />
<br />
Discover available modules and their order:<br />
$ cat /proc/asound/modules<br />
0 snd_hda_intel<br />
1 snd_ca0106<br />
<br />
Disable the undesired video card audio codec in {{filename|/etc/modprobe.d/modprobe.conf}}:<br />
# /etc/modprobe.d/modprobe.conf<br />
#<br />
install snd_hda_intel /bin/false<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.d/modprobe.conf. or try it with "modprobe snd-hda-intel power_save=0"<br />
<br />
===Alsamixer Does Not Run===<br />
<br />
If running alsamixer does not work and you wind up with the following error<br />
alsamixer: function snd_ctl_open failed for default: No such device or directory<br />
<br />
You should first check /etc/group to ensure that your current user is in the 'audio' group. Don't forget to log out and log in again for the group changes.<br />
<br />
Then you might need to re-install your kernel. Run 'pacman -S kernel26' or whichever patchset you prefer to use.<br />
<br />
===S/PDIF Output Does Not Work===<br />
<br />
If the optical/coaxial digital output of your motherboard/sound card is not working or stopped working, and have already enabled and unmuted it in alsamixer, try running<br />
iecset audio on<br />
<br />
as root.<br />
<br />
You can also put this command in rc.local as it sometimes it may stop working after a reboot.<br />
<br />
===HDMI Output Does Not Work===<br />
<br />
If the HDMI output of your motherboard/sound card is not working or stopped working, and have already enabled and unmuted it in alsamixer, try the following.<br />
<br />
Query for Playback Devices:<br />
<br />
% aplay -l<br />
**** List of PLAYBACK Hardware Devices ****<br />
card 0: NVidia [HDA NVidia], device 0: ALC1200 Analog [ALC1200 Analog]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 0: NVidia [HDA NVidia], device 1: ALC1200 Digital [ALC1200 Digital]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 0: NVidia [HDA NVidia], device 3: NVIDIA HDMI [NVIDIA HDMI]<br />
Subdevices: 0/1<br />
Subdevice #0: subdevice #0<br />
<br />
Now that we have the info for the HDMI device, try a test, In the example below, 0 is the card number and 3 is the device number.<br />
<br />
% aplay -D plughw:0,3 /usr/share/sounds/alsa/Front_Center.wav<br />
<br />
If aplay does not output any errors, but still no sound is heared, "reboot" the receiver, monitor or tv set. Since the HDMI interface executes a handshake on connection, it might have noticed before that there was no audio stream embedded, and disabled audio decoding.<br />
<br />
If the test is successful, edit/create asound.conf in /etc to set HDMI as the default audio device, reboot, and audio should now work. There might be a better way to do this??<br />
<br />
% cat /etc/asound.conf<br />
pcm.!default {<br />
type plug<br />
slave.pcm {<br />
type hw<br />
card 0<br />
device 3<br />
}<br />
}<br />
<br />
If the this inconclusive<br />
<br />
===No Adjustable PCM Channel===<br />
<br />
You may find that you lack adjustable PCM channel. In this case try to remove all sound-related stuff from MODULES section in /etc/rc.conf, except for snd-NAME-OF-MODULE and snd-pcm-oss.<br />
<br />
===HP TX2500===<br />
<br />
Add these 2 lines into {{Filename|/etc/modprobe.d/modprobe.conf}}:<br />
options snd-cmipci mpu_port=0x330 fm_port=0x388<br />
options snd-hda-intel index=0 model=toshiba position_fix=1<br />
<br />
And don't forget to enable 'hal' in the DAEMONS section of your {{Filename|/etc/rc.conf}}.<br />
<br />
options snd-hda-intel model=hp (works for tx2000cto)<br />
<br />
===Skipping Sound When Playing MP3===<br />
<br />
If you have sound skipping when playing MP3 files and you have more then 2 speakers attached to your computer (i.e. > 2 speaker system), run alsamixer and disable the channels for the speakers that you '''DON'T''' have (i.e. don't enable the sound for the center speaker if you don't have a center speaker.<br />
<br />
===Using a USB Headset and External USB Sound Cards===<br />
<br />
If you are using a USB headset with ALSA you can try using asoundconf (currently only available from the AUR) to set the headset as the primary sound output. ''note: before running please make sure you have usb audio module enabled<br />
#modprobe snd-usb-audio<br />
<br />
you can add this to /etc/rc.conf if you wish''<br />
<br />
# asoundconf is-active<br />
# asoundconf list<br />
# asoundconf set-default-card <chosen soundcard><br />
<br />
===KDE Settings===<br />
<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 />
Log out and log back in as user xyz to get sound to work (I had to kill X, logout then log back in as user xyz, then start X and open Firefox and bam audio working on YouTube)<br />
<br />
* '''KDE 3.3:''' Go to ''K Menu &rarr; Multimedia &rarr; KMix''<br />
** Choose ''Settings &rarr; 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 />
===Error 'Unkown hardware' Appears After a Kernel Update===<br />
<br />
The following messages may be displayed during the start-up ALSA after the kernel update:<br />
Unknown hardware "foo" "bar" ...<br />
Hardware is initialized using a guess method<br />
/usr/sbin/alsactl: set_control:nnnn:failed to obtain info for control #mm (No such file or directory)<br />
<br />
Simply store ALSA mixer settings again (as root):<br />
# alsactl store<br />
<br />
===HDA Analyzer===<br />
<br />
If the mappings to your audio pins(plugs) do not correspond but ALSA works fine, you could try HDA Analyzer -- a pyGTK2 GUI for HD-audio control can be found [http://www.alsa-project.org/main/index.php/HDA_Analyzer at the ALSA wiki].<br />
Try tweaking the Widget Control section of the PIN nodes, to make microphones IN and headphone jacks OUT. Referring to the Config Defaults heading is a good idea.<br />
<br />
===Beep system===<br />
<br />
If you have this annoying beep every time you use backspace or when you run halt/reboot from X, just run the following commands.<br />
# amixer set Beep 0% mute<br />
# alsactl store<br />
<br />
After that, you can remove<br />
xset -b<br />
from your ~/.xinitrc and<br />
MODULES=(!pcspkr !snd-pcsp)<br />
from /etc/rc.conf (only if you used them for solving your beep problem).<br />
<br />
==Example configurations==<br />
The following should serve as a guide for more advanced setups. The configuration takes place in /etc/asound.conf as mentioned earlier in this article. None of the following configurations are guaranteed to be working. <br />
<br />
===Upmixing of stereo sources to 7.1 using dmix while saturated sources do not get upmixed===<br />
# 2008-11-15<br />
#<br />
# This .asoundrc will allow the following:<br />
#<br />
# - upmix stereo files to 7.1 speakers.<br />
# - playback real 7.1 sounds, on 7.1 speakers,<br />
# - allow the playback of both stereo (upmixed) and surround(7.1) sources at the same time.<br />
# - use the 6th and 7th channel (side speakers) as a separate soundcard, i.e. for headphones<br />
# (This is called the "alternate" output throughout the file, device names prefixed with 'a')<br />
# - play mono sources in stereo (like skype & ekiga) on the alterate output<br />
#<br />
# Make sure you have "8 Channels" and NOT "6 Channels" selected in alsamixer!<br />
#<br />
# Please try the following commands, to make sure everything is working as it should.<br />
#<br />
# To test stereo upmix : speaker-test -c2 -Ddefault -twav<br />
# To test surround(5.1): speaker-test -c6 -Dplug:dmix6 -twav<br />
# To test surround(7.1): speaker-test -c6 -Dplug:dmix8 -twav<br />
# To test alternative output: speaker-test -c2 -Daduplex -twav<br />
# To test mono upmix: speaker-test -c1 -Dmonoduplex -twav<br />
#<br />
#<br />
# It may not work out of the box for all cards. If it doesnt work for you, read the comments throughout the file.<br />
# The basis of this file was written by wishie of #alsa, and then modified with info from various sources by <br />
# squisher. Svenstaro modified it for 7.1 output support.<br />
<br />
#Define the soundcard to use<br />
pcm.snd_card {<br />
type hw<br />
card 0<br />
device 0<br />
}<br />
<br />
# 8 channel dmix - output whatever audio, to all 8 speakers<br />
pcm.dmix8 {<br />
type dmix<br />
ipc_key 1024<br />
ipc_key_add_uid false<br />
ipc_perm 0660<br />
slave {<br />
pcm "snd_card"<br />
rate 48000<br />
channels 8<br />
period_time 0<br />
period_size 1024<br />
buffer_time 0<br />
buffer_size 5120<br />
}<br />
<br />
# Some cards, like the "nforce" variants require the following to be uncommented. <br />
# It routes the audio to the correct speakers.<br />
# bindings {<br />
# 0 0<br />
# 1 1<br />
# 2 4<br />
# 3 5<br />
# 4 2<br />
# 5 3<br />
# 6 6<br />
# 7 7<br />
# }<br />
}<br />
<br />
# upmixing - duplicate stereo data to all 8 channels<br />
pcm.ch71dup {<br />
type route<br />
slave.pcm dmix8<br />
slave.channels 8<br />
ttable.0.0 1<br />
ttable.1.1 1<br />
ttable.0.2 1<br />
ttable.1.3 1<br />
ttable.0.4 0.5<br />
ttable.1.4 0.5<br />
ttable.0.5 0.5<br />
ttable.1.5 0.5<br />
ttable.0.6 1<br />
ttable.1.7 1<br />
}<br />
<br />
# this creates a six channel soundcard<br />
# and outputs to the eight channel one<br />
# i.e. for usage in mplayer I had to define in ~/.mplayer/config:<br />
# ao=alsa:device=dmix6<br />
# channels=6<br />
pcm.dmix6 {<br />
type route<br />
slave.pcm dmix8<br />
slave.channels 8<br />
ttable.0.0 1<br />
ttable.1.1 1<br />
ttable.2.2 1<br />
ttable.3.3 1<br />
ttable.4.4 1<br />
ttable.5.5 1<br />
ttable.6.6 1<br />
ttable.7.7 1<br />
}<br />
<br />
# share the microphone, i.e. because virtualbox grabs it by default<br />
pcm.microphone {<br />
type dsnoop<br />
ipc_key 1027<br />
slave {<br />
pcm "snd_card"<br />
}<br />
}<br />
<br />
# rate conversion, needed i.e. for wine<br />
pcm.2chplug {<br />
type plug<br />
slave.pcm "ch71dup"<br />
}<br />
pcm.a2chplug {<br />
type plug<br />
slave.pcm "dmix8"<br />
}<br />
<br />
# routes the channel for the alternative<br />
# 2 channel output, which becomes the 7th and 8th channel <br />
# on the real soundcard<br />
#pcm.alt2ch {<br />
# type route<br />
# slave.pcm "a2chplug"<br />
# slave.channels 8<br />
# ttable.0.6 1<br />
# ttable.1.7 1<br />
#}<br />
<br />
# skype and ekiga are only mono, so route left channel to the right channel<br />
# note: this gets routed to the alternative 2 channels<br />
pcm.mono_playback {<br />
type route<br />
slave.pcm "a2chplug"<br />
slave.channels 8<br />
# Send Skype channel 0 to the L and R speakers at full volume<br />
#ttable.0.6 1<br />
#ttable.0.7 1<br />
}<br />
<br />
# 'full-duplex' device for use with aoss<br />
pcm.duplex {<br />
type asym<br />
playback.pcm "2chplug"<br />
capture.pcm "microphone"<br />
}<br />
<br />
#pcm.aduplex {<br />
# type asym<br />
# playback.pcm "alt2ch"<br />
# capture.pcm "microphone"<br />
#}<br />
<br />
pcm.monoduplex {<br />
type asym<br />
playback.pcm "mono_playback"<br />
capture.pcm "microphone"<br />
}<br />
<br />
# for aoss<br />
pcm.dsp0 "duplex"<br />
ctl.mixer0 "duplex"<br />
<br />
# softvol manages volume in alsa<br />
# i.e. wine likes this<br />
pcm.mainvol {<br />
type softvol<br />
slave.pcm "duplex"<br />
control {<br />
name "2ch-Upmix Master"<br />
card 0<br />
}<br />
}<br />
<br />
#pcm.!default "mainvol"<br />
<br />
# set the default device according to the environment<br />
# variable ALSA_DEFAULT_PCM and default to mainvol<br />
pcm.!default {<br />
@func refer<br />
name { @func concat <br />
strings [ "pcm."<br />
{ @func getenv<br />
vars [ ALSA_DEFAULT_PCM ]<br />
default "mainvol"<br />
}<br />
]<br />
}<br />
}<br />
<br />
# uncomment the following if you want to be able to control<br />
# the mixer device through environment variables as well<br />
#ctl.!default {<br />
# @func refer<br />
# name { @func concat <br />
# strings [ "ctl."<br />
# { @func getenv<br />
# vars [ ALSA_DEFAULT_CTL<br />
# ALSA_DEFAULT_PCM<br />
# ]<br />
# default "duplex"<br />
# }<br />
# ]<br />
# }<br />
#}<br />
<br />
===Surround51 incl. upmix stereo & dmix, swap L/R, bad speaker position in room===<br />
<br />
Bad practice but works fine for almost everything without additional per-program/file customization:<br />
pcm.!default {<br />
type route<br />
## forwards to the mixer pcm defined below<br />
slave.pcm dmix51<br />
slave.channels 6<br />
<br />
## "Native Channels" stereo, swap left/right<br />
ttable.0.1 1<br />
ttable.1.0 1<br />
## original normal left/right commented out<br />
# ttable.0.0 1<br />
# ttable.1.1 1<br />
<br />
## route "native surround" so it still works but weaken signal (+ RL/RF swap) <br />
## because my rear speakers are more like random than really behind me<br />
ttable.2.3 0.7<br />
ttable.3.2 0.7<br />
ttable.4.4 0.7<br />
ttable.5.5 0.7<br />
<br />
## stereo => quad speaker "upmix" for "rear" speakers + swap L/R<br />
ttable.0.3 1<br />
ttable.1.2 1<br />
<br />
## stereo L+R => join to Center & Subwoofer 50%/50%<br />
ttable.0.4 0.5<br />
ttable.1.4 0.5<br />
ttable.0.5 0.5<br />
ttable.1.5 0.5<br />
## to test: "$ speaker-test -c6 -twav" and: "$ speaker-test -c2 -twav"<br />
}<br />
<br />
pcm.dmix51 {<br />
type dmix<br />
ipc_key 1024<br />
# let multiple users share<br />
ipc_key_add_uid false <br />
# IPC permissions (octal, default 0600)<br />
# I think changing this fixed something - but I'm not sure what.<br />
ipc_perm 0660 # <br />
slave {<br />
## this is specific to my hda_intel. Often hd:0 is just allready it; To find: $ aplay -L <br />
pcm surround51 <br />
# this rate makes my soundcard crackle<br />
# rate 44100<br />
# this rate stops flash in firefox from playing audio, but I don't need that<br />
rate 48000<br />
channels 6<br />
## Any other values in the 4 lines below seem to make my soundcard crackle, too<br />
period_time 0<br />
period_size 1024<br />
buffer_time 0<br />
buffer_size 4096<br />
}<br />
}<br />
<br />
==External Resources==<br />
<br />
* [http://www.mjmwired.net/kernel/Documentation/sound/alsa/ALSA-Configuration.txt Advanced ALSA module configuration]<br />
* [http://alsa.opensrc.org/index.php/Main_Page Unofficial ALSA Wiki]<br />
* [http://alsa.opensrc.org/index.php/Aadebug A simple shell script to aid ALSA audio debugging]<br />
* [http://bbs.archlinux.org/viewtopic.php?id=36815 HOWTO: Compile driver from svn]<br />
* [http://gentoo-wiki.com/HOWTO_Set_up_a_system-wide_equaliser_with_ALSA_and_LADSPA HOWTO Set up a system-wide equaliser with ALSA and LADSPA]<br />
<br />
* [http://archux.com/page/setting-audio Simple instructions for setting up ALSA]<br />
<!-- vim: set ft=Wikipedia: --></div>Xrchzhttps://wiki.archlinux.org/index.php?title=Advanced_Linux_Sound_Architecture&diff=118923Advanced Linux Sound Architecture2010-10-09T15:12:14Z<p>Xrchz: /* No Headphone Sound with Onboard Intel Sound Card */</p>
<hr />
<div>[[Category:Audio/Video (English)]]<br />
[[Category:HOWTOs (English)]]<br />
{{i18n|ALSA|Advanced Linux Sound Architecture}}<br />
<br />
The Advanced Linux Sound Architecture (ALSA) is a Linux kernel component intended to provide device drivers for sound cards. <br />
<br />
Also see how to [[Allow_multiple_programs_to_play_sound_at_once|allow multiple programs to play sound at once]]<br />
<br />
{{Note|For an alternative sound environment, see the [[Open Sound System]] page.}}<br />
<br />
==Installation==<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 is required unless an ISA card is being used. '''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 -S 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, pacman will handle this automatically.<br />
<br />
==Configuration==<br />
===Set the default sound card===<br />
<br />
====In Kernel Space====<br />
<br />
''Note: snd-pcsp is no longer in the kernel from at least 2.6.35; the only related module is then pcspkr.''<br />
<br />
Telephony-capable modems and snd-pcsp (the internal PC speaker ALSA module) can conflict with the sound card for the default sound card slot. (pcspkr is another, non-ALSA PC speaker module. It will not conflict with ALSA sound cards.) To prevent this, discover your sound card model name with [http://linux.die.net/man/8/lspci lspci(8)] and your ALSA driver module names with ls(1):<br />
<br />
$ ls -l /sys/module/snd/holders<br />
total 0<br />
lrwxrwxrwx 1 root root 0 2009-06-02 23:49 snd_ac97_codec -> ../../snd_ac97_codec<br />
lrwxrwxrwx 1 root root 0 2009-06-02 23:49 snd_intel8x0 -> ../../snd_intel8x0<br />
lrwxrwxrwx 1 root root 0 2009-06-02 23:49 snd_intel8x0m -> ../../snd_intel8x0m<br />
lrwxrwxrwx 1 root root 0 2009-06-02 23:49 snd_pcm -> ../../snd_pcm<br />
lrwxrwxrwx 1 root root 0 2009-06-02 23:53 snd_pcsp -> ../../snd_pcsp<br />
lrwxrwxrwx 1 root root 0 2009-06-02 23:49 snd_timer -> ../../snd_timer<br />
<br />
Then add the names of your sound card modules to:<br />
<br />
{{file |name=/etc/modprobe.d/modprobe.conf (prior to module-init-tools 3.8, use /etc/modprobe.conf) |content=<br />
options snd-intel8x0 index=0<br />
options snd-pcsp index=1<br />
}}<br />
<br />
These entries ensure that the Intel 82801DB-ICH4 sound card will become card 0 and the PC speaker will become card 1.<br />
NB: Some modules do not support indexing options eg. snd-hda-intel. If you experience problems on reboot edit /etc/modprobe.d/modprobe.conf to just have the modules.<br />
<br />
If you do not want snd-pcsp to load at all you can add the following to:<br />
<br />
{{file |name=/etc/rc.conf |content=MODULES=(... !snd-pcsp)<br />
}}<br />
<br />
If you want the PC speaker completely disabled, you can additionally add the following to:<br />
<br />
{{file |name=/etc/rc.conf |content=MODULES=(... !pcspkr)<br />
}}<br />
<br />
<br />
{{Note| You will need to unload all your sound modules and reload them for the changes to take effect. It might be easier to reboot. Your choice. }}<br />
<br />
====In User Space====pcsp<br />
<br />
This method does not require root permissions, is on a per-user basis, and takes effect as soon as any software has been restarted (like your media player, for example).<br />
<br />
Located in {{Filename|/usr/share/alsa/alsa.conf}} is a list of defaults that alsa uses out of the box. These can be overridden in a {{Filename|~/.asoundrc}} file.<br />
{{File|name=~/.asoundrc|content=<br />
defaults.ctl.card 1<br />
defaults.pcm.card 1<br />
defaults.pcm.device 1}}<br />
The 'pcm' options affect which card and device will be used for audio playback. However it is the 'ctl' option affects which card is used by control utilities like alsamixer, amixer, and the like.<br />
<br />
To find out which numbers correspond to what audio device, use {{Codeline|aplay -l}}.<br />
$ aplay -l<br />
**** List of PLAYBACK Hardware Devices ****<br />
card 0: Intel [HDA Intel], device 0: CONEXANT Analog [CONEXANT Analog]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 0: Intel [HDA Intel], device 1: Conexant Digital [Conexant Digital]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 1: JamLab [JamLab], device 0: USB Audio [USB Audio]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 2: Audio [Altec Lansing XT1 - USB Audio], device 0: USB Audio [USB Audio]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<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' | column -t<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,<br />
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 />
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/main/index.php/Matrix:Main ALSA Soundcard Matrix] 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 {{Filename|/etc/rc.conf}} to ensure they are loaded next time (make sure '''snd-NAME-OF-MODULE''' is before '''snd-pcm-oss''').<br />
<br />
===Unmute the channels and test===<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 />
The current version of ALSA installs with all channels '''muted by default''', so even if installation completes successfully and all devices are working properly you will hear no sound. You will need to unmute the channels manually. It is recommended to use {{Codeline|alsamixer}} to accomplish this. From the alsamixer text ui, the label "MM" below a channel indicates that the channel is muted, and "00" indicates that it is open. Press the 'm' key to toggle MM/00. Use arrow-keys left and right to navigate through the channels and the arrow-keys up and down to adjust the volume. Such things as Master and PCM and possibly Speaker will need to unmuted for your sound to work.<br />
<br />
{{Note | When using '''{{Codeline|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. '''{{Codeline|amixer}}''' understands the percent sign (%), not numbers. If you use a number (say, 90) then '''{{Codeline|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 />
* Now run a test<br />
<br />
# speaker-test -c 2<br />
<br />
{{Note | Some cards need to have digital output muted/turned off in order to hear analog sound. For the Soundblaster Audigy LS mute the IEC958 channel.}}<br />
<br />
If you cannot hear anything, double check your mixer settings, being sure to unmute PCM, MASTER (and some machines such as the IBM Thinkpad have an additional 'SPEAKER' channel) and try the alsaconf utility as root:<br />
# alsaconf<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 if it is not already available:<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 {{Codeline|alsactl store}} once to create {{Filename|/etc/asound.state}}.<br />
<br />
# alsactl store<br />
<br />
* Edit {{Filename|/etc/[[rc.conf]]}} and add {{Codeline|"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 />
* If the mixer settings are not loaded on boot-up, add the following line to {{Filename|/etc/rc.local}}:<br />
<br />
# alsactl restore<br />
<br />
* These methods still may not work, or you may prefer to have audio settings for individual users. In this case, run {{Codeline|alsactl store -f ~/.asoundrc}} as a normal user. This will save and restore volume settings on a per user basis. To automate this process, add the respective commands to {{Filename|~/.bash_login}} and {{Filename|~/.bash_logout}}, or the correct locations for the shell of your choice.<br />
<br />
For zsh, use {{Filename|~/.zlogin}} and {{Filename|~/.zlogout}}.<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 />
<br />
* add following lines to {{Filename|/etc/rc.local}}:<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 />
$ amixer scontrols<br />
<br />
===System-Wide Equalizer===<br />
====Using AlsaEqual (provides UI)====<br />
<br />
Install [http://aur.archlinux.org/packages.php?ID=27066 alsaequal] from the [[AUR]].<br />
<br />
{{Note | If you have a x86_64-system and are using a 32bit-flashplugin the sound in flash will not work. Either you have to disable alsaequal or build alsaequal for 32bit.}}<br />
<br />
After installing package Insert the following into your ALSA configuration file ({{Filename|~/.asoundrc}} or {{Filename|/etc/asound.conf}}):<br />
<br />
ctl.equal {<br />
type equal;<br />
}<br />
<br />
pcm.plugequal {<br />
type equal;<br />
# Modify the line below if you don't<br />
# want to use sound card 0.<br />
#slave.pcm "plughw:0,0";<br />
#by default we want to play from more sources at time:<br />
slave.pcm "plug:dmix";<br />
}<br />
<br />
#pcm.equal {<br />
# Or if you want the equalizer to be your<br />
# default soundcard uncomment the following<br />
# line and comment the above line.<br />
pcm.!default {<br />
type plug;<br />
slave.pcm plugequal;<br />
}<br />
<br />
<br />
Then Reload your alsa settings (as root).<br />
# /etc/rc.d/alsa restart<br />
not sure if this is really needed - more important is to shut down all applications using ALSA...<br />
<br />
And you are ready to change your equalizer using command<br />
$ alsamixer -D equal<br />
<br />
Note that configuration file is different for each user (until not specified else) it's saved in '''$HOME/.alsaequal.bin'''.<br />
so if you want to use AlsaEqual with [[mpd]] or another software running under different user, you can configure it using<br />
# su mpd -c 'alsamixer -D equal'<br />
or eg. you can make symlink to your '''.alsaequal.bin''' in his home...<br />
<br />
====Using mbeq====<br />
{{Note | This method requires the use of a ladspa plugin which might use quite a bit of CPU when sound plays. In addition, this was made with stereophonic sound (e.g. headphones) in mind.}}<br />
<br />
* You will need, in addition to the aforementioned userspace utilities, alsa-plugins.<br />
# pacman -S alsa-plugins<br />
* Get the ladspa and swh-plugins packages too if you don't already have them.<br />
# pacman -S ladspa swh-plugins<br />
* If you haven't already created either an {{Filename|~/.asoundrc}} or a {{Filename|/etc/asound.conf}} file, then create either one<br />
$ vim ~/.asoundrc<br />
* Insert the following into your ALSA configuration file ({{Filename|~/.asoundrc}} or {{Filename|/etc/asound.conf}}):<br />
<br />
{{file |name=/etc/asound.conf |content=pcm.eq {<br />
type ladspa<br><br />
# The output from the EQ can either go direct to a hardware device<br />
# (if you have a hardware mixer, e.g. SBLive/Audigy) or it can go<br />
# to the software mixer shown here.<br />
#slave.pcm "plughw:0,0"<br />
slave.pcm "plug:dmix"<br><br />
# Sometimes you may need to specify the path to the plugins,<br />
# especially if you've just installed them. Once you've logged<br />
# out/restarted this shouldn't be necessary, but if you get errors<br />
# about being unable to find plugins, try uncommenting this.<br />
#path "/usr/lib/ladspa"<br><br />
plugins [<br />
{<br />
label mbeq<br />
id 1197<br />
input {<br />
#this setting is here by example, edit to your own taste<br />
#bands: 50hz, 100hz, 156hz, 220hz, 311hz, 440hz, 622hz, 880hz, 1250hz, 1750hz, 25000hz,<br />
#50000hz, 10000hz, 20000hz<br />
controls [ -5 -5 -5 -5 -5 -10 -20 -15 -10 -10 -10 -10 -10 -3 -2 ]<br />
}<br />
}<br />
]<br />
}<br><br />
# Redirect the default device to go via the EQ - you may want to do<br />
# this last, once you're sure everything is working. Otherwise all<br />
# your audio programs will break/crash if something has gone wrong.<br><br />
pcm.!default {<br />
type plug<br />
slave.pcm "eq"<br />
}<br><br />
# Redirect the OSS emulation through the EQ too (when programs are running through "aoss")<br><br />
pcm.dsp0 {<br />
type plug<br />
slave.pcm "eq"<br />
}<br />
}}<br />
<br />
*Reload your alsa settings (as root).<br />
# /etc/rc.d/alsa restart<br />
<br />
*You should be good to go (if not, ask in the forum).<br />
<br />
==Troubleshooting==<br />
===Model Settings===<br />
<br />
Although Alsa detects your soundcard through the BIOS at times Alsa may not be able to recognize your [http://www.kernel.org/doc/Documentation/sound/alsa/HD-Audio-Models.txt model type]. The soundcard chip can be found in <code>alsamixer</code> (e.g. ALC662) and the model can be set in {{Filename|/etc/modprobe.d/modprobe.conf}} or {{Filename|/etc/modprobe.d/sound.conf}}. For example:<br />
<br />
options snd-hda-intel model=MODEL<br />
<br />
There are other model settings too. For most cases Alsa defaults will do. If you want to look at more specific settings for your soundcard take a look at the [http://bugtrack.alsa-project.org/main/index.php/Matrix:Main Alsa Soundcard List] find your model, then Details, then look at the "Setting up modprobe..." section. Enter these values in {{Filename|/etc/modprobe.d/modprobe.conf}}. For example, for an Intel AC97 audio:<br />
<br />
<pre># ALSA portion<br />
alias char-major-116 snd<br />
alias snd-card-0 snd-intel8x0<br />
# module options should go here<br />
<br />
# OSS/Free portion<br />
alias char-major-14 soundcore<br />
alias sound-slot-0 snd-card-0<br />
<br />
# card #1<br />
alias sound-service-0-0 snd-mixer-oss<br />
alias sound-service-0-1 snd-seq-oss<br />
alias sound-service-0-3 snd-pcm-oss<br />
alias sound-service-0-8 snd-seq-oss<br />
alias sound-service-0-12 snd-pcm-oss</pre><br />
<br />
===Conflicting PC Speaker===<br />
<br />
Remember, ALSA installs with all channels '''muted by default''' (see previous section, [[Advanced Linux Sound Architecture#Unmute the channels and test|unmuting your soundcard]]).<br />
<br />
However, if you're sure nothing is muted, that your drivers are installed correctly, and that your volume is right, but you still do not hear anything, then try blacklisting snd-pcsp (kernels < 2.6.35) or pcspkr from your modules array in rc.conf:<br />
<br />
MODULES=(!snd-pcsp ... )<br />
<br />
Note that this will disable your PC's internal speaker.<br />
If that doesn't work, then try adding the following line to <code>/etc/modprobe.d/modprobe.conf</code>:<br />
<br />
options snd-NAME-OF-MODULE ac97_quirk=0<br />
<br />
The above fix has been observed to work with <code>via82xx</code><br />
options snd-NAME-OF-MODULE ac97_quirk=1<br />
The above fix has been reported to work with <code>snd_intel8x0</code><br />
<br />
===No Microphone Input===<br />
Make sure that all the volume levels are up under recording in alsamixer, and that CAPTURE is active on the microphone (in alsamixer, select it and press space). You may also need to enable and increase the volume of Line-in in the Playback section.<br />
<br />
To test the microphone, run these commands:<br />
arecord -d 5 test-mic.wav<br />
aplay test-mic.wav<br />
<br />
You may want to see arecord's man page to play with it a little bit. Anyway, if you are unable to hear anything, your microphone may be broken or in the wrong hole.<br />
<br />
Some programs use try to use OSS as the main input software. Add the following line to <code>/etc/rc.conf</code> to prevent OSS modules from being loaded:<br />
<br />
MODULES=(!snd_pcm_oss !snd_mixer_oss !snd_seq_oss ... )<br />
<br />
===Setting the default Microphone/Capture Device===<br />
Some applications (Pidgin, Adobe Flash) do not provide an option to change the capture device. It becomes an issue if your microphone is on a separate device (i.e. USB webcam or microphone) than your internal sound card. To change only the default capture device, leaving the default playback device as is, you can modify your ~/.asoundrc file to include the following:<br />
<br />
pcm.usb<br />
{<br />
type hw<br />
card U0x46d0x81d<br />
}<br />
<br />
pcm.!default<br />
{<br />
type asym<br />
playback.pcm<br />
{<br />
type plug<br />
slave.pcm "dmix"<br />
}<br />
capture.pcm <br />
{<br />
type plug<br />
slave.pcm "usb"<br />
}<br />
}<br />
<br />
<br />
Replace "U0x46d0x81d" with your capture device's card name in ALSA. You can use 'arecord -L' to list all the capture devices detected by ALSA.<br />
<br />
===Internal Microphone not working===<br />
<br />
First make sure all the volume levels are up under recording in alsamixer. In my case adding the following option to /etc/sound.conf and reloading the snd-* module produced a new volume setting called Capture which was capturing for the internal mic. For eg, for snd-hda-intel add <br />
<br />
options snd-hda-intel enable_msi=1<br />
<br />
Then reload the module (as below), up the recording volume of Capture and then test.<br />
<br />
rmmod snd-hda-intel<br />
modprobe snd-hda-intel<br />
<br />
===No Sound with Onboard Intel Sound Card===<br />
<br />
There may be an issue with two conflicting modules loaded, namely <code>snd_intel8x0</code> and <code>snd_intel8x0m</code>. In this case, edit <code>rc.conf</code> and in the MODULES array blacklist the latter one so that it reads <code>!snd_intel8x0m</code> afterwards.<br />
<br />
''Muting'' the "External Amplifier" in <code>alsamixer</code> or <code>amixer</code> may also help. See [http://alsa.opensrc.org/index.php/Intel8x0#Dell_Inspiron_8600_.28and_probably_others.29 the ALSA wiki].<br />
<br />
===No Headphone Sound with Onboard Intel Sound Card===<br />
With '''Intel Corporation 82801 I (ICH9 Family) HD Audio Controller''' on laptop, you may need to add this line to modprobe or sound.conf:<br />
<br />
options snd-hda-intel model=$model<br />
<br />
Where $model is any one of the following (in order of possibility to work, but not merit):<br />
<br />
* dell-vostro<br />
* olpc-xo-1_5<br />
* laptop<br />
<br />
You can see all the available models in the kernel documentation. For example [http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.35.y.git;a=blob;f=Documentation/sound/alsa/HD-Audio-Models.txt;h=dc25bb84b83b49665a7ed850e7bf5423d50cd3ba;hb=HEAD here], but check that it's the correct version of that document for your kernel version.<br />
<br />
Note that there is a high chance none of the input devices (all internal and external mics) will work if you choose to do this, so it's either your headphones or your mic. Please report to ALSA if you are affected by this bug.<br />
<br />
And also, if you have problems getting beeps to work (pcspkr):<br />
<br />
options snd-hda-intel model=$model enable=1 index=0<br />
<br />
===No sound when S/PDIF video card is installed===<br />
<br />
Discover available modules and their order:<br />
$ cat /proc/asound/modules<br />
0 snd_hda_intel<br />
1 snd_ca0106<br />
<br />
Disable the undesired video card audio codec in {{filename|/etc/modprobe.d/modprobe.conf}}:<br />
# /etc/modprobe.d/modprobe.conf<br />
#<br />
install snd_hda_intel /bin/false<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.d/modprobe.conf. or try it with "modprobe snd-hda-intel power_save=0"<br />
<br />
===Alsamixer Does Not Run===<br />
<br />
If running alsamixer does not work and you wind up with the following error<br />
alsamixer: function snd_ctl_open failed for default: No such device or directory<br />
<br />
You should first check /etc/group to ensure that your current user is in the 'audio' group. Don't forget to log out and log in again for the group changes.<br />
<br />
Then you might need to re-install your kernel. Run 'pacman -S kernel26' or whichever patchset you prefer to use.<br />
<br />
===S/PDIF Output Does Not Work===<br />
<br />
If the optical/coaxial digital output of your motherboard/sound card is not working or stopped working, and have already enabled and unmuted it in alsamixer, try running<br />
iecset audio on<br />
<br />
as root.<br />
<br />
You can also put this command in rc.local as it sometimes it may stop working after a reboot.<br />
<br />
===HDMI Output Does Not Work===<br />
<br />
If the HDMI output of your motherboard/sound card is not working or stopped working, and have already enabled and unmuted it in alsamixer, try the following.<br />
<br />
Query for Playback Devices:<br />
<br />
% aplay -l<br />
**** List of PLAYBACK Hardware Devices ****<br />
card 0: NVidia [HDA NVidia], device 0: ALC1200 Analog [ALC1200 Analog]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 0: NVidia [HDA NVidia], device 1: ALC1200 Digital [ALC1200 Digital]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 0: NVidia [HDA NVidia], device 3: NVIDIA HDMI [NVIDIA HDMI]<br />
Subdevices: 0/1<br />
Subdevice #0: subdevice #0<br />
<br />
Now that we have the info for the HDMI device, try a test, In the example below, 0 is the card number and 3 is the device number.<br />
<br />
% aplay -D plughw:0,3 /usr/share/sounds/alsa/Front_Center.wav<br />
<br />
If aplay does not output any errors, but still no sound is heared, "reboot" the receiver, monitor or tv set. Since the HDMI interface executes a handshake on connection, it might have noticed before that there was no audio stream embedded, and disabled audio decoding.<br />
<br />
If the test is successful, edit/create asound.conf in /etc to set HDMI as the default audio device, reboot, and audio should now work. There might be a better way to do this??<br />
<br />
% cat /etc/asound.conf<br />
pcm.!default {<br />
type plug<br />
slave.pcm {<br />
type hw<br />
card 0<br />
device 3<br />
}<br />
}<br />
<br />
If the this inconclusive<br />
<br />
===No Adjustable PCM Channel===<br />
<br />
You may find that you lack adjustable PCM channel. In this case try to remove all sound-related stuff from MODULES section in /etc/rc.conf, except for snd-NAME-OF-MODULE and snd-pcm-oss.<br />
<br />
===HP TX2500===<br />
<br />
Add these 2 lines into {{Filename|/etc/modprobe.d/modprobe.conf}}:<br />
options snd-cmipci mpu_port=0x330 fm_port=0x388<br />
options snd-hda-intel index=0 model=toshiba position_fix=1<br />
<br />
And don't forget to enable 'hal' in the DAEMONS section of your {{Filename|/etc/rc.conf}}.<br />
<br />
options snd-hda-intel model=hp (works for tx2000cto)<br />
<br />
===Skipping Sound When Playing MP3===<br />
<br />
If you have sound skipping when playing MP3 files and you have more then 2 speakers attached to your computer (i.e. > 2 speaker system), run alsamixer and disable the channels for the speakers that you '''DON'T''' have (i.e. don't enable the sound for the center speaker if you don't have a center speaker.<br />
<br />
===Using a USB Headset and External USB Sound Cards===<br />
<br />
If you are using a USB headset with ALSA you can try using asoundconf (currently only available from the AUR) to set the headset as the primary sound output. ''note: before running please make sure you have usb audio module enabled<br />
#modprobe snd-usb-audio<br />
<br />
you can add this to /etc/rc.conf if you wish''<br />
<br />
# asoundconf is-active<br />
# asoundconf list<br />
# asoundconf set-default-card <chosen soundcard><br />
<br />
===KDE Settings===<br />
<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 />
Log out and log back in as user xyz to get sound to work (I had to kill X, logout then log back in as user xyz, then start X and open Firefox and bam audio working on YouTube)<br />
<br />
* '''KDE 3.3:''' Go to ''K Menu &rarr; Multimedia &rarr; KMix''<br />
** Choose ''Settings &rarr; 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 />
===Error 'Unkown hardware' Appears After a Kernel Update===<br />
<br />
The following messages may be displayed during the start-up ALSA after the kernel update:<br />
Unknown hardware "foo" "bar" ...<br />
Hardware is initialized using a guess method<br />
/usr/sbin/alsactl: set_control:nnnn:failed to obtain info for control #mm (No such file or directory)<br />
<br />
Simply store ALSA mixer settings again (as root):<br />
# alsactl store<br />
<br />
===HDA Analyzer===<br />
<br />
If the mappings to your audio pins(plugs) do not correspond but ALSA works fine, you could try HDA Analyzer -- a pyGTK2 GUI for HD-audio control can be found [http://www.alsa-project.org/main/index.php/HDA_Analyzer at the ALSA wiki].<br />
Try tweaking the Widget Control section of the PIN nodes, to make microphones IN and headphone jacks OUT. Referring to the Config Defaults heading is a good idea.<br />
<br />
===Beep system===<br />
<br />
If you have this annoying beep every time you use backspace or when you run halt/reboot from X, just run the following commands.<br />
# amixer set Beep 0% mute<br />
# alsactl store<br />
<br />
After that, you can remove<br />
xset -b<br />
from your ~/.xinitrc and<br />
MODULES=(!pcspkr !snd-pcsp)<br />
from /etc/rc.conf (only if you used them for solving your beep problem).<br />
<br />
==Example configurations==<br />
The following should serve as a guide for more advanced setups. The configuration takes place in /etc/asound.conf as mentioned earlier in this article. None of the following configurations are guaranteed to be working. <br />
<br />
===Upmixing of stereo sources to 7.1 using dmix while saturated sources do not get upmixed===<br />
# 2008-11-15<br />
#<br />
# This .asoundrc will allow the following:<br />
#<br />
# - upmix stereo files to 7.1 speakers.<br />
# - playback real 7.1 sounds, on 7.1 speakers,<br />
# - allow the playback of both stereo (upmixed) and surround(7.1) sources at the same time.<br />
# - use the 6th and 7th channel (side speakers) as a separate soundcard, i.e. for headphones<br />
# (This is called the "alternate" output throughout the file, device names prefixed with 'a')<br />
# - play mono sources in stereo (like skype & ekiga) on the alterate output<br />
#<br />
# Make sure you have "8 Channels" and NOT "6 Channels" selected in alsamixer!<br />
#<br />
# Please try the following commands, to make sure everything is working as it should.<br />
#<br />
# To test stereo upmix : speaker-test -c2 -Ddefault -twav<br />
# To test surround(5.1): speaker-test -c6 -Dplug:dmix6 -twav<br />
# To test surround(7.1): speaker-test -c6 -Dplug:dmix8 -twav<br />
# To test alternative output: speaker-test -c2 -Daduplex -twav<br />
# To test mono upmix: speaker-test -c1 -Dmonoduplex -twav<br />
#<br />
#<br />
# It may not work out of the box for all cards. If it doesnt work for you, read the comments throughout the file.<br />
# The basis of this file was written by wishie of #alsa, and then modified with info from various sources by <br />
# squisher. Svenstaro modified it for 7.1 output support.<br />
<br />
#Define the soundcard to use<br />
pcm.snd_card {<br />
type hw<br />
card 0<br />
device 0<br />
}<br />
<br />
# 8 channel dmix - output whatever audio, to all 8 speakers<br />
pcm.dmix8 {<br />
type dmix<br />
ipc_key 1024<br />
ipc_key_add_uid false<br />
ipc_perm 0660<br />
slave {<br />
pcm "snd_card"<br />
rate 48000<br />
channels 8<br />
period_time 0<br />
period_size 1024<br />
buffer_time 0<br />
buffer_size 5120<br />
}<br />
<br />
# Some cards, like the "nforce" variants require the following to be uncommented. <br />
# It routes the audio to the correct speakers.<br />
# bindings {<br />
# 0 0<br />
# 1 1<br />
# 2 4<br />
# 3 5<br />
# 4 2<br />
# 5 3<br />
# 6 6<br />
# 7 7<br />
# }<br />
}<br />
<br />
# upmixing - duplicate stereo data to all 8 channels<br />
pcm.ch71dup {<br />
type route<br />
slave.pcm dmix8<br />
slave.channels 8<br />
ttable.0.0 1<br />
ttable.1.1 1<br />
ttable.0.2 1<br />
ttable.1.3 1<br />
ttable.0.4 0.5<br />
ttable.1.4 0.5<br />
ttable.0.5 0.5<br />
ttable.1.5 0.5<br />
ttable.0.6 1<br />
ttable.1.7 1<br />
}<br />
<br />
# this creates a six channel soundcard<br />
# and outputs to the eight channel one<br />
# i.e. for usage in mplayer I had to define in ~/.mplayer/config:<br />
# ao=alsa:device=dmix6<br />
# channels=6<br />
pcm.dmix6 {<br />
type route<br />
slave.pcm dmix8<br />
slave.channels 8<br />
ttable.0.0 1<br />
ttable.1.1 1<br />
ttable.2.2 1<br />
ttable.3.3 1<br />
ttable.4.4 1<br />
ttable.5.5 1<br />
ttable.6.6 1<br />
ttable.7.7 1<br />
}<br />
<br />
# share the microphone, i.e. because virtualbox grabs it by default<br />
pcm.microphone {<br />
type dsnoop<br />
ipc_key 1027<br />
slave {<br />
pcm "snd_card"<br />
}<br />
}<br />
<br />
# rate conversion, needed i.e. for wine<br />
pcm.2chplug {<br />
type plug<br />
slave.pcm "ch71dup"<br />
}<br />
pcm.a2chplug {<br />
type plug<br />
slave.pcm "dmix8"<br />
}<br />
<br />
# routes the channel for the alternative<br />
# 2 channel output, which becomes the 7th and 8th channel <br />
# on the real soundcard<br />
#pcm.alt2ch {<br />
# type route<br />
# slave.pcm "a2chplug"<br />
# slave.channels 8<br />
# ttable.0.6 1<br />
# ttable.1.7 1<br />
#}<br />
<br />
# skype and ekiga are only mono, so route left channel to the right channel<br />
# note: this gets routed to the alternative 2 channels<br />
pcm.mono_playback {<br />
type route<br />
slave.pcm "a2chplug"<br />
slave.channels 8<br />
# Send Skype channel 0 to the L and R speakers at full volume<br />
#ttable.0.6 1<br />
#ttable.0.7 1<br />
}<br />
<br />
# 'full-duplex' device for use with aoss<br />
pcm.duplex {<br />
type asym<br />
playback.pcm "2chplug"<br />
capture.pcm "microphone"<br />
}<br />
<br />
#pcm.aduplex {<br />
# type asym<br />
# playback.pcm "alt2ch"<br />
# capture.pcm "microphone"<br />
#}<br />
<br />
pcm.monoduplex {<br />
type asym<br />
playback.pcm "mono_playback"<br />
capture.pcm "microphone"<br />
}<br />
<br />
# for aoss<br />
pcm.dsp0 "duplex"<br />
ctl.mixer0 "duplex"<br />
<br />
# softvol manages volume in alsa<br />
# i.e. wine likes this<br />
pcm.mainvol {<br />
type softvol<br />
slave.pcm "duplex"<br />
control {<br />
name "2ch-Upmix Master"<br />
card 0<br />
}<br />
}<br />
<br />
#pcm.!default "mainvol"<br />
<br />
# set the default device according to the environment<br />
# variable ALSA_DEFAULT_PCM and default to mainvol<br />
pcm.!default {<br />
@func refer<br />
name { @func concat <br />
strings [ "pcm."<br />
{ @func getenv<br />
vars [ ALSA_DEFAULT_PCM ]<br />
default "mainvol"<br />
}<br />
]<br />
}<br />
}<br />
<br />
# uncomment the following if you want to be able to control<br />
# the mixer device through environment variables as well<br />
#ctl.!default {<br />
# @func refer<br />
# name { @func concat <br />
# strings [ "ctl."<br />
# { @func getenv<br />
# vars [ ALSA_DEFAULT_CTL<br />
# ALSA_DEFAULT_PCM<br />
# ]<br />
# default "duplex"<br />
# }<br />
# ]<br />
# }<br />
#}<br />
<br />
===Surround51 incl. upmix stereo & dmix, swap L/R, bad speaker position in room===<br />
<br />
Bad practice but works fine for almost everything without additional per-program/file customization:<br />
pcm.!default {<br />
type route<br />
## forwards to the mixer pcm defined below<br />
slave.pcm dmix51<br />
slave.channels 6<br />
<br />
## "Native Channels" stereo, swap left/right<br />
ttable.0.1 1<br />
ttable.1.0 1<br />
## original normal left/right commented out<br />
# ttable.0.0 1<br />
# ttable.1.1 1<br />
<br />
## route "native surround" so it still works but weaken signal (+ RL/RF swap) <br />
## because my rear speakers are more like random than really behind me<br />
ttable.2.3 0.7<br />
ttable.3.2 0.7<br />
ttable.4.4 0.7<br />
ttable.5.5 0.7<br />
<br />
## stereo => quad speaker "upmix" for "rear" speakers + swap L/R<br />
ttable.0.3 1<br />
ttable.1.2 1<br />
<br />
## stereo L+R => join to Center & Subwoofer 50%/50%<br />
ttable.0.4 0.5<br />
ttable.1.4 0.5<br />
ttable.0.5 0.5<br />
ttable.1.5 0.5<br />
## to test: "$ speaker-test -c6 -twav" and: "$ speaker-test -c2 -twav"<br />
}<br />
<br />
pcm.dmix51 {<br />
type dmix<br />
ipc_key 1024<br />
# let multiple users share<br />
ipc_key_add_uid false <br />
# IPC permissions (octal, default 0600)<br />
# I think changing this fixed something - but I'm not sure what.<br />
ipc_perm 0660 # <br />
slave {<br />
## this is specific to my hda_intel. Often hd:0 is just allready it; To find: $ aplay -L <br />
pcm surround51 <br />
# this rate makes my soundcard crackle<br />
# rate 44100<br />
# this rate stops flash in firefox from playing audio, but I don't need that<br />
rate 48000<br />
channels 6<br />
## Any other values in the 4 lines below seem to make my soundcard crackle, too<br />
period_time 0<br />
period_size 1024<br />
buffer_time 0<br />
buffer_size 4096<br />
}<br />
}<br />
<br />
==External Resources==<br />
<br />
* [http://www.mjmwired.net/kernel/Documentation/sound/alsa/ALSA-Configuration.txt Advanced ALSA module configuration]<br />
* [http://alsa.opensrc.org/index.php/Main_Page Unofficial ALSA Wiki]<br />
* [http://alsa.opensrc.org/index.php/Aadebug A simple shell script to aid ALSA audio debugging]<br />
* [http://bbs.archlinux.org/viewtopic.php?id=36815 HOWTO: Compile driver from svn]<br />
* [http://gentoo-wiki.com/HOWTO_Set_up_a_system-wide_equaliser_with_ALSA_and_LADSPA HOWTO Set up a system-wide equaliser with ALSA and LADSPA]<br />
<br />
* [http://archux.com/page/setting-audio Simple instructions for setting up ALSA]<br />
<!-- vim: set ft=Wikipedia: --></div>Xrchzhttps://wiki.archlinux.org/index.php?title=Firefox/Profile_on_RAM&diff=118922Firefox/Profile on RAM2010-10-09T14:27:05Z<p>Xrchz: /* From the AUR */</p>
<hr />
<div>[[Category:Internet and Email (English)]]<br />
[[Category:Scripts (English)]]<br />
[[Category:HOWTOs (English)]]<br />
Assuming that there is memory to spare, caching all, or part of [[Firefox]]'s profile to RAM using [[Wikipedia:tmpfs|tmpfs]] offers significant advantages. Even though opting for the partial route is an improvement by itself, the latter can make Firefox even more responsive compared to its stock configuration. Benefits include, among others:<br />
*reduced disk read/writes (ideal for [[Maximizing performance#Tuning for an SSD|SSD]])<br />
*heightened responsive feel<br />
*many operations within Firefox, such as quick search and history queries, are nearly instantaneous<br />
<br />
Both of previously mentioned options make use of native shared memory; [[/dev/shm]], a directory that behaves just as ordinary mounted file systems do, only with the notable exception that all of its content is stored in RAM.<br />
<br />
Because data placed therein cannot survive a shutdown, a script used when [[#Relocating the entire profile to RAM|moving the whole profile to RAM]] overcomes this limitation by syncing back to disk prior system shut down, whereas [[#Relocating only the cache to RAM|only relocating the cache]] is a quick, less inclusive solution.<br />
<br />
==Relocating only the cache to RAM==<br />
<small>''Adapted from [http://bbs.archlinux.org/viewtopic.php?pid=604369 this forum post]''</small><br />
<br />
After entering {{codeline|about:config}} into the address bar, create a new string by right-clicking in the bottom half, selecting ''New'', followed by ''String''. Assign its value:<br />
browser.cache.disk.parent_directory<br />
<br />
Now, double-click the newly created string and direct it towards the RAM directory:<br />
/dev/shm/''firefox-cache''<br />
<br />
Finally, create the directory and ensure its permissions have security in mind:<br />
install -dm700 /dev/shm/''firefox-cache''<br />
<br />
Upon restarting Firefox, it will start using {{Filename|/dev/shm/firefox-cache}} as the cache directory. Do mind that the directory and its contents will ''not'' be saved after a reboot using this method.<br />
<br />
==Relocating the entire profile to RAM==<br />
===Warning===<br />
'''Note''' this is broken in the current version of firefox (3.6.3). The xpti engine freaks out and dies if filesystem links are involved in any addon that supplies a xpt file (see https://bugzilla.mozilla.org/show_bug.cgi?id=551152). That said, these instructions should resume working once firefox is fixed. A temporary workaround is to delete the compatibility.ini file before launching firefox, like so:<br />
{{file|name=/usr/bin/firefox|content=<br />
+ rm -f ~/.mozilla/firefox/*/compatibility.ini<br />
"$dist_bin/run-mozilla.sh" $script_args "$dist_bin/$MOZILLA_BIN" "$@"<br />
}}<br />
<br />
Another workaround, if {{Codeline|firefox}} fails to start, is to run {{Codeline|firefox --safe-mode}}, then just quit, then run {{Codeline|firefox}} again.<br />
<br />
===Before you start===<br />
Before potentially compromising Firefox's profile, be sure to make a backup for quick restoration. Replace {{codeline|xyz.default}} as appropriate and use {{codeline|tar}} to make a backup:<br />
$ tar zcvfp ~/firefox_profile_backup.tar.gz ~/.mozilla/firefox/'''xyz.default'''<br />
<br />
===The script===<br />
<small>''Adapted from [http://www.verot.net/firefox_tmpfs.htm verot.net's Speed up Firefox with tmpfs]''</small><br />
<br />
The script will first move Firefox's profile to a new static location, make a sub-directory in {{filename|/dev/shm}}, softlink to it and later populate it with the contents of the profile. As before, replace the bold sections to suit. The only value that absolutely needs to be altered is, again, {{codeline|xyz.default}}.<br />
<br />
Be sure that [[rsync]] is installed and save the script to {{filename|~/bin/firefox-sync}}, for example:<br />
{{file|name=firefox-sync|content=<br />
#!/bin/bash<br />
STATIC='''main'''<br />
LINK='''xyz.default'''<br />
VOLATILE='''/dev/shm/$USER/firefox'''<br />
<nowiki><br />
cd ~/.mozilla/firefox<br />
<br />
[[ -r $VOLATILE ]] || install -dm700 $VOLATILE<br />
<br />
if [[ `readlink $LINK` != $VOLATILE ]]; then<br />
mv $LINK $STATIC<br />
ln -s $VOLATILE $LINK<br />
fi<br />
<br />
if [[ -e $LINK/.unpacked ]]; then<br />
rsync -av --delete --exclude .unpacked ./$LINK/ ./$STATIC/<br />
else<br />
rsync -av ./$STATIC/ ./$LINK/<br />
touch $LINK/.unpacked<br />
fi<br />
</nowiki><br />
}}<br />
<br />
Close Firefox, make the script executable and test it:<br />
$ killall firefox; chmod +x ''~/bin/firefox-sync''; ''~/bin/firefox-sync''<br />
<br />
Run Firefox again to gauge the results. The second time the script runs, it will then preserve the RAM profile by copying it back to disk.<br />
Firefox could be called firefox-bin as well<br />
$ killall firefox'''-bin'''; chmod +x ''~/bin/firefox-sync''; ''~/bin/firefox-sync''<br />
<br />
===From the AUR===<br />
The script is available as a [http://aur.archlinux.org/packages.php?ID=41541 package].<br />
This version automatically picks the first {{codeline|xyz.default}} directory in your {{filename|~/.mozilla/firefox}} (although that means you should install it with sudo, not as root).<br />
<br />
The script also provides a firefox wrapper {{codeline|syncfox}}, which runs {{codeline|firefox-sync}} before and after {{codeline|firefox}}. This is an alternative to syncing with cron, or on login/logout (described below). Be careful with the "Restart Firefox" button within firefox, though, since this might not start the wrapper.<br />
<br />
===Automation===<br />
Seeing that forgetting to sync the profile can lead to disastrous results, automating the process seems like a logical course of action.<br />
<br />
===cron job===<br />
Manipulate the user's [[cron]] table using {{codeline|crontab}}:<br />
$ crontab -e<br />
<br />
Add a line to start the script every 30 minutes,<br />
*/30 * * * * ''~/bin/firefox-sync''<br />
or add the following to do so every 2 hours:<br />
0 */2 * * * ''~/bin/firefox-sync''<br />
<br />
===Sync at login/logout===<br />
Deeming [[bash]] is being used, add the script to the login/logout files:<br />
$ echo '<i>~/bin/firefox-sync</i>' | tee -a ~/.bash_logout ~/.bash_login >/dev/null<br />
<br />
== Resources ==<br />
* [http://en.wikipedia.org/wiki/Tmpfs tmpfs] on Wikipedia<br />
* [[Fstab#tmpfs]]</div>Xrchzhttps://wiki.archlinux.org/index.php?title=/dev/shm&diff=118920/dev/shm2010-10-09T14:16:18Z<p>Xrchz: /* Script-based Method */ Fix bug in script - precedence problem with || and ; in bash?</p>
<hr />
<div>[[Category: Kernel (English)]]<br />
[[Category: File systems (English)]]<br />
The following introduction was taken from [http://www.cyberciti.biz/tips/what-is-devshm-and-its-practical-usage.html nixCraft's article on /dev/shm]:<br />
<br />
:"''<b>/dev/shm</b> is nothing but implementation of traditional shared memory concept. It is an efficient means of passing data between programs. One program will create a memory portion, which other processes (if permitted) can access. This will result into speeding up things on Linux. shm / shmfs is also known as tmpfs, which is a common name for a temporary file storage facility on many Unix-like operating systems. It is intended to appear as a mounted file system, but one which uses virtual memory instead of a persistent storage device. If you type mount command you will see /dev/shm as a tempfs file system. Therefore, it is a file system, which keeps all files in virtual memory. Everything in tmpfs is temporary in the sense that no files will be created on your hard drive. If you unmount a tmpfs instance, everything stored therein is lost. By default almost all Linux distros configured to use /dev/shm.''"<br />
<br />
==Settings==<br />
Alter {{filename|/etc/fstab}}'s entry for {{filename|/dev/shm}} and apply settings with {{codeline|mount -a}}, or reboot:<br />
none /dev/shm tmpfs defaults,size=768M,noexec,nodev,nosuid 0 0<br />
<br />
;size: Accepts 'k', 'm' or 'g' and their capitalized versions as units<br />
;noexec,nodev,nosuid: Universal options for most file-systems affecting permissions. See: {{codeline|man mount}}<br />
<br />
==Usage==<br />
Generally speaking, IO intensive tasks that benefit from fast, No-HDD-read/write-space, such as video encoding, gaming, etc. can make extensive use out of {{filename|shm}}. However, that's not to say that simpler applications can't recieve substantial gains from offloading data onto shared memory. [[Firefox]], for example, shows that having its [[Speed-up Firefox using tmpfs|profile relocated into ram]] makes a big difference.<br />
<br />
===Improving compile times===<br />
==== Script-based Method ====<br />
This is a small script that links [[makepkg]]'s build space to a sub-directory in {{filename|shm}}. Be sure to run it where the [[PKGBUILD]] is located. Also keep in mind that when it detects that a package is ''already'' cached in RAM, the script purges the package's cached build directory.<br />
{{file|name=makepkg-shm|content=<br />
#!/bin/bash<br />
BUILDSCRIPT=PKGBUILD<br />
srcdir=src<br />
<nowiki><br />
. $BUILDSCRIPT || (echo "Error: Failed to source \`$BUILDSCRIPT'"; exit 1)<br />
volatile=/dev/shm/$USER/makepkg/$pkgname<br />
<br />
if [[ -f $srcdir/.tmpfs ]]; then<br />
rm -rf $volatile $srcdir<br />
echo "Success: Purged \`$srcdir' and \`$volatile'"<br />
elif [[ -e $srcdir && `readlink $srcdir` != $volatile ]]; then<br />
echo "Error: \`$srcdir' exists and is not a link to \`$volatile', aborting"; exit 2<br />
else<br />
install -dm700 $volatile<br />
ln -s $volatile $srcdir<br />
touch $srcdir/.tmpfs<br />
echo "Success: \`$srcdir' linked to \`$volatile'"<br />
fi<br />
</nowiki><br />
}}<br />
<br />
Save it as {{filename|~/bin/makepkg-shm}}, for example, and make it executable:<br />
$ chmod +x ~/bin/makepkg-shm<br />
<br />
Or get it from the [http://aur.archlinux.org/packages.php?ID=41579 AUR].<br />
<br />
==== .bashrc-based Method ====<br />
<br />
Another method is to simply add a few lines to {{Filename|~/.bashrc}} which simply copies the directory containing the PKGBUILD, files to /dev/shm which can be accomplished by appending the following to said file:<br />
<br />
bi () {<br />
cp -a $1 /dev/shm<br />
cd /dev/shm/$1<br />
here=`pwd`<br />
echo you are here $here<br />
}<br />
<br />
$1 is the first arg which is the dir name you wish to copy. Example:<br />
<br />
bi /path/to/pkgbuild_files/firefox-pgo<br />
you are here /dev/shm/firefox-pgo</div>Xrchzhttps://wiki.archlinux.org/index.php?title=Firefox/Profile_on_RAM&diff=118885Firefox/Profile on RAM2010-10-09T07:38:54Z<p>Xrchz: /* From the AUR */</p>
<hr />
<div>[[Category:Internet and Email (English)]]<br />
[[Category:Scripts (English)]]<br />
[[Category:HOWTOs (English)]]<br />
Assuming that there is memory to spare, caching all, or part of [[Firefox]]'s profile to RAM using [[Wikipedia:tmpfs|tmpfs]] offers significant advantages. Even though opting for the partial route is an improvement by itself, the latter can make Firefox even more responsive compared to its stock configuration. Benefits include, among others:<br />
*reduced disk read/writes (ideal for [[Maximizing performance#Tuning for an SSD|SSD]])<br />
*heightened responsive feel<br />
*many operations within Firefox, such as quick search and history queries, are nearly instantaneous<br />
<br />
Both of previously mentioned options make use of native shared memory; [[/dev/shm]], a directory that behaves just as ordinary mounted file systems do, only with the notable exception that all of its content is stored in RAM.<br />
<br />
Because data placed therein cannot survive a shutdown, a script used when [[#Relocating the entire profile to RAM|moving the whole profile to RAM]] overcomes this limitation by syncing back to disk prior system shut down, whereas [[#Relocating only the cache to RAM|only relocating the cache]] is a quick, less inclusive solution.<br />
<br />
==Relocating only the cache to RAM==<br />
<small>''Adapted from [http://bbs.archlinux.org/viewtopic.php?pid=604369 this forum post]''</small><br />
<br />
After entering {{codeline|about:config}} into the address bar, create a new string by right-clicking in the bottom half, selecting ''New'', followed by ''String''. Assign its value:<br />
browser.cache.disk.parent_directory<br />
<br />
Now, double-click the newly created string and direct it towards the RAM directory:<br />
/dev/shm/''firefox-cache''<br />
<br />
Finally, create the directory and ensure its permissions have security in mind:<br />
install -dm700 /dev/shm/''firefox-cache''<br />
<br />
Upon restarting Firefox, it will start using {{Filename|/dev/shm/firefox-cache}} as the cache directory. Do mind that the directory and its contents will ''not'' be saved after a reboot using this method.<br />
<br />
==Relocating the entire profile to RAM==<br />
===Warning===<br />
'''Note''' this is broken in the current version of firefox (3.6.3). The xpti engine freaks out and dies if filesystem links are involved in any addon that supplies a xpt file (see https://bugzilla.mozilla.org/show_bug.cgi?id=551152). That said, these instructions should resume working once firefox is fixed. A temporary workaround is to delete the compatibility.ini file before launching firefox, like so:<br />
{{file|name=/usr/bin/firefox|content=<br />
+ rm -f ~/.mozilla/firefox/*/compatibility.ini<br />
"$dist_bin/run-mozilla.sh" $script_args "$dist_bin/$MOZILLA_BIN" "$@"<br />
}}<br />
<br />
Another workaround, if {{Codeline|firefox}} fails to start, is to run {{Codeline|firefox --safe-mode}}, then just quit, then run {{Codeline|firefox}} again.<br />
<br />
===Before you start===<br />
Before potentially compromising Firefox's profile, be sure to make a backup for quick restoration. Replace {{codeline|xyz.default}} as appropriate and use {{codeline|tar}} to make a backup:<br />
$ tar zcvfp ~/firefox_profile_backup.tar.gz ~/.mozilla/firefox/'''xyz.default'''<br />
<br />
===The script===<br />
<small>''Adapted from [http://www.verot.net/firefox_tmpfs.htm verot.net's Speed up Firefox with tmpfs]''</small><br />
<br />
The script will first move Firefox's profile to a new static location, make a sub-directory in {{filename|/dev/shm}}, softlink to it and later populate it with the contents of the profile. As before, replace the bold sections to suit. The only value that absolutely needs to be altered is, again, {{codeline|xyz.default}}.<br />
<br />
Be sure that [[rsync]] is installed and save the script to {{filename|~/bin/firefox-sync}}, for example:<br />
{{file|name=firefox-sync|content=<br />
#!/bin/bash<br />
STATIC='''main'''<br />
LINK='''xyz.default'''<br />
VOLATILE='''/dev/shm/$USER/firefox'''<br />
<nowiki><br />
cd ~/.mozilla/firefox<br />
<br />
[[ -r $VOLATILE ]] || install -dm700 $VOLATILE<br />
<br />
if [[ `readlink $LINK` != $VOLATILE ]]; then<br />
mv $LINK $STATIC<br />
ln -s $VOLATILE $LINK<br />
fi<br />
<br />
if [[ -e $LINK/.unpacked ]]; then<br />
rsync -av --delete --exclude .unpacked ./$LINK/ ./$STATIC/<br />
else<br />
rsync -av ./$STATIC/ ./$LINK/<br />
touch $LINK/.unpacked<br />
fi<br />
</nowiki><br />
}}<br />
<br />
Close Firefox, make the script executable and test it:<br />
$ killall firefox; chmod +x ''~/bin/firefox-sync''; ''~/bin/firefox-sync''<br />
<br />
Run Firefox again to gauge the results. The second time the script runs, it will then preserve the RAM profile by copying it back to disk.<br />
Firefox could be called firefox-bin as well<br />
$ killall firefox'''-bin'''; chmod +x ''~/bin/firefox-sync''; ''~/bin/firefox-sync''<br />
<br />
===From the AUR===<br />
The script is available as a [http://aur.archlinux.org/packages.php?ID=41541 package].<br />
This version automatically picks the first {{codeline|xyz.default}} directory in your {{filename|~/.mozilla/firefox}} (although that means you should install it with sudo, not as root).<br />
<br />
The script also provides a firefox wrapper {{codeline|syncfox}}, which runs {{codeline|firefox-sync}} before and after {{codeline|firefox}}. This is an alternative to syncing with cron, or on login/logout (described below).<br />
<br />
===Automation===<br />
Seeing that forgetting to sync the profile can lead to disastrous results, automating the process seems like a logical course of action.<br />
<br />
===cron job===<br />
Manipulate the user's [[cron]] table using {{codeline|crontab}}:<br />
$ crontab -e<br />
<br />
Add a line to start the script every 30 minutes,<br />
*/30 * * * * ''~/bin/firefox-sync''<br />
or add the following to do so every 2 hours:<br />
0 */2 * * * ''~/bin/firefox-sync''<br />
<br />
===Sync at login/logout===<br />
Deeming [[bash]] is being used, add the script to the login/logout files:<br />
$ echo '<i>~/bin/firefox-sync</i>' | tee -a ~/.bash_logout ~/.bash_login >/dev/null<br />
<br />
== Resources ==<br />
* [http://en.wikipedia.org/wiki/Tmpfs tmpfs] on Wikipedia<br />
* [[Fstab#tmpfs]]</div>Xrchzhttps://wiki.archlinux.org/index.php?title=Firefox/Profile_on_RAM&diff=118884Firefox/Profile on RAM2010-10-09T07:38:35Z<p>Xrchz: /* From the AUR */</p>
<hr />
<div>[[Category:Internet and Email (English)]]<br />
[[Category:Scripts (English)]]<br />
[[Category:HOWTOs (English)]]<br />
Assuming that there is memory to spare, caching all, or part of [[Firefox]]'s profile to RAM using [[Wikipedia:tmpfs|tmpfs]] offers significant advantages. Even though opting for the partial route is an improvement by itself, the latter can make Firefox even more responsive compared to its stock configuration. Benefits include, among others:<br />
*reduced disk read/writes (ideal for [[Maximizing performance#Tuning for an SSD|SSD]])<br />
*heightened responsive feel<br />
*many operations within Firefox, such as quick search and history queries, are nearly instantaneous<br />
<br />
Both of previously mentioned options make use of native shared memory; [[/dev/shm]], a directory that behaves just as ordinary mounted file systems do, only with the notable exception that all of its content is stored in RAM.<br />
<br />
Because data placed therein cannot survive a shutdown, a script used when [[#Relocating the entire profile to RAM|moving the whole profile to RAM]] overcomes this limitation by syncing back to disk prior system shut down, whereas [[#Relocating only the cache to RAM|only relocating the cache]] is a quick, less inclusive solution.<br />
<br />
==Relocating only the cache to RAM==<br />
<small>''Adapted from [http://bbs.archlinux.org/viewtopic.php?pid=604369 this forum post]''</small><br />
<br />
After entering {{codeline|about:config}} into the address bar, create a new string by right-clicking in the bottom half, selecting ''New'', followed by ''String''. Assign its value:<br />
browser.cache.disk.parent_directory<br />
<br />
Now, double-click the newly created string and direct it towards the RAM directory:<br />
/dev/shm/''firefox-cache''<br />
<br />
Finally, create the directory and ensure its permissions have security in mind:<br />
install -dm700 /dev/shm/''firefox-cache''<br />
<br />
Upon restarting Firefox, it will start using {{Filename|/dev/shm/firefox-cache}} as the cache directory. Do mind that the directory and its contents will ''not'' be saved after a reboot using this method.<br />
<br />
==Relocating the entire profile to RAM==<br />
===Warning===<br />
'''Note''' this is broken in the current version of firefox (3.6.3). The xpti engine freaks out and dies if filesystem links are involved in any addon that supplies a xpt file (see https://bugzilla.mozilla.org/show_bug.cgi?id=551152). That said, these instructions should resume working once firefox is fixed. A temporary workaround is to delete the compatibility.ini file before launching firefox, like so:<br />
{{file|name=/usr/bin/firefox|content=<br />
+ rm -f ~/.mozilla/firefox/*/compatibility.ini<br />
"$dist_bin/run-mozilla.sh" $script_args "$dist_bin/$MOZILLA_BIN" "$@"<br />
}}<br />
<br />
Another workaround, if {{Codeline|firefox}} fails to start, is to run {{Codeline|firefox --safe-mode}}, then just quit, then run {{Codeline|firefox}} again.<br />
<br />
===Before you start===<br />
Before potentially compromising Firefox's profile, be sure to make a backup for quick restoration. Replace {{codeline|xyz.default}} as appropriate and use {{codeline|tar}} to make a backup:<br />
$ tar zcvfp ~/firefox_profile_backup.tar.gz ~/.mozilla/firefox/'''xyz.default'''<br />
<br />
===The script===<br />
<small>''Adapted from [http://www.verot.net/firefox_tmpfs.htm verot.net's Speed up Firefox with tmpfs]''</small><br />
<br />
The script will first move Firefox's profile to a new static location, make a sub-directory in {{filename|/dev/shm}}, softlink to it and later populate it with the contents of the profile. As before, replace the bold sections to suit. The only value that absolutely needs to be altered is, again, {{codeline|xyz.default}}.<br />
<br />
Be sure that [[rsync]] is installed and save the script to {{filename|~/bin/firefox-sync}}, for example:<br />
{{file|name=firefox-sync|content=<br />
#!/bin/bash<br />
STATIC='''main'''<br />
LINK='''xyz.default'''<br />
VOLATILE='''/dev/shm/$USER/firefox'''<br />
<nowiki><br />
cd ~/.mozilla/firefox<br />
<br />
[[ -r $VOLATILE ]] || install -dm700 $VOLATILE<br />
<br />
if [[ `readlink $LINK` != $VOLATILE ]]; then<br />
mv $LINK $STATIC<br />
ln -s $VOLATILE $LINK<br />
fi<br />
<br />
if [[ -e $LINK/.unpacked ]]; then<br />
rsync -av --delete --exclude .unpacked ./$LINK/ ./$STATIC/<br />
else<br />
rsync -av ./$STATIC/ ./$LINK/<br />
touch $LINK/.unpacked<br />
fi<br />
</nowiki><br />
}}<br />
<br />
Close Firefox, make the script executable and test it:<br />
$ killall firefox; chmod +x ''~/bin/firefox-sync''; ''~/bin/firefox-sync''<br />
<br />
Run Firefox again to gauge the results. The second time the script runs, it will then preserve the RAM profile by copying it back to disk.<br />
Firefox could be called firefox-bin as well<br />
$ killall firefox'''-bin'''; chmod +x ''~/bin/firefox-sync''; ''~/bin/firefox-sync''<br />
<br />
===From the AUR===<br />
The script is available as a [http://aur.archlinux.org/packages.php?ID=41541 package].<br />
This version automatically picks the first {{codeline|xyz.default}} directory in your {{filename|~/.mozilla/firefox}} (although that means you should install it with sudo, not as root).<br />
<br />
The script also provides a firefox wrapper {{codeline|syncfox}}, which runs {{codeline|firefox-sync}} before and after {{codeline|firefox}}. This is an alternative to syncing with cron, or on login/logout.<br />
<br />
===Automation===<br />
Seeing that forgetting to sync the profile can lead to disastrous results, automating the process seems like a logical course of action.<br />
<br />
===cron job===<br />
Manipulate the user's [[cron]] table using {{codeline|crontab}}:<br />
$ crontab -e<br />
<br />
Add a line to start the script every 30 minutes,<br />
*/30 * * * * ''~/bin/firefox-sync''<br />
or add the following to do so every 2 hours:<br />
0 */2 * * * ''~/bin/firefox-sync''<br />
<br />
===Sync at login/logout===<br />
Deeming [[bash]] is being used, add the script to the login/logout files:<br />
$ echo '<i>~/bin/firefox-sync</i>' | tee -a ~/.bash_logout ~/.bash_login >/dev/null<br />
<br />
== Resources ==<br />
* [http://en.wikipedia.org/wiki/Tmpfs tmpfs] on Wikipedia<br />
* [[Fstab#tmpfs]]</div>Xrchzhttps://wiki.archlinux.org/index.php?title=Talk:Disable_clearing_of_boot_messages&diff=118883Talk:Disable clearing of boot messages2010-10-09T06:45:59Z<p>Xrchz: </p>
<hr />
<div>{{cli|% read -t5 -n1<br/><br />
zsh: bad option: -1}}<br />
<br />
What's going on here?<br />
<br />
Oh I guess zsh read is different from bash read... Is it definitely going to be bash for rc.local?</div>Xrchzhttps://wiki.archlinux.org/index.php?title=Talk:Disable_clearing_of_boot_messages&diff=118882Talk:Disable clearing of boot messages2010-10-09T06:42:52Z<p>Xrchz: </p>
<hr />
<div>{{cli|% read -t5 -n1<br/><br />
zsh: bad option: -1}}<br />
<br />
What's going on here?</div>Xrchzhttps://wiki.archlinux.org/index.php?title=/dev/shm&diff=118853/dev/shm2010-10-08T23:05:43Z<p>Xrchz: /* Script-based Method */</p>
<hr />
<div>[[Category: Kernel (English)]]<br />
[[Category: File systems (English)]]<br />
The following introduction was taken from [http://www.cyberciti.biz/tips/what-is-devshm-and-its-practical-usage.html nixCraft's article on /dev/shm]:<br />
<br />
:"''<b>/dev/shm</b> is nothing but implementation of traditional shared memory concept. It is an efficient means of passing data between programs. One program will create a memory portion, which other processes (if permitted) can access. This will result into speeding up things on Linux. shm / shmfs is also known as tmpfs, which is a common name for a temporary file storage facility on many Unix-like operating systems. It is intended to appear as a mounted file system, but one which uses virtual memory instead of a persistent storage device. If you type mount command you will see /dev/shm as a tempfs file system. Therefore, it is a file system, which keeps all files in virtual memory. Everything in tmpfs is temporary in the sense that no files will be created on your hard drive. If you unmount a tmpfs instance, everything stored therein is lost. By default almost all Linux distros configured to use /dev/shm.''"<br />
<br />
==Settings==<br />
Alter {{filename|/etc/fstab}}'s entry for {{filename|/dev/shm}} and apply settings with {{codeline|mount -a}}, or reboot:<br />
none /dev/shm tmpfs defaults,size=768M,noexec,nodev,nosuid 0 0<br />
<br />
;size: Accepts 'k', 'm' or 'g' and their capitalized versions as units<br />
;noexec,nodev,nosuid: Universal options for most file-systems affecting permissions. See: {{codeline|man mount}}<br />
<br />
==Usage==<br />
Generally speaking, IO intensive tasks that benefit from fast, No-HDD-read/write-space, such as video encoding, gaming, etc. can make extensive use out of {{filename|shm}}. However, that's not to say that simpler applications can't recieve substantial gains from offloading data onto shared memory. [[Firefox]], for example, shows that having its [[Speed-up Firefox using tmpfs|profile relocated into ram]] makes a big difference.<br />
<br />
===Improving compile times===<br />
==== Script-based Method ====<br />
This is a small script that links [[makepkg]]'s build space to a sub-directory in {{filename|shm}}. Be sure to run it where the [[PKGBUILD]] is located. Also keep in mind that when it detects that a package is ''already'' cached in RAM, the script purges the package's cached build directory.<br />
{{file|name=makepkg-shm|content=<br />
#!/bin/bash<br />
BUILDSCRIPT=PKGBUILD<br />
srcdir=src<br />
<nowiki><br />
. $BUILDSCRIPT || echo "Error: Failed to source \`$BUILDSCRIPT'"; exit 1<br />
volatile=/dev/shm/$USER/makepkg/$pkgname<br />
<br />
if [[ -f $srcdir/.tmpfs ]]; then<br />
rm -rf $volatile $srcdir<br />
echo "Success: Purged \`$srcdir' and \`$volatile'"<br />
elif [[ -e $srcdir && `readlink $srcdir` != $volatile ]]; then<br />
echo "Error: \`$srcdir' exists and is not a link to \`$volatile', aborting"; exit 2<br />
else<br />
install -dm700 $volatile<br />
ln -s $volatile $srcdir<br />
touch $srcdir/.tmpfs<br />
echo "Success: \`$srcdir' linked to \`$volatile'"<br />
fi<br />
</nowiki><br />
}}<br />
<br />
Save it as {{filename|~/bin/makepkg-shm}}, for example, and make it executable:<br />
$ chmod +x ~/bin/makepkg-shm<br />
<br />
Or get it from the [http://aur.archlinux.org/packages.php?ID=41579 AUR].<br />
<br />
==== .bashrc-based Method ====<br />
<br />
Another method is to simply add a few lines to {{Filename|~/.bashrc}} which simply copies the directory containing the PKGBUILD, files to /dev/shm which can be accomplished by appending the following to said file:<br />
<br />
bi () {<br />
cp -a $1 /dev/shm<br />
cd /dev/shm/$1<br />
here=`pwd`<br />
echo you are here $here<br />
}<br />
<br />
$1 is the first arg which is the dir name you wish to copy. Example:<br />
<br />
bi /path/to/pkgbuild_files/firefox-pgo<br />
you are here /dev/shm/firefox-pgo</div>Xrchzhttps://wiki.archlinux.org/index.php?title=Firefox/Profile_on_RAM&diff=118802Firefox/Profile on RAM2010-10-07T19:43:29Z<p>Xrchz: /* Relocating the entire profile to RAM */ added link to aur pkg</p>
<hr />
<div>[[Category:Internet and Email (English)]]<br />
[[Category:Scripts (English)]]<br />
[[Category:HOWTOs (English)]]<br />
Assuming that there is memory to spare, caching all, or part of [[Firefox]]'s profile to RAM using [[Wikipedia:tmpfs|tmpfs]] offers significant advantages. Even though opting for the partial route is an improvement by itself, the latter can make Firefox even more responsive compared to its stock configuration. Benefits include, among others:<br />
*reduced disk read/writes (ideal for [[Maximizing performance#Tuning for an SSD|SSD]])<br />
*heightened responsive feel<br />
*many operations within Firefox, such as quick search and history queries, are nearly instantaneous<br />
<br />
Both of previously mentioned options make use of native shared memory; [[/dev/shm]], a directory that behaves just as ordinary mounted file systems do, only with the notable exception that all of its content is stored in RAM.<br />
<br />
Because data placed therein cannot survive a shutdown, a script used when [[#Relocating the entire profile to RAM|moving the whole profile to RAM]] overcomes this limitation by syncing back to disk prior system shut down, whereas [[#Relocating only the cache to RAM|only relocating the cache]] is a quick, less inclusive solution.<br />
<br />
==Relocating only the cache to RAM==<br />
<small>''Adapted from [http://bbs.archlinux.org/viewtopic.php?pid=604369 this forum post]''</small><br />
<br />
After entering {{codeline|about:config}} into the address bar, create a new string by right-clicking in the bottom half, selecting ''New'', followed by ''String''. Assign its value:<br />
browser.cache.disk.parent_directory<br />
<br />
Now, double-click the newly created string and direct it towards the RAM directory:<br />
/dev/shm/''firefox-cache''<br />
<br />
Finally, create the directory and ensure its permissions have security in mind:<br />
install -dm700 /dev/shm/''firefox-cache''<br />
<br />
Upon restarting Firefox, it will start using {{Filename|/dev/shm/firefox-cache}} as the cache directory. Do mind that the directory and its contents will ''not'' be saved after a reboot using this method.<br />
<br />
==Relocating the entire profile to RAM==<br />
===Warning===<br />
'''Note''' this is broken in the current version of firefox (3.6.3). The xpti engine freaks out and dies if filesystem links are involved in any addon that supplies a xpt file (see https://bugzilla.mozilla.org/show_bug.cgi?id=551152). That said, these instructions should resume working once firefox is fixed. A temporary workaround is to delete the compatibility.ini file before launching firefox, like so:<br />
{{file|name=/usr/bin/firefox|content=<br />
+ rm -f ~/.mozilla/firefox/*/compatibility.ini<br />
"$dist_bin/run-mozilla.sh" $script_args "$dist_bin/$MOZILLA_BIN" "$@"<br />
}}<br />
<br />
Another workaround, if {{Codeline|firefox}} fails to start, is to run {{Codeline|firefox --safe-mode}}, then just quit, then run {{Codeline|firefox}} again.<br />
<br />
===Before you start===<br />
Before potentially compromising Firefox's profile, be sure to make a backup for quick restoration. Replace {{codeline|xyz.default}} as appropriate and use {{codeline|tar}} to make a backup:<br />
$ tar zcvfp ~/firefox_profile_backup.tar.gz ~/.mozilla/firefox/'''xyz.default'''<br />
<br />
===The script===<br />
<small>''Adapted from [http://www.verot.net/firefox_tmpfs.htm verot.net's Speed up Firefox with tmpfs]''</small><br />
<br />
The script will first move Firefox's profile to a new static location, make a sub-directory in {{filename|/dev/shm}}, softlink to it and later populate it with the contents of the profile. As before, replace the bold sections to suit. The only value that absolutely needs to be altered is, again, {{codeline|xyz.default}}.<br />
<br />
Be sure that [[rsync]] is installed and save the script to {{filename|~/bin/firefox-sync}}, for example:<br />
{{file|name=firefox-sync|content=<br />
#!/bin/bash<br />
STATIC='''main'''<br />
LINK='''xyz.default'''<br />
VOLATILE='''/dev/shm/$USER/firefox'''<br />
<nowiki><br />
cd ~/.mozilla/firefox<br />
<br />
[[ -r $VOLATILE ]] || install -dm700 $VOLATILE<br />
<br />
if [[ `readlink $LINK` != $VOLATILE ]]; then<br />
mv $LINK $STATIC<br />
ln -s $VOLATILE $LINK<br />
fi<br />
<br />
if [[ -e $LINK/.unpacked ]]; then<br />
rsync -av --delete --exclude .unpacked ./$LINK/ ./$STATIC/<br />
else<br />
rsync -av ./$STATIC/ ./$LINK/<br />
touch $LINK/.unpacked<br />
fi<br />
</nowiki><br />
}}<br />
<br />
Close Firefox, make the script executable and test it:<br />
$ killall firefox; chmod +x ''~/bin/firefox-sync''; ''~/bin/firefox-sync''<br />
<br />
Run Firefox again to gauge the results. The second time the script runs, it will then preserve the RAM profile by copying it back to disk.<br />
Firefox could be called firefox-bin as well<br />
$ killall firefox'''-bin'''; chmod +x ''~/bin/firefox-sync''; ''~/bin/firefox-sync''<br />
<br />
===From the AUR===<br />
The script is available as a [http://aur.archlinux.org/packages.php?ID=41541 package].<br />
This version automatically picks the first {{codeline|xyz.default}} directory in your {{filename|~/.mozilla/firefox}} (although that means you should install it with sudo, not as root).<br />
<br />
===Automation===<br />
Seeing that forgetting to sync the profile can lead to disastrous results, automating the process seems like a logical course of action.<br />
<br />
===cron job===<br />
Manipulate the user's [[cron]] table using {{codeline|crontab}}:<br />
$ crontab -e<br />
<br />
Add a line to start the script every 30 minutes,<br />
*/30 * * * * ''~/bin/firefox-sync''<br />
or add the following to do so every 2 hours:<br />
0 */2 * * * ''~/bin/firefox-sync''<br />
<br />
===Sync at login/logout===<br />
Deeming [[bash]] is being used, add the script to the login/logout files:<br />
$ echo '<i>~/bin/firefox-sync</i>' | tee -a ~/.bash_logout ~/.bash_login >/dev/null<br />
<br />
== Resources ==<br />
* [http://en.wikipedia.org/wiki/Tmpfs tmpfs] on Wikipedia<br />
* [[Fstab#tmpfs]]</div>Xrchzhttps://wiki.archlinux.org/index.php?title=Solid_state_drive&diff=118102Solid state drive2010-09-26T08:06:24Z<p>Xrchz: /* Partition Alignment */</p>
<hr />
<div>[[Category: Storage (English)]]<br />
{{expansion}}<br />
{{Article summary start}}<br />
{{Article summary text|This article covers many aspects of SSDs (solid state drives) as they relate to Linux; however, the underlying principals and key learning presented within are general enough to be applicable to users running SSDs on other operating systems such as the Windows family of products as well as MacOS X. Beyond the aforementioned information, Linux users will benefit from the tweaks/optimization presented herein.}}<br />
{{Article summary heading|Related Articles}}<br />
{{Article summary wiki|SSD Benchmarking}}<br />
{{Article summary wiki|SSD Memory Cell Clearing}}<br />
{{Article summary end}}<br />
<br />
==Introduction==<br />
Solid State Drives (SSDs) are not PnP devices. Special considerations such as partition alignment, choice of file system, TRIM support, etc. are needed to setup SSDs for optimal performance. This article attempts to capture referenced, key learnings to enable users to get the most out of SSDs under Linux. Users are encouraged to read this article in its entirety before acting on recommendations as the content is organized by topic, not necessarily by any systematic or chronologically relevant order.<br />
<br />
{{Note|This article is targeted at users running Linux, but much of the content is also relevant to our friends using both Windows and MacOS X.}}<br />
===Advantages over HDDs===<br />
*Fast read speeds - 2-3x faster than modern desktop HDDs (7,200 RPM using SATA2 interface).<br />
*Sustained read speeds - No decrease in read speed across the entirety of the device. HDD performance tapers off as the drive heads move from the center to the end of the HDD.<br />
*Minimal access time - Approx. 0.1 ms (100 ns) vs. 12-20 ms (12,000-20,000 ns) for desktop HDDs.<br />
*High degree of reliability.<br />
*No moving parts.<br />
*Minimal heat production.<br />
*Minimal power consumption - Fractions of a W at idle and 1-2 W while reading/writing vs. 10-30 W for a HDD depending on RPMs.<br />
*Light-weight - ideal for laptops.<br />
<br />
===Limitations===<br />
*Cost - High cost per GB vs. HDDs (dollars per GB vs. pennies per GB).<br />
*Capacity.<br />
<br />
==Pre-Purchase Considerations==<br />
There are several key features to look for prior to purchasing a contemporary SSD.<br />
===Key Features===<br />
*Native [http://en.wikipedia.org/wiki/TRIM TRIM] support is a vital feature that both prolongs SSD lifetime and reduces loss of performance for write operations over time.<br />
*Buying the right sized SSD is key. As with all filesystems, target <75 % occupancy for all SSD partitions to ensure efficient use by the kernel.<br />
<br />
===Reviews===<br />
This section is not meant to be all-inclusive, but does capture some key reviews.<br />
*[http://www.anandtech.com/show/2738 SSD Anthology (history lesson, a bit dated)]<br />
*[http://www.anandtech.com/show/2829 SSD Relapse (refresher and more up to date]<br />
*[http://forums.anandtech.com/showthread.php?t=2069761 One user's recommendations]<br />
<br />
==Tips for Maximizing SSD Performance==<br />
===Partition Alignment ===<br />
===== High-level Overview =====<br />
'''Proper partition alignment is essential for optimal performance and longevity.''' Key to alignment is partitioning to (at least) the EBS (erase block size) of the SSD. <br />
<br />
{{Note|The EBS is largely vendor specific; a google search on the model of interest would be a good idea! The Intel X25-M for example is thought to have an EBS of 512 KiB, but Intel has yet to publish anything officially to this end.}}<br />
<br />
If the partitions aren't aligned to begin at multiples of the EBS (512 KiB for example), aligning the file system is a pointless exercise because everything is skewed by the start offset of the partition. Traditionally, hard drives were addressed by indicating the ''cylinder'', the ''head'', and the ''sector'' at which data was to be read or written. These represented the radial position, the drive head (= platter and side) and the axial position of the data respectively. With LBA (logical block addressing), this is no longer the case. Instead, the entire hard drive is addressed as one continuous stream of data.<br />
<br />
The Linux utility fdisk, however, still uses a virtual C-H-S system where users can define any number of heads and sectors (the cylinders are calculated automatically from the drive's capacity), with partitions always starting and ending at intervals of heads x cylinders. '''Thus, one needs to choose a number of heads and sectors of which the SSD's erase block size is a multiple.''' This is accomplished by setting the number of heads (or tracks per cylinder) and sectors (per track) to coincide with the EBS.<br />
<br />
Ted Tso recommends using a setting of [http://ldn.linuxfoundation.org/blog-entry/aligning-filesystems-ssd%E2%80%99s-erase-block-size 224*56] (=2^8*49) which results in (2^8*512=) 128 KiB alignment:<br />
<br />
# fdisk -H 224 -S 56 /dev/sdX<br />
<br />
While others advocate a setting of [http://www.nuclex.org/blog/personal/80-aligning-an-ssd-on-linux 32*32] (=2^10) which results in (2^10*512=) 512 KiB alignment:<br />
<br />
# fdisk -H 32 -S 32 /dev/sdX<br />
<br />
How does the math work out? The alignment number is the largest power-of-two divisor of the cylinder boundary positions on the disk. The size in bytes of the cylinders is H*S*512 = (tracks per cylinder) * (sectors per track) * (sector size). Factorize H, S and sector size (512=2^9) into prime factors, and take all the 2s. In the first case above we have to ignore the non-power-of-two factor of 7^2=49.<br />
<br />
{{Note|In order to be compatible with MS-DOS, a partition starting on the first cylinder would skip one track, reducing its alignment to track level (4k for -S 56 and 16k for -S 32). The easiest way to maximally align the first partition is to start it at cylinder 2 rather than the default of cylinder 1 as shown in the example below.}}<br />
<br />
===== Fdisk Usage Summary =====<br />
*Start fdisk using the correct values for H and S specific to your SSD as described above.<br />
*If the SSD is brand new, create a new empty DOS partition table with the 'o' command.<br />
*Create a new partition with the 'n' command (primary type/1st partition).<br />
*Start on sector 2 rather than on sector 1 to ensure MS-DOS compatibility if this is required; accept the default value if not.<br />
*Use the +xG format to extend the partition x gigabytes.<br />
*Change the partition's system id from the default type of Linux (type 83) to the desired type via the 't' command. This is an optional step should the user wish to create another type of partition for example, swap, NTFS, etc. Note that a complete listing of all valid partition types is available via the 'l' command.<br />
*Assign other partitions in a like fashion.<br />
*Write the table to disk and exit via the 'w' command.<br />
<br />
When finished, users may format their newly created partitions with the 'mkfs.x /dev/sdXN' where x is the filesystem, X is the drive letter, and N is the partition number.<br />
The following example will format the first partition on the first disk to ext4 using the defaults specified in {{Filename|/etc/mke2fs.conf}}:<br />
# mkfs.ext4 /dev/sda1<br />
<br />
{{Warning|Using the mkfs command can be dangerous as a simple mistake can result in formatting the WRONG partition and in data loss! TRIPLE check the target of this command before hitting the Enter key!}}<br />
<br />
==== Detailed Usage Example ====<br />
{{Note|The following section is meant to be illustrative of the process of partitioning an Intel X25-M SSD with a single 12 Gig, Linux partition. It is in no way the definitive method for doing so, nor are the switches used to start fdisk in this specific example necessarily the correct values for other brands/models of SSDs!}}<br />
<br />
<pre># fdisk -H 32 -S 32 /dev/sdb<br />
<br />
The number of cylinders for this disk is set to 15711.<br />
There is nothing wrong with that, but this is larger than 1024,<br />
and could in certain setups cause problems with:<br />
1) software that runs at boot time (e.g., old versions of LILO)<br />
2) booting and partitioning software from other OSs<br />
(e.g., DOS FDISK, OS/2 FDISK)<br />
<br />
Command (m for help): o<br />
Building a new DOS disklabel with disk identifier 0x8cb3d286.<br />
Changes will remain in memory only, until you decide to write them.<br />
After that, of course, the previous content won't be recoverable.<br />
<br />
The number of cylinders for this disk is set to 15711.<br />
There is nothing wrong with that, but this is larger than 1024,<br />
and could in certain setups cause problems with:<br />
1) software that runs at boot time (e.g., old versions of LILO)<br />
2) booting and partitioning software from other OSs<br />
(e.g., DOS FDISK, OS/2 FDISK)<br />
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)<br />
<br />
Command (m for help): n<br />
Command action<br />
e extended<br />
p primary partition (1-4)<br />
p<br />
Partition number (1-4): 1<br />
First cylinder (1-15711, default 1): 2<br />
Last cylinder, +cylinders or +size{K,M,G} (2-15711, default 15711): +12G<br />
<br />
Command (m for help): w<br />
The partition table has been altered!<br />
<br />
Calling ioctl() to re-read partition table.<br />
Syncing disks.</pre><br />
<br />
The rest of the SSD was partitioned in a like fashion giving two partitions totally. Here is the output of an fdisk list command:<br />
<pre># fdisk -l /dev/sdb<br />
<br />
Disk /dev/sdb: 80.0 GB, 80026361856 bytes<br />
32 heads, 32 sectors/track, 152638 cylinders<br />
Units = cylinders of 1024 * 512 = 524288 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
Disk identifier: 0x76b978dc<br />
<br />
Device Boot Start End Blocks Id System<br />
/dev/sdb1 2 24578 12583424 83 Linux<br />
/dev/sdb2 24579 152638 65566720 83 Linux</pre><br />
<br />
And a fdisk -lu command:<br />
<pre># fdisk -lu /dev/sdb<br />
<br />
Disk /dev/sdb: 80.0 GB, 80026361856 bytes<br />
32 heads, 32 sectors/track, 152638 cylinders, total 156301488 sectors<br />
Units = sectors of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
Disk identifier: 0x76b978dc<br />
<br />
Device Boot Start End Blocks Id System<br />
/dev/sdb1 1024 25167871 12583424 83 Linux<br />
/dev/sdb2 25167872 156301311 65566720 83 Linux</pre><br />
<br />
==== Using GPT and gdisk/parted instead ====<br />
[http://wiki.archlinux.org/index.php/GUID_Partition_Table GPT] is an alternative partitioning style, and if you use the GPT version of fdisk (gdisk), or GNU parted, these programs can do alignment automatically, or easier.<br />
<br />
==== Special Considerations for Logical Partitions ====<br />
<br />
---Place holder for content. <br />
<br />
==== Special Considerations for RAID0 Setups with Multiple SSDs ====<br />
<br />
---Place holder for content.<br />
<br />
===Encrypted partition===<br />
<br />
When using cryptsetup, define a sufficient payload ([http://www.spinics.net/lists/dm-crypt/msg02421.html see here]):<br />
cryptsetup luksFormat --align-payload=8192 ...<br />
But remember that DISCARD/TRIM feature is NOT SUPPORTED by device-mapper (but they're working on it, [http://news.gmane.org/find-root.php?group=gmane.linux.kernel.device-mapper.dm-crypt&article=4075 see here])<br />
<br />
===Mount Flags===<br />
There are several key mount flags to use in one's {{filename|/etc/fstab}} entries for SSD partitions.<br />
<br />
*'''noatime''' - Reading accesses to the file system will no longer result in an update to the atime information associated with the file. The importance of the noatime setting is that it eliminates the need by the system to make writes to the file system for files which are simply being read. Since writes can be somewhat expensive as mentioned in previous section, this can result in measurable performance gains. Note that the write time information to a file will continue to be updated anytime the file is written to with this option enabled.<br />
*'''discard''' - The discard flag will enable the benefits of the TRIM command so long as one is using kernel version >=2.6.33. It does not work with ext3; using the discard flag for an ext3 root partition will result in it being mounted read-only.<br />
<br />
/dev/sda1 / ext4 defaults,noatime,discard 0 1<br />
/dev/sda2 /home ext4 defaults,noatime,discard 0 1<br />
<br />
{{Note|It is critically important that users switch the controller driving the SSD to AHCI mode (not IDE mode) to ensure that the kernel is able to use the TRIM command.}} <br />
{{Warning|Users need to be certain that kernel version 2.6.33 or above is being used AND that their SSD supports TRIM before attempting to mount a partition with the discard flag. Data loss can occur otherwise!}}<br />
<br />
====Special considerations for Mac computers====<br />
<br />
By default, Apple's firmware switches SATA drives into IDE mode (not AHCI mode) when booting any OS besides Mac OS. It is easy to switch back to AHCI if you are using [[GRUB2]] with an Intel SATA controller.<br />
<br />
First determine the PCI identifier of your SATA controller. Run the command<br />
# lspci -nn<br />
and find the line that says "SATA AHCI Controller". The PCI identifier is in square brackets and should look like 8086:27c4 (but the last digits may be different).<br />
<br />
Now edit /boot/grub/grub.cfg and add the line <br />
# setpci -d 8086:27c4 90.b=40<br />
right above the "set root" line of each OS you want to enable AHCI for. Be sure to substitute the appropriate PCI identifier.<br />
<br />
(credit: http://darkfader.blogspot.com/2010/04/windows-on-intel-mac-and-ahci-mode.html)<br />
<br />
===I/O Scheduler===<br />
<br />
Consider switching from the default scheduler which under Arch is cfq (completely fair queuing), to the noop or deadline scheduler for an SSD. Using the noop scheduler for example simplifies requests in the order they are received, without giving any consideration to where the data physically resides on the disk. This option is thought to be advantageous SSDs since seek times are identical for all sectors on the SSD. For more on schedulers, see [http://www.linux-mag.com/id/7564/1 this] Linux-mag article.<br />
<br />
The cfq scheduler is enabled by default on Arch. Verify this by viewing the contents /sys/block/sda/queue/scheduler:<br />
$ cat /sys/block/sdX/queue/scheduler<br />
noop deadline [cfq]<br />
<br />
The scheduler currently in use is denoted from the available schedulers by the brackets. To switch to another scheduler (noop in this example), one can add the following line in {{Filename|/etc/rc.local}}:<br />
# echo noop > /sys/block/sdX/queue/scheduler<br />
<br />
{{Note|Only switch the scheduler to noop or deadline for SSDs. Keeping the cfq scheduler for all other physical HDDs is highly recommended.}}<br />
<br />
{{Note|Many sites suggest using the noop scheduler for SSDs. While this might be true for the Intel X25-M drives which are optimized for random read/write operation, it can also be detrimental to performance for other SSDs which are optimized for contiguous read/write (JMicron-based SSDs for example). The cfq scheduler may be a better choice for these drives.}}<br />
<br />
=== Swap Space on SSDs ===<br />
One can place a swap partition on an SSD. Note that most modern desktops with an excess of 2 Gigs of memory rarely use swap at all. The notable exception is systems which make use of the hibernate feature. The following is recommended tweak for SSDs using a swap partition that will reduce the "swapiness" of the system thus avoiding writes to swap.<br />
<br />
# echo 1 > /proc/sys/vm/swappiness<br />
<br />
Or one can simply modify {{Filename|/etc/sysctl.conf}} as recommended in the [http://wiki.archlinux.org/index.php/Maximizing_performance#Swappiness Maximizing Performance] wiki article.<br />
<br />
vm.swappiness=1<br />
vm.vfs_cache_pressure=50<br />
<br />
=== SSD Memory Cell Clearing ===<br />
On occasion, users may wish to completely reset an SSD's cells to the same virgin state they were at the time he/she installed the device thus restoring it to its [http://www.anandtech.com/storage/showdoc.aspx?i=3531&p=8 factory default write performance]. Write performance is known to degrade over time even on SSDs with native TRIM support. TRIM only safeguards against file deletes, not replacements such as an incremental save.<br />
<br />
The reset is easily accomplished in a three step procedure denoted on the [[SSD Memory Cell Clearing]] wiki article.<br />
<br />
==Tips for Minimizing SSD Read/Writes==<br />
An overarching theme for SSD usage should be 'simplicity' in terms of locating high-read/write operations either in RAM (Random Access Memory) or on a physical HDD rather than on an SSD. Doing so will add longevity to an SSD. This is primarily due to the large erase block size (512 KiB in some cases); a lot of small writes result in huge effective writes.<br />
<br />
=== Intelligent Partition Scheme ===<br />
Consider relocating the /var partition to a physical disc on the system rather than on the SSD itself to avoid read/write wear. Many users elect to keep only /, and /home on the SSD (/boot is okay too) locating /var and /tmp on a physical HDD. <br />
<br />
<pre># SSD<br />
/<br />
/home<br />
<br />
# HDD<br />
/boot<br />
/var<br />
/media/data (and other extra partitions, etc.)</pre><br />
<br />
An even better option for /tmp is into RAM provided the system has enough to spare. See the next section for more on this procedure.<br />
<br />
=== The noatime Mount Flag ===<br />
Assign the '''noatime''' flag to partitions residing on SSDs. See the [http://wiki.archlinux.org/index.php/Solid_State_Drives#Mount_Flags Mount Flags] section below for more.<br />
<br />
=== Locate /tmp in RAM ===<br />
For systems with >=2 gigs of memory, locating /tmp in the RAM is desirable and easily achieved by first clearing the physical /tmp partition and then mounting it to tmpfs (RAM) in the {{Filename|/etc/fstab}}. The following line gives an example:<br />
<br />
none /tmp tmpfs nodev,nosuid,noatime,size=1000M,mode=1777 0 0<br />
<br />
=== Locate Browser Profiles in RAM ===<br />
One can easily mount browser profile(s) such as firefox, chromium, etc. into RAM via tmpfs and also use rsync to keep them synced with HDD-based backups. For more on this procedure, see the [http://wiki.archlinux.org/index.php/Speed-up_Firefox_using_tmpfs Speed-up Firefox Using tmpfs] article. In addition to the obvious speed enhancements, users will also save read/write cycles on their SSD by doing so.<br />
<br />
=== Compiling in /dev/shm ===<br />
Intentionally compiling in /dev/shm is a great idea to minimize this problem. For systems with >4 Gigs of memory, the shm line in {{Filename|/etc/fstab}} can be tweaked to use more than 1/2 the physical memory on the system via the size flag.<br />
<br />
Example of a machine with 8 GB of physical memory:<br />
shm /dev/shm tmpfs nodev,nosuid,size=6G 0 0<br />
<br />
=== Disabling Journaling on the Filesystem? ===<br />
Using a journaling filesystem such as ext3 or ext4 on an SSD WITHOUT a journal is an option to decrease read/writes. The obvious drawback of using a filesystem with journaling disabled is data loss as a result of an ungraceful dismount (i.e. post power failure, kernel lockup, etc.). With modern SSDs, [http://thunk.org/tytso/blog/2009/03/01/ssds-journaling-and-noatimerelatime Ted Tso] advocates that journaling can be enabled with minimal extraneous read/write cycles under most circumstances:<br />
<br />
'''Amount of data written (in megabytes) on an ext4 file system mounted with noatime.'''<br />
{| border="1" cellpadding="5"<br />
! operation !! journal !! w/o journal !! percent change<br />
|-<br />
!git clone<br />
|367.0<br />
|353.0<br />
|3.81 %<br />
|-<br />
!make<br />
|207.6<br />
|199.4<br />
|3.95 %<br />
|-<br />
!make clean<br />
|6.45<br />
|3.73<br />
|42.17 %<br />
|}<br />
<br />
''"What the results show is that metadata-heavy workloads, such as make clean, do result in almost twice the amount data written to disk. This is to be expected, since all changes to metadata blocks are first written to the journal and the journal transaction committed before the metadata is written to their final location on disk. However, for more common workloads where we are writing data as well as modifying filesystem metadata blocks, the difference is much smaller."''<br />
<br />
{{Note|The make clean example from the table above typifies the importance of intentionally doing compiling in /dev/shm as recommended in the [http://wiki.archlinux.org/index.php/Solid_State_Drives#Compiling_in_.2Fdev.2Fshm preceding section] of this article!}}<br />
<br />
=== Choice of Filesystem ===<br />
Many options exist for file systems including ext2, ext3, ext4, btrfs, etc.<br />
<br />
==== Btrfs ====<br />
[http://en.wikipedia.org/wiki/Btrfs Btrfs] support has been included with the mainline 2.6.29 release of the Linux kernel. Some feel that it is not mature enough for production use while there are also early adopters of this potential successor to ext4. It should be noted that at the time this article was originally written (27-June-2010), a stable version of btrfs did not exist. See [http://www.madeo.co.uk/?p=346 this] blog entry for more on btrfs.<br />
<br />
==== Ext4 ====<br />
[http://en.wikipedia.org/wiki/Ext4 Ext4] is another filsesystem that has support for SSD. It is considered as stable since 2.6.28 and is mature enough for daily use. Contrary to Btrfs, ext4 does not automatically detects the disk nature and you have to explicitly enable the TRIMM command support using the '''discard''' mounting option in your [[fstab]].<br />
See the [http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/filesystems/btrfs.txt;h=64087c34327fe0ba11e790e0a41224b8e7c1d30c;hb=HEAD official in kernel tree documentation] for further information on ext4.<br />
<br />
=== Use rebase for pacman database synchronization ===<br />
Using [http://xyne.archlinux.ca/projects/rebase/ rebase] instead of {{Codeline|pacman -Sy}} can reduce disk IO since rebase only updates files when necessary, whereas pacman deletes and recreates everything.<br />
<br />
'''Update''' pacman >=3.4.0 already does what rebase does, as pointed out [https://bbs.archlinux.org/viewtopic.php?pid=829887#p829887 here].<br />
<br />
== SSD Benchmarking ==<br />
See the [[SSD Benchmarking]] article for a general process of benchmarking your SSD or to see some of the SSDs in the database.</div>Xrchzhttps://wiki.archlinux.org/index.php?title=Solid_state_drive&diff=117880Solid state drive2010-09-23T00:31:55Z<p>Xrchz: /* Use rebase for pacman database synchronization */</p>
<hr />
<div>[[Category: Storage (English)]]<br />
{{expansion}}<br />
{{Article summary start}}<br />
{{Article summary text|This article covers many aspects of SSDs (solid state drives) as they relate to Linux; however, the underlying principals and key learning presented within are general enough to be applicable to users running SSDs on other operating systems such as the Windows family of products as well as MacOS X. Beyond the aforementioned information, Linux users will benefit from the tweaks/optimization presented herein.}}<br />
{{Article summary heading|Related Articles}}<br />
{{Article summary wiki|SSD Benchmarking}}<br />
{{Article summary wiki|SSD Memory Cell Clearing}}<br />
{{Article summary end}}<br />
<br />
==Introduction==<br />
Solid State Drives (SSDs) are not PnP devices. Special considerations such as partition alignment, choice of file system, TRIM support, etc. are needed to setup SSDs for optimal performance. This article attempts to capture referenced, key learnings to enable users to get the most out of SSDs under Linux. Users are encouraged to read this article in its entirety before acting on recommendations as the content is organized by topic, not necessarily by any systematic or chronologically relevant order.<br />
<br />
{{Note|This article is targeted at users running Linux, but much of the content is also relevant to our friends using both Windows and MacOS X.}}<br />
===Advantages over HDDs===<br />
*Fast read speeds - 2-3x faster than modern desktop HDDs (7,200 RPM using SATA2 interface).<br />
*Sustained read speeds - No decrease in read speed across the entirety of the device. HDD performance tapers off as the drive heads move from the center to the end of the HDD.<br />
*Minimal access time - Approx. 0.1 ms (100 ns) vs. 12-20 ms (12,000-20,000 ns) for desktop HDDs.<br />
*High degree of reliability.<br />
*No moving parts.<br />
*Minimal heat production.<br />
*Minimal power consumption - Fractions of a W at idle and 1-2 W while reading/writing vs. 10-30 W for a HDD depending on RPMs.<br />
*Light-weight - ideal for laptops.<br />
<br />
===Limitations===<br />
*Cost - High cost per GB vs. HDDs (dollars per GB vs. pennies per GB).<br />
*Capacity.<br />
<br />
==Pre-Purchase Considerations==<br />
There are several key features to look for prior to purchasing a contemporary SSD.<br />
===Key Features===<br />
*Native [http://en.wikipedia.org/wiki/TRIM TRIM] support is a vital feature that both prolongs SSD lifetime and reduces loss of performance for write operations over time.<br />
*Buying the right sized SSD is key. As with all filesystems, target <75 % occupancy for all SSD partitions to ensure efficient use by the kernel.<br />
<br />
===Reviews===<br />
This section is not meant to be all-inclusive, but does capture some key reviews.<br />
*[http://www.anandtech.com/show/2738 SSD Anthology (history lesson, a bit dated)]<br />
*[http://www.anandtech.com/show/2829 SSD Relapse (refresher and more up to date]<br />
*[http://forums.anandtech.com/showthread.php?t=2069761 One user's recommendations]<br />
<br />
==Tips for Maximizing SSD Performance==<br />
===Partition Alignment ===<br />
===== High-level Overview =====<br />
'''Proper partition alignment is essential for optimal performance and longevity.''' Key to alignment is partitioning to (at least) the EBS (erase block size) of the SSD. <br />
<br />
{{Note|The EBS is largely vendor specific; a google search on the model of interest would be a good idea! The Intel X25-M for example is thought to have an EBS of 512 KiB, but Intel has yet to publish anything officially to this end.}}<br />
<br />
If the partitions aren't aligned to begin at multiples of the EBS (512 KiB for example), aligning the file system is a pointless exercise because everything is skewed by the start offset of the partition. Traditionally, hard drives were addressed by indicating the ''cylinder'', the ''head'', and the ''sector'' at which data was to be read or written. These represented the radial position, the drive head (= platter and side) and the axial position of the data respectively. With LBA (logical block addressing), this is no longer the case. Instead, the entire hard drive is addressed as one continuous stream of data.<br />
<br />
The Linux utility fdisk, however, still uses a virtual C-H-S system where users can define any number of heads and sectors (the cylinders are calculated automatically from the drive's capacity), with partitions always starting and ending at intervals of heads x cylinders. '''Thus, one needs to choose a number of heads and sectors of which the SSD's erase block size is a multiple.''' This is accomplished by setting the number of heads (or tracks per cylinder) and sectors (per track) to coincide with the EBS.<br />
<br />
Ted Tso recommends using a setting of [http://ldn.linuxfoundation.org/blog-entry/aligning-filesystems-ssd%E2%80%99s-erase-block-size 224*56] (=2^8*49) which results in (2^8*512=) 128 KiB alignment:<br />
<br />
# fdisk -H 224 -S 56 /dev/sdX<br />
<br />
While others advocate a setting of [http://www.nuclex.org/blog/personal/80-aligning-an-ssd-on-linux 32*32] (=2^10) which results in (2^10*512=) 512 KiB alignment:<br />
<br />
# fdisk -H 32 -S 32 /dev/sdX<br />
<br />
How does the math work out? The alignment number is the largest power-of-two divisor of the cylinder boundary positions on the disk. The size in bytes of the cylinders is H*S*512 = (tracks per cylinder) * (sectors per track) * (sector size). Factorize H, S and sector size (512=2^9) into prime factors, and take all the 2s. In the first case above we have to ignore the non-power-of-two factor of 7^2=49.<br />
<br />
{{Note|In order to be compatible with MS-DOS, a partition starting on the first cylinder would skip one track, reducing its alignment to track level (4k for -S 56 and 16k for -S 32). The easiest way to maximally align the first partition is to start it at cylinder 2 rather than the default of cylinder 1 as shown in the example below.}}<br />
<br />
===== Fdisk Usage Summary =====<br />
*Start fdisk using the correct values for H and S specific to your SSD as described above.<br />
*If the SSD is brand new, create a new empty DOS partition table with the 'o' command.<br />
*Create a new partition with the 'n' command (primary type/1st partition).<br />
*Start on sector 2 rather than on sector 1 to ensure MS-DOS compatibility if this is required; accept the default value if not.<br />
*Use the +xG format to extend the partition x gigabytes.<br />
*Change the partition's system id from the default type of Linux (type 83) to the desired type via the 't' command. This is an optional step should the user wish to create another type of partition for example, swap, NTFS, etc. Note that a complete listing of all valid partition types is available via the 'l' command.<br />
*Assign other partitions in a like fashion.<br />
*Write the table to disk and exit via the 'w' command.<br />
<br />
When finished, users may format their newly created partitions with the 'mkfs.x /dev/sdXN' where x is the filesystem, X is the drive letter, and N is the partition number.<br />
The following example will format the first partition on the first disk to ext4 using the defaults specified in {{Filename|/etc/mke2fs.conf}}:<br />
# mkfs.ext4 /dev/sda1<br />
<br />
{{Warning|Using the mkfs command can be dangerous as a simple mistake can result in formatting the WRONG partition and in data loss! TRIPLE check the target of this command before hitting the Enter key!}}<br />
<br />
==== Detailed Usage Example ====<br />
{{Note|The following section is meant to be illustrative of the process of partitioning an Intel X25-M SSD with a single 12 Gig, Linux partition. It is in no way the definitive method for doing so, nor are the switches used to start fdisk in this specific example necessarily the correct values for other brands/models of SSDs!}}<br />
<br />
<pre># fdisk -H 32 -S 32 /dev/sdb<br />
<br />
The number of cylinders for this disk is set to 15711.<br />
There is nothing wrong with that, but this is larger than 1024,<br />
and could in certain setups cause problems with:<br />
1) software that runs at boot time (e.g., old versions of LILO)<br />
2) booting and partitioning software from other OSs<br />
(e.g., DOS FDISK, OS/2 FDISK)<br />
<br />
Command (m for help): o<br />
Building a new DOS disklabel with disk identifier 0x8cb3d286.<br />
Changes will remain in memory only, until you decide to write them.<br />
After that, of course, the previous content won't be recoverable.<br />
<br />
The number of cylinders for this disk is set to 15711.<br />
There is nothing wrong with that, but this is larger than 1024,<br />
and could in certain setups cause problems with:<br />
1) software that runs at boot time (e.g., old versions of LILO)<br />
2) booting and partitioning software from other OSs<br />
(e.g., DOS FDISK, OS/2 FDISK)<br />
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)<br />
<br />
Command (m for help): n<br />
Command action<br />
e extended<br />
p primary partition (1-4)<br />
p<br />
Partition number (1-4): 1<br />
First cylinder (1-15711, default 1): 2<br />
Last cylinder, +cylinders or +size{K,M,G} (2-15711, default 15711): +12G<br />
<br />
Command (m for help): w<br />
The partition table has been altered!<br />
<br />
Calling ioctl() to re-read partition table.<br />
Syncing disks.</pre><br />
<br />
The rest of the SSD was partitioned in a like fashion giving two partitions totally. Here is the output of an fdisk list command:<br />
<pre># fdisk -l /dev/sdb<br />
<br />
Disk /dev/sdb: 80.0 GB, 80026361856 bytes<br />
32 heads, 32 sectors/track, 152638 cylinders<br />
Units = cylinders of 1024 * 512 = 524288 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
Disk identifier: 0x76b978dc<br />
<br />
Device Boot Start End Blocks Id System<br />
/dev/sdb1 2 24578 12583424 83 Linux<br />
/dev/sdb2 24579 152638 65566720 83 Linux</pre><br />
<br />
And a fdisk -lu command:<br />
<pre># fdisk -lu /dev/sdb<br />
<br />
Disk /dev/sdb: 80.0 GB, 80026361856 bytes<br />
32 heads, 32 sectors/track, 152638 cylinders, total 156301488 sectors<br />
Units = sectors of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
Disk identifier: 0x76b978dc<br />
<br />
Device Boot Start End Blocks Id System<br />
/dev/sdb1 1024 25167871 12583424 83 Linux<br />
/dev/sdb2 25167872 156301311 65566720 83 Linux</pre><br />
<br />
<br />
==== Special Considerations for Logical Partitions ====<br />
<br />
---Place holder for content. <br />
<br />
==== Special Considerations for RAID0 Setups with Multiple SSDs ====<br />
<br />
---Place holder for content.<br />
<br />
===Encrypted partition===<br />
<br />
When using cryptsetup, define a sufficient payload ([http://www.spinics.net/lists/dm-crypt/msg02421.html see here]):<br />
cryptsetup luksFormat --align-payload=8192 ...<br />
But remember that DISCARD/TRIM feature is NOT SUPPORTED by device-mapper (but they're working on it, [http://news.gmane.org/find-root.php?group=gmane.linux.kernel.device-mapper.dm-crypt&article=4075 see here])<br />
<br />
===Mount Flags===<br />
There are several key mount flags to use in one's {{filename|/etc/fstab}} entries for SSD partitions.<br />
<br />
*'''noatime''' - Reading accesses to the file system will no longer result in an update to the atime information associated with the file. The importance of the noatime setting is that it eliminates the need by the system to make writes to the file system for files which are simply being read. Since writes can be somewhat expensive as mentioned in previous section, this can result in measurable performance gains. Note that the write time information to a file will continue to be updated anytime the file is written to with this option enabled.<br />
*'''discard''' - The discard flag will enable the benefits of the TRIM command so long as one is using kernel version >=2.6.33. It does not work with ext3; using the discard flag for an ext3 root partition will result in it being mounted read-only.<br />
<br />
/dev/sda1 / ext4 defaults,noatime,discard 0 1<br />
/dev/sda2 /home ext4 defaults,noatime,discard 0 1<br />
<br />
{{Note|It is critically important that users switch the controller driving the SSD to AHCI mode (not IDE mode) to ensure that the kernel is able to use the TRIM command.}} <br />
{{Warning|Users need to be certain that kernel version 2.6.33 or above is being used AND that their SSD supports TRIM before attempting to mount a partition with the discard flag. Data loss can occur otherwise!}}<br />
<br />
====Special considerations for Mac computers====<br />
<br />
By default, Apple's firmware switches SATA drives into IDE mode (not AHCI mode) when booting any OS besides Mac OS. It is easy to switch back to AHCI if you are using [[GRUB2]] with an Intel SATA controller.<br />
<br />
First determine the PCI identifier of your SATA controller. Run the command<br />
# lspci -nn<br />
and find the line that says "SATA AHCI Controller". The PCI identifier is in square brackets and should look like 8086:27c4 (but the last digits may be different).<br />
<br />
Now edit /boot/grub/grub.cfg and add the line <br />
# setpci -d 8086:27c4 90.b=40<br />
right above the "set root" line of each OS you want to enable AHCI for. Be sure to substitute the appropriate PCI identifier.<br />
<br />
(credit: http://darkfader.blogspot.com/2010/04/windows-on-intel-mac-and-ahci-mode.html)<br />
<br />
===I/O Scheduler===<br />
<br />
Consider switching from the default scheduler which under Arch is cfq (completely fair queuing), to the noop or deadline scheduler for an SSD. Using the noop scheduler for example simplifies requests in the order they are received, without giving any consideration to where the data physically resides on the disk. This option is thought to be advantageous SSDs since seek times are identical for all sectors on the SSD. For more on schedulers, see [http://www.linux-mag.com/id/7564/1 this] Linux-mag article.<br />
<br />
The cfq scheduler is enabled by default on Arch. Verify this by viewing the contents /sys/block/sda/queue/scheduler:<br />
$ cat /sys/block/sdX/queue/scheduler<br />
noop deadline [cfq]<br />
<br />
The scheduler currently in use is denoted from the available schedulers by the brackets. To switch to another scheduler (noop in this example), one can add the following line in {{Filename|/etc/rc.local}}:<br />
# echo noop > /sys/block/sdX/queue/scheduler<br />
<br />
{{Note|Only switch the scheduler to noop or deadline for SSDs. Keeping the cfq scheduler for all other physical HDDs is highly recommended.}}<br />
<br />
{{Note|Many sites suggest using the noop scheduler for SSDs. While this might be true for the Intel X25-M drives which are optimized for random read/write operation, it can also be detrimental to performance for other SSDs which are optimized for contiguous read/write (JMicron-based SSDs for example). The cfq scheduler may be a better choice for these drives.}}<br />
<br />
=== Swap Space on SSDs ===<br />
One can place a swap partition on an SSD. Note that most modern desktops with an excess of 2 Gigs of memory rarely use swap at all. The notable exception is systems which make use of the hibernate feature. The following is recommended tweak for SSDs using a swap partition that will reduce the "swapiness" of the system thus avoiding writes to swap.<br />
<br />
# echo 1 > /proc/sys/vm/swappiness<br />
<br />
Or one can simply modify {{Filename|/etc/sysctl.conf}} as recommended in the [http://wiki.archlinux.org/index.php/Maximizing_performance#Swappiness Maximizing Performance] wiki article.<br />
<br />
vm.swappiness=1<br />
vm.vfs_cache_pressure=50<br />
<br />
=== SSD Memory Cell Clearing ===<br />
On occasion, users may wish to completely reset an SSD's cells to the same virgin state they were at the time he/she installed the device thus restoring it to its [http://www.anandtech.com/storage/showdoc.aspx?i=3531&p=8 factory default write performance]. Write performance is known to degrade over time even on SSDs with native TRIM support. TRIM only safeguards against file deletes, not replacements such as an incremental save.<br />
<br />
The reset is easily accomplished in a three step procedure denoted on the [[SSD Memory Cell Clearing]] wiki article.<br />
<br />
==Tips for Minimizing SSD Read/Writes==<br />
An overarching theme for SSD usage should be 'simplicity' in terms of locating high-read/write operations either in RAM (Random Access Memory) or on a physical HDD rather than on an SSD. Doing so will add longevity to an SSD. This is primarily due to the large erase block size (512 KiB in some cases); a lot of small writes result in huge effective writes.<br />
<br />
=== Intelligent Partition Scheme ===<br />
Consider relocating the /var partition to a physical disc on the system rather than on the SSD itself to avoid read/write wear. Many users elect to keep only /, and /home on the SSD (/boot is okay too) locating /var and /tmp on a physical HDD. <br />
<br />
<pre># SSD<br />
/<br />
/home<br />
<br />
# HDD<br />
/boot<br />
/var<br />
/media/data (and other extra partitions, etc.)</pre><br />
<br />
An even better option for /tmp is into RAM provided the system has enough to spare. See the next section for more on this procedure.<br />
<br />
=== The noatime Mount Flag ===<br />
Assign the '''noatime''' flag to partitions residing on SSDs. See the [http://wiki.archlinux.org/index.php/Solid_State_Drives#Mount_Flags Mount Flags] section below for more.<br />
<br />
=== Locate /tmp in RAM ===<br />
For systems with >=2 gigs of memory, locating /tmp in the RAM is desirable and easily achieved by first clearing the physical /tmp partition and then mounting it to tmpfs (RAM) in the {{Filename|/etc/fstab}}. The following line gives an example:<br />
<br />
none /tmp tmpfs nodev,nosuid,noatime,size=1000M,mode=1777 0 0<br />
<br />
=== Locate Browser Profiles in RAM ===<br />
One can easily mount browser profile(s) such as firefox, chromium, etc. into RAM via tmpfs and also use rsync to keep them synced with HDD-based backups. For more on this procedure, see the [http://wiki.archlinux.org/index.php/Speed-up_Firefox_using_tmpfs Speed-up Firefox Using tmpfs] article. In addition to the obvious speed enhancements, users will also save read/write cycles on their SSD by doing so.<br />
<br />
=== Compiling in /dev/shm ===<br />
Intentionally compiling in /dev/shm is a great idea to minimize this problem. For systems with >4 Gigs of memory, the shm line in {{Filename|/etc/fstab}} can be tweaked to use more than 1/2 the physical memory on the system via the size flag.<br />
<br />
Example of a machine with 8 GB of physical memory:<br />
shm /dev/shm tmpfs nodev,nosuid,size=6G 0 0<br />
<br />
=== Disabling Journaling on the Filesystem? ===<br />
Using a journaling filesystem such as ext3 or ext4 on an SSD WITHOUT a journal is an option to decrease read/writes. The obvious drawback of using a filesystem with journaling disabled is data loss as a result of an ungraceful dismount (i.e. post power failure, kernel lockup, etc.). With modern SSDs, [http://thunk.org/tytso/blog/2009/03/01/ssds-journaling-and-noatimerelatime Ted Tso] advocates that journaling can be enabled with minimal extraneous read/write cycles under most circumstances:<br />
<br />
'''Amount of data written (in megabytes) on an ext4 file system mounted with noatime.'''<br />
{| border="1" cellpadding="5"<br />
! operation !! journal !! w/o journal !! percent change<br />
|-<br />
!git clone<br />
|367.0<br />
|353.0<br />
|3.81 %<br />
|-<br />
!make<br />
|207.6<br />
|199.4<br />
|3.95 %<br />
|-<br />
!make clean<br />
|6.45<br />
|3.73<br />
|42.17 %<br />
|}<br />
<br />
''"What the results show is that metadata-heavy workloads, such as make clean, do result in almost twice the amount data written to disk. This is to be expected, since all changes to metadata blocks are first written to the journal and the journal transaction committed before the metadata is written to their final location on disk. However, for more common workloads where we are writing data as well as modifying filesystem metadata blocks, the difference is much smaller."''<br />
<br />
{{Note|The make clean example from the table above typifies the importance of intentionally doing compiling in /dev/shm as recommended in the [http://wiki.archlinux.org/index.php/Solid_State_Drives#Compiling_in_.2Fdev.2Fshm preceding section] of this article!}}<br />
<br />
=== Choice of Filesystem ===<br />
Many options exist for file systems including ext2, ext3, ext4, btrfs, etc.<br />
<br />
==== Btrfs ====<br />
[http://en.wikipedia.org/wiki/Btrfs Btrfs] support has been included with the mainline 2.6.29 release of the Linux kernel. Some feel that it is not mature enough for production use while there are also early adopters of this potential successor to ext4. It should be noted that at the time this article was originally written (27-June-2010), a stable version of btrfs did not exist. See [http://www.madeo.co.uk/?p=346 this] blog entry for more on btrfs.<br />
<br />
==== Ext4 ====<br />
[http://en.wikipedia.org/wiki/Ext4 Ext4] is another filsesystem that has support for SSD. It is considered as stable since 2.6.28 and is mature enough for daily use. Contrary to Btrfs, ext4 does not automatically detects the disk nature and you have to explicitly enable the TRIMM command support using the '''discard''' mounting option in your [[fstab]].<br />
See the [http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/filesystems/btrfs.txt;h=64087c34327fe0ba11e790e0a41224b8e7c1d30c;hb=HEAD official in kernel tree documentation] for further information on ext4.<br />
<br />
=== Use rebase for pacman database synchronization ===<br />
Using [http://xyne.archlinux.ca/projects/rebase/ rebase] instead of {{Codeline|pacman -Sy}} can reduce disk IO since rebase only updates files when necessary, whereas pacman deletes and recreates everything.<br />
<br />
'''Update''' pacman >=3.4.0 already does what rebase does, as pointed out [https://bbs.archlinux.org/viewtopic.php?pid=829887#p829887 here].<br />
<br />
== SSD Benchmarking ==<br />
See the [[SSD Benchmarking]] article for a general process of benchmarking your SSD or to see some of the SSDs in the database.</div>Xrchzhttps://wiki.archlinux.org/index.php?title=Solid_state_drive&diff=117869Solid state drive2010-09-22T23:42:18Z<p>Xrchz: /* Tips for Minimizing SSD Read/Writes */</p>
<hr />
<div>[[Category: Storage (English)]]<br />
{{expansion}}<br />
{{Article summary start}}<br />
{{Article summary text|This article covers many aspects of SSDs (solid state drives) as they relate to Linux; however, the underlying principals and key learning presented within are general enough to be applicable to users running SSDs on other operating systems such as the Windows family of products as well as MacOS X. Beyond the aforementioned information, Linux users will benefit from the tweaks/optimization presented herein.}}<br />
{{Article summary heading|Related Articles}}<br />
{{Article summary wiki|SSD Benchmarking}}<br />
{{Article summary wiki|SSD Memory Cell Clearing}}<br />
{{Article summary end}}<br />
<br />
==Introduction==<br />
Solid State Drives (SSDs) are not PnP devices. Special considerations such as partition alignment, choice of file system, TRIM support, etc. are needed to setup SSDs for optimal performance. This article attempts to capture referenced, key learnings to enable users to get the most out of SSDs under Linux. Users are encouraged to read this article in its entirety before acting on recommendations as the content is organized by topic, not necessarily by any systematic or chronologically relevant order.<br />
<br />
{{Note|This article is targeted at users running Linux, but much of the content is also relevant to our friends using both Windows and MacOS X.}}<br />
===Advantages over HDDs===<br />
*Fast read speeds - 2-3x faster than modern desktop HDDs (7,200 RPM using SATA2 interface).<br />
*Sustained read speeds - No decrease in read speed across the entirety of the device. HDD performance tapers off as the drive heads move from the center to the end of the HDD.<br />
*Minimal access time - Approx. 0.1 ms (100 ns) vs. 12-20 ms (12,000-20,000 ns) for desktop HDDs.<br />
*High degree of reliability.<br />
*No moving parts.<br />
*Minimal heat production.<br />
*Minimal power consumption - Fractions of a W at idle and 1-2 W while reading/writing vs. 10-30 W for a HDD depending on RPMs.<br />
*Light-weight - ideal for laptops.<br />
<br />
===Limitations===<br />
*Cost - High cost per GB vs. HDDs (dollars per GB vs. pennies per GB).<br />
*Capacity.<br />
<br />
==Pre-Purchase Considerations==<br />
There are several key features to look for prior to purchasing a contemporary SSD.<br />
===Key Features===<br />
*Native [http://en.wikipedia.org/wiki/TRIM TRIM] support is a vital feature that both prolongs SSD lifetime and reduces loss of performance for write operations over time.<br />
*Buying the right sized SSD is key. As with all filesystems, target <75 % occupancy for all SSD partitions to ensure efficient use by the kernel.<br />
<br />
===Reviews===<br />
This section is not meant to be all-inclusive, but does capture some key reviews.<br />
*[http://www.anandtech.com/show/2738 SSD Anthology (history lesson, a bit dated)]<br />
*[http://www.anandtech.com/show/2829 SSD Relapse (refresher and more up to date]<br />
*[http://forums.anandtech.com/showthread.php?t=2069761 One user's recommendations]<br />
<br />
==Tips for Maximizing SSD Performance==<br />
===Partition Alignment ===<br />
===== High-level Overview =====<br />
'''Proper partition alignment is essential for optimal performance and longevity.''' Key to alignment is partitioning to (at least) the EBS (erase block size) of the SSD. <br />
<br />
{{Note|The EBS is largely vendor specific; a google search on the model of interest would be a good idea! The Intel X25-M for example is thought to have an EBS of 512 KiB, but Intel has yet to publish anything officially to this end.}}<br />
<br />
If the partitions aren't aligned to begin at multiples of the EBS (512 KiB for example), aligning the file system is a pointless exercise because everything is skewed by the start offset of the partition. Traditionally, hard drives were addressed by indicating the ''cylinder'', the ''head'', and the ''sector'' at which data was to be read or written. These represented the radial position, the drive head (= platter and side) and the axial position of the data respectively. With LBA (logical block addressing), this is no longer the case. Instead, the entire hard drive is addressed as one continuous stream of data.<br />
<br />
The Linux utility fdisk, however, still uses a virtual C-H-S system where users can define any number of heads and sectors (the cylinders are calculated automatically from the drive's capacity), with partitions always starting and ending at intervals of heads x cylinders. '''Thus, one needs to choose a number of heads and sectors of which the SSD's erase block size is a multiple.''' This is accomplished by setting the number of heads (or tracks per cylinder) and sectors (per track) to coincide with the EBS.<br />
<br />
Ted Tso recommends using a setting of [http://ldn.linuxfoundation.org/blog-entry/aligning-filesystems-ssd%E2%80%99s-erase-block-size 224*56] (=2^8*49) which results in (2^8*512=) 128 KiB alignment:<br />
<br />
# fdisk -H 224 -S 56 /dev/sdX<br />
<br />
While others advocate a setting of [http://www.nuclex.org/blog/personal/80-aligning-an-ssd-on-linux 32*32] (=2^10) which results in (2^10*512=) 512 KiB alignment:<br />
<br />
# fdisk -H 32 -S 32 /dev/sdX<br />
<br />
How does the math work out? The alignment number is the largest power-of-two divisor of the cylinder boundary positions on the disk. The size in bytes of the cylinders is H*S*512 = (tracks per cylinder) * (sectors per track) * (sector size). Factorize H, S and sector size (512=2^9) into prime factors, and take all the 2s. In the first case above we have to ignore the non-power-of-two factor of 7^2=49.<br />
<br />
{{Note|In order to be compatible with MS-DOS, a partition starting on the first cylinder would skip one track, reducing its alignment to track level (4k for -S 56 and 16k for -S 32). The easiest way to maximally align the first partition is to start it at cylinder 2 rather than the default of cylinder 1 as shown in the example below.}}<br />
<br />
===== Fdisk Usage Summary =====<br />
*Start fdisk using the correct values for H and S specific to your SSD as described above.<br />
*If the SSD is brand new, create a new empty DOS partition table with the 'o' command.<br />
*Create a new partition with the 'n' command (primary type/1st partition).<br />
*Start on sector 2 rather than on sector 1 to ensure MS-DOS compatibility if this is required; accept the default value if not.<br />
*Use the +xG format to extend the partition x gigabytes.<br />
*Change the partition's system id from the default type of Linux (type 83) to the desired type via the 't' command. This is an optional step should the user wish to create another type of partition for example, swap, NTFS, etc. Note that a complete listing of all valid partition types is available via the 'l' command.<br />
*Assign other partitions in a like fashion.<br />
*Write the table to disk and exit via the 'w' command.<br />
<br />
When finished, users may format their newly created partitions with the 'mkfs.x /dev/sdXN' where x is the filesystem, X is the drive letter, and N is the partition number.<br />
The following example will format the first partition on the first disk to ext4 using the defaults specified in {{Filename|/etc/mke2fs.conf}}:<br />
# mkfs.ext4 /dev/sda1<br />
<br />
{{Warning|Using the mkfs command can be dangerous as a simple mistake can result in formatting the WRONG partition and in data loss! TRIPLE check the target of this command before hitting the Enter key!}}<br />
<br />
==== Detailed Usage Example ====<br />
{{Note|The following section is meant to be illustrative of the process of partitioning an Intel X25-M SSD with a single 12 Gig, Linux partition. It is in no way the definitive method for doing so, nor are the switches used to start fdisk in this specific example necessarily the correct values for other brands/models of SSDs!}}<br />
<br />
<pre># fdisk -H 32 -S 32 /dev/sdb<br />
<br />
The number of cylinders for this disk is set to 15711.<br />
There is nothing wrong with that, but this is larger than 1024,<br />
and could in certain setups cause problems with:<br />
1) software that runs at boot time (e.g., old versions of LILO)<br />
2) booting and partitioning software from other OSs<br />
(e.g., DOS FDISK, OS/2 FDISK)<br />
<br />
Command (m for help): o<br />
Building a new DOS disklabel with disk identifier 0x8cb3d286.<br />
Changes will remain in memory only, until you decide to write them.<br />
After that, of course, the previous content won't be recoverable.<br />
<br />
The number of cylinders for this disk is set to 15711.<br />
There is nothing wrong with that, but this is larger than 1024,<br />
and could in certain setups cause problems with:<br />
1) software that runs at boot time (e.g., old versions of LILO)<br />
2) booting and partitioning software from other OSs<br />
(e.g., DOS FDISK, OS/2 FDISK)<br />
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)<br />
<br />
Command (m for help): n<br />
Command action<br />
e extended<br />
p primary partition (1-4)<br />
p<br />
Partition number (1-4): 1<br />
First cylinder (1-15711, default 1): 2<br />
Last cylinder, +cylinders or +size{K,M,G} (2-15711, default 15711): +12G<br />
<br />
Command (m for help): w<br />
The partition table has been altered!<br />
<br />
Calling ioctl() to re-read partition table.<br />
Syncing disks.</pre><br />
<br />
The rest of the SSD was partitioned in a like fashion giving two partitions totally. Here is the output of an fdisk list command:<br />
<pre># fdisk -l /dev/sdb<br />
<br />
Disk /dev/sdb: 80.0 GB, 80026361856 bytes<br />
32 heads, 32 sectors/track, 152638 cylinders<br />
Units = cylinders of 1024 * 512 = 524288 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
Disk identifier: 0x76b978dc<br />
<br />
Device Boot Start End Blocks Id System<br />
/dev/sdb1 2 24578 12583424 83 Linux<br />
/dev/sdb2 24579 152638 65566720 83 Linux</pre><br />
<br />
And a fdisk -lu command:<br />
<pre># fdisk -lu /dev/sdb<br />
<br />
Disk /dev/sdb: 80.0 GB, 80026361856 bytes<br />
32 heads, 32 sectors/track, 152638 cylinders, total 156301488 sectors<br />
Units = sectors of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
Disk identifier: 0x76b978dc<br />
<br />
Device Boot Start End Blocks Id System<br />
/dev/sdb1 1024 25167871 12583424 83 Linux<br />
/dev/sdb2 25167872 156301311 65566720 83 Linux</pre><br />
<br />
<br />
==== Special Considerations for Logical Partitions ====<br />
<br />
---Place holder for content. <br />
<br />
==== Special Considerations for RAID0 Setups with Multiple SSDs ====<br />
<br />
---Place holder for content.<br />
<br />
===Encrypted partition===<br />
<br />
When using cryptsetup, define a sufficient payload ([http://www.spinics.net/lists/dm-crypt/msg02421.html see here]):<br />
cryptsetup luksFormat --align-payload=8192 ...<br />
But remember that DISCARD/TRIM feature is NOT SUPPORTED by device-mapper (but they're working on it, [http://news.gmane.org/find-root.php?group=gmane.linux.kernel.device-mapper.dm-crypt&article=4075 see here])<br />
<br />
===Mount Flags===<br />
There are several key mount flags to use in one's {{filename|/etc/fstab}} entries for SSD partitions.<br />
<br />
*'''noatime''' - Reading accesses to the file system will no longer result in an update to the atime information associated with the file. The importance of the noatime setting is that it eliminates the need by the system to make writes to the file system for files which are simply being read. Since writes can be somewhat expensive as mentioned in previous section, this can result in measurable performance gains. Note that the write time information to a file will continue to be updated anytime the file is written to with this option enabled.<br />
*'''discard''' - The discard flag will enable the benefits of the TRIM command so long as one is using kernel version >=2.6.33. It does not work with ext3; using the discard flag for an ext3 root partition will result in it being mounted read-only.<br />
<br />
/dev/sda1 / ext4 defaults,noatime,discard 0 1<br />
/dev/sda2 /home ext4 defaults,noatime,discard 0 1<br />
<br />
{{Note|It is critically important that users switch the controller driving the SSD to AHCI mode (not IDE mode) to ensure that the kernel is able to use the TRIM command.}} <br />
{{Warning|Users need to be certain that kernel version 2.6.33 or above is being used AND that their SSD supports TRIM before attempting to mount a partition with the discard flag. Data loss can occur otherwise!}}<br />
<br />
====Special considerations for Mac computers====<br />
<br />
By default, Apple's firmware switches SATA drives into IDE mode (not AHCI mode) when booting any OS besides Mac OS. It is easy to switch back to AHCI if you are using [[GRUB2]] with an Intel SATA controller.<br />
<br />
First determine the PCI identifier of your SATA controller. Run the command<br />
# lspci -nn<br />
and find the line that says "SATA AHCI Controller". The PCI identifier is in square brackets and should look like 8086:27c4 (but the last digits may be different).<br />
<br />
Now edit /boot/grub/grub.cfg and add the line <br />
# setpci -d 8086:27c4 90.b=40<br />
right above the "set root" line of each OS you want to enable AHCI for. Be sure to substitute the appropriate PCI identifier.<br />
<br />
(credit: http://darkfader.blogspot.com/2010/04/windows-on-intel-mac-and-ahci-mode.html)<br />
<br />
===I/O Scheduler===<br />
<br />
Consider switching from the default scheduler which under Arch is cfq (completely fair queuing), to the noop or deadline scheduler for an SSD. Using the noop scheduler for example simplifies requests in the order they are received, without giving any consideration to where the data physically resides on the disk. This option is thought to be advantageous SSDs since seek times are identical for all sectors on the SSD. For more on schedulers, see [http://www.linux-mag.com/id/7564/1 this] Linux-mag article.<br />
<br />
The cfq scheduler is enabled by default on Arch. Verify this by viewing the contents /sys/block/sda/queue/scheduler:<br />
$ cat /sys/block/sdX/queue/scheduler<br />
noop deadline [cfq]<br />
<br />
The scheduler currently in use is denoted from the available schedulers by the brackets. To switch to another scheduler (noop in this example), one can add the following line in {{Filename|/etc/rc.local}}:<br />
# echo noop > /sys/block/sdX/queue/scheduler<br />
<br />
{{Note|Only switch the scheduler to noop or deadline for SSDs. Keeping the cfq scheduler for all other physical HDDs is highly recommended.}}<br />
<br />
{{Note|Many sites suggest using the noop scheduler for SSDs. While this might be true for the Intel X25-M drives which are optimized for random read/write operation, it can also be detrimental to performance for other SSDs which are optimized for contiguous read/write (JMicron-based SSDs for example). The cfq scheduler may be a better choice for these drives.}}<br />
<br />
=== Swap Space on SSDs ===<br />
One can place a swap partition on an SSD. Note that most modern desktops with an excess of 2 Gigs of memory rarely use swap at all. The notable exception is systems which make use of the hibernate feature. The following is recommended tweak for SSDs using a swap partition that will reduce the "swapiness" of the system thus avoiding writes to swap.<br />
<br />
# echo 1 > /proc/sys/vm/swappiness<br />
<br />
Or one can simply modify {{Filename|/etc/sysctl.conf}} as recommended in the [http://wiki.archlinux.org/index.php/Maximizing_performance#Swappiness Maximizing Performance] wiki article.<br />
<br />
vm.swappiness=1<br />
vm.vfs_cache_pressure=50<br />
<br />
=== SSD Memory Cell Clearing ===<br />
On occasion, users may wish to completely reset an SSD's cells to the same virgin state they were at the time he/she installed the device thus restoring it to its [http://www.anandtech.com/storage/showdoc.aspx?i=3531&p=8 factory default write performance]. Write performance is known to degrade over time even on SSDs with native TRIM support. TRIM only safeguards against file deletes, not replacements such as an incremental save.<br />
<br />
The reset is easily accomplished in a three step procedure denoted on the [[SSD Memory Cell Clearing]] wiki article.<br />
<br />
==Tips for Minimizing SSD Read/Writes==<br />
An overarching theme for SSD usage should be 'simplicity' in terms of locating high-read/write operations either in RAM (Random Access Memory) or on a physical HDD rather than on an SSD. Doing so will add longevity to an SSD. This is primarily due to the large erase block size (512 KiB in some cases); a lot of small writes result in huge effective writes.<br />
<br />
=== Intelligent Partition Scheme ===<br />
Consider relocating the /var partition to a physical disc on the system rather than on the SSD itself to avoid read/write wear. Many users elect to keep only /, and /home on the SSD (/boot is okay too) locating /var and /tmp on a physical HDD. <br />
<br />
<pre># SSD<br />
/<br />
/home<br />
<br />
# HDD<br />
/boot<br />
/var<br />
/media/data (and other extra partitions, etc.)</pre><br />
<br />
An even better option for /tmp is into RAM provided the system has enough to spare. See the next section for more on this procedure.<br />
<br />
=== The noatime Mount Flag ===<br />
Assign the '''noatime''' flag to partitions residing on SSDs. See the [http://wiki.archlinux.org/index.php/Solid_State_Drives#Mount_Flags Mount Flags] section below for more.<br />
<br />
=== Locate /tmp in RAM ===<br />
For systems with >=2 gigs of memory, locating /tmp in the RAM is desirable and easily achieved by first clearing the physical /tmp partition and then mounting it to tmpfs (RAM) in the {{Filename|/etc/fstab}}. The following line gives an example:<br />
<br />
none /tmp tmpfs nodev,nosuid,noatime,size=1000M,mode=1777 0 0<br />
<br />
=== Locate Browser Profiles in RAM ===<br />
One can easily mount browser profile(s) such as firefox, chromium, etc. into RAM via tmpfs and also use rsync to keep them synced with HDD-based backups. For more on this procedure, see the [http://wiki.archlinux.org/index.php/Speed-up_Firefox_using_tmpfs Speed-up Firefox Using tmpfs] article. In addition to the obvious speed enhancements, users will also save read/write cycles on their SSD by doing so.<br />
<br />
=== Compiling in /dev/shm ===<br />
Intentionally compiling in /dev/shm is a great idea to minimize this problem. For systems with >4 Gigs of memory, the shm line in {{Filename|/etc/fstab}} can be tweaked to use more than 1/2 the physical memory on the system via the size flag.<br />
<br />
Example of a machine with 8 GB of physical memory:<br />
shm /dev/shm tmpfs nodev,nosuid,size=6G 0 0<br />
<br />
=== Disabling Journaling on the Filesystem? ===<br />
Using a journaling filesystem such as ext3 or ext4 on an SSD WITHOUT a journal is an option to decrease read/writes. The obvious drawback of using a filesystem with journaling disabled is data loss as a result of an ungraceful dismount (i.e. post power failure, kernel lockup, etc.). With modern SSDs, [http://thunk.org/tytso/blog/2009/03/01/ssds-journaling-and-noatimerelatime Ted Tso] advocates that journaling can be enabled with minimal extraneous read/write cycles under most circumstances:<br />
<br />
'''Amount of data written (in megabytes) on an ext4 file system mounted with noatime.'''<br />
{| border="1" cellpadding="5"<br />
! operation !! journal !! w/o journal !! percent change<br />
|-<br />
!git clone<br />
|367.0<br />
|353.0<br />
|3.81 %<br />
|-<br />
!make<br />
|207.6<br />
|199.4<br />
|3.95 %<br />
|-<br />
!make clean<br />
|6.45<br />
|3.73<br />
|42.17 %<br />
|}<br />
<br />
''"What the results show is that metadata-heavy workloads, such as make clean, do result in almost twice the amount data written to disk. This is to be expected, since all changes to metadata blocks are first written to the journal and the journal transaction committed before the metadata is written to their final location on disk. However, for more common workloads where we are writing data as well as modifying filesystem metadata blocks, the difference is much smaller."''<br />
<br />
{{Note|The make clean example from the table above typifies the importance of intentionally doing compiling in /dev/shm as recommended in the [http://wiki.archlinux.org/index.php/Solid_State_Drives#Compiling_in_.2Fdev.2Fshm preceding section] of this article!}}<br />
<br />
=== Choice of Filesystem ===<br />
Many options exist for file systems including ext2, ext3, ext4, btrfs, etc.<br />
<br />
==== Btrfs ====<br />
[http://en.wikipedia.org/wiki/Btrfs Btrfs] support has been included with the mainline 2.6.29 release of the Linux kernel. Some feel that it is not mature enough for production use while there are also early adopters of this potential successor to ext4. It should be noted that at the time this article was originally written (27-June-2010), a stable version of btrfs did not exist. See [http://www.madeo.co.uk/?p=346 this] blog entry for more on btrfs.<br />
<br />
==== Ext4 ====<br />
[http://en.wikipedia.org/wiki/Ext4 Ext4] is another filsesystem that has support for SSD. It is considered as stable since 2.6.28 and is mature enough for daily use. Contrary to Btrfs, ext4 does not automatically detects the disk nature and you have to explicitly enable the TRIMM command support using the '''discard''' mounting option in your [[fstab]].<br />
See the [http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/filesystems/btrfs.txt;h=64087c34327fe0ba11e790e0a41224b8e7c1d30c;hb=HEAD official in kernel tree documentation] for further information on ext4.<br />
<br />
=== Use rebase for pacman database synchronization ===<br />
Using [http://xyne.archlinux.ca/projects/rebase/ rebase] instead of {{Codeline|pacman -Sy}} can reduce disk IO since rebase only updates files when necessary, whereas pacman deletes and recreates everything.<br />
<br />
== SSD Benchmarking ==<br />
See the [[SSD Benchmarking]] article for a general process of benchmarking your SSD or to see some of the SSDs in the database.</div>Xrchzhttps://wiki.archlinux.org/index.php?title=Improve_pacman_performance&diff=117861Improve pacman performance2010-09-22T23:27:08Z<p>Xrchz: /* pacman-cage */</p>
<hr />
<div>[[Category:Package management (English)]]<br />
[[Category:HOWTOs (English)]]<br />
{{i18n|Improve_Pacman_Performance}}<br />
[[de:Pacman beschleunigen]]<br />
<br />
== Improving Database Access Speeds ==<br />
<br />
Pacman stores all package information in a collection of small files, one for each package. Improving database access speeds reduces the time taken in database-related tasks, e.g. searching packages and resolving package dependencies. The safest and easiest method is to run as root:<br />
<br />
# pacman-optimize && sync<br />
<br />
This will attempt to put all the small files together in one (physical) location on the hard disk so that the hard disk head does not have to move so much when accessing all the packages. This method is safe, but is not foolproof. It depends on your filesystem, disk usage and empty space fragmentation. Another more aggressive option would be to first remove uninstalled packages from cache and to remove unused repositories before database optimization:<br />
<br />
# pacman -Sc && pacman-optimize && sync<br />
<br />
===pacman-cage===<br />
'''pacman-cage''' is a script that puts the pacman database, {{Filename|/var/lib/pacman}}, in a single loop file containing its own file-system that can speed up access times. This very simple alteration that improves pacman's speed for tasks like searching and updating. The script makes a backup (at installation only) in case something goes wrong but has caused some users to lose their database (e.g. when used in a chroot). Use with caution.<br />
<br />
pacman-cage is now part of [http://aur.archlinux.org/packages.php?ID=5907 pactools] in [[AUR]] and has been renamed pt-pacman-cage (with his brother pt-pacman-uncage).<br />
<br />
'''Update''' [http://aur.archlinux.org/packages.php?ID=32483 This package] is probably better.<br />
<br />
== Improving Download Speeds ==<br />
<br />
Firstly, if your download speeds have been reduced to a crawl, ensure you are using one of the many [[mirrors]] and not ftp.archlinux.org, which, [http://www.archlinux.org/news/302/ as of March 2007], is now throttled.<br />
<br />
Pacman's speed in downloading packages can be improved by using a different application to download packages instead of Pacman's built-in file downloader.<br />
<br />
In all cases, make sure you have the latest Pacman before doing any modifications.<br />
<br />
# pacman -Syu<br />
<br />
=== Using wget ===<br />
<br />
This is also very handy if you need more powerful proxy settings than pacman's built-in capabilities. <br />
<br />
To use <code>wget</code>, first install it with <code>pacman -S wget</code> and then modify <code>/etc/pacman.conf</code> by adding the following line to the <code>[options]</code> section:<br />
<br />
XferCommand = /usr/bin/wget -c --passive-ftp -c %u<br />
<br />
Instead of putting <code>wget</code> parameters in {{Filename|/etc/pacman.conf}}, you can also modify the {{Filename|wget}} configuration file directly (the system-wide file is {{Filename|/etc/wgetrc}}, per user files are {{Filename|$HOME/.wgetrc}}.<br />
<br />
=== Using aria2 ===<br />
<br />
[[aria2]] is a lightweight download utility with support for resumable and segmented HTTP/HTTPS and FTP downloads. [http://aria2.sourceforge.net/ aria2] allows for multiple and simultaneous HTTP/HTTPS and FTP connections to an Arch mirror, which should result in an increase in download speeds for both file and package retrieval. <br />
<br />
==== Installation ====<br />
<br />
Download and install {{Package Official|aria2}} and its dependencies:<br />
<br />
# pacman -S aria2<br />
<br />
==== Configuration ====<br />
<br />
Edit {{Filename|/etc/pacman.conf}} by adding the following line to the <code>[option]</code> section:<br />
<br />
XferCommand = /usr/bin/aria2c --allow-overwrite=true -c --file-allocation=none --log-level=error -m2 --max-connection-per-server=2 --max-file-not-found=5 --min-split-size=5M --no-conf --remote-time=true --summary-interval=60 -t5 -d / -o %o %u<br />
<br />
==== Option Details ====<br />
<br />
; <tt>/usr/bin/aria2c</tt>: The full PATH to the aria2 executable.<br />
; <tt>--allow-overwrite=true</tt>: Restart download if a corresponding control file does not exist. (Default: false)<br />
; <tt>-c, --continue</tt>: Continue downloading a partially downloaded file if a corresponding control file exists.<br />
; <tt>--file-allocation=none</tt>: Do not pre-allocate file space before download begins. (Default: prealloc) <b><sup>1</sup></b><br />
; <tt>--log-level=error</tt>: Set log level to output errors only. (Default: debug)<br />
; <tt>-m2, --max-tries=2</tt>: Make 2 maximum attempts to download specified file(s) per mirror. (Default: 5)<br />
; <tt>--max-connection-per-server=2</tt>: Set a maximum of 2 connections to each mirror per file. (Default: 1)<br />
; <tt>--max-file-not-found=5</tt>: Force download to fail if a single byte is not received within 5 attempts. (Default: 0)<br />
; <tt>--min-split-size=5M</tt>: Only split the file if the size is larger than 2;5MB = 10MB. (Default: 20M)<br />
; <tt>--no-conf</tt>: Disable loading an {{Filename|aria2.conf}} file if it exists. (Default: {{Filename|~/.aria2/aria2.conf}})<br />
; <tt>--remote-time=true</tt>: Apply timestamps of the remote file(s) and apply them to the local file(s). (Default: false)<br />
; <tt>--summary-interval=60</tt>: Output download progress summary every 60 seconds. (Default: 60) <b><sup>2</sup></b><br />
; <tt>-t5, --timeout=5</tt>: Set a 5 second timeout per mirror after a connection is established. (Default: 60)<br />
; <tt>-d, --dir</tt>: The directory to store the downloaded file(s) as specified by [[pacman|pacman]].<br />
; <tt>-o, --output</tt>: The output file name(s) of the downloaded file(s). <br />
; <tt>%o</tt>: Variable which represents the local filename(s) as specified by pacman.<br />
; <tt>%u</tt>: Variable which represents the download URL as specified by pacman.<br />
<br />
==== Additional Notes ====<br />
<br />
; <sup>1</sup> <tt>--file-allocation=falloc</tt>: Recommended for newer file systems such as ext4 (with extents support), btrfs or xfs as it allocates large files (GB) almost instantly. Do not use falloc with legacy file systems such as ext3 as prealloc consumes approximately the same amount of time as standard allocation would while locking the aria2 process from proceeding to download.<br />
<br />
;<sup>2</sup> <tt>--summary-interval=0</tt>: Supresses download progress summary output and may improve overall performance. Logs will continue to be output according to the value specified in the <tt>log-level</tt> option.<br />
<br />
=== Powerpill ===<br />
'''''[http://xyne.archlinux.ca/info/powerpill Powerpill]''''' is a wrapper for pacman that uses aria2 to download packages. Unlike the other aria2 solutions, powerpill uses '''simultaneous''' downloads for all files and segmented downloads only for larger files, which really makes the most of your bandwidth without wasting time splitting small files unnecessarily. Powerpill is available in the community repo.<br />
<br />
# pacman -S powerpill<br />
<br />
For more info, see the [[Powerpill]] wiki article.<br />
<br />
=== Using airpac ===<br />
<br />
In a nutshell, [http://aur.archlinux.org/packages.php?ID=26118 airpac] is an aria2c wrapper for pacman. Unlike powerpill, which acts as a frontend to pacman, airpac serves as a backend downloader for pacman. On the other hand, however, it behaves similarly to powerpill, as far as downloading is concerned, since both use aria2c to actually download the files. Because it is a backend though, it cannot download multiple packages simultaneously as powerpill can.<br />
<br />
Essentially, airpac is the Python implementation of the pacget script below. However, the main difference lies in the handling of aria2c output. airpac shows only the most relevant info, i.e., the download progress, although it currently doesn't use a progressbar (maybe in the near future). Also, airpac caches the db files so that they won't be downloaded for every <code>pacman -Sy</code>. On the downside, this breaks <code>pacman -Syy</code> since airpac has no way of knowing the options pacman is executed with. As a workaround, however, one can use <code>pacman -Sc</code> to delete the cached files in '''/var/lib/pacman/.airpac'''.<br />
<br />
The configuration file is located in '''/etc/airpac.conf'''. This is actually an aria2c config file. Because of this, the user can directly configure how aria2c is used by airpac without meddling with airpac's code. For more info about the available options, consult the aria2c manpage.<br />
<br />
airpac also uses the ''Server Performance Profile'' feature of aria2c by default. The statistics file is located in '''/var/lib/airpac.stats'''. The default URI selector is ''adaptive''.<br />
<br />
'''Usage in /etc/pacman.conf'''<br />
XferCommand = /usr/bin/airpac %u %o<br />
<br />
=== pacget (aria2) Mirror Script ===<br />
<br />
This script will greatly improve the download speed for broadband users. It uses the servers in /etc/pacman.d/mirrorlist as mirrors in aria2. What happens is that aria2 downloads from multiple servers simultaneously which gives a huge boost in download speed.<br />
<br />
Take note that you have to put 'exec' before /usr/bin/pacget in the XferCommand. This is needed so that when you terminate pacget or aria2 (with process id used by pacget), pacman would also terminate. This would prevent inconvenience because Pacman would not persist downloading a file when you tell it not to.<br />
<br />
WARNING: You may experience some problems if the mirrors used are out-of-sync or are simply not up-to-date. Just use the [[Reflector]] script to generate a list of up-to-date and ''fast'' mirrors. Also, ftp.archlinux.org resolves to two IPs. You may want to choose only one of them and hard code ftp.archlinux.org and the chosen IP address to /etc/hosts.<br />
<br />
'''/usr/bin/pacget'''<br />
<pre><br />
#!/bin/bash<br />
<br />
msg() {<br />
echo ""<br />
echo -e " \033[1;34m->\033[1;0m \033[1;1m${1}\033[1;0m" >&2<br />
}<br />
<br />
error() {<br />
echo -e "\033[1;31m==> ERROR:\033[1;0m \033[1;1m$1\033[1;0m" >&2<br />
}<br />
<br />
CONF=/etc/pacget.conf<br />
STATS=/etc/pacget.stats<br />
ARIA2=$(which aria2c 2> /dev/null)<br />
<br />
# ----- do some checks first -----<br />
if [ ! -x "$ARIA2" ]; then<br />
error "aria2c was not found or isn't executable."<br />
exit 1<br />
fi<br />
<br />
if [ $# -ne 2 ]; then<br />
error "Incorrect number of arguments"<br />
exit 1<br />
fi<br />
<br />
filename=$(basename $1)<br />
server=${1%/$filename}<br />
<br />
# Determine which repo is being used<br />
repo=$(awk -F'/' '$(NF-2)~/^(community|core|extra|testing)$/{print $(NF-2)}' <<< $server)<br />
[ -z $repo ] && repo="custom"<br />
<br />
# For db files, or when using a custom repo (which most likely doesn't have any mirror),<br />
# use only the URL passed by pacman; Otherwise, extract the list of servers (from the include file of the repo) to download from<br />
url=$1<br />
if ! [[ $filename = *.db.tar.gz || $repo = "custom" ]]; then<br />
mirrorlist=$(awk -F' *= *' '$0~"^\\["r"\\]",/Include *= */{l=$2} END{print l}' r=$repo /etc/pacman.conf)<br />
if [ -n mirrorlist ]; then<br />
num_conn=$(grep ^split $CONF | cut -d'=' -f2)<br />
url=$(sed -r '/^Server *= */!d; s/Server *= *//; s/\$repo'"/$repo/; s:$:/$filename:" $mirrorlist | head -n $(($num_conn * 2)))<br />
fi<br />
fi<br />
<br />
msg "Downloading $filename"<br />
cd /var/cache/pacman/pkg/<br />
<br />
touch $STATS<br />
<br />
$ARIA2 --conf-path=$CONF --max-tries=1 --max-file-not-found=5 \<br />
--uri-selector=adaptive --server-stat-if=$STATS --server-stat-of=$STATS \<br />
--allow-overwrite=true --remote-time=true --log-level=error --summary-interval=0 \<br />
$url --out=${filename}.pacget && [ ! -f ${filename}.pacget.aria2 ] && mv ${filename}.pacget $2 && chmod 644 $2<br />
<br />
exit $?<br />
</pre><br />
<br />
'''/etc/pacget.conf'''<br />
<pre><br />
# The log file<br />
log=/var/log/pacget.log<br />
# Server timeout period<br />
timeout=5<br />
# 'none' or 'falloc'<br />
file-allocation=none<br />
</pre><br />
<br />
Save this script as /usr/bin/pacget.<br />
chmod 755 /usr/bin/pacget<br />
This makes the script an executable<br />
<br />
In /etc/pacman.conf, in the [options] section, the following needs to be added:<br />
XferCommand = exec /usr/bin/pacget %u %o<br />
<br />
PS: If you use ftp.archlinux.org as the first server listed in your include files (/etc/pacman.d/*), some problems may occur when the mirrors you are using have not yet synced. To make great use of this script, choose a mirror (that syncs in a timely manner) that is more appropriate for you, then put that on top of the server lists. This is to prevent downloading only from ftp.archlinux.org when the mirrors have not yet synced. The rankmirrors python script can be useful in this case.<br />
<br />
=== Using other applications ===<br />
<br />
There are other downloading applications that you can use with Pacman. Here they are, and their associated XferCommand settings:<br />
<br />
* <code>snarf</code>: <code>XferCommand = /usr/bin/snarf -N %u</code><br />
* <code>lftp</code>: <code>XferCommand = /usr/bin/lftp -c pget %u</code><br />
* <code>axel</code>: <code>XferCommand = /usr/bin/axel -n 2 -v -a -o %o %u</code><br />
<br />
== Choosing the fastest mirror ==<br />
When downloading packages pacman uses the mirrors in the order they are in /etc/pacman.d/mirrorlist.The mirror which is at the top of the list by default however may not be the fastest for you.<br />
<br />
=== Choosing a local mirror ===<br />
The simple way is to edit mirrorlist file by placing a local mirror at the top of the list. pacman will then use this mirror for preference.<br />
<br />
Alternativley the pacman.conf file can be edited by placing a local mirror before the line sourcing the mirrorlist file, i.e. where it says "add your preferred servers here". It is safer if you use the same server for each repository.<br />
<br />
=== Using rankmirror ===<br />
<br />
You can use rankmirrors to rank pacman mirrors by their connection and opening speed.<br />
<br />
Backup the original in case any problems come up:<br />
<br />
mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.org<br />
<br />
Then run rankmirrors to test and add the five fastest mirrors:<br />
<br />
rankmirrors -n 5 /etc/pacman.d/mirrorlist.org > /etc/pacman.d/mirrorlist<br />
<br />
See the help for more information.<br />
<br />
rankmirrors -h<br />
<br />
=== After changing mirrors ===<br />
<br />
After changing your mirror it is a good idea to refresh the pacman database. Using two y's forces a download of a fresh copy of the master package list from the server even if they are thought to be up to date.<br />
<br />
# pacman -Syy<br />
<br />
== Sharing packages over your LAN ==<br />
<br />
If you happen to run several Arch boxes on your LAN, you can share packages so that you can greatly decrease your download times. Keep in mind you should not share between different architectures (i.e. i686 and x86_64) or you'll get into troubles.<br />
There are actually 2 ways to achieve this :<br />
<br />
=== The do-it-yourself way ===<br />
<br />
Get your hands dirty: http://wiki.archlinux.org/index.php/Howto_Upgrade_via_Home_Network<br />
<br />
=== The easy way ===<br />
<br />
Install and configure [http://xyne.archlinux.ca/contributions Xyne]'s pkgd: http://xyne.archlinux.ca/info/pkgd<br />
<br />
[http://bbs.archlinux.org/viewtopic.php?id=64391 Related forum thread]</div>Xrchzhttps://wiki.archlinux.org/index.php?title=Improve_pacman_performance&diff=117860Improve pacman performance2010-09-22T23:26:54Z<p>Xrchz: /* pacman-cage */</p>
<hr />
<div>[[Category:Package management (English)]]<br />
[[Category:HOWTOs (English)]]<br />
{{i18n|Improve_Pacman_Performance}}<br />
[[de:Pacman beschleunigen]]<br />
<br />
== Improving Database Access Speeds ==<br />
<br />
Pacman stores all package information in a collection of small files, one for each package. Improving database access speeds reduces the time taken in database-related tasks, e.g. searching packages and resolving package dependencies. The safest and easiest method is to run as root:<br />
<br />
# pacman-optimize && sync<br />
<br />
This will attempt to put all the small files together in one (physical) location on the hard disk so that the hard disk head does not have to move so much when accessing all the packages. This method is safe, but is not foolproof. It depends on your filesystem, disk usage and empty space fragmentation. Another more aggressive option would be to first remove uninstalled packages from cache and to remove unused repositories before database optimization:<br />
<br />
# pacman -Sc && pacman-optimize && sync<br />
<br />
===pacman-cage===<br />
'''pacman-cage''' is a script that puts the pacman database, {{Filename|/var/lib/pacman}}, in a single loop file containing its own file-system that can speed up access times. This very simple alteration that improves pacman's speed for tasks like searching and updating. The script makes a backup (at installation only) in case something goes wrong but has caused some users to lose their database (e.g. when used in a chroot). Use with caution.<br />
<br />
pacman-cage is now part of [http://aur.archlinux.org/packages.php?ID=5907 pactools] in [[AUR]] and has been renamed pt-pacman-cage (with his brother pt-pacman-uncage)<br />
'''Update''' [http://aur.archlinux.org/packages.php?ID=32483 This package] is probably better.<br />
<br />
== Improving Download Speeds ==<br />
<br />
Firstly, if your download speeds have been reduced to a crawl, ensure you are using one of the many [[mirrors]] and not ftp.archlinux.org, which, [http://www.archlinux.org/news/302/ as of March 2007], is now throttled.<br />
<br />
Pacman's speed in downloading packages can be improved by using a different application to download packages instead of Pacman's built-in file downloader.<br />
<br />
In all cases, make sure you have the latest Pacman before doing any modifications.<br />
<br />
# pacman -Syu<br />
<br />
=== Using wget ===<br />
<br />
This is also very handy if you need more powerful proxy settings than pacman's built-in capabilities. <br />
<br />
To use <code>wget</code>, first install it with <code>pacman -S wget</code> and then modify <code>/etc/pacman.conf</code> by adding the following line to the <code>[options]</code> section:<br />
<br />
XferCommand = /usr/bin/wget -c --passive-ftp -c %u<br />
<br />
Instead of putting <code>wget</code> parameters in {{Filename|/etc/pacman.conf}}, you can also modify the {{Filename|wget}} configuration file directly (the system-wide file is {{Filename|/etc/wgetrc}}, per user files are {{Filename|$HOME/.wgetrc}}.<br />
<br />
=== Using aria2 ===<br />
<br />
[[aria2]] is a lightweight download utility with support for resumable and segmented HTTP/HTTPS and FTP downloads. [http://aria2.sourceforge.net/ aria2] allows for multiple and simultaneous HTTP/HTTPS and FTP connections to an Arch mirror, which should result in an increase in download speeds for both file and package retrieval. <br />
<br />
==== Installation ====<br />
<br />
Download and install {{Package Official|aria2}} and its dependencies:<br />
<br />
# pacman -S aria2<br />
<br />
==== Configuration ====<br />
<br />
Edit {{Filename|/etc/pacman.conf}} by adding the following line to the <code>[option]</code> section:<br />
<br />
XferCommand = /usr/bin/aria2c --allow-overwrite=true -c --file-allocation=none --log-level=error -m2 --max-connection-per-server=2 --max-file-not-found=5 --min-split-size=5M --no-conf --remote-time=true --summary-interval=60 -t5 -d / -o %o %u<br />
<br />
==== Option Details ====<br />
<br />
; <tt>/usr/bin/aria2c</tt>: The full PATH to the aria2 executable.<br />
; <tt>--allow-overwrite=true</tt>: Restart download if a corresponding control file does not exist. (Default: false)<br />
; <tt>-c, --continue</tt>: Continue downloading a partially downloaded file if a corresponding control file exists.<br />
; <tt>--file-allocation=none</tt>: Do not pre-allocate file space before download begins. (Default: prealloc) <b><sup>1</sup></b><br />
; <tt>--log-level=error</tt>: Set log level to output errors only. (Default: debug)<br />
; <tt>-m2, --max-tries=2</tt>: Make 2 maximum attempts to download specified file(s) per mirror. (Default: 5)<br />
; <tt>--max-connection-per-server=2</tt>: Set a maximum of 2 connections to each mirror per file. (Default: 1)<br />
; <tt>--max-file-not-found=5</tt>: Force download to fail if a single byte is not received within 5 attempts. (Default: 0)<br />
; <tt>--min-split-size=5M</tt>: Only split the file if the size is larger than 2;5MB = 10MB. (Default: 20M)<br />
; <tt>--no-conf</tt>: Disable loading an {{Filename|aria2.conf}} file if it exists. (Default: {{Filename|~/.aria2/aria2.conf}})<br />
; <tt>--remote-time=true</tt>: Apply timestamps of the remote file(s) and apply them to the local file(s). (Default: false)<br />
; <tt>--summary-interval=60</tt>: Output download progress summary every 60 seconds. (Default: 60) <b><sup>2</sup></b><br />
; <tt>-t5, --timeout=5</tt>: Set a 5 second timeout per mirror after a connection is established. (Default: 60)<br />
; <tt>-d, --dir</tt>: The directory to store the downloaded file(s) as specified by [[pacman|pacman]].<br />
; <tt>-o, --output</tt>: The output file name(s) of the downloaded file(s). <br />
; <tt>%o</tt>: Variable which represents the local filename(s) as specified by pacman.<br />
; <tt>%u</tt>: Variable which represents the download URL as specified by pacman.<br />
<br />
==== Additional Notes ====<br />
<br />
; <sup>1</sup> <tt>--file-allocation=falloc</tt>: Recommended for newer file systems such as ext4 (with extents support), btrfs or xfs as it allocates large files (GB) almost instantly. Do not use falloc with legacy file systems such as ext3 as prealloc consumes approximately the same amount of time as standard allocation would while locking the aria2 process from proceeding to download.<br />
<br />
;<sup>2</sup> <tt>--summary-interval=0</tt>: Supresses download progress summary output and may improve overall performance. Logs will continue to be output according to the value specified in the <tt>log-level</tt> option.<br />
<br />
=== Powerpill ===<br />
'''''[http://xyne.archlinux.ca/info/powerpill Powerpill]''''' is a wrapper for pacman that uses aria2 to download packages. Unlike the other aria2 solutions, powerpill uses '''simultaneous''' downloads for all files and segmented downloads only for larger files, which really makes the most of your bandwidth without wasting time splitting small files unnecessarily. Powerpill is available in the community repo.<br />
<br />
# pacman -S powerpill<br />
<br />
For more info, see the [[Powerpill]] wiki article.<br />
<br />
=== Using airpac ===<br />
<br />
In a nutshell, [http://aur.archlinux.org/packages.php?ID=26118 airpac] is an aria2c wrapper for pacman. Unlike powerpill, which acts as a frontend to pacman, airpac serves as a backend downloader for pacman. On the other hand, however, it behaves similarly to powerpill, as far as downloading is concerned, since both use aria2c to actually download the files. Because it is a backend though, it cannot download multiple packages simultaneously as powerpill can.<br />
<br />
Essentially, airpac is the Python implementation of the pacget script below. However, the main difference lies in the handling of aria2c output. airpac shows only the most relevant info, i.e., the download progress, although it currently doesn't use a progressbar (maybe in the near future). Also, airpac caches the db files so that they won't be downloaded for every <code>pacman -Sy</code>. On the downside, this breaks <code>pacman -Syy</code> since airpac has no way of knowing the options pacman is executed with. As a workaround, however, one can use <code>pacman -Sc</code> to delete the cached files in '''/var/lib/pacman/.airpac'''.<br />
<br />
The configuration file is located in '''/etc/airpac.conf'''. This is actually an aria2c config file. Because of this, the user can directly configure how aria2c is used by airpac without meddling with airpac's code. For more info about the available options, consult the aria2c manpage.<br />
<br />
airpac also uses the ''Server Performance Profile'' feature of aria2c by default. The statistics file is located in '''/var/lib/airpac.stats'''. The default URI selector is ''adaptive''.<br />
<br />
'''Usage in /etc/pacman.conf'''<br />
XferCommand = /usr/bin/airpac %u %o<br />
<br />
=== pacget (aria2) Mirror Script ===<br />
<br />
This script will greatly improve the download speed for broadband users. It uses the servers in /etc/pacman.d/mirrorlist as mirrors in aria2. What happens is that aria2 downloads from multiple servers simultaneously which gives a huge boost in download speed.<br />
<br />
Take note that you have to put 'exec' before /usr/bin/pacget in the XferCommand. This is needed so that when you terminate pacget or aria2 (with process id used by pacget), pacman would also terminate. This would prevent inconvenience because Pacman would not persist downloading a file when you tell it not to.<br />
<br />
WARNING: You may experience some problems if the mirrors used are out-of-sync or are simply not up-to-date. Just use the [[Reflector]] script to generate a list of up-to-date and ''fast'' mirrors. Also, ftp.archlinux.org resolves to two IPs. You may want to choose only one of them and hard code ftp.archlinux.org and the chosen IP address to /etc/hosts.<br />
<br />
'''/usr/bin/pacget'''<br />
<pre><br />
#!/bin/bash<br />
<br />
msg() {<br />
echo ""<br />
echo -e " \033[1;34m->\033[1;0m \033[1;1m${1}\033[1;0m" >&2<br />
}<br />
<br />
error() {<br />
echo -e "\033[1;31m==> ERROR:\033[1;0m \033[1;1m$1\033[1;0m" >&2<br />
}<br />
<br />
CONF=/etc/pacget.conf<br />
STATS=/etc/pacget.stats<br />
ARIA2=$(which aria2c 2> /dev/null)<br />
<br />
# ----- do some checks first -----<br />
if [ ! -x "$ARIA2" ]; then<br />
error "aria2c was not found or isn't executable."<br />
exit 1<br />
fi<br />
<br />
if [ $# -ne 2 ]; then<br />
error "Incorrect number of arguments"<br />
exit 1<br />
fi<br />
<br />
filename=$(basename $1)<br />
server=${1%/$filename}<br />
<br />
# Determine which repo is being used<br />
repo=$(awk -F'/' '$(NF-2)~/^(community|core|extra|testing)$/{print $(NF-2)}' <<< $server)<br />
[ -z $repo ] && repo="custom"<br />
<br />
# For db files, or when using a custom repo (which most likely doesn't have any mirror),<br />
# use only the URL passed by pacman; Otherwise, extract the list of servers (from the include file of the repo) to download from<br />
url=$1<br />
if ! [[ $filename = *.db.tar.gz || $repo = "custom" ]]; then<br />
mirrorlist=$(awk -F' *= *' '$0~"^\\["r"\\]",/Include *= */{l=$2} END{print l}' r=$repo /etc/pacman.conf)<br />
if [ -n mirrorlist ]; then<br />
num_conn=$(grep ^split $CONF | cut -d'=' -f2)<br />
url=$(sed -r '/^Server *= */!d; s/Server *= *//; s/\$repo'"/$repo/; s:$:/$filename:" $mirrorlist | head -n $(($num_conn * 2)))<br />
fi<br />
fi<br />
<br />
msg "Downloading $filename"<br />
cd /var/cache/pacman/pkg/<br />
<br />
touch $STATS<br />
<br />
$ARIA2 --conf-path=$CONF --max-tries=1 --max-file-not-found=5 \<br />
--uri-selector=adaptive --server-stat-if=$STATS --server-stat-of=$STATS \<br />
--allow-overwrite=true --remote-time=true --log-level=error --summary-interval=0 \<br />
$url --out=${filename}.pacget && [ ! -f ${filename}.pacget.aria2 ] && mv ${filename}.pacget $2 && chmod 644 $2<br />
<br />
exit $?<br />
</pre><br />
<br />
'''/etc/pacget.conf'''<br />
<pre><br />
# The log file<br />
log=/var/log/pacget.log<br />
# Server timeout period<br />
timeout=5<br />
# 'none' or 'falloc'<br />
file-allocation=none<br />
</pre><br />
<br />
Save this script as /usr/bin/pacget.<br />
chmod 755 /usr/bin/pacget<br />
This makes the script an executable<br />
<br />
In /etc/pacman.conf, in the [options] section, the following needs to be added:<br />
XferCommand = exec /usr/bin/pacget %u %o<br />
<br />
PS: If you use ftp.archlinux.org as the first server listed in your include files (/etc/pacman.d/*), some problems may occur when the mirrors you are using have not yet synced. To make great use of this script, choose a mirror (that syncs in a timely manner) that is more appropriate for you, then put that on top of the server lists. This is to prevent downloading only from ftp.archlinux.org when the mirrors have not yet synced. The rankmirrors python script can be useful in this case.<br />
<br />
=== Using other applications ===<br />
<br />
There are other downloading applications that you can use with Pacman. Here they are, and their associated XferCommand settings:<br />
<br />
* <code>snarf</code>: <code>XferCommand = /usr/bin/snarf -N %u</code><br />
* <code>lftp</code>: <code>XferCommand = /usr/bin/lftp -c pget %u</code><br />
* <code>axel</code>: <code>XferCommand = /usr/bin/axel -n 2 -v -a -o %o %u</code><br />
<br />
== Choosing the fastest mirror ==<br />
When downloading packages pacman uses the mirrors in the order they are in /etc/pacman.d/mirrorlist.The mirror which is at the top of the list by default however may not be the fastest for you.<br />
<br />
=== Choosing a local mirror ===<br />
The simple way is to edit mirrorlist file by placing a local mirror at the top of the list. pacman will then use this mirror for preference.<br />
<br />
Alternativley the pacman.conf file can be edited by placing a local mirror before the line sourcing the mirrorlist file, i.e. where it says "add your preferred servers here". It is safer if you use the same server for each repository.<br />
<br />
=== Using rankmirror ===<br />
<br />
You can use rankmirrors to rank pacman mirrors by their connection and opening speed.<br />
<br />
Backup the original in case any problems come up:<br />
<br />
mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.org<br />
<br />
Then run rankmirrors to test and add the five fastest mirrors:<br />
<br />
rankmirrors -n 5 /etc/pacman.d/mirrorlist.org > /etc/pacman.d/mirrorlist<br />
<br />
See the help for more information.<br />
<br />
rankmirrors -h<br />
<br />
=== After changing mirrors ===<br />
<br />
After changing your mirror it is a good idea to refresh the pacman database. Using two y's forces a download of a fresh copy of the master package list from the server even if they are thought to be up to date.<br />
<br />
# pacman -Syy<br />
<br />
== Sharing packages over your LAN ==<br />
<br />
If you happen to run several Arch boxes on your LAN, you can share packages so that you can greatly decrease your download times. Keep in mind you should not share between different architectures (i.e. i686 and x86_64) or you'll get into troubles.<br />
There are actually 2 ways to achieve this :<br />
<br />
=== The do-it-yourself way ===<br />
<br />
Get your hands dirty: http://wiki.archlinux.org/index.php/Howto_Upgrade_via_Home_Network<br />
<br />
=== The easy way ===<br />
<br />
Install and configure [http://xyne.archlinux.ca/contributions Xyne]'s pkgd: http://xyne.archlinux.ca/info/pkgd<br />
<br />
[http://bbs.archlinux.org/viewtopic.php?id=64391 Related forum thread]</div>Xrchzhttps://wiki.archlinux.org/index.php?title=Firefox/Profile_on_RAM&diff=117828Firefox/Profile on RAM2010-09-22T05:50:22Z<p>Xrchz: /* Warning */</p>
<hr />
<div>[[Category:Internet and Email (English)]]<br />
[[Category:Scripts (English)]]<br />
[[Category:HOWTOs (English)]]<br />
Assuming that there is memory to spare, caching all, or part of [[Firefox]]'s profile to RAM using [[Wikipedia:tmpfs|tmpfs]] offers significant advantages. Even though opting for the partial route is an improvement by itself, the latter can make Firefox even more responsive compared to its stock configuration. Benefits include, among others:<br />
*reduced disk read/writes (ideal for [[Maximizing performance#Tuning for an SSD|SSD]])<br />
*heightened responsive feel<br />
*many operations within Firefox, such as quick search and history queries, are nearly instantaneous<br />
<br />
Both of previously mentioned options make use of native shared memory; [[/dev/shm]], a directory that behaves just as ordinary mounted file systems do, only with the notable exception that all of its content is stored in RAM.<br />
<br />
Because data placed therein cannot survive a shutdown, a script used when [[#Relocating the entire profile to RAM|moving the whole profile to RAM]] overcomes this limitation by syncing back to disk prior system shut down, whereas [[#Relocating only the cache to RAM|only relocating the cache]] is a quick, less inclusive solution.<br />
<br />
==Relocating only the cache to RAM==<br />
<small>''Adapted from [http://bbs.archlinux.org/viewtopic.php?pid=604369 this forum post]''</small><br />
<br />
After entering {{codeline|about:config}} into the address bar, create a new string by right-clicking in the bottom half, selecting ''New'', followed by ''String''. Assign its value:<br />
browser.cache.disk.parent_directory<br />
<br />
Now, double-click the newly created string and direct it towards the RAM directory:<br />
/dev/shm/''firefox-cache''<br />
<br />
Finally, create the directory and ensure its permissions have security in mind:<br />
install -dm700 /dev/shm/''firefox-cache''<br />
<br />
Upon restarting Firefox, it will start using {{Filename|/dev/shm/firefox-cache}} as the cache directory. Do mind that the directory and its contents will ''not'' be saved after a reboot using this method.<br />
<br />
==Relocating the entire profile to RAM==<br />
===Warning===<br />
'''Note''' this is broken in the current version of firefox (3.6.3). The xpti engine freaks out and dies if filesystem links are involved in any addon that supplies a xpt file (see https://bugzilla.mozilla.org/show_bug.cgi?id=551152). That said, these instructions should resume working once firefox is fixed. A temporary workaround is to delete the compatibility.ini file before launching firefox, like so:<br />
{{file|name=/usr/bin/firefox|content=<br />
+ rm -f ~/.mozilla/firefox/*/compatibility.ini<br />
"$dist_bin/run-mozilla.sh" $script_args "$dist_bin/$MOZILLA_BIN" "$@"<br />
}}<br />
<br />
Another workaround, if {{Codeline|firefox}} fails to start, is to run {{Codeline|firefox --safe-mode}}, then just quit, then run {{Codeline|firefox}} again.<br />
<br />
===Before you start===<br />
Before potentially compromising Firefox's profile, be sure to make a backup for quick restoration. Replace {{codeline|xyz.default}} as appropriate and use {{codeline|tar}} to make a backup:<br />
$ tar zcvfp ~/firefox_profile_backup.tar.gz ~/.mozilla/firefox/'''xyz.default'''<br />
<br />
===The script===<br />
<small>''Adapted from [http://www.verot.net/firefox_tmpfs.htm verot.net's Speed up Firefox with tmpfs]''</small><br />
<br />
The script will first move Firefox's profile to a new static location, make a sub-directory in {{filename|/dev/shm}}, softlink to it and later populate it with the contents of the profile. As before, replace the bold sections to suit. The only value that absolutely needs to be altered is, again, {{codeline|xyz.default}}.<br />
<br />
Be sure that [[rsync]] is installed and save the script to {{filename|~/bin/firefox-sync}}, for example:<br />
{{file|name=firefox-sync|content=<br />
#!/bin/bash<br />
STATIC='''main'''<br />
LINK='''xyz.default'''<br />
VOLATILE='''/dev/shm/$USER/firefox'''<br />
<nowiki><br />
cd ~/.mozilla/firefox<br />
<br />
[[ -r $VOLATILE ]] || install -dm700 $VOLATILE<br />
<br />
if [[ `readlink $LINK` != $VOLATILE ]]; then<br />
mv $LINK $STATIC<br />
ln -s $VOLATILE $LINK<br />
fi<br />
<br />
if [[ -e $LINK/.unpacked ]]; then<br />
rsync -av --delete --exclude .unpacked ./$LINK/ ./$STATIC/<br />
else<br />
rsync -av ./$STATIC/ ./$LINK/<br />
touch $LINK/.unpacked<br />
fi<br />
</nowiki><br />
}}<br />
<br />
Close Firefox, make the script executable and test it:<br />
$ killall firefox; chmod +x ''~/bin/firefox-sync''; ''~/bin/firefox-sync''<br />
<br />
Run Firefox again to gauge the results. The second time the script runs, it will then preserve the RAM profile by copying it back to disk.<br />
Firefox could be called firefox-bin as well<br />
$ killall firefox'''-bin'''; chmod +x ''~/bin/firefox-sync''; ''~/bin/firefox-sync''<br />
<br />
===Automation===<br />
Seeing that forgetting to sync the profile can lead to disastrous results, automating the process seems like a logical course of action.<br />
<br />
===cron job===<br />
Manipulate the user's [[cron]] table using {{codeline|crontab}}:<br />
$ crontab -e<br />
<br />
Add a line to start the script every 30 minutes,<br />
*/30 * * * * ''~/bin/firefox-sync''<br />
or add the following to do so every 2 hours:<br />
0 */2 * * * ''~/bin/firefox-sync''<br />
<br />
===Sync at login/logout===<br />
Deeming [[bash]] is being used, add the script to the login/logout files:<br />
$ echo '<i>~/bin/firefox-sync</i>' | tee -a ~/.bash_logout ~/.bash_login >/dev/null<br />
<br />
== Resources ==<br />
* [http://en.wikipedia.org/wiki/Tmpfs tmpfs] on Wikipedia<br />
* [[Fstab#tmpfs]]</div>Xrchzhttps://wiki.archlinux.org/index.php?title=Firefox/Profile_on_RAM&diff=117821Firefox/Profile on RAM2010-09-22T02:01:49Z<p>Xrchz: </p>
<hr />
<div>[[Category:Internet and Email (English)]]<br />
[[Category:Scripts (English)]]<br />
[[Category:HOWTOs (English)]]<br />
Assuming that there is memory to spare, caching all, or part of [[Firefox]]'s profile to RAM using [[Wikipedia:tmpfs|tmpfs]] offers significant advantages. Even though opting for the partial route is an improvement by itself, the latter can make Firefox even more responsive compared to its stock configuration. Benefits include, among others:<br />
*reduced disk read/writes (ideal for [[Maximizing performance#Tuning for an SSD|SSD]])<br />
*heightened responsive feel<br />
*many operations within Firefox, such as quick search and history queries, are nearly instantaneous<br />
<br />
Both of previously mentioned options make use of native shared memory; [[/dev/shm]], a directory that behaves just as ordinary mounted file systems do, only with the notable exception that all of its content is stored in RAM.<br />
<br />
Because data placed therein cannot survive a shutdown, a script used when [[#Relocating the entire profile to RAM|moving the whole profile to RAM]] overcomes this limitation by syncing back to disk prior system shut down, whereas [[#Relocating only the cache to RAM|only relocating the cache]] is a quick, less inclusive solution.<br />
<br />
==Relocating only the cache to RAM==<br />
<small>''Adapted from [http://bbs.archlinux.org/viewtopic.php?pid=604369 this forum post]''</small><br />
<br />
After entering {{codeline|about:config}} into the address bar, create a new string by right-clicking in the bottom half, selecting ''New'', followed by ''String''. Assign its value:<br />
browser.cache.disk.parent_directory<br />
<br />
Now, double-click the newly created string and direct it towards the RAM directory:<br />
/dev/shm/''firefox-cache''<br />
<br />
Finally, create the directory and ensure its permissions have security in mind:<br />
install -dm700 /dev/shm/''firefox-cache''<br />
<br />
Upon restarting Firefox, it will start using {{Filename|/dev/shm/firefox-cache}} as the cache directory. Do mind that the directory and its contents will ''not'' be saved after a reboot using this method.<br />
<br />
==Relocating the entire profile to RAM==<br />
===Warning===<br />
'''Note''' this is broken in the current version of firefox (3.6.3). The xpti engine freaks out and dies if filesystem links are involved in any addon that supplies a xpt file (see https://bugzilla.mozilla.org/show_bug.cgi?id=551152). That said, these instructions should resume working once firefox is fixed. A temporary workaround is to delete the compatibility.ini file before launching firefox, like so:<br />
{{file|name=/usr/bin/firefox|content=<br />
+ rm -f ~/.mozilla/firefox/*/compatibility.ini<br />
"$dist_bin/run-mozilla.sh" $script_args "$dist_bin/$MOZILLA_BIN" "$@"<br />
}}<br />
'''Update''' Script below seems to work as-is on Firefox 3.6.10, although the bug above is not closed.<br />
<br />
===Before you start===<br />
Before potentially compromising Firefox's profile, be sure to make a backup for quick restoration. Replace {{codeline|xyz.default}} as appropriate and use {{codeline|tar}} to make a backup:<br />
$ tar zcvfp ~/firefox_profile_backup.tar.gz ~/.mozilla/firefox/'''xyz.default'''<br />
<br />
===The script===<br />
<small>''Adapted from [http://www.verot.net/firefox_tmpfs.htm verot.net's Speed up Firefox with tmpfs]''</small><br />
<br />
The script will first move Firefox's profile to a new static location, make a sub-directory in {{filename|/dev/shm}}, softlink to it and later populate it with the contents of the profile. As before, replace the bold sections to suit. The only value that absolutely needs to be altered is, again, {{codeline|xyz.default}}.<br />
<br />
Be sure that [[rsync]] is installed and save the script to {{filename|~/bin/firefox-sync}}, for example:<br />
{{file|name=firefox-sync|content=<br />
#!/bin/bash<br />
STATIC='''main'''<br />
LINK='''xyz.default'''<br />
VOLATILE='''/dev/shm/$USER/firefox'''<br />
<nowiki><br />
cd ~/.mozilla/firefox<br />
<br />
[[ -r $VOLATILE ]] || install -dm700 $VOLATILE<br />
<br />
if [[ `readlink $LINK` != $VOLATILE ]]; then<br />
mv $LINK $STATIC<br />
ln -s $VOLATILE $LINK<br />
fi<br />
<br />
if [[ -e $LINK/.unpacked ]]; then<br />
rsync -av --delete --exclude .unpacked ./$LINK/ ./$STATIC/<br />
else<br />
rsync -av ./$STATIC/ ./$LINK/<br />
touch $LINK/.unpacked<br />
fi<br />
</nowiki><br />
}}<br />
<br />
Close Firefox, make the script executable and test it:<br />
$ killall firefox; chmod +x ''~/bin/firefox-sync''; ''~/bin/firefox-sync''<br />
<br />
Run Firefox again to gauge the results. The second time the script runs, it will then preserve the RAM profile by copying it back to disk.<br />
Firefox could be called firefox-bin as well<br />
$ killall firefox'''-bin'''; chmod +x ''~/bin/firefox-sync''; ''~/bin/firefox-sync''<br />
<br />
===Automation===<br />
Seeing that forgetting to sync the profile can lead to disastrous results, automating the process seems like a logical course of action.<br />
<br />
===cron job===<br />
Manipulate the user's [[cron]] table using {{codeline|crontab}}:<br />
$ crontab -e<br />
<br />
Add a line to start the script every 30 minutes,<br />
*/30 * * * * ''~/bin/firefox-sync''<br />
or add the following to do so every 2 hours:<br />
0 */2 * * * ''~/bin/firefox-sync''<br />
<br />
===Sync at login/logout===<br />
Deeming [[bash]] is being used, add the script to the login/logout files:<br />
$ echo '<i>~/bin/firefox-sync</i>' | tee -a ~/.bash_logout ~/.bash_login >/dev/null<br />
<br />
== Resources ==<br />
* [http://en.wikipedia.org/wiki/Tmpfs tmpfs] on Wikipedia<br />
* [[Fstab#tmpfs]]</div>Xrchz