存档

文章标签 ‘bootloader’

用 syslinux 引导 Windows

2009年3月22日 dipplum 2 条评论

FAT 分区的引导扇区(Boot Sector)的功能是将 Windows XP 的 ntldr 文件,或 Windows Vista 的 bootmgr 文件加载到内存适当位置,由此启动 Windows。

Linux 下可以创建 Windows 的 FAT 文件系统,但是不能创建 FAT 文件系统中的 Boot Sector,也就是不能创建可以引导的 FAT 分区,因而 Linux 下无法创建可以引导的 Windows 磁盘。

不过可以曲线救国,通过 syslinux 来引导 Windows。 首先,将 syslinux 安装到 Windows 分区设备上。

syslinux /dev/sdXY

然后,将 syslinux 自带的 chain.c32 文件拷贝到 Windows 分区上。如果是 Debian,这一文件在 /usr/lib/syslinux/ 目录下。

接着,在 Windows 分区上创建 syslinux.cfg 文件

default 1
timeout 0
label 1
  kernel chain.c32
  append hd0,1 ntldr=ntldr

chain.c32 接受的第一个参数代表启动第1块硬盘的第1个分区,并装载分区上的 ntldr 文件。用该配置文件可以引导 Windows XP。如果需要引导 Windows Vista,需要修改成下述内容:

default 1
timeout 0
label 1
  kernel chain.c32
  append hd0,1 ntldr=bootmgr

chain.32 接受的参数说明如下

  • option “swap” to support swapping of BIOS drive numbers. This is necessary to boot certain operating systems (DOS, Windows) from a secondary drive.
  • option “file=” to support loading a boot file from the SYSLINUX filesystem instead of loading the boot sector from the drive.
  • option “seg=” to control the load location.
  • option “ntldr=” as a shorthand for “seg=0×2000 file=”; use this to load one of WinNT’s loaders
  • options “freedos=” and “msdos=”/”pcdos=” as shorthands for “seg=0×60 file=” and “seg=0×70 file=” respectively; use this to load FreeDOS’s kernel.sys, MS-DOS’s io.sys or PC-DOS’s ibmbio.sys.
This work by dipplum is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 China Mainland.