We use PXE quite a lot here. Both the Linux and Windows installers are based on PXE booting, plus we use it to run memtest on new machines and DoDwipe on old machines.
Recently, I needed to update the BIOS on a batch of Dell Optiplex machines. Rather than using flash drives, I wanted to use our existing PXE server to run the BIOS updater.
Dell's BIOS tools run in either Windows or DOS, so a bootable DOS image seemed the best way to go. Unfortunately, as the single exe file is made to run under Windows or DOS, it's quite large (9MB) so a floppy image wasn't going to cut it. What I needed was a 10MB hard disk image. I found one on the internet, but was unable to get the BIOS updater to fit, too much other stuff. So I rolled my own.
Here is how. Start out with a FreeDOS floppy image. I used a 2.88MB floppy image that I found at fdos.org. The first time I tried to boot it using qemu I thought it was broken, but then I realised it was a zipped floppy img (.imz). D'oh!
To make a hard drive image, use qemu to create a raw disk image of the required size. In this case, 10MB.
qemu-img create -f raw hd.raw 10M
Then, you can boot qemu from the floppy, and with the hard drive file. The
-boot a
tells qemu to boot from floppy.qemu -fda FDSTD.288 -hda hd.raw -boot a
The first thing I did was to add
C:\FDOS
to the path (because I kept getting annoyed having to type it in front of every command). To prepare the hard drive image, we need to partition and format it correctly and then copy the relevant files to it. First things first, create the partition using fdisk. Create a new primary partition, mark it active and (if necessary) change it's type to FAT16 (type 6). Then make sure it has a Master Boot Record, using fdisk /MBR
. After creating the partition you will have to reboot the vm.
Next, format the drive, and use the
sys
command to make it bootable.A:\> format C:
A:\> sys C
Then copy the following files from the root of the floppy drive to the root of the hard drive (ie from A:\ to C:)
AUTOEXEC.BAT
CONFIG.SYS
UMBPCI.SYS
UMBPCI.TXT
SYS.COM
Finally, create the
C:\FDOS
directory and copy everything from A:\FDOS
into it.MKDIR C:\FDOS
copy A:\FDOS\*.* C:\FDOS
That should do it. To check if everything is OK, boot the qemu vm with just the hard disk image. It should boot fine. (I'd then add
SET PATH=.;C:\FDOS
to the AUTOEXEC.BAT
file)qemu -hda hd.raw
Now that you have a working image, you can loopback mount it in linux to add the files you need. You will need to specify the offset to the filesystem. To find it, use
file
on your image.[root@test1 freedos]# file hd.raw
hd.raw: x86 boot sector, FREE-DOS Beta 0.9 MBR; partition 1: ID=0x6, active, starthead 1, startsector 63, 20097 sectors, code offset 0xfc
The key here id the startsector, 63. Each sector is 512 bytes so our offset is 63*512, or 32256. You can mount the file system like so.
[root@test1 freedos]# mkdir /mnt/img
[root@test1 freedos]# mount -t vfat -o loop,offset=32256 hd.raw /mnt/img
Then simply copy any additional files to
/mnt/img
. Don't forget to umount /mnt/img
.
To get the image to PXE boot, use the following in your config file. I think syslinux expects disk images to have a .img suffix so name the file something appropriate.
menu title BIOS updates
label optiplex9020
menu label Dell Optiplex 9020 A03
kernel memdisk
append initrd=bios_9020_A03.img raw
Retirado de: https://www.cs.waikato.ac.nz/~dbaird/work/2013/11/05/pxe-boot-freedos-hard-disk-image/
Em 20/05/2018
Nenhum comentário:
Postar um comentário
Observação: somente um membro deste blog pode postar um comentário.