找回密码
 注册
查看: 7959|回复: 6

制作USB盘启动的Debian安装盘!

[复制链接]
发表于 2004-11-29 18:23:21 | 显示全部楼层 |阅读模式
Installing Debian Sarge
from a USB memory stick (USB key)
Maintained by Pascal Le Bail <[email protected]>.
I want to thank everyone who sent me hints and corrections to this page.

Many Debian boxes need their floppy and/or CD-ROM drives only for setting up the system and for rescue purposes. If you operate some servers, you will probably already have thought about omitting those drives and using an USB memory stick for installing and (when necessary) for recovering the system. This is also useful for small systems which have no room for unnecessary drives.

You can find the latest version of this document at http://d-i.pascal.at/.

Prerequisites
This document applies only to Debian Sarge on the i386 architecture. For a successful installation on such a system, you will need:

A mainboard with a USB connector
A BIOS capable of booting from a USB memory stick (the corresponding item on the BIOS setup screen is usually called "Boot from USB-ZIP" or sometimes "Boot from removable disk"). In some cases it might help to upgrade your BIOS.
A USB memory stick large enough to contain the necessary files (see below). To increase your chances, a stick which complies to USB 1.1 and not USB 2.0 is recommended, since there seem to be some BIOSes out there which cannot boot from USB 2.0 media.
If you want more than a minimal installation, you will also need access to those parts of Debian, which don't fit on the USB stick. In most cases, a network interface and a connection to a Debian mirror will be used. Of course, you can also use a Debian CD-ROM (set) or its image on any local drive instead.
Obtaining the files
The files required for booting from a USB stick can be found in the main/installer-i386/current/images directory of the Debian distribution. There you will find some subdirectories for different boot media. If you want to use the USB stick only for booting and then to fetch the packages of the base system over the network (from a Debian mirror), you should change to the netboot directory. If you want to install the base system from a Debian ISO image contained on the USB stick, then choose the hd-media directory.

Preparing the stick
For preparing the USB stick you will need a system where Linux is already running and where USB is supported. You should assure that the usb-storage kernel module is loaded (modprobe usb-storage) and try to find out which SCSI device the USB stick has been mapped to (in this example /dev/sda is used). To write to your stick, you will probably have to turn off its write protection switch.

In order to start the kernel after booting from the USB stick, we will put a boot loader on the stick. Although any boot loader (e.g. LILO) should work, it's convenient to use SYSLINUX, since it uses a FAT16 partition and can be reconfigured by just editing a text file. Any operating system which supports the FAT file system can be used to make changes to the configuration of the boot loader. Since most USB sticks come pre-configured with a single FAT16 partition, you probably won't have to repartition or reformat the stick. If you have to repartition it anyway, start cfdisk or any other partitioning tool and create a FAT16 partition.

Copying the files - the easy way
There is an all-in-one file which contains all the installer files (including the kernel) as well as SYSLINUX and its configuration file. It resides in the hd-media subdirectory of the Debian installer images directory and is called boot.img.gz. You only have to extract it to the FAT partition on your USB stick:

    zcat boot.img.gz >/dev/sda1
Again, take care that you use the correct device name for your USB stick.

After that, mount the partition on your USB memory stick (mount /dev/sda1 /mnt) and copy a Debian netinst or businesscard ISO image to it (please note that the file name must end in .ISO).

Partitionless installation: Instead of /dev/sda1 you may also use /dev/sda as your target. This leaves your stick without a partition table so that it will contain only the file system. The advantage of this method is that you don't have to rely on the existing (and possibly buggy) master boot record (MBR) of your USB stick. But be aware that you won't be able to access your stick using some third-party operating systems.

Copying the files - the more flexible way
If you like more flexibility or just want to know what's going on, you should use the following method to put the files on your stick:

Unless you have already a FAT16 file system on your stick, use

    mkdosfs /dev/sda1
to create one. Take care that you use the correct device name for your USB stick. The mkdosfs command is contained in the dosfstools Debian package.

To put SYSLINUX onto the partition, install the syslinux and mtools packages on your system, and type

    syslinux /dev/sda1
Again, take care that you use the correct device name. The partition must not be mounted when starting SYSLINUX. This procedure writes a boot sector to the partition and creates the file ldlinux.sys which contains the boot loader code.

Note: Although the Debian syslinux package does not officially depend on mtools, it definitely needs mtools to write to the FAT file system.

Mount the USB memory stick (mount /dev/sda1 /mnt), choose a Debian installer subdirectory as explained above and copy the following files to the stick:

vmlinuz - the Debian installer kernel
initrd.gz - the initial ramdisk image
the SYSLINUX configuration file (see below)
optionally a Debian ISO image
If you want to rename the files, please note that SYSLINUX can only process DOS (8.3) file names.

The syslinux.cfg configuration file should contain the following two lines:

default vmlinuz
append initrd=initrd.gz ramdisk_size=10240 root=/dev/rd/0 devfs=mount,dall rw DEBCONF_PRIORITY=medium

The DEBCONF_PRIORITY=medium lets the installer ask some additional questions which might be useful, but you may of course leave this option out.

Now you may put any Debian ISO image (businesscard, netinst or even a full one) onto your stick (if it fits). The file name of such an image must end in ".iso". If you want to install over the network, you will of course skip this step.

Finally the directory listing of the USB stick could look somewhat like this:

drwxr-xr-x    2 root     root        16384 Jan  1  1970 .
drwxr-xr-x   25 root     root         4096 Aug  6 23:03 ..
-rwxr-xr-x    1 root     root      2554051 Nov 10 14:15 initrd.gz
-r-xr-xr-x    1 root     root         7828 Nov 10 14:15 ldlinux.sys
-rwxr-xr-x    1 root     root    117735424 Nov 10 14:16 netinst.iso
-rwxr-xr-x    1 root     root          140 Nov 10 14:16 syslinux.cfg
-rwxr-xr-x    1 root     root       769886 Nov 10 14:16 vmlinuz

When you are done, unmount the USB memory stick (umount /mnt) and activate its write protection switch.

Booting
Now connect the USB stick to the target system, boot it, enter the BIOS setup program and change the boot device to USB-ZIP. If everything works, SYSLINUX will load the kernel and the initial ramdisk, and the Debian installer will start.

Troubleshooting
If your system refuses to boot from the USB stick, the stick may contain an invalid master boot record (MBR). To fix this, use the install-mbr command from the package "mbr" (thanks for this tip to Marco d'Itri). If your USB stick is mapped to /dev/sda, remove the write protection and type

    install-mbr /dev/sda
Important: Don't use install-mbr if you did a partitionless installation as mentioned above.

Hardware list
The USB based installation has been reported to work on the following systems:

VIA EPIA-M 10000 mainboard, BIOS Version 1.0F, 128 MB USB 1.1 stick
VIA EPIA-M 10000 mainboard, BIOS Version 1.0F, 512 MB USB 2.0 stick
VIA EPIA 5000 mainboard, BIOS Version 1.09, 128 MB USB 1.1 stick
Laptop with AMIBIOS 08.00.09
Supermicro 5013C server, 512 MB USB 2.0 stick (but the kernel doesn't recognize the SATA disks)
Gigabyte GA-7VAXP mainboard, 128 MB HP USB-MP3 key plugged into hub of Happy Hacker USB keyboard
ASUS P4C800-E Deluxe mainboard, BIOS Rev. 1015, 64 MB Fujitsu Siemens Memorybird USB 1.1 stick
MSI K8T-Neo Mainboard (for AMD64) with via K8T800 chipset

--------------------------------------------------------------------------------

Additions
Andreas John ([email protected], http://www.net-lab.net/):

I report to make a USB Stick work on a K7VMM Mainboard. There are two things you should take care for:

This particular Board has an AMIBIOS V 1.21.12. The Feature Setup in BIOS-Setup allows you to To enable/disable USB at all but also to enable "USB Device Legacy Support" and support for a "ThumbDrive Suppor for DOS". You will need to enable this to make the stick boot. I guess that there are some BIOSes out, which have similar features, so Keep you eyes open!

Another hint I want to give is that with many BIOSes you may press F8 shortly after POST (Power On Self Test, this is what "beeps" several times if your hardware is corrupt) to get in some kind of boot-menu, which lets you choose your preferred boot drive. There you can see your USB Stick by name. Mine is of type "USB RMD-FDD". If you don't get it there something is wrong with your hardware. If you are able to choose the device, but it doesn't boot, there is probably something wrong with the boot loader. Please check twice if you /dev/sdX device holds all neccessary files: syslinux, initrd, vmlinuz. boot.img.gz I took had no kernel on it! So I copied initrd and vmlinuz from the netboot directory onto /dev/sdX.

Adrian Bader:

I have a MSI K8T-Neo Mainboard (for AMD64) with via K8T800 chipset and it works properly.

It is important to enable these three things: USB in general (which is usually the case), "boot from other devices" and "USB Legacy Support" for "all Devices". Then we can press F11 during the bootup, which pops up the table to select the prefered boot device. There we can select the USB Memory Stick.


--------------------------------------------------------------------------------

Please send comments, additions and corrections to Pascal Le Bail. Last updated: 2004-09-08
发表于 2004-11-30 09:52:06 | 显示全部楼层
老大的原创?
如果是的话,你的英文一定很好!
如果不是你的原创,可以翻译一下吗?
回复

使用道具 举报

发表于 2004-11-30 19:27:19 | 显示全部楼层
老大  鬼子的东西看不懂啊  帮忙翻开
回复

使用道具 举报

 楼主| 发表于 2004-11-30 22:58:38 | 显示全部楼层
这么简单的单词你们都……唉……谁有时间,帮忙翻翻吧
回复

使用道具 举报

发表于 2005-1-29 11:27:52 | 显示全部楼层

我的U盘只有32兆,安装不了系统

我的U盘只有32兆(用Linux的人的硬件系统都差),没有地方放ISO文件,启动系统后却安装不了系统, 怎么办啊?
回复

使用道具 举报

发表于 2005-2-4 22:26:15 | 显示全部楼层

Re: 制作USB盘启动的Debian安装盘!

从优盘安装debian sarge
Maintained by Pascal Le Bail <[email protected]>.
I want to thank everyone who sent me hints and corrections to this page.

很多的debian用户都用他们的软盘或者cdrom仅仅是为了安装系统,或者是系统救援。如果你管理着一些服务器,你可能已经想到省略这些驱动器而使用优盘来安装和恢复系统。这也非常适合那些没有足够的空间安装必需的驱动器而使用精简系统的人。

你能找到这个文档最新的更新在:http://d-i.pascal.at/.

准备:
这个文档仅仅适用于基于i386架构的debian sarge系统。为了成功的安装这个系统,你需要:
一个有usb接口的主板
主板bios能够支持从usb启动(在主板设置里面经常是"boot from usb-zip"或者"boot from removable disk" )如果有可能,你需要升级你的bios。
一个能够容纳必须的文件的优盘(文件在下面列出)。为了增加成功的机会,最好使用usb1.1的优盘而不是usb2.0的优盘,因为有些bios可能不能从usb2.0的介质启动。如果你需要的不仅仅是一个迷你的系统,你需要安装那些和优盘无关的debian部分。大多数状况下,一个网络接口和到debian镜像的连接是很用得上的。当然,你也可以使用debian的cdrom或者它的镜像。
获得文件
从优盘启动系统的文件可以从debian的发行版中的/installer-i386/current/images这个目录下面找到。在这个目录下面你可能找到一些子目录,里面存放着不同的启动方式。如果你希望仅仅适用优盘来启动,然后从网络获得基本系统的包文件,你需要进入netboot目录。如果你想从debian 光盘来安装基本系统,那么就选择hd-media这个目录。
优盘的使用
为了使用一个这样的优盘,你需要一个已经跑起来的linux系统,并且这个系统能够支持usb。你需要保证usb-storage这个内核模块已经加载了(modprobe usb-storage),然后试着找出这个优盘映射到了哪一个scsi驱动器。也就是使用了哪一个sda设备(译者:也就是你使用的优盘是sda?)。为了保证优盘可写,你应该关闭你的优盘的写保护。

为了从优盘启动后启动内核,我们需要在优盘中放一个引导。尽管任何引导(比如 lilo)都可以,它对于sysylinux很方便,基于优盘使用fat16分区,而且可以通过编辑一个文本文档来设置。任何支持fat文件系统的操作系统都可一个改变引导的设置。又因为优盘能够能够在一个独立的fat16分区下被提前设置,你大可不必将优盘分区或者格式化。如果你重新分区了。启动cfdisk或者其他的分区工具来创建一个fat16分区。

拷贝文件--简单的办法。

有一个 万能的文件,包含了所有的安装文件(也包括内核)还有sysylinux和它的设置文件。它在hd-media子目录下,名字叫做boot.img.gz.你只需要借压缩它到你的优盘的fat分区。
  zcat boot.img.gz >/dev/sda1

再次提醒,确保你对于你的优盘使用了正确的驱动器名称。

之后:将你的优盘挂载道系统上去(mount /dev/sda1 /mnt),然后拷贝debian的netinst 或者businesscard光盘镜像到这里(注意文件后缀必须是.iso)。

没有分区的安装:何/dev/sda1不同的是,你需要使用/dev/sda为你的目标盘。这样使你的优盘没有分区表,所以它将仅仅是一个文件系统。这个方法的好处在于,你不需要依赖你的优盘上已经存在的mbr。但是要意识到,你将不可能在你的优盘上使用第三个操作系统。

拷贝文件--一个复杂一点的办法
如果你喜欢更复杂的办法或者想弄明白它究竟是怎么回事,你需要按照下面的办法将文件拷贝到你的优盘上去。

除非你已经在你的优盘上使用fat16文件系统,那么使用
mkdosfs /dev/sda1
来创建一个。确保对你的优盘使用了正确的驱动器名称。mkdosfs命令包含在dosfstools这个debian包中。

为了将sysylinux放置在分区上,安装sysylinux和mtools包在你的系统上

syslinux /dev/sda1
再啰嗦一次,确保使用了正确的驱动器名称。这个分区不能再启动syslinux的时候被挂载。这个操作写了这个分区的引导区,并且创建了包含引导信息的文件ldlinux.sys.

注意:尽管debian syslinux包不是正式的依赖于mtolls这个包,但是它需要mtools来写fat这个文件系统。

将优盘挂载(mount /dev/sda1 /mnt),选择一个debian的安装子目录,就如同前面所说的,将那些文件拷贝到优盘上
vmlinuz--debian的安装内核
initrd.gz--初始化内存的镜像
syslinux的配置文件(在下面)
人意的一个debian 光盘镜像
如果你希望重命名这些文件,请注意,syslinux只能处理dos(8.3)的文件名。
syslinux.cfg这个配置文件应该包含下面几行
default vmlinuz
append initrd=initrd.gz ramdisk_size=10240 root=/dev/rd/0 devfs=mount,dall rw DEBCONF_PRIORITY=medium


DEBCONF_PRIORITY=medium是在安装程序提问时,告诉哪些可能是有用的,但是不需要不需要在意细节的。(译者:也就是默认的)
现在你可以放入debian 的iso光盘,businesscard,netinst或者一个完全安装版的光盘到你的优盘上,这个文件名或者光盘镜像名称必须以.iso结尾。如果你想从网络安装,你需要跳过这些步骤。

最后在优盘上的文件是这些:

drwxr-xr-x    2 root     root        16384 Jan  1  1970 .
drwxr-xr-x   25 root     root         4096 Aug  6 23:03 ..
-rwxr-xr-x    1 root     root      2554051 Nov 10 14:15 initrd.gz
-r-xr-xr-x    1 root     root         7828 Nov 10 14:15 ldlinux.sys
-rwxr-xr-x    1 root     root    117735424 Nov 10 14:16 netinst.iso
-rwxr-xr-x    1 root     root          140 Nov 10 14:16 syslinux.cfg
-rwxr-xr-x    1 root     root       769886 Nov 10 14:16 vmlinuz
如果你已经完成,那么就卸载你的优盘 umount /mnt并且打开你的优盘的写保护。

启动

现在,将你的优盘插入目标系统,启动,进入bios设置,选择从usb-zip启动。如果一切正常,syslinux将引导内核并且初始化内存,然后debian安装程序将会启动。

疑难问题:
如果你的系统无法从优盘启动,优盘必须有一个正确的mbr。如果你的优盘映射到了/dev/sda,关闭写保护,然后
install-mbr /dev/sda
重要的是:在你不分区安装,不要使用install-mbr

硬件列表
优盘安装在下面的系统上能够工作


VIA EPIA-M 10000 mainboard, BIOS Version 1.0F, 128 MB USB 1.1 stick
VIA EPIA-M 10000 mainboard, BIOS Version 1.0F, 512 MB USB 2.0 stick
VIA EPIA 5000 mainboard, BIOS Version 1.09, 128 MB USB 1.1 stick
Laptop with AMIBIOS 08.00.09
Supermicro 5013C server, 512 MB USB 2.0 stick (but the kernel doesn't recognize the SATA disks)
Gigabyte GA-7VAXP mainboard, 128 MB HP USB-MP3 key plugged into hub of Happy Hacker USB keyboard
ASUS P4C800-E Deluxe mainboard, BIOS Rev. 1015, 64 MB Fujitsu Siemens Memorybird USB 1.1 stick
MSI K8T-Neo Mainboard (for AMD64) with via K8T800 chipset

--------------------------------------------------------------------------------
附录:
Andreas John ([email protected], http://www.net-lab.net/):
我在k7vmm的主板上试验成功,你需要注意两点:
这个特别的主板有一个 AMIBIOS V 1.21.12. 在bios设置feature setup里面,允许你完全打开或者关闭usb,也可以开启"usb device legacy support"和支持"thumbdrive support for DOS" ,你需要开启这个选项使优盘能够工作。我想有一些bios和这个有相似之处,所以请大家擦亮眼睛。
另外一个就是对于许多bios来说,你需要在通电自检后短暂的按F8进入启动设置。在这里你可以选择你喜欢的启动驱动器。在这里你可能看到你的优盘的名字。我的就是"usb rmd-fdd",如果你没有搞定或者你的硬件有问题,如果你可以选择设备,但是不能启动,那么很可能是你的引导部分有问题。请检查两遍你的/dev/sdx设备含有所有必需的文件:syslinux,initrd, vmlinuz. boot.img.gz  我没有放内核在上面,所有我从netboot目录拷贝了initrd 和vmlinuz到/dev/sdx

Adrian Bader:
我有一个MSI K8T-Neo 主板 (for AMD64) 和via K8T800的芯片组,它能正常运行.

确保这三件事情非常重要:usb在普通模式下(通常这个会成为一个很重要的原因),"boot from other devices"和"usb legacy support"打开,。然后我在启动中按住F11,就到了选择启动驱动器的画面。然后我可以选择从优盘启动

--------------------------------------------------------------------------------

Please send comments, additions and corrections to Pascal Le Bail. Last updated: 2004-09-08[/quote]
回复

使用道具 举报

发表于 2005-2-4 22:27:24 | 显示全部楼层
很简单的翻译了一下,这是我第一次在这里发言,也是第一次翻译文章,很多不足之处还请大家多多原谅!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2025-2-14 00:24 , Processed in 0.023238 second(s), 15 queries .

© 2001-2025 Discuz! Team. Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表