https://wiki.archlinux.org/api.php?action=feedcontributions&user=Samlt&feedformat=atomArchWiki - User contributions [en]2024-03-29T12:33:03ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Syslinux&diff=235125Syslinux2012-11-12T21:43:24Z<p>Samlt: /* Manual Install */ wrong option for sgdisk</p>
<hr />
<div>[[Category:Boot loaders]]<br />
[[es:Syslinux]]<br />
[[fr:Syslinux]]<br />
[[it:Syslinux]]<br />
[[tr:Syslinux]]<br />
[[zh-CN:Syslinux]]<br />
{{Article summary start}}<br />
{{Article summary text|Describes installing and configuring Syslinux, a collection of bootloaders.}}<br />
{{Article summary heading|Overview}}<br />
{{Article summary text|{{Boot process overview}}}}<br />
{{Article summary end}}<br />
<br />
[[Wikipedia:SYSLINUX|Syslinux]] is a collection of boot loaders capable of booting from hard drives, CDs, and over the network via PXE. It supports the [[Wikipedia:File Allocation Table|FAT]], [[Wikipedia:ext2|ext2]], [[Ext3|ext3]], [[Ext4|ext4]], and [[Btrfs]] file systems.<br />
<br />
{{Note|Since Syslinux 4, Extlinux and Syslinux are the same thing.}} <br />
{{Note|Syslinux UEFI support is currently present only in upstream git repo and is of alpha quality. See [[UEFI_Bootloaders#SYSLINUX]] for more info.}}<br />
<br />
== Syslinux Boot Process ==<br />
# '''Load MBR'''. At boot, the computer loads the [[MBR]] ({{ic|/usr/lib/syslinux/mbr.bin}}). <br />
# '''Search active partition'''. The MBR looks for the partition that is marked as active (boot flag). <br />
# '''Execute volume boot record'''. Once found, the volume boot record (VBR) will be executed. In the case of ext2/3/4 and FAT12/16/32, the starting sector of {{ic|ldlinux.sys}} is hard-coded into the VBR.<br />
# '''Execute ldlinux.sys'''. The VBR will execute ({{ic|ldlinux.sys}}). Therefore, if the location of {{ic|ldlinux.sys}} changes, Syslinux will no longer boot. (In the case of Btrfs, the above method will not work since files move around resulting in the sector location of {{ic|ldlinux.sys}} changing. Therefore, the entire Syslinux code needs to be stored outside the filesystem. The code is stored in the sectors following the VBR.) <br />
# '''Search configuration file'''. Once Syslinux is fully loaded, it looks for a configuration file, either {{ic|extlinux.conf}} or {{ic|syslinux.cfg}}. <br />
# '''Load configuration'''. If one is found, the configuration file is loaded. If no configuration file is found, you will be given a Syslinux prompt.<br />
<br />
== Installation ==<br />
<br />
[[Pacman|Install]] {{Pkg|syslinux}} from the [[official repositories]].<br />
<br />
=== Automatic Install ===<br />
The {{ic|syslinux-install_update}} script will install Syslinux, copy/symlink {{ic|*.c32}} modules to {{ic|/boot/syslinux}}, set the boot flag and install the boot code in the MBR. It can handle [[Master Boot Record|MBR]] and [[GUID Partition Table|GPT]] disks along with software RAID.<br />
<br />
:1. If you use a separate boot partition make sure that it is mounted. Check with {{ic|lsblk}}; if you don't see a {{ic|/boot}} mountpoint, mount it before you go any further.<br />
<br />
:2. Run {{ic|syslinux-install_update}} with flags: {{ic|-i}} (install the files), {{ic|-a}} (mark the partition ''active'' with the ''boot'' flag), {{ic|-m}} (install the ''MBR'' boot code):<br />
# syslinux-install_update -i -a -m<br />
<br />
:3. Edit {{ic|/boot/syslinux/syslinux.cfg}}.<br />
<br />
=== Manual Install ===<br />
{{Note| If you are unsure of which partition table you are using (MBR or GPT), you are likely using the MBR partition table. Most of the time GPT will create a special MBR-style partition (type {{ic|0xEE}}) using the whole disk which will be displayed with the following command:<br />
# fdisk -l /dev/sda<br />
<br />
or alternatively:<br />
# sgdisk -p /dev/sda<br />
<br />
will show "GPT: not present" if it is not a GPT disk.<br />
}}<br />
<br />
{{Note| If you are trying to rescue an installed system with a live CD, be sure to [[Change_Root|chroot]] into it before executing these commands. If you do not chroot first, you must prepend all file paths (not {{ic|/dev/}} paths) with the mount point.}}<br />
<br />
Your boot partition, on which you plan to install Syslinux, must contain a FAT, ext2, ext3, ext4, or Btrfs file system. You should install it on a mounted directory, not a {{ic|/dev/sdXY}} device. You do not have to install it on the root directory of a file system, e.g., with device {{ic|/dev/sda1}} mounted on {{ic|/boot}} you can install Syslinux in the {{ic|syslinux}} directory:<br />
# mkdir /boot/syslinux<br />
# extlinux --install /boot/syslinux <br />
<br />
==== MBR Partition Table ====<br />
{{Box||See the main article: [[Master Boot Record]]|#E5E5FF|#FCFCFC}}<br />
<br />
Next you need to mark your boot partition active in your partition table. Applications capable of doing this include {{ic|fdisk}}, {{ic|cfdisk}}, {{ic|sfdisk}}, {{ic|parted/gparted}}. It should look like this:<br />
{{hc|# fdisk -l /dev/sda|<br />
[...]<br />
Device Boot Start End Blocks Id System<br />
/dev/sda1 * 2048 104447 51200 83 Linux<br />
/dev/sda2 104448 625142447 312519000 83 Linux<br />
}}<br />
<br />
Install the MBR:<br />
# dd bs=440 count=1 conv=notrunc if=/usr/lib/syslinux/mbr.bin of=/dev/sda<br />
<br />
An alternate MBR which Syslinux provides is: {{ic|altmbr.bin}}. This MBR does ''not'' scan for bootable partitions; instead, the last byte of the MBR is set to a value indicating which partition to boot from. Here is an example of how {{ic|altmbr.bin}} can be copied into position:<br />
# printf '\x5' | cat /usr/lib/syslinux/altmbr.bin - | dd bs=440 count=1 iflag=fullblock conv=notrunc of=/dev/sda<br />
<br />
In this case, a single byte of value 5 is appended to the contents of {{ic|altmbr.bin}} and the resulting 440 bytes are written to the MBR on device {{ic|sda}}. Syslinux was installed on the first logical partition ({{ic|/dev/sda5}}) of the disk.<br />
<br />
==== GUID Partition Table aka GPT ====<br />
{{Box||See the main article: [[GUID Partition Table]]|#E5E5FF|#FCFCFC}}<br />
<br />
Bit 2 of the attributes for the {{ic|/boot}} partition needs to be set.<br />
# sgdisk /dev/sda --attributes=1:set:2<br />
<br />
This would toggle the attribute ''legacy BIOS bootable'' on partition 1. To check:<br />
# sgdisk /dev/sda --attributes=1:show<br />
1:2:1 (legacy BIOS bootable)<br />
<br />
Install the MBR:<br />
# dd bs=440 conv=notrunc count=1 if=/usr/lib/syslinux/gptmbr.bin of=/dev/sda<br />
<br />
==== Rebooting ====<br />
When you reboot your system now, you will have a Syslinux prompt. To automatically boot your system or get a boot menu, you still need to create a configuration file.<br />
<br />
== Configuration ==<br />
The Syslinux configuration file, {{ic|syslinux.cfg}}, should be created in the same directory where you installed Syslinux. In our case, {{ic|/boot/syslinux/}}.<br />
<br />
The bootloader will look for either {{ic|syslinux.cfg}} (preferred) or {{ic|extlinux.conf}}<br />
<br />
{{Tip|<br />
* Instead of {{ic|LINUX}}, the keyword {{ic|KERNEL}} can also be used. {{ic|KERNEL}} tries to detect the type of the file, while {{ic|LINUX}} always expects a Linux kernel. <br />
* {{ic|TIMEOUT}} value is in units of '''1/10''' of a second.<br />
}}<br />
<br />
=== Examples ===<br />
==== Basic Config ====<br />
This is a simple configuration file that will show a {{ic|boot:}} prompt and automatically boot after 5 seconds.<br />
<br />
{{Note|The partition in question needs to be whatever you have as {{ic|/}} (root), not {{ic|/boot}}.}}<br />
<br />
Configuration:<br />
{{hc|/boot/syslinux/syslinux.cfg|<nowiki><br />
PROMPT 1<br />
TIMEOUT 50<br />
DEFAULT arch<br />
<br />
LABEL arch<br />
LINUX ../vmlinuz-linux<br />
APPEND root=/dev/sda2 ro<br />
INITRD ../initramfs-linux.img<br />
<br />
LABEL archfallback<br />
LINUX ../vmlinuz-linux<br />
APPEND root=/dev/sda2 ro<br />
INITRD ../initramfs-linux-fallback.img</nowiki><br />
}}<br />
<br />
If you want to boot directly without seeing a prompt, set {{ic|PROMPT}} to {{ic|0}}.<br />
<br />
If you want to use [[UUID]] for persistent device naming instead of device names, change the {{ic|APPEND}} line to your equivalent {{ic|UUID}} of the root partition:<br />
APPEND root='''UUID='''978e3e81-8048-4ae1-8a06-aa727458e8ff ro<br />
<br />
If you use encryption [[LUKS]] change the {{ic|APPEND}} line to use your encrypted volume:<br />
APPEND root=/dev/mapper/<group>-<name> cryptdevice=/dev/sda2:<name> ro<br />
<br />
If you are using software [[Wikipedia:RAID|RAID]] using [http://neil.brown.name/blog/mdadm mdadm], change the {{ic|APPEND}} line to accommodate your RAID arrays. As an example the following accommodates three RAID 1 array's and sets the appropriate one as root:<br />
APPEND root=/dev/md1 ro md=0,/dev/sda2,/dev/sdb2 md=1,/dev/sda3,/dev/sdb3 md=2,/dev/sda4,/dev/sdb4<br />
<br />
==== Text Boot menu ====<br />
Syslinux also allows you to use a boot menu. To use it, copy the {{ic|menu}} COM32 module to your Syslinux directory:<br />
# cp /usr/lib/syslinux/menu.c32 /boot/syslinux/<br />
<br />
If {{ic|/boot}} is in the same partition as {{ic|/usr}}, a symlink will also work:<br />
# ln -s /usr/lib/syslinux/menu.c32 /boot/syslinux/<br />
<br />
Configuration:<br />
{{hc|/boot/syslinux/syslinux.cfg|<nowiki><br />
UI menu.c32<br />
PROMPT 0<br />
<br />
MENU TITLE Boot Menu<br />
TIMEOUT 50<br />
DEFAULT arch<br />
<br />
LABEL arch<br />
MENU LABEL Arch Linux<br />
LINUX ../vmlinuz-linux<br />
APPEND root=/dev/sda2 ro<br />
INITRD ../initramfs-linux.img<br />
<br />
LABEL archfallback<br />
MENU LABEL Arch Linux Fallback<br />
LINUX ../vmlinuz-linux<br />
APPEND root=/dev/sda2 ro<br />
INITRD ../initramfs-linux-fallback.img</nowiki><br />
}}<br />
<br />
For more details about the menu system, see [http://git.kernel.org/?p=boot/syslinux/syslinux.git;a=blob;f=doc/menu.txt the Syslinux documentation].<br />
<br />
==== Graphical Boot menu ====<br />
Syslinux also allows you to use a graphical boot menu. To use it, copy the {{ic|vesamenu}} COM32 module to your Syslinux folder:<br />
# cp /usr/lib/syslinux/vesamenu.c32 /boot/syslinux/<br />
<br />
If {{ic|/boot}} is the same partition as {{ic|/}}, a symlink will also work:<br />
# ln -s /usr/lib/syslinux/vesamenu.c32 /boot/syslinux/<br />
<br />
[http://projects.archlinux.org/archiso.git/tree/configs/releng/syslinux This config] uses the same menu design as the Arch Install CD. The background file can be found there too.<br />
<br />
Configuration:<br />
{{hc|/boot/syslinux/syslinux.cfg|<nowiki><br />
UI vesamenu.c32<br />
DEFAULT arch<br />
PROMPT 0<br />
MENU TITLE Boot Menu<br />
MENU BACKGROUND splash.png<br />
TIMEOUT 50<br />
<br />
MENU WIDTH 78<br />
MENU MARGIN 4<br />
MENU ROWS 5<br />
MENU VSHIFT 10<br />
MENU TIMEOUTROW 13<br />
MENU TABMSGROW 11<br />
MENU CMDLINEROW 11<br />
MENU HELPMSGROW 16<br />
MENU HELPMSGENDROW 29<br />
<br />
# Refer to http://www.syslinux.org/wiki/index.php/Comboot/menu.c32<br />
<br />
MENU COLOR border 30;44 #40ffffff #a0000000 std<br />
MENU COLOR title 1;36;44 #9033ccff #a0000000 std<br />
MENU COLOR sel 7;37;40 #e0ffffff #20ffffff all<br />
MENU COLOR unsel 37;44 #50ffffff #a0000000 std<br />
MENU COLOR help 37;40 #c0ffffff #a0000000 std<br />
MENU COLOR timeout_msg 37;40 #80ffffff #00000000 std<br />
MENU COLOR timeout 1;37;40 #c0ffffff #00000000 std<br />
MENU COLOR msg07 37;40 #90ffffff #a0000000 std<br />
MENU COLOR tabmsg 31;40 #30ffffff #00000000 std<br />
<br />
<br />
LABEL arch<br />
MENU LABEL Arch Linux<br />
LINUX ../vmlinuz-linux<br />
APPEND root=/dev/sda2 ro<br />
INITRD ../initramfs-linux.img<br />
<br />
<br />
LABEL archfallback<br />
MENU LABEL Arch Linux Fallback<br />
LINUX ../vmlinuz-linux<br />
APPEND root=/dev/sda2 ro<br />
INITRD ../initramfs-linux-fallback.img</nowiki><br />
}}<br />
<br />
Since Syslinux 3.84, {{ic|vesamenu.c32}} supports the {{ic|MENU RESOLUTION $WIDTH $HEIGHT}} directive.<br />
To use it, insert {{ic|MENU RESOLUTION 1440 900}} into your config for a 1440x900 resolution.<br />
The background picture has to have exactly the right resolution, however, as Syslinux will otherwise refuse to load the menu.<br />
<br />
=== Auto Boot ===<br />
If you don't want to see the Syslinux menu at all, comment out all {{ic|UI}} commands and make sure there is a {{ic|DEFAULT}} set in your {{ic|syslinux.cfg}}.<br />
<br />
=== Chainloading ===<br />
If you want to chainload other operating systems (such as Windows) or boot loaders, copy (or symlink) the {{ic|chain.c32}} module to the Syslinux directory (for details, see the instructions in the previous section). Then create a section in the configuration file:<br />
{{hc|/boot/syslinux/syslinux.cfg|<br />
...<br />
LABEL windows<br />
MENU LABEL Windows<br />
COM32 chain.c32<br />
APPEND hd0 3<br />
...<br />
}}<br />
<br />
{{ic|hd0 3}} is the third partition on the first BIOS drive - drives are counted from zero, but partitions are counted from one. <br />
<br />
If you are unsure about which drive your BIOS thinks is "first", you can instead use the MBR identifier, or if you are using GPT, the filesystem labels. To use the MBR identifier, run the command<br />
{{hc|# fdisk -l /dev/sdb|<nowiki><br />
Disk /dev/sdb: 128.0 GB, 128035676160 bytes <br />
255 heads, 63 sectors/track, 15566 cylinders, total 250069680 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: 0xf00f1fd3<br />
<br />
Device Boot Start End Blocks Id System<br />
/dev/sdb1 2048 4196351 2097152 7 HPFS/NTFS/exFAT<br />
/dev/sdb2 4196352 250066943 122935296 7 HPFS/NTFS/exFAT</nowiki><br />
}}<br />
<br />
replacing {{ic|/dev/sdb}} with the drive you wish to chainload. Using the hexadecimal number under Disk identifier: {{ic|0xf00f1fd3}} in this case, the syntax in {{ic|syslinux.cfg}} is<br />
{{hc|/boot/syslinux/syslinux.cfg|<br />
...<br />
LABEL windows<br />
MENU LABEL Windows<br />
COM32 chain.c32<br />
APPEND mbr:0xf00f1fd3<br />
...<br />
}}<br />
<br />
For more details about chainloading, see [http://www.syslinux.org/wiki/index.php/Comboot/chain.c32 the Syslinux wiki].<br />
<br />
If you have [[GRUB]] installed on the same partition, you can chainload it by using: <br />
{{hc|/boot/syslinux/syslinux.cfg|<nowiki><br />
...<br />
LABEL grub2<br />
MENU LABEL Grub2<br />
COM32 chain.c32<br />
append file=../grub/boot.img<br />
...</nowiki><br />
}}<br />
<br />
This may be required for booting from ISO images.<br />
<br />
=== Chainloading other Linux systems ===<br />
Chainloading another bootloader such as Windows' is pretty obvious, as there is a definite bootloader to chain to. But with Syslinux, it is only able to load files residing on the same partition as the configuration file. Thus, if you have another version of Linux on a separate partition, without a shared {{ic|/boot}}, it becomes necessary to employ Extlinux. Essentially, Extlinux can be installed on the partition superblock and be called as a separate bootloader from the MBR installed by Syslinux. Extlinux is part of the Syslinux project and is included with the {{Pkg|syslinux}} package.<br />
<br />
The following instructions assume you have Syslinux installed already. These instructions will also assume that the typical Arch Linux configuration path of {{ic|/boot/syslinux}} is being used and the chainloaded {{ic|/}} is on {{ic|/dev/sda3}}. <br />
<br />
From a booted Linux (likely the partition that Syslinux is set up to boot), mount the other root partition to your desired mount point. In this example this will be {{ic|/mnt}}. Also, if a separate {{ic|/boot}} partition is used on the second operating system, that will also need to be mounted. The example assumes this is {{ic|/dev/sda2}}.<br />
# mount /dev/sda3 /mnt<br />
# mount /dev/sda2 /mnt/boot (only necessary for separate /boot)<br />
Install Extlinux and copy necessary {{ic|*.c32}} files<br />
# extlinux -i /mnt/boot/syslinux<br />
# cp /usr/lib/syslinux/{chain,menu}.c32 /mnt/boot/syslinux<br />
<br />
Create {{ic|/mnt/boot/syslinux/syslinux.cfg}}. Below is an example:<br />
{{hc|/boot/syslinux/syslinux.cfg '''on /dev/sda3'''|<nowiki><br />
timeout 10<br />
<br />
ui menu.c32<br />
<br />
<br />
label Other Linux<br />
linux /boot/vmlinuz-linux<br />
initrd /boot/initramfs-linux.img<br />
append root=/dev/sda3 ro quiet<br />
<br />
<br />
label MAIN<br />
com32 chain.c32<br />
append hd0 0</nowiki><br />
}}<br />
<br />
taken from [[User:Djgera|Djgera's user wiki page]].<br />
<br />
=== Using memtest ===<br />
Install {{Pkg|memtest+}} from the [[official repositories]].<br />
<br />
Use this {{ic|LABEL}} section to launch [[Wikipedia:Memtest86|memtest]]:<br />
{{hc|/boot/syslinux/syslinux.cfg|<br />
...<br />
LABEL memtest<br />
MENU LABEL Memtest86+<br />
LINUX ../memtest86+/memtest.bin<br />
...<br />
}}<br />
<br />
=== HDT ===<br />
[http://hdt-project.org/ HDT (Hardware Detection Tool)] displays hardware information. Like before, the {{ic|.c32}} file has to be copied or symlinked from {{ic|/boot/syslinux/}}.<br />
For PCI info, either copy or symlink {{ic|/usr/share/hwdata/pci.ids}} to {{ic|/boot/syslinux/pci.ids}} and add the following to your configuration file:<br />
{{hc|/boot/syslinux/syslinux.cfg|<br />
LABEL hdt<br />
MENU LABEL Hardware Info<br />
COM32 hdt.c32<br />
}}<br />
<br />
=== Reboot and power off ===<br />
Use the following sections to reboot or power off your machine:<br />
{{hc|/boot/syslinux/syslinux.cfg|<br />
LABEL reboot<br />
MENU LABEL Reboot<br />
COM32 reboot.c32<br />
<br />
LABEL poweroff<br />
MENU LABEL Power Off<br />
COMBOOT poweroff.com<br />
}}<br />
<br />
=== Clear Menu ===<br />
To clear the screen when exiting the menu, add the following line:<br />
{{hc|/boot/syslinux/syslinux.cfg|<br />
MENU CLEAR<br />
}}<br />
<br />
=== Keyboard remapping ===<br />
If you often have to edit your boot parameters, you might want to remap your keyboard layout. This allows you to enter "=", "/" and other characters easily on a non-US keyboard.<br />
<br />
First you have to create a compatible keymap (for example a German one):<br />
# cp /usr/share/kbd/keymaps/i386/qwerty/us.map.gz ./<br />
# cp /usr/share/kbd/keymaps/i386/qwertz/de.map.gz ./<br />
# gunzip {de,us}.map.gz<br />
# mv de.{,k}map<br />
# mv us.{,k}map<br />
# keytab-lilo de > de.ktl<br />
<br />
Copy {{ic|de.ktl}} as root to {{ic|/boot/syslinux/}} and set ownership to root:<br />
# chown root:root /boot/syslinux/de.ktl<br />
<br />
Now edit {{ic|syslinux.conf}} and add:<br />
{{hc|/boot/syslinux/syslinux.cfg|<br />
KBDMAP de.ktl<br />
}}<br />
<br />
=== Hiding the menu ===<br />
Use the option:<br />
{{hc|/boot/syslinux/syslinux.cfg|<br />
MENU HIDDEN<br />
}}<br />
to hide the menu while displaying only the timeout. Press any key to bring up the menu.<br />
<br />
== Troubleshooting ==<br />
=== Using the Syslinux prompt===<br />
You can type in the {{ic|LABEL}} name of the entry that you want to boot (as per your {{ic|syslinux.cfg}}). If you used the example configurations, just type:<br />
boot: arch<br />
<br />
If you get an error that the configuration file could not be loaded, you can pass your needed boot parameters, e.g.:<br />
boot: ../vmlinuz-linux root=/dev/sda2 ro initrd=../initramfs-linux.img<br />
<br />
If you do not have access to {{ic|boot:}} in [[Ramdisk|ramfs]], and therefore temporarily unable to boot kernel again,<br />
:1. Create a temporary directory, in order to mount your root partition (if it does not exist already):<br />
# mkdir -p /new_root<br />
:2. Mount {{ic|/}} under {{ic|/new_root}} (in case {{ic|/boot/}} is on the same partition, otherwise you will need to mount them both):<br />
{{Note|If {{ic|/boot}} is on its own ext2 partition then busybox cannot mount it.}}<br />
# mount /dev/sd[a-z][1-9] /new_root<br />
<br />
:3. Use {{ic|vim}} and edit {{ic|syslinux.cfg}} again to suit your needs and save file.<br />
:4. Reboot.<br />
<br />
=== No Default or UI found on some computers ===<br />
Certain motherboard manufacturers have less compatibility for booting from USB devices than others. While an ext4 formatted USB drive may boot on a more recent computer, some computers may hang if the boot partition containing the ''kernel'' and ''initrd'' are not on a FAT16 partition. To prevent an older machine from loading {{ic|ldlinux}} and failing to read {{ic|syslinux.cfg}}, use {{ic|cfdisk}} to create a FAT16 partition (<=2GB) and format using {{Pkg|dosfstools}}:<br />
# mkfs.msdos -F 16 /dev/sda1<br />
<br />
then install and configure Syslinux.<br />
<br />
=== Missing Operating System ===<br />
If you get this message, check if the partition that contains {{ic|/boot}} has the boot flag enabled. If the flag is enabled, then perhaps this partition starts at sector 1 rather than sector 63 or 2048. Check this with {{ic|fdisk -l}}. If it starts at sector 1, you can move the partition(s) with {{ic|gparted}} from a rescue disk. Or, if you have a separate boot partition, you can back up {{ic|/boot}} with <br />
# cp -a /boot /boot.bak<br />
and then boot up with the Arch install disk. Next, use {{ic|cfdisk}} to delete the {{ic|/boot}} partition, and recreate it. This time it should begin at the proper sector, '''63'''. Now mount your partitions and {{ic|chroot}} into your mounted system, as described in the beginners guide. Restore {{ic|/boot}} with the command<br />
# cp -a /boot.bak/* /boot<br />
Check if {{ic|/etc/fstab}} is correct, run:<br />
# syslinux-install_update -iam<br />
and reboot.<br />
<br />
=== Windows boots up, ignoring Syslinux ===<br />
'''Solution:''' Make sure the partition that contains {{ic|/boot}} has the boot flag enabled. Also, make sure the boot flag is not enabled on the Windows partition. See the installation section above.<br />
<br />
The MBR that comes with Syslinux looks for the first active partition that has the boot flag set. The Windows partition was likely found first and had the boot flag set. If you wanted, you could use the MBR that Windows or MS-DOS {{ic|fdisk}} provides.<br />
<br />
=== Menu entries do nothing ===<br />
You select a menu entry and it does nothing, it just ''"refreshes"'' the menu. This usually means that you have an error in your {{ic|syslinux.cfg}} file. Hit {{Keypress|Tab}} to edit your boot parameters. Alternatively, press {{Keypress|Esc}} and type in the {{ic|LABEL}} of your boot entry (e.g. ''arch'').<br />
<br />
=== Cannot remove ldlinux.sys ===<br />
<br />
The {{ic|ldlinux.sys}} file has the immutable attribute set, which prevents it from being deleted or overwritten. This is because the sector location of the file must not change or else Syslinux has to be reinstalled. To remove it, run:<br />
# chattr -i /boot/syslinux/ldlinux.sys<br />
# rm /boot/syslinux/ldlinux.sys<br />
<br />
=== White block in upper left corner when using vesamenu ===<br />
Problem:<br />
''As of linux-3.0, the modesetting driver tries to keep the current contents of the screen after changing the resolution (at least it does so with my Intel, when having Syslinux in text mode). It seems that this goes wrong when combined with the vesamenu module in Syslinux (the white block is actually an attempt to keep the Syslinux menu, but the driver fails to capture the picture from vesa graphics mode).''<br />
<br />
If you have a custom resolution and a {{ic|vesamenu}} with early modesetting, try to append the following in {{ic|syslinux.cfg}} to remove the white block and continue in graphics mode:<br />
APPEND root=/dev/sda6 ro 5 '''vga=current''' quiet splash<br />
<br />
== See also ==<br />
* [http://www.syslinux.org Official Website]<br />
* [http://www.josephn.net/scrapbook/pxelinux_stuff PXELinux configuration]</div>Samlthttps://wiki.archlinux.org/index.php?title=VCS_package_guidelines&diff=27215VCS package guidelines2007-07-23T13:00:09Z<p>Samlt: /* A few tips */ replaced an overkilling one liner</p>
<hr />
<div>[[Category:Package management (English)]]<br />
[[Category:Development (English)]]<br />
[[Category:Package development (English)]]<br />
[[Category:Tutorials (English)]]<br />
<br />
:''This is actually very easy and doesn't require any special knowledge. However, the more you know about cvs and svn the easier it is. Many people introduce custom variables into the PKGBUILD that can over complicate things. These are not ''really'' necessary but do help to clarify the syntax of the cvs/svn/git commands, which can appear quite complex.''<br />
<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|Arch CVS %26 SVN PKGBUILD guidelines}}<br />
{{i18n_entry|繁體中文|Arch CVS %26 SVN PKGBUILD 編寫指南}}<br />
{{i18n_entry|简体中文|Arch CVS %26 SVN %26 GIT PKGBUILD 编写指南}}<br />
{{i18n_links_end}}<br />
<br />
<br />
==A few tips==<br />
<br />
* Suffix <code>pkgname</code> with <code>-cvs</code> or <code>-svn</code> or <code>-git</code> where applicable - this prevents confusion with non-development versions e.g. fluxbox-svn or fvwm-cvs vs fluxbox and fvwm.<br />
* You must also be careful about pacman conflicts. For example fluxbox-svn will conflict with fluxbox. In this case you need to use the <tt>conflicts=</tt> field<br />
conflicts=('fluxbox')<br />
: You should also use the <tt>provides=</tt> field so that pkgs that require fluxbox to be installed recognize your fluxbox-svn pkg as fluxbox<br />
provides=('fluxbox')<br />
: You should AVOID using <tt>replaces=</tt> it generally causes unnecessary problems<br />
*When using/defining the cvsroot use anonymous<b>:</b>@ rather than anonymous@ to avoid having to press enter to give blank password ''OR'' anonymous<b>:password</b>@ - if a password is required.<br />
* cvs and svn PKGBUILDs may not require a source or md5sum array but these fields '''must''' be included in the PKGBUILD if you wish to submit it to the AUR, otherwise the pkg will be rejected. They may be left blank though.<br />
<pre>source=()<br />
md5sums=()</pre><br />
* It is rarely necessary to use the pkgrel field when building CVS/SVN/GIT pkgs - any changes to the pkg will often be on another day and so are usually accounted for by a change in pkgver (assuming pkgver is used to hold a date format)<br />
* don't forget to include cvs or subversion in <code>makedepends=</code> as necessary<br />
* to preserve the integrity of the checked out code it is usually possible to build in a separate build dir e.g. having checked out source code to src/$_cvsmod from $startdir you can use:<br />
<pre> mkdir src/$_cvsmod-build<br />
<br />
cd src/$_cvsmod-build<br />
../$_cvsmod/configure</pre><br />
''OR'' if that fails you can try:<br />
<pre> cp -r src/$_cvsmod src/$_cvsmod-build<br />
cd src/$_cvsmod-build</pre><br />
<br />
* With the introduction of the AUR it is most important to avoid using backtick execution to create pkg variables<br />
** For cvs pkgs you should avoid <code>pkgver=`date +%y%m%d`</code> - this also interferes with the functionality of the AUR. Instead it is still possible to use a date format for the $pkgver variable and to use the cvs -D option to check out code from that date (see below)<br />
** For svn you can use the revision number. An easy way to find the revision number is to use the following command:<br />
svn log $_svntrunk --limit 1 | sed -e '/^r/!d' -e 's/^r\([0-9]\+\) .*/\1/;q'<br />
That command grabs the most recent log entry from the svn repo and finds the revision number, which is prefixed with an r. This is from the fluxbox svn log, the revision number is in the top left, r4084<br />
<pre><br />
------------------------------------------------------------------------<br />
r4084 | mathias | 2005-07-20 19:29:01 +0100 (Wed, 20 Jul 2005) | 16 lines<br />
<br />
Changed some *Focus options, just to make some things a bit more clear.<br />
the "Sloppy" was always a bit .. imprecise.<br />
</pre><br />
<br />
==Example CVS PKGBUILD==<br />
<br />
Here is a PKGBUILD for bmp-cvs that utilizes some of the tips above<br />
<br />
<pre># Contributor: Lukas Sabota <punkrockguy318@comcast.net><br />
# Contributor: dibblethewrecker dibblethewrecker.at.jiwe.dot.org<br />
arch=(i686 x86_64)<br />
pkgname=bmp-cvs<br />
pkgver=20050728<br />
pkgrel=1<br />
pkgdesc="A multimedia player that uses the WinAmp 2.x UI, GTK2, and is based on XMMS. This will checkout and package the latest CVS version."<br />
url="http://beepmp.sourceforge.net/"<br />
license=<br />
depends=('gtk2' 'libvorbis' 'alsa-lib' 'audiofile' 'libglade' 'id3lib' 'x-server')<br />
provides=('bmp')<br />
conflicts=('bmp')<br />
makedepends=('cvs')<br />
install=$pkgname.install<br />
<br />
_cvsroot=":pserver:anonymous:@cvs.sourceforge.net:/cvsroot/beepmp"<br />
_cvsmod="bmp"<br />
<br />
build() {<br />
cd $startdir/src<br />
msg "Connecting to $_cvsmod.sourceforge.net CVS server...."<br />
if [ -d $_cvsmod/CVS ]; then<br />
cd $_cvsmod<br />
cvs -z3 update -d<br />
else<br />
cvs -z3 -d $_cvsroot co -D $pkgver -f $_cvsmod<br />
cd $_cvsmod<br />
fi<br />
./autogen.sh<br />
<br />
msg "CVS checkout done or server timeout"<br />
msg "Starting make..."<br />
<br />
cp -r ../$_cvsmod ../$_cvsmod-build<br />
cd ../$_cvsmod-build<br />
<br />
./configure --prefix=/usr<br />
make || return 1<br />
make DESTDIR=$startdir/pkg install || return 1<br />
<br />
mkdir -p $startdir/pkg/usr/share/xmms/Skins<br />
mv $startdir/pkg/usr/share/bmp/Skins/* $startdir/pkg/usr/share/xmms/Skins<br />
rmdir $startdir/pkg/usr/share/bmp/Skins<br />
<br />
rm -r $startdir/src/$_cvsmod-build<br />
}<br />
# vim:syntax=sh<br />
</pre><br />
<br />
==Example SVN PKGBUILD==<br />
<br />
If you use the <tt>source</tt> command on the PKGBUILD first it will store the _svntrunk and _svnmod variables. So if you run :<br />
source PKGBUILD<br />
svn info $_svntrunk<br />
you can get the revision number(Or,Last Changed Rev) which can be used in pkgver<br />
<br />
<pre><br />
# Contributor: Lukas Sabota <punkrockguy318@comcast.net><br />
# Contributor: dibblethewrecker dibblethewrecker.at.jiwe.dot.org<br />
arch=(i686 x86_64)<br />
pkgname=fluxbox-svn<br />
pkgver=4084<br />
pkgrel=1<br />
pkgdesc="Fluxbox-svn is the bleeding edge version of a lightweight yet \<br />
customizable windowmanager for X. This will checkout and package the latest SVN version."<br />
url="http://www.fluxbox.org"<br />
license=<br />
<br />
depends=('bash' 'x-server')<br />
makedepends=('subversion')<br />
conflicts=('blackbox' 'fluxbox' 'fluxbox-devel' 'fluxbox-cvs')<br />
provides=('fluxbox')<br />
<br />
source=()<br />
md5sums=()<br />
<br />
_svntrunk=svn://svn.berlios.de/fluxbox/trunk<br />
_svnmod=fluxbox<br />
<br />
build() {<br />
cd $startdir/src<br />
<br />
if [ -d $_svnmod/.svn ]; then<br />
(cd $_svnmod && svn up -r $pkgver)<br />
else<br />
svn co $_svntrunk --config-dir ./ -r $pkgver $_svnmod<br />
fi<br />
<br />
msg "SVN checkout done or server timeout"<br />
msg "Starting make..."<br />
<br />
cp -r $_svnmod $_svnmod-build<br />
cd $_svnmod-build<br />
<br />
./autogen.sh<br />
<br />
# fix for crap fb issue<br />
mkdir data<br />
cp ../$_svnmod/data/keys data/<br />
<br />
./configure --prefix=/usr --enable-xinerama --enable-imlib2 --enable-debug<br />
make || return 1<br />
make DESTDIR=$startdir/pkg/ install<br />
<br />
rm -rf $startdir/src/$_svnmod-build<br />
}<br />
# vim:syntax=sh</pre><br />
<br />
==Example GIT PKGBUILD==<br />
<br />
<pre><br />
arch=(i686 x86_64)<br />
pkgname=compiz-git<br />
pkgver=20060707<br />
pkgrel=1<br />
pkgdesc="Composite and window manager for Xgl"<br />
url="http://en.opensuse.org/Compiz"<br />
license=""<br />
depends=('xgl-cvs' 'mesa-xgl-cvs' 'cairo-devel' 'libxevie' \<br />
'startup-notification' 'libpng' 'libxdamage' \<br />
'libxrandr' 'libwnck-compiz' 'gnome-desktop' 'control-center' \<br />
'libsvg-cairo' 'libxcomposite')<br />
makedepends=('git')<br />
conflicts=()<br />
replaces=()<br />
backup=()<br />
install=compiz.install<br />
source=(compiz-intel-copy-pixel-issue-workaround-1.diff)<br />
md5sums=('10a157b86d528bca2be6731c5eaff7b3')<br />
<br />
_gitroot="git://anongit.freedesktop.org/git/xorg/app/compiz"<br />
_gitname="compiz"<br />
build() {<br />
export CFLAGS="$CFLAGS -I/opt/mesa-xgl-cvs/include"<br />
cd $startdir/src<br />
msg "Connecting to git.freedesktop.org GIT server...."<br />
<br />
if [ -d $startdir/src/$_gitname ] ; then<br />
cd $_gitname && git-pull origin<br />
msg "The local files are updated."<br />
else<br />
git clone $_gitroot<br />
fi<br />
<br />
msg "GIT checkout done or server timeout"<br />
msg "Starting make..."<br />
<br />
cp -r $startdir/src/$_gitname $startdir/src/$_gitname-build<br />
cd $startdir/src/$_gitname-build<br />
patch -Np0 -i ${startdir}/src/compiz-intel-copy-pixel-issue-workaround-1.diff<br />
<br />
ACLOCAL="aclocal -I /opt/gnome/share/aclocal" ./autogen.sh --host=${CHOST} \<br />
--prefix=/usr \<br />
--infodir=/usr/share/info \<br />
--mandir=/usr/man \<br />
--sysconfdir=/opt/gnome/etc \<br />
--enable-gnome \<br />
--enable-libsvg-cairo \<br />
--enable-gconf-dump \<br />
--disable-kde || return 1<br />
make || return 1<br />
make DESTDIR=$startdir/pkg install<br />
<br />
find $startdir/pkg -type f -name '*.la' -exec rm {} \;<br />
} <br />
</pre><br />
As you see, I use "-git" suffix in the pkgname, and two variables, _gitroot and _gitname for identify the repositories and the name of the package.<br />
I need to introduce an if condition: <br />
<pre><br />
if [ -d $startdir/src/$_gitname ] ; then<br />
cd $_gitname && git-pull origin<br />
msg "The local files are updated."<br />
else<br />
git clone $_gitroot<br />
fi<br />
</pre><br />
because we have two commands, one for updating source and one for getting it. I copy the source code in a "-build" directory ( the same thing that we do with -cvs and -svn program ).<br />
<br />
==Example darcs PKGBUILD==<br />
<pre><br />
pkgname=psi-darcs<br />
pkgver=20070404<br />
pkgrel=2<br />
pkgdesc="Psi - Jabber client (with SSL support) darcs version"<br />
makedepends=('darcs' 'qt4>=4.2')<br />
depends=('qt4>=4.2' 'openssl' 'libxss' 'cyrus-sasl' 'aspell') <br />
source=()<br />
conflicts=('psi')<br />
provides=('psi')<br />
url="http://psi-im.org/"<br />
md5sums=()<br />
<br />
_darcsmod="psi"<br />
_darcstrunk="http://dev.psi-im.org/darcs"<br />
<br />
build() {<br />
cd $startdir/src/<br />
# Erasing previous build<br />
msg "Checking for previous build"<br />
# get the sources<br />
if [[ -d $_darcsmod/_darcs ]]<br />
then<br />
msg "Retrieving missing patches"<br />
cd $_darcsmod<br />
darcs pull -a $_darcstrunk/$_darcsmod<br />
else<br />
msg "Retrieving complete sources"<br />
darcs get --partial --set-scripts-executable $_darcstrunk/$_darcsmod<br />
cd $_darcsmod<br />
fi<br />
<br />
. /etc/profile.d/qt4.sh<br />
export PATH=$QTDIR/bin:$PATH<br />
<br />
# building<br />
msg "Starting build"<br />
./configure --prefix=/usr --disable-xmms<br />
make || return 1<br />
make INSTALL_ROOT=$startdir/pkg install<br />
}<br />
</pre><br />
<br />
==versionpkg - a <tt>makepkg</tt> wrapper for CVS/SVN builds==<br />
This is a very simple script that allows you to easily update your CVS and SVN packages without having to edit the PKGBUILDs manually to enter the date or revision number.<br />
<br />
Simply run this script rather than <tt>makepkg</tt> in the build dir. This script completely removes the need for backtick execution to set the date or tag version in PKGBUILDs.<br />
<br />
To use the script;<br />
* Ensure that pkgver is declared within the first ten lines of the PKGBUILD or it won't work!<br />
* Ensure you have included the following custom variables and checkout command:<br />
* CVS<br />
_cvsroot=<br />
: The root of the CVS server - remember to include a colon (:) after the username as outlined above<br />
_cvsmod=<br />
: Simply the CVS module name you wish to check out e.g.<br />
_cvsroot=":pserver:anonymous:@mplayerhq.hu:/cvsroot/ffmpeg"<br />
_cvsmod="ffmpeg"<br />
: Here is the checkout command for CVS that uses the above variables. The <strong>-D</strong> option is essential for proper use of <code>versionpkg</code> and is best used in combination with the <strong>-f</strong> option. Use of <strong>-D</strong> without <strong>-f</strong> may result in errors<br />
cvs -z9 -q -d $_cvsroot co -D $pkgver -f $_cvsmod<br />
: -z controls the level of compression (1 is low 9 is high)<br />
: -D specifies the date to check out, we use $pkgver as that is set to the current date by the script.<br />
: -q is a quiet switch<br />
* SVN<br />
_svntrunk=<br />
: The address of the SVN trunk<br />
_svnmod=<br />
: Again the module you wish to check out from trun e.g.<br />
_svntrunk=svn://svn.berlios.de/fluxbox/trunk<br />
_svnmod=fluxbox<br />
: Here is the checkout command for SVN that uses the above variables. The <strong>-r</strong> option is essential for proper use of <code>versionpkg</code>.<br />
svn co $_svntrunk --config-dir ./ -r $pkgver $_svnmod<br />
: Here -r specifies the revision number, we use $pkgver as that is set to the latest revision number by the script.<br />
<br />
===The script!===<br />
To improve security, versionpkg can now be installed directly from [community] <code>pacman -S versionpkg</code>. I strongly recommend that you use that. The script below is purely for illustrative purposes :)<br><br />
Changelog:<br />
* check for both CVS/SVN vars<br />
* If build fails revert to previous pkgver to allow correct gensync operation<br />
* Added support for coloured messages<br />
<pre>#!/bin/bash<br />
<br />
# versionpkg - a makepkg wrapper for building CVS/SVN pkgs<br />
# dibblethewrecker.at.jiwe.org<br />
<br />
# makepkg configuration<br />
[ -f /etc/makepkg.conf ] && source /etc/makepkg.conf<br />
<br />
# SUBROUTINES<br />
plain() {<br />
if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then<br />
echo -e " \033[1;1m$1\033[1;0m" >&2<br />
else<br />
echo " $1" >&2<br />
fi<br />
}<br />
msg() {<br />
if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then<br />
echo -e "\033[1;32m==>\033[1;0m \033[1;1m$1\033[1;0m" >&2<br />
else<br />
echo "==> $1" >&2<br />
fi<br />
}<br />
warning() {<br />
if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then<br />
echo -e "\033[1;33m==> WARNING:\033[1;0m \033[1;1m$1\033[1;0m" >&2<br />
else<br />
echo "==> WARNING: $1" >&2<br />
fi<br />
}<br />
error() {<br />
if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then<br />
echo -e "\033[1;31m==> ERROR:\033[1;0m \033[1;1m$1\033[1;0m" >&2<br />
else<br />
echo "==> ERROR: $1" >&2<br />
fi<br />
return 1<br />
}<br />
<br />
source ./PKGBUILD<br />
oldpkgver=$pkgver<br />
<br />
if [ ! -z ${_cvsroot} ] && [ ! -z ${_cvsmod} ] ; then<br />
cvsdate=`date +%Y%m%d`<br />
sed -i "1,11 s|pkgver=$oldpkgver|pkgver=$cvsdate|" ./PKGBUILD<br />
makepkg $@<br />
if [ $? -gt 0 ] ; then<br />
error "Reverting pkgver..."<br />
sed -i "1,11 s|pkgver=$cvsdate|pkgver=$oldpkgver|" ./PKGBUILD<br />
fi <br />
elif [ ! -z ${_svntrunk} ] && [ ! -z ${_svnmod} ] ; then<br />
svnrevno=`svn log $_svntrunk --limit 1 | grep -m 1 -o "r.*" | cut -d \| -f 1 | sed s@r@@g`<br />
msg "Current revision number is $svnrevno"<br />
if [ "${1}" != "-f" ] && [ "${oldpkgver}" == "${svnrevno}" ] ; then<br />
error "No new revision available. (use -f to overwrite)"<br />
exit<br />
fi<br />
sleep 3<br />
sed -i "1,11 s|pkgver=$oldpkgver|pkgver=$svnrevno|" ./PKGBUILD<br />
makepkg $@<br />
if [ $? -gt 0 ] ; then<br />
error "Reverting pkgver..."<br />
sed -i "1,11 s|pkgver=$svnrevno|pkgver=$oldpkgver|" ./PKGBUILD<br />
fi <br />
else<br />
error "No SVN or CVS variables found! Aborting..."<br />
exit<br />
fi<br />
</pre></div>Samlt