Boot File

with open('boot.bin', 'wb') as bin_file:
    _bytes = [ b'\x00' for _ in range(510) ]
    _bytes.append(b'\x55')
    _bytes.append(b'\xAA')
    bin_file.write(b''.join(_bytes))
# inside shell
file boot.bin
boot.bin: DOS/MBR boot sector
 
xxd ./boot.bin
 
# to modify using vim editor
xxd ./bin/app | vim โ€”
 
# inside vim save like this
# :%!xxd -r > ./bin/new_boot.bin
# source: https://medium.com/notes-and-tips-in-full-stack-development/modify-binary-files-with-vim-c35b40c499e
 
# validate your boot file
qemu-system-x86_64 ./new_boot.bin