我怎样写一个bin文件(512字节)到软盘的第一个扇区(0扇区)? [英] How do I write a bin file (512 bytes) to the first sector (sector 0) of a floppy disk?

查看:292
本文介绍了我怎样写一个bin文件(512字节)到软盘的第一个扇区(0扇区)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样写一个.bin文件是在软盘的第一个扇区/虚拟软盘/软盘映像?

How do I write a .bin file to be in the first sector of a floppy disk/virtual floppy disk/floppy image?

我试图启动一个简单的512字节的引导程序。上随处可见大小写着512字节,所以我应该是不错的了。

I'm trying to boot a simple 512-byte bootloader. The size on everywhere says "512 bytes" so I should be good already.

其他信息:

引导程序简单地显示一个字符串,我正在学习简单组装。有些工作是在Windows制成,有的在 Ubuntu的  14.04 (可信赖的塔尔羊)(如果这事项)。

The bootloader simply displays a string, and I'm learning simple assembly. Some of the work is made in Windows and some in Ubuntu 14.04 (Trusty Tahr) (if this matters).

尽管它有引导程序的标志,它甚至没有开机。

It doesn't boot even though it has the bootloader sign.

推荐答案

如果你是在Linux上,你可以使用的 DD 的工具做到这一点。有一个版本的 DD 的用于Microsoft Windows,以及。

If you are on Linux you can do it with DD utility. There is a version of DD for Microsoft Windows as well.

如果您要进行零填充的虚拟磁盘映像720K软盘的大小,你可以使用的 DD 的是这样的:

If you wish to make a zero filled virtual disk image the size of a 720K floppy you can use dd like this:

dd if=/dev/zero of=disk.img bs=1024 count=720

这将创建一个名为 disk.img ,其尺寸1024 * 720 = 737280字节。那就是零填补了1.44MB软盘映像可以创建:

This would create a file called disk.img that is 1024*720 = 737280 bytes in size. A 1.44MB floppy image that is zero filled can be created with:

dd if=/dev/zero of=disk.img bs=1024 count=1440


在图像的开头写入二进制图象到虚拟软盘起点可以这样来完成:


Writing a binary image to a virtual floppy starting at the beginning of the image can be done like this:

dd if=bootload.bin of=disk.img conv=notrunc 

这个例子把文件 bootload.bin ,并将其放置在磁盘映像(称为之初<​​code> disk.img 在这种情况下),而截断( =单次转​​换notrunc之外)如果不使用 =单次转​​换notrunc之外上虚拟磁盘映像是将数据写入 bootload.bin 并截断磁盘映像到bootloader的大小。

This example take the file bootload.bin and places it at the beginning of the disk image (called disk.img in this case) without truncation (conv=notrunc) If you don't use conv=notrunc on a virtual disk image it will write bootload.bin and truncate disk image to the size of the bootloader.

DD 的也有通过跳转到比盘的开头以外的点写入到磁盘映像的特定部分的能力。如果您需要放置在一个特定部门的信息(code /数据),这非常有用。本实施例可用于放置一个引导加载程序的第二阶段的磁盘映像的第一512字节的扇区后:

DD also has the ability to write to specific parts of a a disk image by jumping to a point other than the beginning of the disk. This is useful if you need to place information (code/data) in a particular sector. This example could be used to place the second stage of a boot loader after the first 512 byte sector of the disk image:

dd if=stage2.bin of=disk.img bs=512 seek=1 conv=notrunc

BS = 512 设置块大小为512(使得它更容易,因为它是最软盘扇区的典型尺寸)。 寻求= 1 寻求第一块(512字节)过去影像的开始,然后写入文件 stage2.bin 。我们需要 =单次转​​换notrunc之外再次,因为我们不希望的 DD 的截断在其中,阶段2点磁盘映像。斌结束。

bs=512 sets the block size to 512 (makes it easier since it is the typical size of most floppy disk sector). seek=1 seeks to the first block (512 bytes) past the beginning of the image and then writes the file stage2.bin . We need conv=notrunc again because we don't want DD to truncate the disk image at the point where stage2.bin ends.

dd if=stage2.bin of=disk.img bs=512 seek=18 conv=notrunc

这例子是类似上却写之前跳过9216字节(512 * 18) stage2.bin

This example is similar to the last but it skips over 9216 bytes (512*18) before writing stage2.bin

如果您有连接到一个Linux系统(和root访问权限)软盘你可以写的东西引导程序像

If you have a floppy attached to a Linux system (and root access) you can write the bootloader with something like

dd if=bootload.bin of=/dev/fd0 

其中,的/ dev / FD0 是您的软盘设备。 的/ dev / FD0 一般软盘(如果present)和的/ dev / FD1 是软盘B(如present)。

where /dev/fd0 is the device for your floppy. /dev/fd0 is generally floppy disk A (if present) and /dev/fd1 is floppy disk B (if present).

如果您正在运行Microsoft Windows就有的 DD 的实用程序中提供这里。最新下载 dd-0.6beta3.zip 是建议的最低版本。它有一些功能较老的没有。只要打开zip文件并解压到您的Windows路径上的位置。

If you are running on Microsoft Windows there is a version of the DD utility available here . The latest download is dd-0.6beta3.zip and is the minimum recommended version. It has some features older ones didn't. Just open the zip file and extract it to a place on your Windows path.

这篇关于我怎样写一个bin文件(512字节)到软盘的第一个扇区(0扇区)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆