日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

Syslinux

發布時間:2023/12/20 linux 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Syslinux 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Syslinux是一個優秀的系統啟動加載器,可引導自硬盤、光盤和通過PXE的網絡啟動。支持fat, ext2, ext3, ext4 and btrfs文件系統.

注意: 從Syslinux 4起, Extlinux和Syslinux是指同一個東西的

Contents

  • 1 Syslinux 引導過程
  • 2 安裝
    • 2.1 自動完成安裝
    • 2.2 手工完成安裝
      • 2.2.1 MBR分區表
      • 2.2.2 GUID Partition Table aka GPT
      • 2.2.3 重啟
  • 3 配置 syslinux
    • 3.1 示例
      • 3.1.1 比較簡單的 Syslinux 配置
      • 3.1.2 文本的啟動菜單
      • 3.1.3 圖形化的啟動菜單
    • 3.2 Chainloading
    • 3.3 使用內存測試 memtest
    • 3.4 使用硬件探測工具HDT
    • 3.5 重啟和關閉電源
  • 4 常見問題
    • 4.1 I have a Syslinux Prompt - Yikes!
    • 4.2 某些電腦中,會出現沒找到默認配置或者界面
    • 4.3 MISSING OPERATING SYSTEM
    • 4.4 Windows boots up! No Syslinux!
    • 4.5 進入子菜單,但干不了任何事
    • 4.6 無法刪除ldlinux.sys
  • 5 更多信息可見

Syslinux 引導過程

電腦啟動時,會先加載MBR (/usr/lib/syslinux/mbr.bin),然后MBR查找那些活動的分區(標注了可啟動的),找到這個分區后,卷啟動記錄程序(VBR=volume boot record)將被執行。如果是ext2/3/4和fat 12/16/32,ldlinux.sys開始的扇區是被寫死進卷啟動記錄程序里的,卷啟動記錄程序將執行(ldlinux.sys)。當然,如果ldlinux.sys 的位置發生改變,syslinux將無法加載。如果是btrfs,因為文件不斷移動導致ldlinux.sys扇區的位置不斷變化,而讓上面方法失效。從而使得整個syslinux需要被存儲在文件系統之外。程序將被存儲在卷啟動記錄程序之后。

當syslinux完全加載完畢,它將自動尋找一個配置文件,名字叫 extlinux.conf 或者syslinux.cfg.找到之后,將加載整個配置文件,否則,將給出提示。


安裝

自動完成安裝

syslinux-install_update腳本將自動安裝Syslinux, 復制COM32模塊到/boot/syslinux, 設置啟動標識,安裝到MBR.可自動根據softraid處理MBR和 GPT磁盤。

下面是過程: 1. 安裝Syslinux

pacman -S syslinux

2. 確認/boot是否已經加載
3. 運行腳本syslinux-install_update ,參數使用 -i (安裝) -a (設可啟動標識) -m (安裝到mbr)

/usr/sbin/syslinux-install_update -i -a -m

4. 修改配置文件 /boot/syslinux/syslinux.cfg

Note: For this to work with GPT, the gptfdisk package is needed as the backend for setting the boot flag.

手工完成安裝

Note: 若你不知你所使用的分區表是使用什么 (MBR or GPT), 默認一般使用的是MBR分區表。大部分情況下,GPT將使用整個磁盤創建一個特殊的MBR-類型的分區(type 0xEE) ,使用下面命令可顯示: # fdisk -l /dev/sda

或者可以這樣:

# sgdisk -l /dev/sda

若其非GPT磁盤,將顯示 " GPT: not present".

Note: If you are trying to rescue an installed system with a live CD, be sure to chroot into it before executing these commands. If you do not chroot first, you must prepend all file paths (not /dev/ paths) with the mount point.

Make sure you have the syslinux package installed. Then install Syslinux onto your boot partition, which must contain a fat, ext2, ext3, ext4, or btrfs file system.

# mkdir /boot/syslinux # extlinux --install /boot/syslinux #run on a mounted directory (not /dev/sdXY) /boot/syslinux/ is device /dev/sda1

MBR分區表

需要標識啟動分區為激活狀態.可用這些工具實現:fdisk, cfdisk, sfdisk, (g)parted.最后結果看起來是這樣:

# fdisk -l /dev/sda [...]Device Boot Start End Blocks Id System /dev/sda1 * 2048 104447 51200 83 Linux /dev/sda2 104448 625142447 312519000 83 Linux

安裝到主啟動卷區:

# dd bs=440 conv=notrunc count=1 if=/usr/lib/syslinux/mbr.bin of=/dev/sda

GUID Partition Table aka GPT

Main article GUID_Partition_Table

Bit 2 of the attributes for the /boot partition need to be set.

# sgdisk /dev/sda --attributes=1:set:2

This would toggle the attribute legacy BIOS bootable on partition 1

Verify:

# sgdisk /dev/sda --attributes=1:show 1:2:1 (legacy BIOS bootable)

安裝主啟動卷區:

# dd bs=440 conv=notrunc count=1 if=/usr/lib/syslinux/gptmbr.bin of=/dev/sda

重啟

如果此時重啟,會有提示,以確認是自動啟動還是給出一個啟動菜單,此時需要創建一個配置文件。

配置 syslinux

syslinux的配置文件 syslinux.cfg 必須和syslinux放在同一個目錄下,在我們的例子中,是 '/boot/syslinux/'

啟動器將自動尋找這兩個配置文件:syslinux.cfg (優先) 或者 extlinux.conf

補充:

  • Instead of LINUX, the keyword KERNEL can also be used. KERNEL tries to detect the type of the file, while LINUX always expects a Linux kernel.
  • TIMEOUT 的值是1/10秒,也就是50代表5秒

示例

比較簡單的 Syslinux 配置

這是一個非常簡單的配置,有啟動提示,并且在5秒后自動啟動第一個系統。

配置文件:

PROMPT 1 TIMEOUT 50 DEFAULT archLABEL archLINUX ../vmlinuz-linuxAPPEND root=/dev/sda2 roINITRD ../initramfs-linux.imgLABEL archfallbackLINUX ../vmlinuz-linuxAPPEND root=/dev/sda2 roINITRD ../initramfs-linux-fallback.img

若不想看到提示,設置PROMPT(顯示時間)為0.

文本的啟動菜單

把模塊menu COM32復制到syslinux目錄中,即可使用文本菜單:

# cp /usr/lib/syslinux/menu.c32 /boot/syslinux/

若沒有給/boot單獨分區,且和/usr同一分區,那么,也可以僅使用一個軟鏈接:

# ln -s /usr/lib/syslinux/menu.c32 /boot/syslinux/

配置:

UI menu.c32 PROMPT 0MENU TITLE Boot Menu TIMEOUT 50 DEFAULT archLABEL archMENU LABEL Arch LinuxLINUX ../vmlinuz-linuxAPPEND root=/dev/sda2 roINITRD ../initramfs-linux.imgLABEL archfallbackMENU LABEL Arch Linux FallbackLINUX /vmlinuz-linuxAPPEND root=/dev/sda2 roINITRD /initramfs-linux-fallback.img

更多信息可見: http://git.kernel.org/?p=boot/syslinux/syslinux.git;a=blob;f=doc/menu.txt.

圖形化的啟動菜單

把vesamenu COM32移入到syslinux目錄中,可使用圖形啟動界面:

# cp /usr/lib/syslinux/vesamenu.c32 /boot/syslinux/

若沒有給/boot單獨分區,且和/usr同一分區,那么,也可以僅使用一個軟鏈接:?:

# ln -s /usr/lib/syslinux/vesamenu.c32 /boot/syslinux/

This config uses the same menu design as the Arch Install CD: syslinux.cfg

The background file can be found here: splash.png

Config:

UI vesamenu.c32 DEFAULT arch PROMPT 0 MENU TITLE Boot Menu MENU BACKGROUND splash.png TIMEOUT 50MENU WIDTH 78 MENU MARGIN 4 MENU ROWS 5 MENU VSHIFT 10 MENU TIMEOUTROW 13 MENU TABMSGROW 11 MENU CMDLINEROW 11 MENU HELPMSGROW 16 MENU HELPMSGENDROW 29# Refer to http://syslinux.zytor.com/wiki/index.php/Doc/menuMENU COLOR border 30;44 #40ffffff #a0000000 std MENU COLOR title 1;36;44 #9033ccff #a0000000 std MENU COLOR sel 7;37;40 #e0ffffff #20ffffff all MENU COLOR unsel 37;44 #50ffffff #a0000000 std MENU COLOR help 37;40 #c0ffffff #a0000000 std MENU COLOR timeout_msg 37;40 #80ffffff #00000000 std MENU COLOR timeout 1;37;40 #c0ffffff #00000000 std MENU COLOR msg07 37;40 #90ffffff #a0000000 std MENU COLOR tabmsg 31;40 #30ffffff #00000000 stdLABEL archMENU LABEL Arch LinuxLINUX ../vmlinuz-linuxAPPEND root=/dev/sda2 roINITRD ../initramfs-linux.imgLABEL archfallbackMENU LABEL Arch Linux FallbackLINUX ../vmlinuz-linuxAPPEND root=/dev/sda2 roINITRD ../initramfs-linux-fallback.img


Since Syslinux 3.84 vesamenu.c32 supports the "MENU RESOLUTION $WIDTH $HEIGHT" directive.To use it, insert "MENU RESOLUTION 1440 900" into your config for a 1440x900 resolution.The background picture has to have exactly the right resolution however as syslinux will otherwise refuse to load the menu.

Chainloading

If you want to chainload other operating systems (such as Windows) or boot loaders, copy (or symlink) the chain.c32 module to the syslinux folder (for details, see the instructions in the previous section). Then, create a section in the configuration file:

LABEL windowsMENU LABEL WindowsCOM32 chain.c32APPEND hd0 3

hd0 3 is the third partition on the first BIOS drive - drives are counted from zero, but partitions are counted from one. For more details about chainloading, see [1].

If you have grub2 installed in your boot partition, you can chainload it by using:

LABEL grub2MENU LABEL Grub2COM32 chain.c32append file=../grub/boot.img

This maybe required for booting from iso images.

使用內存測試 memtest

使用下面的 LABEL章節部分,可加載(需要安裝軟件包:memtest86+,否則不起作用):

LABEL memtestMENU LABEL Memtest86+LINUX ../memtest86+/memtest.bin

使用硬件探測工具HDT

HDT (Hardware Detection Tool) displays hardware information. Like before, the .c32 file has to be copied or symlinked from /boot/syslinux/.For pci info either copy or symlink /usr/share/hwdata/pci.ids to /boot/syslinux/pci.ids

LABEL hdtMENU LABEL Hardware InfoCOM32 hdt.c32

重啟和關閉電源

Use the following sections to reboot or power off your machine.

LABEL rebootMENU LABEL RebootCOM32 reboot.c32LABEL poweroffMENU LABEL Power OffCOMBOOT poweroff.com

常見問題

I have a Syslinux Prompt - Yikes!

You can type in the LABEL name of the entry that you want to boot (as per your syslinux.cfg). If you used the example configs just type

boot: arch

If you get an error that the config file could not be loaded you can pass your needed boot parameters, e.g.:

boot: ../vmlinuz-linux root=/dev/sda2 ro initrd=../initramfs-linux.img

If you don't have access to 'boot:' in ramfs, and therefore temporarily unable to boot kernel again

1) create temp directory, in order to mount your root partition (if it doesn't exist already)

mkdir -p /new_root

2) mount / under /new_root (in case /boot/ is on same partition, otherwise you'll need to mount them both)

mount /dev/sd[a-z][1-9] /new_root

3) use 'vi' and edit syslinux.cfg again to suit your needs and save file;

4) reboot

某些電腦中,會出現沒找到默認配置或者界面

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 ldlinux and failing to read syslinux.cfg, use cfdisk to create a fat-16 partition (<=2GB) and format with

# pacman -S dosfstools # mkfs.msdos -F 16 /dev/sda1

then install and configure syslinux.

MISSING OPERATING SYSTEM

If you get this message, check if the partition that contains /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 fdisk -l. If it starts at sector 1, you can move the partition(s) with gparted from a rescue disk. Or, if you have a separate boot partition, you can back up /boot with

cp -a /boot /boot.bak

and then boot up with the arch install disk. Next, use cfdisk to delete the /boot partition, and recreate it. This time it should begin at the proper sector, 63. Now mount your partitions and chroot into your mounted system, as described in the beginners guide. Restore /boot with the command

cp -a /boot.bak/* /boot

Check if /etc/fstab is correct. Then run

/usr/sbin/syslinux-install_update -iam

and reboot.

Windows boots up! No Syslinux!

Solution: Make sure the partition that contains /boot has the boot flag enabled. Also, make sure the boot flag is not enabled on the windows partition. See the installation section above.

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 msdos fdisk provides.

進入子菜單,但干不了任何事

You select a menu entry and it does nothing. It "refreshes" the menu
This usually means that you have an error in your configuration. Hit TAB to edit your boot parameters. Alternatively, press ESC and type in the LABEL of your boot entry (Example: arch)


無法刪除ldlinux.sys

ldlinux.sys has the immutable attribute set which prevents the file 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:

chattr -i /boot/syslinux/ldlinux.sys rm /boot/syslinux/ldlinux.sys

更多信息可見

  • The Syslinux Project's website.

總結

以上是生活随笔為你收集整理的Syslinux的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。