Disk building tools

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
0b1
Member
Member
Posts: 35
Joined: Sun Feb 04, 2018 8:04 pm

Disk building tools

Post by 0b1 »

Another contribution from Rabbie for budding OS devs.

https://github.com/0bOne/wufs

WUFS tools are written in node.js with the following purpose:
- Create a a raw disk image for use in Bochs or QEMU, or for subsequently converting into another virtual hard drive form (I use qemu-img).
- Inject a boot loader
- Initialize a file system, usage bitmap and root folder.
- Inject the kernel executable into the root folder.

While tools exist to do much of this, I wanted something that was a script so it would be transparent, contemporary and easy to modify for those who (more than likely) want to roll their own file system rather than use an existing or my WUFS file system.

Not that there is anything wrong with existing file systems. It just that, as OS Devs, we like to do our own thing!

(And if anyone wants to contribute an existing file systems to the WUFS tools, or their own to make it more well known, let me know!)

It also includes a handy (if a little slow) raw disk dump utility, that is file system independent and produces compact hex/ascii output like this:

Code: Select all

Disk dump of bootable.raw
Taken  Sat May 22 2021 10:39:36 GMT-0400 (Eastern Daylight Time)
Sector size:  0x200, Block size: 0x1000
Disk size: 0xa00000 bytes, 0b5000 sectors, 0ba00 blocks
========================================================================

Boot loader found in sectors 0x0000 to 0x000e
[START OF BOOT LOADER]
BLOCKADDR BYTEADDR HEX												          ASCII			
0000 0000 00000000 31 c0 8e d8 88 16 82 7d b8 00 00 8e d0 bc fe 07  1......}........
0000 0000 00000010 be d8 7c e8 94 01 be 19 7d e8 8e 01 8a 16 82 7d  ..|.....}......}
0000 0000 00000020 b4 08 bf 00 00 cd 13 0f 82 a1 00 88 16 84 7d 88  ..............}.
0000 0000 00000030 36 87 7d 88 c8 24 3f a2 88 7d 31 c0 a1 fa 7d 48  6.}..$?..}1...}H
0000 0000 00000040 50 89 c2 e8 7e 01 be 3a 7d e8 5e 01 a1 fa 7d 48  P...~..:}.^...}H
0000 0000 00000050 a3 85 7d b8 00 7e a3 7e 7d b1 02 b6 00 b5 00 8a  ..}..~.~}.......
0000 0000 00000060 16 82 7d a1 85 7d 31 db 8a 1e 88 7d 39 d8 7e 02  ..}..}1....}9.~.
...note: skip a few lines so you can see the end of the first sector...
0000 0000 000001b0 00 89 e5 ac 08 c0 74 09 b4 0e bb 00 00 cd 10 eb  ......t.........
0000 0000 000001c0 f2 89 ec c3 89 e5 52 51 b9 04 00 c1 c2 04 89 d0  ......RQ........
0000 0000 000001d0 24 0f 3c 0a 7c 02 04 07 04 30 b4 0e bb 00 00 cd  $.<.|....0......
0000 0000 000001e0 10 e2 e8 59 5a c3 00 00 00 00 00 00 00 00 00 00  ...Y............
0000 0000 000001f0 00 00 00 00 00 00 00 00 00 00 0e 00 dd dd 55 aa  ..............U.
...note: skip a few more so you can see how empty sectors appear...
...note: also the bitmap node signature and a marker to show where the boot loader ends...
000e 0001 00001de0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
000e 0001 00001df0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
[END OF BOOT LOADER]
000f 0001 00001e00 to 00002000 [ALL ZERO]
0010 0002 00002000 52 42 46 53 5f 42 49 54 4d 41 50 5f 49 4e 46 4f  RBFS_BITMAP_INFO
0010 0002 00002010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0010 0002 00002020 1f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0010 0002 00002030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
It might help with troubleshooting your file system, boot loader, etc.

Let me know if you want extra features or have (constructive) feedback or suggestions.
Code or code not. There is no try.
Post Reply