https://wiki.archlinux.org/api.php?action=feedcontributions&user=Mach1NE&feedformat=atomArchWiki - User contributions [en]2024-03-28T21:28:21ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=GRUB_Legacy&diff=222013GRUB Legacy2012-09-08T02:25:44Z<p>Mach1NE: Updated link to GNU GRUB (Legacy)</p>
<hr />
<div>[[Category:Boot loaders]]<br />
[[Category:System recovery]]<br />
[[cs:GRUB]]<br />
[[de:GRUB]]<br />
[[el:GRUB]]<br />
[[es:GRUB]]<br />
[[fr:GRUB]]<br />
[[he:GRUB]]<br />
[[it:GRUB Legacy]]<br />
[[nl:GRUB]]<br />
[[ru:GRUB]]<br />
[[tr:Grub]]<br />
[[uk:GRUB]]<br />
[[zh-CN:GRUB Legacy]]<br />
{{Article summary start}}<br />
{{Article summary text|Covers various aspects of Arch Linux's default bootloader, the GRand Unified Bootloader (GRUB).}}<br />
{{Article summary heading|Overview}}<br />
{{Article summary text|{{Boot process overview}}}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Boot Debugging}}<br />
{{Article summary wiki|grub-gfx}}<br />
{{Article summary wiki|Kernel parameters}}<br />
{{Article summary end}}<br />
<br />
[http://www.gnu.org/software/grub/grub-legacy.html GNU GRUB (Legacy)] is a [http://www.gnu.org/software/grub/manual/multiboot/ multiboot] bootloader maintained by the [[GNU Project]]. It was derived from GRUB, the GRand Unified Bootloader, which was originally designed and implemented by Erich Stefan Boleyn. <br />
<br />
Briefly, the ''bootloader'' is the first software program that runs when a computer starts. It is responsible for loading and transferring control to the Linux kernel. The kernel, in turn, initializes the rest of the operating system.<br />
<br />
{{Note|GRUB Legacy has been deprecated and replaced by [[GRUB2]] in Arch Linux. See the news [http://www.archlinux.org/news/grub-legacy-no-longer-supported/ here]. Users are recommended to switch to [[GRUB2]] or [[Syslinux]] instead. See [[#Upgrading to [[GRUB]](2)]] below.}}<br />
<br />
{{Note|The {{pkg|grub}} package does not support [[GPT]] disks, [[Btrfs]] filesystem and [[UEFI]] firmwares.}}<br />
<br />
== Installation ==<br />
<br />
The GRUB package is installed by default when you install Arch Linux. If you previously decided not to install this package, you can [[pacman|install]] the {{pkg|grub}} package from the [[Official Repositories|official repositories]].<br />
<br />
Additionally, GRUB must be installed to the boot sector of a drive or partition to serve as a bootloader. This is covered in the [[#Bootloader installation]] section.<br />
<br />
== Upgrading to [[GRUB]](2) ==<br />
=== Is upgrading necessary ===<br />
The short answser is No. GRUB legacy will not be removed from your system and will stay fully functional.<br />
<br />
However, as any other packages which are not supported anymore, future bugs may not be fixed. So you should consider upgrading to GRUB version 2.x, or one of the other supported [[Boot Loader]]s.<br />
<br />
=== How to upgrade ===<br />
Upgrade from [[GRUB Legacy]] to [[GRUB]](2) is the much same as installing GRUB(2) from a running Arch Linux. Detailed instructions is covered [[GRUB2#Installation|here]].<br />
<br />
== Configuration ==<br />
<br />
The configuration file is located at {{ic|/boot/grub/menu.lst}}. Edit this file to suit your needs.<br />
<br />
* {{ic|timeout #}} -- time to wait (in seconds) before the {{ic|default}} operating system is automatically loaded.<br />
* {{ic|default #}} -- the default boot entry that is chosen when the {{ic|timeout}} has expired.<br />
<br />
An example configuration ({{ic|/boot}} is on a separate partition):<br />
<br />
{{hc<br />
|/boot/grub/menu.lst<br />
|<nowiki><br />
# Config file for GRUB - The GNU GRand Unified Bootloader<br />
# /boot/grub/menu.lst<br />
<br />
# DEVICE NAME CONVERSIONS<br />
#<br />
# Linux GRUB<br />
# -------------------------<br />
# /dev/fd0 (fd0)<br />
# /dev/sda (hd0)<br />
# /dev/sdb2 (hd1,1)<br />
# /dev/sda3 (hd0,2)<br />
#<br />
<br />
# FRAMEBUFFER RESOLUTION SETTINGS<br />
# +-------------------------------------------------+<br />
# | 640x480 800x600 1024x768 1280x1024<br />
# ----+--------------------------------------------<br />
# 256 | 0x301=769 0x303=771 0x305=773 0x307=775<br />
# 32K | 0x310=784 0x313=787 0x316=790 0x319=793<br />
# 64K | 0x311=785 0x314=788 0x317=791 0x31A=794<br />
# 16M | 0x312=786 0x315=789 0x318=792 0x31B=795<br />
# +-------------------------------------------------+<br />
# for more details and different resolutions see<br />
# https://wiki.archlinux.org/index.php/GRUB#Framebuffer_Resolution<br />
<br />
# general configuration:<br />
timeout 5<br />
default 0<br />
color light-blue/black light-cyan/blue<br />
<br />
# boot sections follow<br />
# each is implicitly numbered from 0 in the order of appearance below<br />
#<br />
# TIP: If you want a 1024x768 framebuffer, add "vga=773" to your kernel line.<br />
#<br />
#-*<br />
<br />
# (0) Arch Linux<br />
title Arch Linux<br />
root (hd0,0)<br />
kernel /vmlinuz-linux root=/dev/sda3 ro<br />
initrd /initramfs-linux.img<br />
<br />
# (1) Windows<br />
#title Windows<br />
#rootnoverify (hd0,0)<br />
#makeactive<br />
#chainloader +1<br />
</nowiki>}}<br />
<br />
=== Finding GRUB's root ===<br />
<br />
GRUB must be told where its files reside on the system, since multiple instances may exist (i.e., in multi-boot environments). GRUB files always reside under {{ic|/boot}}, which may be on a dedicated partition.<br />
<br />
{{Note|GRUB defines storage devices differently than conventional kernel naming does.<br />
<br />
* Hard disks are defined as '''(hdX)'''; this also refers to any USB storage devices.<br />
* Device and partitioning numbering begin at zero. For example, the first hard disk recognized in the BIOS will be defined as '''(hd0)'''. The second device will be called '''(hd1)'''. This also applies to partitions. So, the second partition on the first hard disk will be defined as '''(hd0,1)'''.}}<br />
<br />
If you are unaware of the the location of {{ic|/boot}}, use the GRUB shell {{ic|find}} command to locate the GRUB files. Enter the GRUB shell as root by:<br />
<br />
{{bc|# grub}}<br />
<br />
The following example is for systems ''without'' a separate {{ic|/boot}} partition, wherein {{ic|/boot}} is merely a directory under {{ic|/}}:<br />
<br />
{{bc|grub> find /boot/grub/stage1}}<br />
<br />
The following example is for systems ''with'' a separate {{ic|/boot}} partition:<br />
<br />
{{bc|grub> find /grub/stage1}}<br />
<br />
GRUB will find the file, and output the location of the {{ic|stage1}} file. For example:<br />
{{hc|grub> find /grub/stage1|<br />
(hd0,0)}}<br />
<br />
This value should be entered on the {{ic|root}} line in your configuration file. Type {{ic|quit}} to exit the shell.<br />
<br />
=== Dual booting with Windows ===<br />
<br />
Add the following to the end of your {{ic|/boot/grub/menu.lst}} (assuming that your Windows partition is on the first partition of the first drive):<br />
{{hc|/boot/grub/menu.lst|<nowiki><br />
title Windows<br />
rootnoverify (hd0,0)<br />
makeactive<br />
chainloader +1<br />
</nowiki>}}<br />
<br />
{{Note|If you are attempting to dual-boot with Windows 7, you should comment out the line {{ic|makeactive}}.}}<br />
<br />
{{Note|Windows 2000 and later versions do NOT need to be on the first partition to boot (contrary to popular belief). If the Windows partition changes (i.e. if you add a partition before the Windows partition), you will need to edit the Windows {{ic|boot.ini}} file to reflect the change (see [http://vlaurie.com/computers2/Articles/bootini.htm this article] for details on how to do that).}}<br />
<br />
If Windows is located on another hard disk, the map command must be used. This will make your Windows install think it is actually on the first drive. Assuming that your Windows partition is on the first partition of the second drive:<br />
{{hc|/boot/grub/menu.lst|<nowiki><br />
title Windows<br />
map (hd0) (hd1)<br />
map (hd1) (hd0)<br />
rootnoverify (hd1,0)<br />
makeactive<br />
chainloader +1<br />
</nowiki>}}<br />
<br />
{{Note|If you are attempting to dual-boot with Windows 7, you should comment out the line {{ic|makeactive}}.}}<br />
<br />
=== Dual booting with GNU/Linux ===<br />
<br />
This can be done the same way that an Arch Linux install is defined. For example:<br />
{{hc|/boot/grub/menu.lst|<nowiki><br />
title Other Linux<br />
root (hd0,2)<br />
kernel /path/to/kernel root=/dev/sda3 ro<br />
initrd /path/to/initrd<br />
</nowiki>}}<br />
<br />
{{Note| There may be other options that are required, and an initial RAM disk may not be used. Examine the other distribution's {{ic|/boot/grub/menu.lst}} to match boot options, or see [[#chainloader and configfile]] (recommended).}}<br />
<br />
=== {{ic|chainloader}} and {{ic|configfile}} ===<br />
<br />
To facilitate system maintenance, the {{ic|chainloader}} or {{ic|configfile}} command should be used to boot another Linux distribution that provides an "automagic" GRUB configuration mechanism (e.g. Debian, Ubuntu, openSUSE). This allows the distribution to manage its own {{ic|menu.lst}} and boot options.<br />
<br />
* The {{ic|chainloader}} command will load another bootloader (rather than a kernel image); useful if another bootloader is installed in a partition's boot sector (GRUB, for example). This allows one to install a "main" instance of GRUB to the [[MBR]] and distribution-specific instances of GRUB to each partition boot record (PBR).<br />
<br />
* The {{ic|configfile}} command will instruct the currently running GRUB instance to load the specified configuration file. This can be used to load another distribution's {{ic|menu.lst}} without a separate GRUB installation. The caveat of this approach is that other {{ic|menu.lst}} may not be compatible with the installed version of GRUB; some distributions heavily patch their versions of GRUB.<br />
<br />
For example, GRUB is to be installed to the [[MBR]] and some other bootloader (be it GRUB or [[LILO]]) is already installed to the boot sector of {{ic|(hd0,2)}}.<br />
<br />
---------------------------------------------<br />
| | | | % |<br />
| M | | | B % |<br />
| B | (hd0,0) | (hd0,1) | L % (hd0,2) |<br />
| R | | | % |<br />
| | | | % |<br />
---------------------------------------------<br />
| ^<br />
| chainloading |<br />
-----------------------------<br />
<br />
One can simply include in {{ic|menu.lst}}:<br />
<br />
title Other Linux<br />
root (hd0,2)<br />
chainloader +1<br />
<br />
Or, if the bootloader on {{ic|(hd0,2)}} is GRUB:<br />
<br />
title Other Linux<br />
root (hd0,2)<br />
configfile /boot/grub/menu.lst<br />
<br />
The {{ic|chainloader}} command can also be used to load the MBR of a second drive:<br />
<br />
title Other drive<br />
rootnoverify (hd1)<br />
chainloader +1<br />
<br />
=== Dual booting with GNU/Linux (GRUB2) ===<br />
<br />
If the other Linux distribution uses GRUB2 (e.g. Ubuntu 9.10+), and you installed its boot loader to its root partition, you can add an entry like this one to your {{ic|/boot/grub/menu.lst}}:<br />
{{hc|/boot/grub/menu.lst|<nowiki><br />
# other Linux using GRUB2<br />
title Ubuntu<br />
root (hd0,2)<br />
kernel /boot/grub/core.img<br />
</nowiki>}}<br />
<br />
Selecting this entry at boot will load the other distribution's GRUB2 menu assuming that the distribution is installed on {{ic|/dev/sda3}}.<br />
<br />
== Bootloader installation ==<br />
<br />
=== Manual recovery of GRUB libs ===<br />
<br />
The {{ic|*stage*}} files are expected to be in {{ic|/boot/grub}}, which may not be the case if the bootloader was not installed during system installation or if the partition/filesystem was damaged, accidentally deleted, etc. <br />
<br />
Manually copy the GRUB libs like so:<br />
{{bc|# cp -a /usr/lib/grub/i386-pc/* /boot/grub}}<br />
<br />
{{Note|Do not forget to mount the system's boot partition if your setup uses a separate one! The above assumes that either the boot partition resides on the root filesystem or is mounted to /boot on the root file system!}}<br />
<br />
=== General notes about bootloader installation === <br />
GRUB may be installed from a separate medium (e.g. a LiveCD), or directly from a running Arch install. The GRUB bootloader is ''seldom'' required to be reinstalled and installation is ''not'' necessary when:<br />
<br />
* The configuration file is updated.<br />
* The {{pkg|grub}} package is updated.<br />
<br />
Installation is ''necessary'' when:<br />
<br />
* A bootloader is not already installed.<br />
* Another operating system overwrites the Linux bootloader.<br />
* The bootloader fails for some unknown reason.<br />
<br />
Before continuing, a few notes:<br />
<br />
* Be sure that your GRUB configuration is correct ({{ic|/boot/grub/menu.lst}}) before proceeding. Refer to [[#Finding GRUB's root]] to ensure your devices are defined correctly.<br />
* GRUB must be installed on the [[MBR]] (first sector of the hard disk), or the first partition of the first storage device to be recognized by most BIOSes. To allow individual distributions the ability to manage their own GRUB menus, multiple instances of GRUB can be used, see [[#chainloader and configfile]].<br />
* Installing the GRUB bootloader may need to be done from within a {{ic|chroot}}ed environment (i.e. from installed environment via a separate medium) for cases like RAID configurations or if you forgot/broke your GRUB installation. You will need to [[Change Root]] from a LiveCD or another Linux installation to do so.<br />
<br />
First, enter the GRUB shell:<br />
<br />
{{bc|# grub}}<br />
<br />
Use the {{ic|root}} command with the output from the {{ic|find}} command (see [[#Finding GRUB's root]]) to instruct GRUB which partition contains stage1 (and therefore, {{ic|/boot}}):<br />
<br />
{{bc|grub> root (hd1,0)}}<br />
<br />
{{Tip|The GRUB shell also supports tab-completion. If you type 'root (hd' then press {{Keypress|Tab}} twice you will see the available storage devices, this can also be done for partitions. Tab-completion also works from the GRUB boot menu. If there is an error in your configuration file you can edit in the boot menu and use tab-completion to help find devices and partitions. See [[#Edit GRUB entries in the boot menu]].}}<br />
<br />
=== Installing to the MBR ===<br />
<br />
The following example installs GRUB to the [[MBR]] of the first drive:<br />
<br />
{{bc|grub> setup (hd0)}}<br />
<br />
=== Installing to a partition ===<br />
<br />
The following example installs GRUB to the first partition of the first drive:<br />
<br />
{{bc|grub> setup (hd0,0)}}<br />
<br />
After running {{ic|setup}}, enter {{ic|quit}} to exit the shell. If you chrooted, [[Change Root|exit your chroot and unmount partitions]]. Now reboot to test.<br />
<br />
=== Alternate method (grub-install) ===<br />
<br />
{{Note|This procedure is known to be less reliable, the recommended method is to use the GRUB shell.}}<br />
<br />
Use the {{ic|grub-install}} command followed by the location to install the bootloader. For example to install the GRUB bootloader to the MBR of the first drive:<br />
<br />
{{bc|# grub-install /dev/sda}}<br />
<br />
GRUB will indicate whether it successfully installs. If it does not, you will have to use the GRUB shell method.<br />
<br />
== Tips and tricks ==<br />
<br />
Additional configuration notes.<br />
<br />
=== Graphical boot ===<br />
<br />
For those desiring eye candy, see [[grub-gfx]]. [[GRUB2]] also offers enhanced graphical capabilities, such as background images and bitmap fonts.<br />
<br />
=== Framebuffer resolution ===<br />
<br />
One can use the resolution given in the {{ic|menu.lst}}, but you might want to use your LCD wide-screen at its full native resolution. Here is what you can do to achieve this:<br />
<br />
On [[Wikipedia:VESA BIOS Extensions#Linux video mode numbers|Wikipedia]], there is a list of extended framebuffer resolutions (i.e. beyond the ones in the VBE standard). But, for example, the one I want to use for 1440x900 ({{ic|1=vga=867}}) does not work. This is because the graphic card manufacturers are free to choose any number they wish, as this is not part of the VBE 3 standard. This is why these codes change from one card to the other (possibly even for the same manufacturer).<br />
<br />
So instead of using that table, you can use one of the tools mentioned below to get the correct code:<br />
<br />
==== GRUB recognized value ====<br />
<br />
This is an easy way to find the resolution code using only GRUB itself.<br />
<br />
On the kernel line, specify that the kernel should ask you which mode to use.<br />
<br />
kernel /vmlinuz-linux root=/dev/sda1 ro '''vga=ask'''<br />
<br />
Now reboot. GRUB will now present a list of suitable codes to use and the option to scan for even more.<br />
<br />
You can pick the code you would like to use (do not forget it, it is needed for the next step) and boot using it.<br />
<br />
Now replace {{ic|ask}} in the kernel line with the correct one you have picked.<br />
<br />
e.g. the kernel line for {{ic|[369] 1680x1050x32}} would be:<br />
<br />
kernel /vmlinuz-linux root=/dev/sda1 ro '''vga=0x369'''<br />
<br />
==== hwinfo ====<br />
<br />
# Install {{Pkg|hwinfo}} from '''[community]'''.<br />
# Run {{ic|hwinfo --framebuffer}} as root.<br />
# Pick up the code corresponding to the desired resolution.<br />
# Use the 6 digit code with 0x prefix in {{ic|1=vga=}} kernel option in {{ic|menu.lst}}. Or convert it to decimal to avoid the use of 0x prefix.<br />
<br />
Example output of '''hwinfo''':<br />
<br />
Mode 0x0364: 1440x900 (+1440), 8 bits<br />
Mode 0x0365: 1440x900 (+5760), 24 bits<br />
<br />
And the kernel line:<br />
<br />
kernel /vmlinuz-linux root=/dev/sda1 ro '''vga=0x0365'''<br />
<br />
{{Note|''vbetest'' gives you VESA mode to which we need to add 512 to get the correct value to use in kernel option line. While ''hwinfo'' gives you directly the correct value needed by the kernel.}}<br />
<br />
==== vbetest ====<br />
<br />
# Install the {{AUR|lrmi}} package from the [[AUR]] that contains the '''vbetest''' tool (x86_64 users will need to use [[#hwinfo]] above).<br />
# Run {{ic|vbetest}} as root <br />
# Then note the number in [ ] corresponding to your desired resolution.<br />
# Press 'q' to quit '''vbetest''' interactive prompt. <br />
## As an option, in a console as root, you can test the mode you just picked up by running {{ic|vbetest -m <yourcode>}} and see a pattern like [http://www.phoronix.net/image.php?id=803&image=x_vbespy_5 this one]<br />
# Add '''512''' to the discovered value picked up above and use the total value to define the {{ic|1=vga=}} parameter in the kernel options of {{ic|menu.lst}}.<br />
# Reboot to enjoy the result<br />
<br />
For example '''vbetest''' on one computer:<br />
<br />
[356] 1440x900 (256 color palette)<br />
[357] 1440x900 (8:8:8)<br />
<br />
So here the number you want is 357. Then, 357 + 512 = 869, so you will use '''vga=869'''. Add your value to the end of the kernel line in {{ic|menu.lst}} as shown below:<br />
<br />
kernel /vmlinuz-linux root=/dev/sda1 ro '''vga=869'''<br />
<br />
{{Note|<br />
* (8:8:8) is for 24-bit color (24bit is 32bit)<br />
* (5:6:5) is for 16-bit color<br />
* (5:5:5) is for 15-bit color<br />
}}<br />
<br />
=== Naming partitions ===<br />
==== By Label ====<br />
If you alter (or plan to alter) partition sizes from time to time, you might want to consider defining your drive/partitions by a label. You can label ext2, ext3, ext4 partitions by:<br />
<br />
e2label </dev/drive|partition> label<br />
<br />
The label name can be up to 16 characters long but cannot have spaces for GRUB to understand it. Then define it in your {{ic|menu.lst}}:<br />
<br />
kernel /boot/vmlinuz-linux root=/dev/disk/by-label/Arch_Linux ro<br />
<br />
==== By UUID ====<br />
<br />
The [[Persistent_block_device_naming#by-uuid | UUID]] (Universally Unique IDentifier) of a partition may be discovered with {{ic|blkid}} or {{ic|ls -l /dev/disk/by-uuid}}. It is defined in {{ic|menu.lst}} with either:<br />
<br />
kernel /boot/vmlinuz-linux root=/dev/disk/by-uuid/<uuid number><br />
<br />
or<br />
<br />
kernel /boot/vmlinuz-linux root=UUID=<uuid number><br />
<br />
=== Boot as root (single-user mode) ===<br />
<br />
At the boot loader, select an entry and edit it ('e' key). Append the following parameters to the kernel options:<br />
[...] single init=/bin/bash<br />
This will start in single-user mode (init 1), i.e. you will end up to a root prompt without being asked for password.<br />
This may be useful for recovery features, like resetting the root password.<br />
However, this is a huge security flaw if you have not set any [[Grub#Password_protection|password protection]] for grub.<br />
<br />
=== Password protection ===<br />
<br />
You can enable password protection in the GRUB configuration file for operating systems you wish to have protected. Bootloader password protection may be desired if your BIOS lacks such functionality and you need the extra security.<br />
<br />
First, choose a password you can remember and then encrypt it:<br />
<br />
# grub-md5-crypt<br />
Password:<br />
Retype password:<br />
$1$ZOGor$GABXUQ/hnzns/d5JYqqjw<br />
<br />
Then add your password to the beginning of the GRUB configuration file at {{ic|/boot/grub/menu.lst}} (the password must be at the beginning of the configuration file for GRUB to be able to recognize it):<br />
<br />
{{bc|<br />
# general configuration<br />
timeout 5<br />
default 0<br />
color light-blue/black light-cyan/blue<br />
<br />
password --md5 $1$ZOGor$GABXUQ/hnzns/d5JYqqjw<br />
}}<br />
<br />
{{Note|Remember that Grub uses the standard QWERTY layout for input.}}<br />
<br />
Then for each operating system you wish to protect, add the {{ic|lock}} command:<br />
<br />
{{bc|<nowiki><br />
# (0) Arch Linux<br />
title Arch Linux<br />
lock<br />
root (hd0,1)<br />
kernel /boot/vmlinuz-linux root=/dev/disk/by-label/Arch_Linux ro<br />
initrd /boot/initramfs-linux.img<br />
</nowiki>}}<br />
<br />
{{Warning|If you disable booting from other boot devices (like a CD drive) in the BIOS's settings and then password protect all your operating system entries, it could be difficult to re-enable booting back into the operating systems if the password is forgotten.}}<br />
It is always possible to reset your BIOS settings by setting the appropriate jumper on the motherboard (see your motherboard's manual, as it is specific to every model). So in case other have access to the hardware, there is basically no way to prevent boot breakthroughs.<br />
<br />
=== Restart with named boot choice ===<br />
<br />
If you realize that you often need to switch to some other non-default OS (e.g. Windows) having to reboot and wait for the GRUB menu to appear is tedious. GRUB offers a way to record your OS choice when restarting instead of waiting for the menu, by designating a temporary new default which will be reset as soon as it has been used.<br />
<br />
Supposing a simple {{ic|menu.lst}} setup like this:<br />
<br />
{{hc<br />
|/boot/grub/menu.lst<br />
|<nowiki><br />
# general configuration:<br />
timeout 10<br />
default 0<br />
color light-blue/black light-cyan/blue<br />
<br />
# (0) Arch<br />
title Arch Linux<br />
root (hd0,1)<br />
kernel /boot/vmlinuz-linux root=/dev/disk/by-label/ARCH ro<br />
initrd /boot/initramfs-linux.img<br />
<br />
# (1) Windows<br />
title Windows XP<br />
rootnoverify (hd0,0)<br />
makeactive<br />
chainloader +1<br />
</nowiki>}}<br />
<br />
Arch is the default (0). We want to restart in to Windows. Change {{ic|default 0}} to {{ic|default saved}} -- this will record the current default in a {{ic|default}} file in the GRUB directory whenever the '''savedefault''' command is used. Now add the line {{ic|savedefault 0}} to the bottom of the Windows entry. Whenever Windows is booted, it will reset the default to Arch, thus making changing the default to Windows temporary. <br />
<br />
Now all that is needed is a way to easily change the default manually. This can be accomplished using the command {{ic|grub-set-default}}. So, to reboot into Windows, enter the following command:<br />
<br />
{{bc|$ sudo grub-set-default 1 && sudo shutdown -r now}}<br />
<br />
For ease of use, you might to wish to implement the "[[Allow users to shutdown]] fix" (including {{ic|/sbin/grub-set-default}} amongst the commands the user is allowed to issue without supplying a password).<br />
<br />
=== LILO and GRUB interaction ===<br />
<br />
If the [[LILO]] package is installed on your system, remove it with<br />
<br />
{{bc|# pacman -R lilo}}<br />
<br />
as some tasks (e.g. kernel compilation using {{ic|make all}}) will make a LILO call, and LILO will then be installed over GRUB. LILO may have been included in your base system, depending on your installer media version and whether you selected/deselected it during the package selection stage.<br />
<br />
{{Note|{{ic|pacman -R lilo}} will not remove LILO from the MBR if it has been installed there; it will merely remove the {{pkg|lilo}} package. The LILO bootloader installed to the MBR will be overwritten when GRUB (or another bootloader) is installed over it.}}<br />
<br />
=== GRUB boot disk ===<br />
<br />
First, format a floppy disk:<br />
<br />
fdformat /dev/fd0<br />
mke2fs /dev/fd0<br />
<br />
Now mount the disk:<br />
<br />
mount -t ext2 /dev/fd0 /mnt/fl<br />
<br />
Install GRUB to the disk:<br />
<br />
grub-install --root-directory=/mnt/fl '(fd0)'<br />
<br />
Copy your {{ic|menu.lst}} file to the disk:<br />
<br />
cp /boot/grub/menu.lst /mnt/fl/boot/grub/menu.lst<br />
<br />
Now unmount your floppy:<br />
<br />
umount /mnt/fl<br />
<br />
Now you should be able to restart your computer with the disk in the drive and it should boot to GRUB. Make sure that your floppy disk is set to have higher priority than your hard drive when booting in your BIOS first, of course.<br />
<br />
See also: [http://www.supergrubdisk.org/ Super GRUB Disk]<br />
<br />
===Hide GRUB menu===<br />
<br />
The {{ic|hiddenmenu}} option can be used in order to hide the menu by default. That way no menu is displayed and the default option is going to be automatically selected after the timeout passes.<br />
Still, you are able to press {{Keypress|Esc}} and the menu shows up. To use it, just add to your {{ic|/boot/grub/menu.lst}}:<br />
hiddenmenu<br />
<br />
== Advanced Debugging ==<br />
<br />
Content moved to [[Boot_Debugging]]<br />
<br />
== Troubleshooting ==<br />
<br />
=== GRUB Error 17 ===<br />
{{Note| the solution below works also for GRUB Error 15}}<br />
'''The first check to do is to unplug any external drive. Seems obvious, but sometimes we get tired ;)'''<br />
<br />
If your partition table gets messed up, an unpleasant "GRUB error 17" message might be the only thing that greets you on your next reboot. There are a number of reasons why the partition table could get messed up. Commonly, users who manipulate their partitions with [[GParted]] -- particularly logical drives -- can cause the order of the partitions to change. For example, you delete {{ic|/dev/sda6}} and resize {{ic|/dev/sda7}}, then finally re-create what used to be {{ic|/dev/sda6}} only now it appears at the bottom of the list, {{ic|/dev/sda9}} for example. Although the physical order of the partitions/logical drives has not changed, the order in which they are recognized has changed.<br />
<br />
Fixing the partition table is easy. Boot from your Arch CD/DVD/USB, login as root and fix the partition table:<br />
<br />
# fdisk /dev/sda<br />
<br />
Once in disk, enter e[x]tra/expert mode, [f]ix the partition order, then [w]rite the table and exit.<br />
<br />
You can verify that the partition table was indeed fixed by issuing an {{ic|fdisk -l}}. Now you just need to fix GRUB. See the [[#Bootloader installation]] section above.<br />
<br />
Basically you need to tell GRUB the correct location of your {{ic|/boot}} then re-write GRUB to the [[MBR]] on the disk.<br />
<br />
For example:<br />
<br />
# grub<br />
<br />
grub> root (hd0,6)<br />
grub> setup (hd0)<br />
grub> quit<br />
<br />
See [[http://stringofthoughts.wordpress.com/2009/05/24/grub-error-17-debianubuntu this page]] for a more in-depth summary of this section.<br />
<br />
=== /boot/grub/stage1 not read correctly ===<br />
If you see this error message while trying to set up GRUB, and you are not using a fresh partition table, it is worth checking it.<br />
<br />
# fdisk -l /dev/sda<br />
<br />
This will show you the partition table for {{ic|/dev/sda}}. So check here, whether the "Id" values of your partitions are correct. <br />
The "System" column will show you the description of the "Id" values.<br />
<br />
If your boot partition is marked as being "HPFS/NTFS", for example, then you have to change it to "Linux". To do this, go to fdisk,<br />
<br />
# fdisk /dev/sda<br />
<br />
change a partition's system id with [t], select you partition number and type in the new system id (Linux = 83). <br />
You can also list all available system ids by typing "L" instead of a system id.<br />
<br />
If you have changed a partitions system id, you should [v]erify your partition table and then [w]rite it.<br />
<br />
Now try to set up GRUB again.<br />
<br />
[[https://bbs.archlinux.org/viewtopic.php?pid=799930 Here]] is the forum post reporting this problem.<br />
<br />
=== Accidental install to a Windows partition ===<br />
<br />
If you accidentally install GRUB to a Windows partition, GRUB will write some information to the boot sector of the partition, erasing the reference to the Windows bootloader. (This is true for NTLDR the bootloader for Windows XP and earlier, unsure about later versions).<br />
<br />
To fix this you will need to use the Windows Recovery Console for your Windows release. Because many computer manufacturers do not include this with their product (many choose to use a recovery partition) Microsoft has made them available for download. If you use XP, look at [http://tips.vlaurie.com/2006/05/recovery-console-for-those-without-an-xp-disk/ this page] to be able to turn the floppy disks to a Recovery CD. Boot the Recovery CD (or enable Windows Recovery mode) and run {{ic|fixboot}} to repair the partition boot sector. After this, you will have to install GRUB again---this time, to the MBR, not to the Windows partition---to boot Linux.<br />
<br />
See [[MBR#Restoring a Windows boot record|further discussion here]].<br />
<br />
=== Edit GRUB entries in the boot menu ===<br />
<br />
Once you have selected and entry in the boot menu, you can edit it by pressing key {{Keypress|e}}. Use tab-completion if you need to to discover devices then {{Keypress|Esc}} to exit. Then you can try to boot by pressing {{Keypress|b}}. <br />
{{Note|These settings '''will not be saved'''.}}<br />
<br />
=== device.map error ===<br />
<br />
If an error is raised mentioning {{ic|/boot/grub/device.map}} during installation or boot, run:<br />
<br />
# grub-install --recheck /dev/sda<br />
<br />
to force GRUB to recheck the device map, even if it already exists. This may be necessary after resizing partitions or adding/removing drives.<br />
<br />
=== KDE reboot pull-down menu fails ===<br />
<br />
If you have opened a sub-menu with the list of all operating systems configured in GRUB, selected one, and upon restart, you still booted your default OS, then you might want to check if you have the line:<br />
<br />
default saved<br />
<br />
in {{ic|/boot/grub/menu.lst}}.<br />
<br />
=== GRUB fails to find or install to any virtio ''/dev/vd*'' or other non-BIOS devices ===<br />
I had trouble installing GRUB while installing Arch Linux in an virtual KVM machine using a virtio device for hard drive. To install GRUB, I figured out the following:<br />
Enter a virtual console by typing {{Keypress|Ctrl+Alt+F2}} or any other F-key for a free virtual console.<br />
This assumes that your root file system is mounted in the folder {{ic|/mnt}} and the boot file system is either mounted or stored in the folder {{ic|/mnt/boot}}.<br />
<br />
1. Assure that all needed GRUB files is present in your boot directory (assuming it is mounted in {{ic|/mnt/boot}} folder), by issuing the command:<br />
<br />
# ls /mnt/boot/grub<br />
<br />
2. If the {{ic|/mnt/boot/grub}} folder already contains all the needed files, jump to step 3. Otherwise, do the following commands (replacing {{ic|/mnt}}, {{ic|your_kernel}} and {{ic|your_initrd}} with the real paths and file names). You should also have the {{ic|menu.lst}} file written to this folder:<br />
<br />
# mkdir -p /mnt/boot/grub # if the folder is not yet present<br />
# cp -r /boot/grub/stage1 /boot/grub/stage2 /mnt/boot/grub<br />
# cp -r your_kernel your_initrd /mnt/boot<br />
<br />
3. Start the GRUB shell with the following command:<br />
<br />
# grub --device-map=/dev/null<br />
<br />
4. Enter the following commands. Replace {{ic|/dev/vda}}, and {{ic|(hd0,0)}} with the correct device and partition corresponding to your setup.<br />
<br />
device (hd0) /dev/vda<br />
root (hd0,0)<br />
setup (hd0)<br />
quit<br />
<br />
5. If GRUB reports no error messages, then you probably are done. You also need to add appropriate modules to the ramdisk. For more information, please refer to the KVM guide on [[KVM#Preparing_an_.28Arch.29_Linux_guest|Preparing an (Arch) Linux guest]]<br />
<br />
==See also==<br />
* [http://www.gnu.org/software/grub/ GNU GRUB]<br />
* [http://www.troubleshooters.com/linux/grub/index.htm GRUB Grotto]<br />
* [[Boot Debugging]] - Debugging with Grub, set module values</div>Mach1NEhttps://wiki.archlinux.org/index.php?title=Arduino&diff=221701Arduino2012-09-06T03:23:52Z<p>Mach1NE: typo error "availible"</p>
<hr />
<div>[[Category:Development]]<br />
[[Category:Mathematics and science]]<br />
Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It is intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments. More information is available on the [http://www.arduino.cc/ Arduino HomePage].<br />
<br />
==Installation==<br />
<br />
* Install {{AUR|arduino}} from the [[Arch User Repository|AUR]].<br />
* Add yourself to the {{ic|uucp}} [[Users and Groups|group]]. (More information in the next section: "Accessing serial")<br />
<br />
==Configuration==<br />
<br />
===Accessing serial===<br />
<br />
The arduino board communicates with the PC via a serial connection or a serial over USB connection. So the user needs read/write access to the serial device file. [[Udev]] creates files in /dev/tts/ owned by group uucp so adding the user to the uucp group gives the required read/write access.<br />
<br />
gpasswd -a <user> uucp<br />
<br />
{{Note|You will have to logout and login again for this to take effect.}}<br />
<br />
Briefly run the {{ic|arduino}} command and stop it, then modify {{ic|~/.arduino/preferences.txt}} .<br />
<br />
Change serial port from COM1 to your serial port. With your arduino board connected, you can find out what your serial port is with:<br />
<br />
ls /dev/ttyUSB* /dev/ttyACM*<br />
<br />
If in doubt, unconnect the board and look which of these disappears, and/or monitor {{ic|/var/log/everything.log}}.<br />
<br />
The line to change in {{ic|~/.arduino/preferences.txt}} should look something like this when you are done:<br />
<br />
serial.port=/dev/ttyACM3<br />
<br />
Rerun {{ic|arduino}}. If you get a message like "Arduino Uno on /dev/tty*" message in the GUI's lower right corner, connection has been established.<br />
<br />
== stty ==<br />
<br />
Preparing<br />
stty -F /dev/ttyACM0 cs8 9600 ignbrk -brkint -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts<br />
<br />
Sending commands through Terminal without new line after command<br />
echo -n "Hello World" > /dev/ttyACM0<br />
<br />
Reading what your Arduino has to tell you<br />
cat /dev/ttyACM0<br />
<br />
==Working with Uno/Mega2560==<br />
<br />
The Arduino Uno and Mega2560 have an onboard USB interface (an Atmel 8U2) that accepts serial data, so they are accessed through /dev/ttyACM0 created by the cdc-acm kernel module when it is plugged in.<br />
<br />
The 8U2 firmware may need an update to ease serial communications. See [http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1286350399] for more details and reply #11 for a fix. The original arduino bbs, where you can find an image explaining how to get your Uno into DFU, is now in a read-only state. If you do not have an account to view the image, see [http://www.scribd.com/doc/45913857/Arduino-UNO].<br />
<br />
You can perform a general function test of the Uno by putting it in loopback mode and typing characters into the arduino serial monitor at 115200 baud. It should echo the characters back to you. To put it in loopback, short pins 0 -> 1 on the digital side and either hold the reset button or short the GND -> RESET pins while you type.<br />
<br />
== Running Arduino Uno ==<br />
<br />
Once Arduino is running you must ensure you have selected the correct board from the Tools->Boards menu item:<br />
Arduino Uno<br />
<br />
Secondly you must ensure you have selected the correct serial port from the Tools->Serial Port menu item as explained above.<br />
<br />
Once these are done you should be able to write and upload sketches to your Arduino Uno without any issues.<br />
<br />
==Alternatives for IDE==<br />
<br />
===ArduIDE===<br />
<br />
ArduIDE is a Qt-based IDE for Arduino. {{aur|arduide-git}} is available in the [[AUR]].<br />
<br />
If you prefer working from terminal, below there are some other options to choose from.<br />
<br />
===gnoduino===<br />
<br />
{{aur|gnoduino}} is an implementation of original Arduino IDE for GNOME available in the [[AUR]]. The original Arduino IDE software is written in Java. This is a Python implementation and it is targeted at GNOME but will work on xfce4 and other WM. Its purpose is to be light, while maintaining compatibility with the original Arduino IDE. The source editor is based on gtksourceview.<br />
<br />
===Scons===<br />
<br />
Using [http://www.scons.org/ scons] together with [http://code.google.com/p/arscons/ arscons] it is very easy to use to compile and upload Arduino projects from the command line. Scons is based on python and you will need python-pyserial to use the serial interface. Install everything with<br />
<br />
# pacman -S python-pyserial scons<br />
<br />
That will get the dependencies you need too. You will also need Arduino itself so install it as described above. Create project directory (eg. test), then create a arduino project file in your new directory. Use the same name as the directory and add .pde (eg. test.pde). Get the [http://arscons.googlecode.com/git/SConstruct SConstruct] script from arscons and put it in your directory. Have a peek in it and, if necessary, edit it. It is a python script. Edit your project as you please, then run<br />
<br />
$ scons # This will build the project<br />
$ scons upload # This will upload the project to your Arduino<br />
<br />
===Makefile===<br />
Update 2011-03-12. Arduino Is not shipping a Makefile with version (22). The Makefile from the [http://code.google.com/p/dogm128/source/browse/libraries/Dogm/examples/SpaceTrash/Makefile.uno_dogs102 dogm128] project works for me though.<br />
<br />
Instead of using the arduino IDE it is possible to use another editor and a Makefile.<br />
<br />
Set up a directory to program your Arduino and copy the Makefile into this directory. A copy of the Makefile can be obtained from /usr/share/arduino/hardware/cores/arduino/Makefile<br />
<br />
You will have to modify this a little bit to reflect your settings. The makefile should be pretty self explainatory. Here are some lines you may have to edit.<br />
<br />
PORT = usually /dev/ttyUSBx, where x is the usb serial port your arduino is plugged into<br />
TARGET = your sketch's name<br />
ARDUINO = /usr/share/arduino/lib/targets/arduino<br />
<br />
Depending on which library functions you call in your sketch, you may need to compile parts of the library. To do that you need to edit your SRC and CXXSRC to include the required libraries.<br />
<br />
Now you should be able to make && make upload to your board to execute your sketch.<br />
<br />
===Arduino-CMake===<br />
<br />
Using [https://github.com/queezythegreat/arduino-cmake arduino-cmake] and [http://www.cmake.org/cmake/resources/software.html CMake] you can build Arduino firmware from the command line using multiple build systems. CMake lets you generate the build system that fits your needs, using the tools you like. It can generate any type of build system, from simple Makefiles, to complete projects for Eclipse, Visual Studio, XCode, etc.<br />
<br />
Requirements:<br />
* [http://www.archlinux.org/packages/?sort=&q=cmake CMake]<br />
* [https://aur.archlinux.org/packages.php?ID=8388 Arduino SDK]<br />
* [http://www.archlinux.org/packages/?sort=&q=gcc-avr gcc-avr]<br />
* [http://www.archlinux.org/packages/?sort=&q=binutils-avr binutils-avr]<br />
* [http://www.archlinux.org/packages/?sort=&q=avr-libc avr-libc]<br />
* [http://www.archlinux.org/packages/?sort=&q=avrdude avrdude]<br />
<br />
==Troubleshooting==<br />
<br />
===delay() function does not work===<br />
{{Out of date|the current arduino-git package is reported in the talk page as not being affected by this issue.|section=Update troubleshooting?}}<br />
There are some cases where the delay() function does not work, causing programs such as the example [http://www.arduino.cc/en/Tutorial/Blink Blink] to malfunction. <br />
It appears that the Arch compiler sometimes generates code that writes to addresses before the start of memory. RAM starts at address 0x200 on the mega, but the Blink code has the delay() timer variables located at 0x100-0x10b. This only seems to happen when the code contains no initialized global variables (.data segment in asm-speak) - the linker is told that the data segment starts at 0x200, but if there is nothing to go in it it generates an incorrect start address for the uninitialized global variables (.bss segment). Since the timer variables are uninitialized globals (or globals initialized to zero) they end up at an illegal address.<br />
<br />
There are currently two ways to bypass this issue.<br />
<br />
* Use '''Serial.begin(9600);''' in '''setup()''' function. [[http://forums.adafruit.com/viewtopic.php?f=25&t=21075 Source post]] <br />
<br />
{{bc|<br />
/*<br />
Blink<br />
Turns on an LED on for one second, then off for one second, repeatedly.<br />
<br />
This example code is in the public domain.<br />
*/<br />
<br />
void setup() { <br />
// initialize the digital pin as an output.<br />
// Pin 13 has an LED connected on most Arduino boards:<br />
pinMode(13, OUTPUT); <br />
Serial.begin(9600);<br />
}<br />
<br />
void loop() {<br />
digitalWrite(13, HIGH); // set the LED on<br />
delay(1000); // wait for a second<br />
digitalWrite(13, LOW); // set the LED off<br />
delay(1000); // wait for a second<br />
}<br />
}}<br />
<br />
* Use an initialized global variable. [[http://arduino.cc/forum/index.php/topic,49900.msg363688.html#msg363688 Source post]]<br />
<br />
{{bc|<nowiki><br />
char dummyvariablecuzmaintainerborkedthecompiler = 123; // force something into the .data segment with non-zero initializer<br />
/*<br />
Blink<br />
Turns on an LED on for one second, then off for one second, repeatedly.<br />
<br />
This example code is in the public domain.<br />
*/<br />
<br />
void setup() { <br />
dummyvariablecuzmaintainerborkedthecompiler++; // stops the linker from removing the global variable<br />
<br />
// initialize the digital pin as an output.<br />
// Pin 13 has an LED connected on most Arduino boards:<br />
pinMode(13, OUTPUT); <br />
}<br />
<br />
void loop() {<br />
digitalWrite(13, HIGH); // set the LED on<br />
delay(1000); // wait for a second<br />
digitalWrite(13, LOW); // set the LED off<br />
delay(1000); // wait for a second<br />
}</nowiki>}}<br />
<br />
Related pages:<br />
* http://arduino.cc/forum/index.php/topic,56841.0.html<br />
* http://arduino.cc/forum/index.php/topic,49900.0.html<br />
* http://arduino.cc/forum/index.php?topic=59409.0.html<br />
<br />
Fedora has the same problem with binutils 2.21 ([https://bugzilla.redhat.com/show_bug.cgi?id=688645 bug report]).<br />
Downgraded packages that work are binutils-avr 2.20.1-3 and gcc-avr 4.5.1-2. <br />
There is also an upstream bug report [http://sourceware.org/bugzilla/show_bug.cgi?id=12757 here] but no one has replied yet.<br />
<br />
===Error when launching Arduino IDE===<br />
If you run the Arduino IDE as a normal user (you should do that of course), you may get this error message :<br />
'''check_group_uucp(): error testing lock file creation Error details:Permission denied'''<br />
<br />
This is probably because you don't have write permissions on ''/run/lock directory''. Try this to see if this solves your problem :<br />
{{bc|<br />
sudo chmod 777 /run/lock<br />
}}<br />
<br />
/run/lock is created on boot by /usr/lib/tmpfiles.d/legacy.conf (both on systemd and initscripts). So if you want to keep the permissions you set, simply copy the file /usr/lib/tmpfiles.d/legacy.conf to /etc/tmpfiles.d/ and edit it there (set 0777 permissions).<br />
You can look here<br />
<br />
=== Error opening serial port ===<br />
You may see the serial port initially when the IDE starts, but the TX/RX leds do nothing when uploading. You may have previously changed the baudrate in the serial monitor to something it does not like. Edit ~/.arduino/preferences.txt so that serial.debug_rate is a different speed, like 115200.<br />
<br />
=== Arduino Mega2560 and new gcc-avr ===<br />
<br />
If you are using gcc-avr >= 4.3.5 then there is a C++ bug in the gcc-avr toolchain which builds bad firmware for the Atmel2560 processors. gcc-avr must be rebuilt using a patch found at [http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45263]. You can read more about the problems at [http://andybrown.me.uk/ws/2010/10/24/the-major-global-constructor-bug-in-avr-gcc/].<br />
<br />
Here is the patch for gcc:<br />
{{bc|<br />
--- gcc-4.5.1.orig/gcc/config/avr/libgcc.S 2009-05-23 17:16:07 +1000<br />
+++ gcc-4.5.1/gcc/config/avr/libgcc.S 2010-08-12 09:38:05 +1000<br />
@@ -802,7 +802,9 @@<br />
mov_h r31, r29<br />
mov_l r30, r28<br />
out __RAMPZ__, r20<br />
+ push r20<br />
XCALL __tablejump_elpm__<br />
+ pop r20<br />
.L__do_global_ctors_start:<br />
cpi r28, lo8(__ctors_start)<br />
cpc r29, r17<br />
@@ -843,7 +845,9 @@<br />
mov_h r31, r29<br />
mov_l r30, r28<br />
out __RAMPZ__, r20<br />
+ push r20<br />
XCALL __tablejump_elpm__<br />
+ pop r20<br />
.L__do_global_dtors_start:<br />
cpi r28, lo8(__dtors_end)<br />
cpc r29, r17<br />
}}<br />
<br />
The easiest way to rebuild gcc-avr is using ABS and makepkg.<br />
<br />
=== Missing twi.o ===<br />
<br />
If the file /usr/share/arduino/lib/targets/libraries/Wire/utility/twi.o does not exist arduino may try to create it. Normal users do not have permission to write there so this will fail. Run arduino as root so it can create the file, after the file has been created arduino can be run under a normal user.<br />
<br />
== Bugs ==<br />
<br />
This section is targeted at the package maintainers.<br />
<br />
{| border="1"<br />
! Symptom !! Cause / Upstream bug report !! Patches / Workarounds !! Patched Packages / End-User solutions<br />
|-<br />
| delay() sleeps forever || ??? || [https://wiki.archlinux.org/index.php/Arduino#delay.28.29_function_doesn.27t_work workaround] || none<br />
|-<br />
| progmem error || [http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49764 bug in gcc-avr (fixed, but unreleased)] || [http://arduino.cc/forum/index.php/topic,66710.msg491529.html#msg491529 workaround] || [https://aur.archlinux.org/packages.php?ID=50146 aur/gcc-avr-svn] or [https://aur.archlinux.org/packages.php?ID=8388 aur/arduino]<br />
|}<br />
<br />
==See also==<br />
<br />
* http://bbs.archlinux.org/viewtopic.php?pid=295312<br />
* http://regomodoslinux.blogspot.com/2007/10/how-to-install-arduino-ide-in-archlinux.html<br />
* http://gunnewiek.com/2011/open-pde-files-with-arduino-ide-in-linux/<br />
* https://bbs.archlinux.org/viewtopic.php?pid=981348</div>Mach1NEhttps://wiki.archlinux.org/index.php?title=Beginners%27_guide&diff=221699Beginners' guide2012-09-06T03:16:26Z<p>Mach1NE: /* Prepare the storage drive */</p>
<hr />
<div><noinclude><br />
[[Category:Getting and installing Arch]]<br />
[[Category:About Arch]]<br />
[[da:Beginners' Guide/Installation]]<br />
[[es:Beginners' Guide/Installation]]<br />
[[hr:Beginners' Guide/Installation]]<br />
[[hu:Beginners' Guide/Installation]]<br />
[[it:Beginners' Guide/Installation]]<br />
[[ko:Beginners' Guide/Installation]]<br />
[[nl:Beginners' Guide/Installatie]]<br />
[[pt:Beginners' Guide/Installation]]<br />
[[ru:Beginners' Guide/Installation]]<br />
[[sr:Beginners' Guide/Installation]]<br />
[[zh-CN:Beginners' Guide/Installation]]<br />
{{Tip|This is part of a multi-page article for The Beginners' Guide. '''[[Beginners' Guide|Click here]]''' if you would rather read the guide in its entirety.}}<br />
</noinclude><br />
== Installation ==<br />
<br />
You are now presented with a shell prompt, automatically logged in as root.<br />
<br />
=== Change the keymap ===<br />
<br />
{{Tip|This step is optional for the vast majority of users and it can be used at any point during the instalation. Useful only if you plan on writing in your own language in any of the configuration files, if you use diacritical marks in the wifi password, etc.}}<br />
<br />
By default, the keyboard layout is set to {{ic|us}}. If you have a non-[[Wikipedia:File:KB_United_States-NoAltGr.svg|US]] keyboard layout, run:<br />
<br />
# loadkeys ''layout''<br />
<br />
...where ''layout'' can be {{ic|fr}}, {{ic|uk}}, {{ic|be-latin1}}, etc. See [[KEYMAP#Keyboard_layouts|here]] for a comprehensive list.<br />
<br />
{{Keypress|Alt + Shift}} activates it.<br />
<br />
Don't worry if some of the letters show up as white squares or as other symbols. It's probably just the console font missing those glyphs. The glyph codes are correct and if you press the correct keys they will show up fine when ''(or if)'' you set up a graphical environment later.<br />
<br />
=== Establish an internet connection ===<br />
<br />
The {{ic|dhcpcd}} network daemon is started automatically at boot and it will attempt to start a wired connection, if available. Try pinging a website to see if it was successful. And since Google is always on...<br />
<br />
{{hc|# ping -c 3 www.google.com|2=<br />
PING www.l.google.com (74.125.132.105) 56(84) bytes of data.<br />
64 bytes from wb-in-f105.1e100.net (74.125.132.105): icmp_req=1 ttl=50 time=17.0 ms<br />
64 bytes from wb-in-f105.1e100.net (74.125.132.105): icmp_req=2 ttl=50 time=18.2 ms<br />
64 bytes from wb-in-f105.1e100.net (74.125.132.105): icmp_req=3 ttl=50 time=16.6 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2003ms<br />
rtt min/avg/max/mdev = 16.660/17.320/18.254/0.678 ms}}<br />
<br />
If you get a {{ic|ping: unknown host}} error, you will need to set up the network manually, as explained below.<br />
<br />
Otherwise, move on to [[#Prepare_the_storage_drive|Prepare the storage drive]].<br />
<br />
==== Wired ====<br />
<br />
Follow this procedure if you need wired connectivity (Ethernet) during the installation process. <br />
<br />
If your computer is connected to an Ethernet network, in most cases, you will have one interface, called {{ic|eth0}}. If you have additional network cards (apart from the one integrated on the motherboard, for example), their name will follow the sequence {{ic|eth1}}, {{ic|eth2}}, etc.<br />
<br />
You need to know these settings:<br />
<br />
* Static IP address.<br />
* Subnet mask.<br />
* Gateway's IP address.<br />
* Name servers' (DNS) IP addresses.<br />
* Domain name (unless you're on a local LAN, in which case you can make it up).<br />
<br />
Activate the connected Ethernet interface, e.g. for {{ic|eth0}}:<br />
<br />
# ip link set eth0 up<br />
<br />
Add the address:<br />
<br />
# ip addr add <ip address>/<subnetmask> dev <interface><br />
<br />
For example:<br />
<br />
# ip addr add 192.168.1.2/24 dev eth0<br />
<br />
For more options, run {{ic|man ip}}.<br />
<br />
Add your gateway like this, substituting your own gateway's IP address:<br />
<br />
# ip route add default via <ip address><br />
<br />
For example:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
Edit {{ic|resolv.conf}}, substituting your name servers' IP addresses and your local domain name:<br />
<br />
{{hc|# nano /etc/resolv.conf|<br />
nameserver 61.23.173.5<br />
nameserver 61.95.849.8<br />
search example.com}}<br />
<br />
{{Note|Currently, you may include a maximum of 3 {{ic|nameserver}} lines.}}<br />
<br />
You should now have a working network connection. If you do not, check the detailed [[Configuring Network]] page.<br />
<br />
==== Wireless ====<br />
<br />
Follow this procedure if you need wireless connectivity (WiFi) during the installation process.<br />
<br />
The wireless drivers and utilities are now available to you in the live environment of the installation media. A good knowledge of your wireless hardware will be of key importance to successful configuration. Note that the following quick-start procedure ''executed at this point in the installation'' will initialize your wireless hardware for use ''in the live environment of the installation media''. These steps (or some other form of wireless management) '''must be repeated from the actual installed system after booting into it'''.<br />
<br />
Also note that these steps are optional if wireless connectivity is unnecessary at this point in the installation; wireless functionality may always be established later.<br />
<br />
{{Note|The following examples use {{ic|wlan0}} for the interface and {{ic|linksys}} for the ESSID. Remember to change these values according to your setup.}}<br />
<br />
The basic procedure will be:<br />
<br />
* (optional) Identify the wireless interface:<br />
<br />
# lspci | grep -i net<br />
<br />
Or, if using a USB adapter:<br />
<br />
# lsusb<br />
<br />
* Ensure udev has loaded the driver, and that the driver has created a usable wireless kernel interface with {{ic|iwconfig}}:<br />
<br />
{{hc|# iwconfig|<nowiki><br />
lo no wireless extensions.<br />
eth0 no wireless extensions.<br />
wlan0 unassociated ESSID:""<br />
Mode:Managed Channel=0 Access Point: Not-Associated<br />
Bit Rate:0 kb/s Tx-Power=20 dBm Sensitivity=8/0<br />
Retry limit:7 RTS thr:off Fragment thr:off<br />
Power Management:off<br />
Link Quality:0 Signal level:0 Noise level:0<br />
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0<br />
Tx excessive retries:0 Invalid misc:0 Missed beacon:0</nowiki>}}<br />
<br />
{{ic|wlan0}} is the available wireless interface in this example. <br />
<br />
{{Note|If you do not see output similar to this, then your wireless driver has not been loaded. If this is the case, you must load the driver yourself. Please see [[Wireless Setup]] for more detailed information.}}<br />
<br />
* Bring the interface up with:<br />
<br />
# ip link set wlan0 up<br />
<br />
A small percentage of wireless chipsets also require firmware, in addition to a corresponding driver. If the wireless chipset requires firmware, you are likely to receive this error when bringing the interface up:<br />
<br />
{{hc|# ip link set wlan0 up|<br />
SIOCSIFFLAGS: No such file or directory}}<br />
<br />
If unsure, invoke {{ic|dmesg}} to query the kernel log for a firmware request from the wireless chipset.<br />
<br />
Example output from an Intel chipset which requires and has requested firmware from the kernel at boot:<br />
<br />
{{hc|# dmesg <nowiki>|</nowiki> grep firmware|<br />
firmware: requesting iwlwifi-5000-1.ucode}}<br />
<br />
If there is no output, it may be concluded that the system's wireless chipset does not require firmware.<br />
<br />
{{Warning|Wireless chipset firmware packages (for cards which require them) are pre-installed under {{ic|/usr/lib/firmware}} in the live environment (on CD/USB stick) '''but must be explicitly installed to your actual system to provide wireless functionality after you reboot into it!''' Package installation is covered later in this guide. Ensure installation of both your wireless module and firmware before rebooting! See [[Wireless Setup]] if you are unsure about the requirement of corresponding firmware installation for your particular chipset.}}<br />
<br />
Next, use {{pkg|netcfg}}'s wifi-menu to connect to a network:<br />
<br />
# wifi-menu wlan0<br />
<br />
You should now have a working network connection. If you do not, check the detailed [[Wireless Setup]] page.<br />
<br />
==== xDSL (PPPoE), analog modem or ISDN ====<br />
<br />
If you have a modem or a router in bridge mode, run:<br />
<br />
# pppoe-setup<br />
<br />
* Type in the username that the ISP provided you with.<br />
* Press {{Keypress|Enter}} for "eth0".<br />
* Press {{Keypress|Enter}} for "no", so that it stays up continuously.<br />
* Type {{ic|server}} (since this is usually the case).<br />
* Press {{Keypress|1}} for a firewall.<br />
* Type in the password that the ISP provided you with.<br />
* Press {{Keypress|y}} at the end.<br />
<br />
To use these settings and connect to your ISP, run:<br />
<br />
# pppoe-start<br />
<br />
For an ''analog'' modem, see [[Direct Modem Connection]].<br />
<br />
==== Behind a proxy server ====<br />
<br />
If you are behind a proxy server, you will need to export the {{ic|http_proxy}} and {{ic|ftp_proxy}} environment variables. '''[[Proxy|Click here]]''' for more information.<br />
<br />
=== Prepare the storage drive ===<br />
<br />
{{Warning|Partitioning can destroy data. You are '''strongly''' cautioned and advised to backup any critical data before proceeding.}}<br />
<br />
Absolute beginners are encouraged to use a graphical partitioning tool. [http://gparted.sourceforge.net/download.php GParted] is a good example, ran from a "live" Linux distribution such as [[Wikipedia:Parted_Magic|Parted Magic]], [[Wikipedia:Ubuntu_(operating_system)|Ubuntu]], [[Wikipedia:Linux_Mint|Linux Mint]], etc. See [[Partitioning]] for some general tips and make sure to format the partitions with a filesystem (e.g. '''ext4''', '''btrfs''', etc) before rebooting.<br />
<br />
If you have already done so, proceed to [[#Mount_the_partitions|Mount the partitions]].<br />
<br />
Otherwise, see the following example.<br />
<br />
==== Example ====<br />
<br />
The Arch Linux install media includes the following partitioning tools:<br />
<br />
* [[Wikipedia:cfdisk|cfdisk]] – supports only [[MBR]] partition tables.<br />
<br />
* [[Wikipedia:gdisk|gdisk]] – supports only [[GPT]] partition tables.<br />
<br />
* [[Wikipedia:parted|parted]] – supports both.<br />
<br />
This example uses '''cfdisk''', but it can be easily followed using '''gdisk''', which will allow for GPT partitioning.<br />
<br />
{{Note|If you are installing to a USB flash key, see [[Installing Arch Linux on a USB key]].}}<br />
<br />
{{Note|If you are not dual booting with Windows, then it is advisable to use [[GPT]] instead of [[MBR]]. GPT partitioning can only be done with '''gdisk''' or '''parted'''. Read [[GPT]] for the list of advantages.}}<br />
<br />
# cfdisk /dev/sda<br />
<br />
The example system will contain a 15GB root ({{ic|/}}) partition, a 1GB {{ic|swap}} partition, and a {{ic|/home}} partition for the remaining space.<br />
<br />
It should be emphasized that partitioning is a personal choice and that this example is only for illustrative purposes. See [[Partitioning]].<br />
<br />
{{Note|If you have a UEFI motherboard you will need another partition to host the UEFI System partition. Read [[Unified_Extensible_Firmware_Interface#Create_an_UEFI_System_Partition_in_Linux|this article]].}}<br />
<br />
;Root:<br />
<br />
* Choose New (or press {{Keypress|N}}).<br />
* Press {{Keypress|Enter}} for Primary.<br />
* Type "15440".<br />
* Press {{Keypress|Enter}} for Beginning.<br />
* Press {{Keypress|Enter}} for Bootable.<br />
<br />
;Swap:<br />
<br />
* Press the down arrow to move to the free space area and choose New (or press {{Keypress|N}}).<br />
* Press {{Keypress|Enter}} for Primary.<br />
* Type "1024".<br />
* Press {{Keypress|Enter}} for Beginning.<br />
* Choose Type (or press {{Keypress|T}}).<br />
* Press any key to scroll down the list.<br />
* Press {{Keypress|Enter}} for {{ic|82}}.<br />
<br />
;Home:<br />
<br />
* Press the down arrow to move to the free space area and choose New (or press {{Keypress|N}}).<br />
* Press {{Keypress|Enter}} for Primary.<br />
* Press {{Keypress|Enter}} to use the rest of the drive (or you could type in the desired size).<br />
<br />
Here's how it should look like:<br />
<br />
Name Flags Part Type FS Type [Label] Size (MB)<br />
-----------------------------------------------------------------------<br />
sda1 Boot Primary Linux 15440<br />
sda2 Primary Linux swap / Solaris 1024<br />
sda3 Primary Linux 133000*<br />
<br />
Double check and make sure that you are happy with the partition sizes as well as the partition table layout before continuing.<br />
<br />
If you would like to start over, you can simply select Quit (or press {{Keypress|Q}}) to quit without saving changes and then restart cfdisk.<br />
<br />
If you are satisfied, choose Write (or press {{Keypress|Shift+W}}) to finalize and to write the partition table to the drive. Type "yes" and choose Quit (or press {{Keypress|Q}}) to exit cfdisk without making any more changes.<br />
<br />
Simply partitioning is not enough; the partitions also need a [[File Systems|filesystem]]. To format the partitions with an ext4 filesystem:<br />
<br />
# mkfs.ext4 /dev/sda1<br />
# mkfs.ext4 /dev/sda3<br />
<br />
Format and activate the swap partition:<br />
<br />
# mkswap /dev/sda2<br />
# swapon /dev/sda2<br />
<br />
=== Mount the partitions ===<br />
<br />
Each partition is identified with a number suffix. For example, {{ic|sda1}} specifies the first partition of the first drive, while {{ic|sda}} designates the entire drive.<br />
<br />
To see the current partition layout:<br />
<br />
# lsblk /dev/sda<br />
<br />
Pay attention, because the mounting order is important.<br />
<br />
First, mount the root partition on {{ic|/mnt}}. Following the example above (yours may be different), it would be:<br />
<br />
# mount /dev/sda1 /mnt<br />
<br />
Then mount any other separate partition (/home, /boot, /var, etc), if you have any:<br />
<br />
# mkdir /mnt/home<br />
# mount /dev/sda3 /mnt/home<br />
# mkdir /mnt/boot<br />
# mount /dev/sda''x'' /mnt/boot<br />
<br />
=== Select installation mirror ===<br />
<br />
Before installing, you may want to edit the {{ic|mirrorlist}} file and place your preferred mirror first. A copy of this file will be installed on your new system by {{ic|pacstrap}} as well, so it's worth getting it right.<br />
<br />
{{hc|# nano /etc/pacman.d/mirrorlist|2=<br />
##<br />
## Arch Linux repository mirrorlist<br />
## Sorted by mirror score from mirror status page<br />
## Generated on 2012-MM-DD<br />
##<br />
<br />
## Score: #, Country<br />
Server = http://mirror.example.xyz/archlinux/$repo/os/$arch<br />
...}}<br />
<br />
* {{Keypress|Alt+6}} to copy a {{ic|Server}} line.<br />
* {{Keypress|PageUp}} key to scroll up.<br />
* {{Keypress|Ctrl+U}} to paste it at the top of the list.<br />
<br />
If you want, you can make it the ''only'' mirror available by getting rid of everything else (using {{Keypress|Ctrl+K}}), but it's usually a good idea to have a few more, in case the first one goes offline.<br />
<br />
{{Tip|Use the [http://www.archlinux.org/mirrorlist/ Mirrorlist Generator] to get an updated list for your country. HTTP mirrors are faster than FTP, because of something called [[Wikipedia:Keepalive|keepalive]]. With FTP, pacman has to send out a signal each time it downloads a package, resulting in a brief pause.}}<br />
<br />
=== Install the base system ===<br />
<br />
The base system is installed using the [https://github.com/falconindy/arch-install-scripts/blob/master/pacstrap.in pacstrap] script.<br />
<br />
# pacstrap /mnt base base-devel<br />
<br />
* {{Grp|base}}: Software packages from the [core] repo to provide the minimal base environment.<br />
<br />
* {{Grp|base-devel}}: Extra tools from [core] such as {{ic|make}}, and {{ic|automake}}. Most beginners should choose to install it, as it will likely be needed to expand the system. The ''base-devel'' group will be required to install software from the [[Arch User Repository]].<br />
<br />
This will give you a basic Arch system. Other packages can be installed later using [[pacman]].<br />
<br />
{{Note|If pacman fails to verify your packages, check your system time. If the system date is invalid (e.g. it shows year 2010), signing keys will be considered expired (or invalid), signature checks on packages will fail and installation will be interrupted. Make sure to correct the system time, either by doing so manually or with the {{Pkg|ntp}} client, and retry running the pacstrap command. Refer to [[Time]] page for more information on correcting system time.}}<br />
<br />
=== Generate an fstab ===<br />
<br />
Generate an [[fstab]] file with the following command. If you prefer to use UUIDs or labels, add the {{ic|-U}} or {{ic|-L}} option, respectively. It's also a good idea to check it before continuing:<br />
<br />
{{Note|If you encounter errors running genfstab or later in the install process, do '''not''' run genfstab again; just edit the fstab file.}}<br />
<br />
# genfstab -p /mnt >> /mnt/etc/fstab<br />
# nano /mnt/etc/fstab<br />
<br />
Only the "/" partition needs "1" for the last field. Everything else should have "2" or "0" (see [[Fstab#Field_definitions|Field definitions]]).<br />
<br />
=== Chroot into the system ===<br />
<br />
Next we [[chroot]] into our newly installed system.<br />
<br />
# arch-chroot /mnt<br />
<br />
=== Configure the base system ===<br />
<br />
{{Tip|Closely following and understanding these steps is of key importance to ensure a properly configured system.}}<br />
<br />
At this stage of the installation, you will configure the primary configuration files of your Arch Linux base system.<br />
<br />
{{ic|/etc/rc.conf}} is the configuration file for Arch's initscripts, and in the past used to also contain configurations for other parts of the system. Unless you are using an alternate init system like [[systemd]], this file specifies which daemons to start during boot-up and some networking and storage information.<br />
<br />
{{Note|Using the legacy configuration options in {{ic|rc.conf}} for system configuring still works (for now) with the default init system, but the new configuration files take precedence and using them is recommended. The new files will also work for configuring [[systemd]].}}<br />
<br />
{| class="wikitable"<br />
|-<br />
! scope="col"| Configuration<br />
! scope="col"| Configuration file(s)<br />
! scope="col"| Legacy [https://projects.archlinux.org/initscripts.git/tree/rc.conf?id=97f0cd6751e8d22c14d7492cdc2186cf41157ba6 rc.conf] section<br />
|-<br />
| align="center"|Hostname<br />
| align="left"|{{ic|/etc/hostname}}<br />
{{ic|/etc/hosts}}<br />
| align="center"|{{ic|NETWORKING}}<br />
|-<br />
| align="center"|Console fonts and keymap<br />
| align="left"|{{ic|/etc/vconsole.conf}}<br />
| align="center"|{{ic|LOCALIZATION}}<br />
|-<br />
| align="center"|Locale<br />
| align="left"|{{ic|/etc/locale.conf}}<br />
{{ic|/etc/locale.gen}}<br />
| align="center"|{{ic|LOCALIZATION}}<br />
|-<br />
| align="center"|Timezone<br />
| align="left"|{{ic|/etc/timezone}}<br />
{{ic|/etc/localtime}}<br />
| align="center"|{{ic|LOCALIZATION}}<br />
|-<br />
| align="center"|Hardware clock<br />
| align="left"|{{ic|/etc/adjtime}}<br />
| align="center"|{{ic|LOCALIZATION}}<br />
|-<br />
| align="center"|Kernel modules<br />
| align="left"|{{ic|/etc/modules-load.d/}}<br />
| align="center"|{{ic|HARDWARE}}<br />
|-<br />
| align="center"|Daemons<br />
| align="left"|{{ic|/etc/rc.conf}}<br />
| align="center"|{{ic|DAEMONS}}<br />
|-<br />
| align="center"|Wired network<br />
| align="left"|{{ic|/etc/rc.conf}}<br />
| align="center"|{{ic|NETWORKING}}<br />
|}<br />
<br />
Configuration files can be created if they do not exist, or edited if you wish to change the defaults.<br />
<br />
For this, you can use the editor [[Nano]]. Press {{Keypress|Ctrl+X}} and when prompted to save changes, press {{Keypress|Y}} and {{Keypress|Enter}} to use the same filename, or you can press {{Keypress|N}} to exit without saving.<br />
<br />
==== Hostname ====<br />
<br />
Add your ''hostname'' in {{ic|/etc/hostname}}:<br />
<br />
# echo '''myhostname''' > /etc/hostname<br />
<br />
Set it to your liking (e.g. ''arch''). This is the name of your computer. And add it to {{ic|/etc/hosts}}, as well:<br />
<br />
{{Warning|This format, including {{ic|localhost}} and your actual hostname, is required for program compatibility. Errors in these entries may cause poor network performance and/or certain programs to open very slowly, or not work at all.}}<br />
<br />
{{hc|# nano /etc/hosts|<br />
127.0.0.1 localhost.localdomain localhost '''myhostname'''<br />
::1 localhost.localdomain localhost '''myhostname'''<br />
<br />
#192.168.1.100 '''myhostname'''.domain.org '''myhostname''' #Uncomment if you use a static IP and remove this comment.}}<br />
<br />
{{Note|{{ic|::1}} is the IPv6 equivalent of {{ic|127.0.0.1}} and should be added.}}<br />
<br />
{{Tip|For convenience, you may also use {{ic|/etc/hosts}} aliases for hosts on your network, and/or on the Web.<br />
<br />
192.168.1.90 media<br />
192.168.1.88 data<br />
<br />
The above example would allow you access a media and data server on your network by name and without the need for typing out their respective IP addresses.}}<br />
<br />
==== Console fonts and keymap ====<br />
<br />
To edit {{ic|vconsole.conf}}:<br />
<br />
{{hc|# nano /etc/vconsole.conf|2=<br />
KEYMAP=us<br />
FONT=<br />
FONT_MAP=}}<br />
<br />
* {{ic|KEYMAP}} – If you want, you can use the one from the beginning of the install process: [[#Change_the_keymap|Change the keymap]], but the default ({{ic|us}}) is fine for the vast majority of keyboards. Please note that this setting is only valid for your TTYs, not any graphical window managers or '''Xorg'''.<br />
<br />
* {{ic|FONT}} – Available alternate console fonts reside in {{ic|/usr/share/kbd/consolefonts/}}. The default (blank) is safe.<br />
<br />
* {{ic|FONT_MAP}} – Defines the console map to load with the setfont program at boot. Possible maps are found in {{ic|/usr/share/kbd/consoletrans}}, if needed. The default (blank) is safe.<br />
<br />
See [[Fonts#Console_fonts|Console fonts]] and {{ic|man vconsole.conf}} for more information.<br />
<br />
==== Timezone ====<br />
<br />
Available time zones and subzones can be found in the {{ic|/usr/share/zoneinfo/<Zone>/<SubZone>}} directories.<br />
<br />
To view the available <Zone>, check the directory {{ic|/usr/share/zoneinfo/}}:<br />
<br />
# ls /usr/share/zoneinfo/<br />
<br />
Similarly, you can check the contents of directories belonging to a <SubZone>:<br />
<br />
# ls /usr/share/zoneinfo/Europe<br />
<br />
Create a symbolic link {{ic|/etc/localtime}} to your zone file {{ic|/usr/share/zoneinfo/<Zone>/<SubZone>}} using this command:<br />
<br />
# ln -s {{ic|/usr/share/zoneinfo/<Zone>/<SubZone>}} /etc/localtime<br />
<br />
'''Example:'''<br />
<br />
# ln -s /usr/share/zoneinfo/Europe/Minsk /etc/localtime<br />
<br />
If you are using systemd's timedated, you might wish to also edit the file {{ic|/etc/timezone}} and write your {{ic|Zone}}/{{ic|Subzone}}.<br />
<br />
'''Example:'''<br />
<br />
{{hc|# nano /etc/timezone|<br />
Europe/Minsk}}<br />
<br />
Read {{ic|man tzset}} for more options.<br />
<br />
The need for {{ic|/etc/timezone}} might go away in the future [http://cgit.freedesktop.org/systemd/systemd/commit/?id=9cb48731b29f508178731b45b0643c816800c05e].<br />
<br />
==== Locale ====<br />
<br />
Locales are used by '''glibc''' and other locale-aware programs or libraries for rendering text, correctly displaying regional monetary values, time and date formats, alphabetic idiosyncrasies, and other locale-specific standards. For a comprehensive list of locales and what they stand for, see [http://www.greendesktiny.com/support/knowledgebase_detail.php?ref=EUH-483 here].<br />
<br />
If you would like to receive system messages in English during the install process and after rebooting, keep reading. Otherwise, see the [[#Example_for_languages_other_than_English|example]].<br />
<br />
There are two files that need editing: {{ic|locale.gen}} and {{ic|locale.conf}}.<br />
<br />
* The {{ic|locale.gen}} file is empty by default (everything is commented out) and you need to remove the {{ic|#}} in front of the line(s) you want. You may uncomment more lines than just English, as long as you choose their [[Wikipedia:UTF-8|UTF-8]] encoding.<br />
<br />
{{hc|# nano /etc/locale.gen|<br />
en_US.UTF-8 UTF-8}}<br />
<br />
# locale-gen<br />
<br />
This will run on every '''glibc''' upgrade, generating all the locales specified in {{ic|/etc/locale.gen}}.<br />
<br />
* The {{ic|locale.conf}} file doesn't exist by default. Setting only {{ic|LANG}} should be enough. It will act as the default value for all other variables.<br />
<br />
{{Note|This file must be readable by regular users, so don't set any weird permissions for it. It is read when a user logs in.}}<br />
<br />
# echo "LANG=en_US.UTF-8" > /etc/locale.conf<br />
<br />
To use other {{ic|LC_*}} variables, first run {{ic|locale}} to see the available options. An advanced example can be found [[Locale#Setting_system-wide_locale|here]].<br />
<br />
{{Warning|Using the {{ic|LC_ALL}} variable is strongly discouraged because it overrides everything.}}<br />
<br />
{{Note|1=Some people have reported errors using this, whereby {{ic|locale -a}} and {{ic|locale}} was incorrectly reporting the locale and would generate the {{ic|bsdcpio: Failed to set default locale.}} error. This can be fixed by:<br />
# export "LANG=''locale''"<br />
...where ''locale'' is whatever locale was set in the above {{ic|locale.conf}}.<br />
}}<br />
<br />
===== Example for languages other than English =====<br />
<br />
If you would like to receive system messages in some other language than English during the install process and after rebooting ''(German, in this example)'', the above procedures are:<br />
<br />
{{hc|# nano /etc/locale.gen|<br />
en_US.UTF-8 UTF-8<br />
de_DE.UTF-8 UTF-8}}<br />
<br />
# locale-gen<br />
<br />
# echo "LANG=de_DE.UTF-8" > /etc/locale.conf<br />
# export LANG=de_DE.UTF-8<br />
<br />
==== Hardware clock ====<br />
<br />
{{Note|Make sure that {{ic|HARDWARECLOCK}} isn't set in {{ic|/etc/rc.conf}}.}}<br />
<br />
Set the hardware clock mode uniformly between your operating systems. Otherwise, they may overwrite the hardware clock and cause time shifts.<br />
<br />
You can generate {{ic|/etc/adjtime}} automatically by using one of the following commands:<br />
<br />
* '''UTC''' (recommended)<br />
<br />
: {{Note|Using [[Wikipedia:Coordinated Universal Time|UTC]] for the hardware clock does not mean that software will display time in UTC.}}<br />
<br />
: {{bc|# hwclock --systohc --utc}}<br />
<br />
* '''localtime''' (discouraged; used by default in Windows)<br />
<br />
: {{Warning|Using ''localtime'' may lead to several known and unfixable bugs. However, there are no plans to drop support for ''localtime''.}}<br />
<br />
: {{bc|# hwclock --systohc --localtime}}<br />
<br />
If you have (or planning on having) a dual boot setup with Windows:<br />
<br />
* Recommended: Set both Arch Linux and Windows to use UTC. A quick [[Time#UTC_in_Windows|registry fix]] is needed. Also, be sure to prevent Windows from synchronizing the time on-line, because the hardware clock will default back to ''localtime''. If you want such functionality (NTP sync), you should use [[ntpd]] on your Arch Linux installation instead.<br />
<br />
* Not recommended: Set Arch Linux to ''localtime'' and remove any time-related daemons from {{ic|/etc/rc.conf}}. This will let Windows take care of hardware clock corrections and you will need to remember to boot into Windows at least two times a year (in Spring and Autumn) when [[Wikipedia:Daylight_savings_time|DTS]] kicks in. So please don't ask on the forums why the clock is one hour behind or ahead if you usually go for days or weeks without booting into Windows.<br />
<br />
==== Kernel modules ====<br />
<br />
{{Tip|All needed modules are automatically loaded by udev, so you will rarely need to add something here. Only add modules that you know are missing.}}<br />
<br />
For kernel modules to load during boot, place a {{ic|*.conf}} file in {{ic|/etc/modules-load.d/}}, with a name based on the program that uses them.<br />
<br />
{{hc|# nano /etc/modules-load.d/virtio-net.conf|<br />
# Load 'virtio-net.ko' at boot.<br />
<br />
virtio-net}}<br />
<br />
If there are more modules to load per {{ic|*.conf}}, the module names can be separated by newlines. A good example can be found [[VirtualBox#Auto-start_modules|here]].<br />
<br />
Empty lines and lines starting with {{ic|#}} or {{ic|;}} are ignored.<br />
<br />
==== Daemons ====<br />
<br />
{{Tip|The {{ic|DAEMONS}} line need not be changed at this time, but it is useful to explain what daemons are, as they will be addressed later in this guide.}}<br />
<br />
[[Wikipedia:Daemon (computing)|Daemons]] are programs that run in the background, waiting for events to occur and offering services. A few good examples are: a web server that waits for a request to deliver a page (e.g. {{ic|httpd}}), an SSH server waiting for a user to log in (e.g. {{ic|sshd}}), a daemon which writes system messages to a log file (e.g. {{ic|syslog-ng}}), a BitTorrent client (e.g. {{ic|rtorrent}}, {{ic|deluged}}), a music player (e.g. {{ic|mpd}}), a login manager (e.g. {{ic|gdm}}, {{ic|slim}}), a firewall (e.g. {{ic|iptables}}), etc. While these are full-featured applications, their work is usually not that visible. Their main advantage is that even if Xorg crashes (or is absent from the system), they will continue to work.<br />
<br />
Daemons can be added to the {{ic|DAEMONS}} line in {{ic|/etc/rc.conf}} and they will start when the system boots, in the order that they are placed. Their names are the equivalent scripts from {{ic|/etc/rc.d/}}.<br />
<br />
{{hc|# nano /etc/rc.conf|2=<br />
DAEMONS=(network @syslog-ng netfs @crond)}}<br />
<br />
* If a script name is prefixed with a bang ({{ic|!}}), it is not run.<br />
<br />
* If a script is prefixed with an "at" symbol ({{ic|@}}), it is run in the background; the startup sequence will not wait for successful completion of this daemon before continuing to the next (this may shorten system boot time). Do not background daemons that are needed by other daemons. For example, {{ic|mpd}} depends on {{ic|network}}, so backgrounding {{ic|network}} may cause {{ic|mpd}} to break.<br />
<br />
* Edit this line whenever new system services are installed, if starting them automatically during boot is desired.<br />
<br />
A list of available services (and their running status) can be found using the command:<br />
<br />
# rc.d list<br />
<br />
=== Configure the network ===<br />
<br />
You need to configure the network again, but this time for your newly installed environment. The procedure and prerequisites are very similar to the one described [[#Establish_an_internet_connection|above]], except we are going to make it persistent and automatically run at boot.<br />
<br />
{{Note|For more in-depth information on network configration, visit [[Configuring Network]] and [[Wireless Setup]].}}<br />
<br />
==== Wired ====<br />
<br />
If you only use a single fixed wired network connection, you can use the {{ic|network}} daemon, a simple solution for both dynamic and static IP addressing.<br />
<br />
First, ensure that the daemon is listed in the {{ic|DAEMONS}} array:<br />
<br />
{{hc|# nano /etc/rc.conf|2=<br />
DAEMONS=(... network ...)}}<br />
<br />
Then configure the {{ic|NETWORKING}} section of {{ic|/etc/rc.conf}} as follows, depending on your IP addressing type:<br />
<br />
; Dynamic IP<br />
<br />
Assuming the network interface to activate at start is {{ic|eth0}}, use this configuration:<br />
<br />
interface=eth0<br />
address=<br />
netmask=<br />
gateway=<br />
<br />
Your DNS server addresses will be automatically filled in by the {{ic|dhcpcd}} daemon.<br />
<br />
; Static IP<br />
<br />
If you have a static IP address, use this configuration:<br />
<br />
interface=eth0<br />
address=192.168.0.2<br />
netmask=255.255.255.0<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
<br />
You will also need to add your name servers' (DNS) IP addresses and your local domain name to your {{ic|/etc/resolv.conf}} like this:<br />
<br />
nameserver 61.23.173.5<br />
nameserver 61.95.849.8<br />
search example.com<br />
<br />
{{Tip|The {{ic|network}} daemon is suitable for systems connecting wired to a single network. For multiple network configurations (e.g. using a laptop), it is recommended to use a network manager program, such as [[netcfg]], which has been designed to manage both wired and wireless connections.}}<br />
<br />
==== Wireless ====<br />
<br />
The {{ic|network}} daemon is not sufficient to handle wireless networking. You will need to install other programs to configure and manage wireless network profiles, such as [[netcfg]].<br />
<br />
[[NetworkManager]] and [[Wicd]] are other popular alternatives.<br />
<br />
* Install the required packages:<br />
<br />
# pacman -S wireless_tools netcfg<br />
<br />
If you use WPA/WPA2 encryption, install:<br />
<br />
# pacman -S wpa_supplicant wpa_actiond<br />
<br />
If your wireless adapter requires a firmware (as described in the above [[#Wireless|Establish an internet connection]] section and also [[Wireless_Setup#Drivers_and_firmware|here]]), install the package containing your firmware. For example:<br />
<br />
# pacman -S zd1211-firmware<br />
<br />
* Connect to the network with {{ic|wifi-menu}} (optionally checking the interface name with {{ic|ip link}}, but usually it's {{ic|wlan0}}), which will generate a profile file in {{ic|/etc/network.d}} named after the SSID. There are also templates available in {{ic|/etc/network.d/examples/}} for manual configuration.<br />
<br />
# wifi-menu<br />
<br />
* Add {{ic|net-auto-wireless}} to the {{ic|DAEMONS}} array in {{ic|/etc/rc.conf}}, daemon which will connect to known networks and gracefully handle roaming and disconnects:<br />
<br />
{{Note|[[Netcfg]] also provides {{ic|net-auto-wired}}, which can be used in conjunction with {{ic|net-auto-wireless}}.}}<br />
<br />
{{hc|# nano /etc/rc.conf|2=<br />
DAEMONS=(... net-auto-wireless ...)}}<br />
<br />
* Make sure that the correct wireless interface (usually {{ic|wlan0}}) is set in {{ic|/etc/conf.d/netcfg}}:<br />
<br />
{{hc|# nano /etc/conf.d/netcfg|2=<br />
WIRELESS_INTERFACE="wlan0"}}<br />
<br />
It is also possible to define a list of network profiles that should be automatically connected, using the {{ic|AUTO_PROFILES}} variable in {{ic|/etc/conf.d/netcfg}}. If {{ic|AUTO_PROFILES}} is not set, all known wireless networks will be tried.<br />
<br />
==== Direct Modem Connection ====<br />
<br />
For xDSL, analog modem (dial-up) and ISDN, see [[Direct Modem Connection]] for detailed instructions.<br />
<br />
=== Create an initial ramdisk environment ===<br />
<br />
Configure {{ic|/etc/mkinitcpio.conf}} as needed (see [[mkinitcpio]]) and create an initial ramdisk with<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Tip|Most users can simply accept the defaults provided in the {{ic|/etc/mkinitcpio.conf}} file.}}<br />
<br />
=== Install and configure a bootloader ===<br />
<br />
Install either Syslinux or GRUB. There is no need to install both. Syslinux is considered to be easier to understand and to configure because it has only one configuration file. In spite of GRUB's many configuration files ''(for which the recommended method is to re-generate the {{ic|grub.cfg}} file each time you change anything in one of those files)'', using GRUB could make it more comfortable to transition to BURG in the future, a much more [http://code.google.com/p/burg/wiki/Screenshots customizable] GRUB fork. Of course, Syslinux can also be customized. [https://bbs.archlinux.org/viewtopic.php?pid=1109328#p1109328 (*)]<br />
<br />
==== Syslinux ====<br />
<br />
{{Note|Syslinux does not yet support [[UEFI]].}}<br />
<br />
Install the {{Pkg|syslinux}} package and then use the {{ic|syslinux-install_update}} script to automatically ''install'' the files ({{ic|-i}}), mark the partition ''active'' with the ''boot'' flag ({{ic|-a}}), and install the ''MBR'' boot code ({{ic|-m}}):<br />
<br />
# pacman -S syslinux<br />
# syslinux-install_update -iam<br />
<br />
{{Tip|If you get the error '''''FAILED to set attribute Legacy BIOS Bootable''''' when running the syslinux-install_update command above, you may need to install the {{gptfdisk}} package (with {{pacman -S gptfdisk}}). There are some operations syslinux operations that require this package. See [https://bugs.archlinux.org/task/29556?opened&#61;12641&status%5B0%5D here] for more details.}}<br />
<br />
Configure {{ic|syslinux.cfg}} to point to the right root partition. This step is vital. If it points to the wrong partition, Arch Linux will not boot. Change {{ic|/dev/sda3}} to reflect your root partition ''(if you partitioned your drive as we did in [[#Prepare_the_storage_drive|the example]], your root partition is sda1)''. Do the same for the fallback entry.<br />
<br />
{{hc|# nano /boot/syslinux/syslinux.cfg|<nowiki><br />
...<br />
LABEL arch<br />
...<br />
APPEND root=/dev/sda3 ro<br />
...</nowiki>}}<br />
<br />
For more information on configuring and using Syslinux, see [[Syslinux]].<br />
<br />
==== GRUB ====<br />
<br />
* For BIOS motherboards:<br />
<br />
{{Note|Please do not use something like {{ic|sda1}}. You want to install to the MBR, not to a partition (which is [[GRUB#Install_to_Partition_or_Partitionless_Disk|discouraged]]).}}<br />
<br />
# pacman -S grub-bios<br />
# grub-install --target=i386-pc --recheck /dev/sda<br />
<br />
Create the {{ic|grub.cfg}} file:<br />
<br />
{{Tip|To automatically search for other operating systems on your computer, install {{Pkg|os-prober}} before running the next command:<br />
# pacman -S os-prober<br />
}}<br />
<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
* For UEFI motherboards:<br />
<br />
{{Note|In rare cases you may need to use {{ic|grub-efi-i386}} instead; on older macs for instance, where Apple hardware uses some kind of mixture between UEFI v1.x and v2.x. In such cases, GRUB would only work with 32 bit modules, even though the CPU may be 64 bit.}}<br />
<br />
{{Note|GRUB is not the only UEFI bootloader available. See [[UEFI Bootloaders]].}}<br />
<br />
# pacman -S grub-efi-x86_64<br />
# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch_grub --recheck<br />
<br />
Don't forget to generate a {{ic|grub.cfg}} as described above.<br />
<br />
For more information on configuring and using GRUB, see [[GRUB]].<br />
<br />
=== Root password ===<br />
<br />
Set the root password with:<br />
<br />
# passwd<br />
<br />
=== Unmount the partitions and reboot ===<br />
<br />
Exit from the chroot environment:<br />
<br />
# exit<br />
<br />
Since the partitions are mounted under {{ic|/mnt}}, we use the following command to unmount them.<br />
<br />
# umount /mnt/{boot,home,}<br />
<br />
Exit the install, and reboot:<br />
<br />
# reboot<br />
<br />
{{Tip|Be sure to remove the installation media, otherwise you will boot back into it!}}<noinclude>{{Beginners' Guide navigation}}</noinclude></div>Mach1NE