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 shellfile boot.binboot.bin: DOS/MBR boot sectorxxd ./boot.bin# to modify using vim editorxxd ./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 fileqemu-system-x86_64 ./new_boot.bin