nanobyte-dev / nanobyte_os

OS tutorial from Nanobyte YouTube channel.
The Unlicense
500 stars 75 forks source link

mkfs.fat: unrecognized option #36

Closed badgeminer closed 1 year ago

badgeminer commented 1 year ago

when running scons I get

scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: `build/i686_debug/kernel/kernel-stripped.elf' is up to date.
Assembling [src/bootloader/stage2/x86.asm]
Assembling [src/bootloader/stage2/crtn.asm]
Linking    [build/i686_debug/stage2/stage2.bin]
Creating disk image...
> creating partition table...
Kernel not configured for semaphores (System V IPC). Not using udev synchronisation code.
> formatting file using fat32...
scons: *** [build/i686_debug/image.img] ErrorReturnCode_1 : 

  RAN: /usr/sbin/mkfs.fat build/i686_debug/image.img -F 32 -n NBOS -R 2 --offset=2048

  STDOUT:
mkfs.fat 4.1 (2017-01-24)
Unknown option: ?

  STDERR:
/usr/sbin/mkfs.fat: unrecognized option '--offset=2048'
Usage: mkfs.fat [-a][-A][-c][-C][-v][-I][-l bad-block-file][-b backup-boot-sector]
       [-m boot-msg-file][-n volume-name][-i volume-id]
       [-s sectors-per-cluster][-S logical-sector-size][-f number-of-FATs]
       [-h hidden-sectors][-F fat-size][-r root-dir-entries][-R reserved-sectors]
       [-M FAT-media-byte][-D drive_number]
       [--invariant]
       [--help]
       /dev/name [blocks]

Traceback (most recent call last):
  File "/usr/lib/scons/SCons/Action.py", line 1209, in execute
    result = self.execfunction(target=target, source=rsources, env=env)
  File "/mnt/c/Users/Ben/Downloads/nanobyte_os-master/nanobyte_os-master/image/SConscript", line 235, in build_image
    build_disk(image, stage1, stage2, kernel, files, env)
  File "/mnt/c/Users/Ben/Downloads/nanobyte_os-master/nanobyte_os-master/image/SConscript", line 176, in build_disk
    create_filesystem(image, file_system, offset=partition_offset)
  File "/mnt/c/Users/Ben/Downloads/nanobyte_os-master/nanobyte_os-master/image/SConscript", line 39, in create_filesystem
    mkfs_fat(target,
  File "/home/badgeminer2/.local/lib/python3.8/site-packages/sh.py", line 1524, in __call__
    return RunningCommand(cmd, call_args, stdin, stdout, stderr)
  File "/home/badgeminer2/.local/lib/python3.8/site-packages/sh.py", line 788, in __init__
    self.wait()
  File "/home/badgeminer2/.local/lib/python3.8/site-packages/sh.py", line 845, in wait
    self.handle_command_exit_code(exit_code)
  File "/home/badgeminer2/.local/lib/python3.8/site-packages/sh.py", line 869, in handle_command_exit_code     
    raise exc
sh.ErrorReturnCode_1:

  RAN: /usr/sbin/mkfs.fat build/i686_debug/image.img -F 32 -n NBOS -R 2 --offset=2048

  STDOUT:
mkfs.fat 4.1 (2017-01-24)
Unknown option: ?

  STDERR:
/usr/sbin/mkfs.fat: unrecognized option '--offset=2048'
Usage: mkfs.fat [-a][-A][-c][-C][-v][-I][-l bad-block-file][-b backup-boot-sector]
       [-m boot-msg-file][-n volume-name][-i volume-id]
       [-s sectors-per-cluster][-S logical-sector-size][-f number-of-FATs]
       [-h hidden-sectors][-F fat-size][-r root-dir-entries][-R reserved-sectors]
       [-M FAT-media-byte][-D drive_number]
       [--invariant]
       [--help]
       /dev/name [blocks]

scons: building terminated because of errors.
badgeminer commented 1 year ago

progress, now I get

scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: `build/i686_debug/kernel/kernel-stripped.elf' is up to date.
Creating disk image...
> creating partition table...
Kernel not configured for semaphores (System V IPC). Not using udev synchronisation code.
> formatting file using fat32...
> installing stage1...
> installing stage2...
> mounting image to build/i686_debug/tmp_mount_1692484414...
> cleaning up...
scons: *** [build/i686_debug/image.img] ErrorReturnCode_1 : 

  RAN: /usr/bin/guestmount build/i686_debug/tmp_mount_1692484414 --add=build/i686_debug/image.img --mount=/dev/sda1

  STDOUT:

  STDERR:
libguestfs: error: /usr/bin/supermin exited with error status 1.
To see full error messages you may need to enable debugging.
Do:
  export LIBGUESTFS_DEBUG=1 LIBGUESTFS_TRACE=1
and run the command again.  For further information, read:
  http://libguestfs.org/guestfs-faq.1.html#debugging-libguestfs
You can also run 'libguestfs-test-tool' and post the *complete* output
into a bug report or message to the libguestfs mailing list.

Traceback (most recent call last):
  File "/usr/lib/scons/SCons/Action.py", line 1209, in execute
    result = self.execfunction(target=target, source=rsources, env=env)
  File "/mnt/c/Users/Ben/Downloads/basic_os-keyboard_driver/basic_os-keyboard_driver/image/SConscript", line 235, in build_image
    build_disk(image, stage1, stage2, kernel, files, env)
  File "/mnt/c/Users/Ben/Downloads/basic_os-keyboard_driver/basic_os-keyboard_driver/image/SConscript", line 193, in build_disk
    mount_fs(image, tempdir)
  File "/mnt/c/Users/Ben/Downloads/basic_os-keyboard_driver/basic_os-keyboard_driver/image/SConscript", line 152, in mount_fs
    sh.guestmount(mount_dir, add=image, mount='/dev/sda1')
  File "/home/badgeminer2/.local/lib/python3.8/site-packages/sh.py", line 1524, in __call__
    return RunningCommand(cmd, call_args, stdin, stdout, stderr)
  File "/home/badgeminer2/.local/lib/python3.8/site-packages/sh.py", line 788, in __init__
    self.wait()
  File "/home/badgeminer2/.local/lib/python3.8/site-packages/sh.py", line 845, in wait
    self.handle_command_exit_code(exit_code)
  File "/home/badgeminer2/.local/lib/python3.8/site-packages/sh.py", line 869, in handle_command_exit_code     
    raise exc
sh.ErrorReturnCode_1:

  RAN: /usr/bin/guestmount build/i686_debug/tmp_mount_1692484414 --add=build/i686_debug/image.img --mount=/dev/sda1

  STDOUT:

  STDERR:
libguestfs: error: /usr/bin/supermin exited with error status 1.
To see full error messages you may need to enable debugging.
Do:
  export LIBGUESTFS_DEBUG=1 LIBGUESTFS_TRACE=1
and run the command again.  For further information, read:
  http://libguestfs.org/guestfs-faq.1.html#debugging-libguestfs
You can also run 'libguestfs-test-tool' and post the *complete* output
into a bug report or message to the libguestfs mailing list.

scons: building terminated because of errors.

by adding

deb http://archive.ubuntu.com/ubuntu lunar main 

to /etc/apt/sources.list then running

sudo apt reinstall dosfstools
badgeminer commented 1 year ago

by folowing @chibicitiberiu's advice in #27 I now get

scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: `build/i686_debug/kernel/kernel-stripped.elf' is up to date.
Creating disk image...
> creating partition table...
Kernel not configured for semaphores (System V IPC). Not using udev synchronisation code.
> formatting file using fat32...
> installing stage1...
> installing stage2...
> mounting image to build/i686_debug/tmp_mount_1692485194...
Please type your username password for running mount:
> cleaning up...
warning: unmount failed
Traceback (most recent call last):
  File "/mnt/c/Users/Ben/Downloads/nanobyte_os-master/nanobyte_os-master/image/SConscript", line 260, in build_disk
    mount_token = mount_fs(image, tempdir, mount_method)
  File "/mnt/c/Users/Ben/Downloads/nanobyte_os-master/nanobyte_os-master/image/SConscript", line 203, in mount_fs
    out = sh.losetup(image, partscan=True, find=True, show=True, _tty_in=True, _unify_ttys=True)
  File "/home/badgeminer2/.local/lib/python3.8/site-packages/sh.py", line 1524, in __call__
    return RunningCommand(cmd, call_args, stdin, stdout, stderr)
  File "/home/badgeminer2/.local/lib/python3.8/site-packages/sh.py", line 788, in __init__
    self.wait()
  File "/home/badgeminer2/.local/lib/python3.8/site-packages/sh.py", line 845, in wait
    self.handle_command_exit_code(exit_code)
  File "/home/badgeminer2/.local/lib/python3.8/site-packages/sh.py", line 869, in handle_command_exit_code     
    raise exc
sh.ErrorReturnCode_1:

  RAN: /usr/bin/sudo -S -k /usr/sbin/losetup build/i686_debug/image.img --partscan --find --show

  STDOUT:
[sudo] password for badgeminer2:
losetup: cannot find an unused loop device

  STDERR:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/mnt/c/Users/Ben/Downloads/nanobyte_os-master/nanobyte_os-master/image/SConscript", line 286, in build_disk
    unmount_fs(tempdir, mount_method, mount_token)
UnboundLocalError: local variable 'mount_token' referenced before assignment
Traceback (most recent call last):
  File "/mnt/c/Users/Ben/Downloads/nanobyte_os-master/nanobyte_os-master/image/SConscript", line 305, in build_image
    build_disk(image, stage1, stage2, kernel, files, env)
  File "/mnt/c/Users/Ben/Downloads/nanobyte_os-master/nanobyte_os-master/image/SConscript", line 260, in build_disk
    mount_token = mount_fs(image, tempdir, mount_method)
  File "/mnt/c/Users/Ben/Downloads/nanobyte_os-master/nanobyte_os-master/image/SConscript", line 203, in mount_fs
    out = sh.losetup(image, partscan=True, find=True, show=True, _tty_in=True, _unify_ttys=True)
  File "/home/badgeminer2/.local/lib/python3.8/site-packages/sh.py", line 1524, in __call__
    return RunningCommand(cmd, call_args, stdin, stdout, stderr)
  File "/home/badgeminer2/.local/lib/python3.8/site-packages/sh.py", line 788, in __init__
    self.wait()
  File "/home/badgeminer2/.local/lib/python3.8/site-packages/sh.py", line 845, in wait
    self.handle_command_exit_code(exit_code)
  File "/home/badgeminer2/.local/lib/python3.8/site-packages/sh.py", line 869, in handle_command_exit_code     
    raise exc
sh.ErrorReturnCode_1:

  RAN: /usr/bin/sudo -S -k /usr/sbin/losetup build/i686_debug/image.img --partscan --find --show

  STDOUT:
[sudo] password for badgeminer2:
losetup: cannot find an unused loop device

  STDERR:

scons: done building targets.

I am on ubuntu wsl

chibicitiberiu commented 1 year ago

What is the output of ls /dev/ | grep loop? Also, what is the output of modprobe loop? (this might require sudo)

badgeminer commented 1 year ago

ls /dev/ | grep loop returns nothing, but ls /dev/ returns

block   stdin    ttyS102  ttyS111  ttyS120  ttyS13   ttyS139  ttyS148  ttyS157  ttyS166  ttyS175  ttyS184  ttyS20  ttyS3   ttyS39  ttyS48  ttyS57  ttyS66  ttyS75  ttyS84  ttyS93
fd      stdout   ttyS103  ttyS112  ttyS121  ttyS130  ttyS14   ttyS149  ttyS158  ttyS167  ttyS176  ttyS185  ttyS21  ttyS30  ttyS4   ttyS49  ttyS58  ttyS67  ttyS76  ttyS85  ttyS94
kmsg    tty      ttyS104  ttyS113  ttyS122  ttyS131  ttyS140  ttyS15   ttyS159  ttyS168  ttyS177  ttyS186  ttyS22  ttyS31  ttyS40  ttyS5   ttyS59  ttyS68  ttyS77  ttyS86  ttyS95
lxss    tty0     ttyS105  ttyS114  ttyS123  ttyS132  ttyS141  ttyS150  ttyS16   ttyS169  ttyS178  ttyS187  ttyS23  ttyS32  ttyS41  ttyS50  ttyS6   ttyS69  ttyS78  ttyS87  ttyS96
null    tty1     ttyS106  ttyS115  ttyS124  ttyS133  ttyS142  ttyS151  ttyS160  ttyS17   ttyS179  ttyS188  ttyS24  ttyS33  ttyS42  ttyS51  ttyS60  ttyS7   ttyS79  ttyS88  ttyS97
ptmx    ttyS0    ttyS107  ttyS116  ttyS125  ttyS134  ttyS143  ttyS152  ttyS161  ttyS170  ttyS18   ttyS189  ttyS25  ttyS34  ttyS43  ttyS52  ttyS61  ttyS70  ttyS8   ttyS89  ttyS98
pts     ttyS1    ttyS108  ttyS117  ttyS126  ttyS135  ttyS144  ttyS153  ttyS162  ttyS171  ttyS180  ttyS19   ttyS26  ttyS35  ttyS44  ttyS53  ttyS62  ttyS71  ttyS80  ttyS9   ttyS99
random  ttyS10   ttyS109  ttyS118  ttyS127  ttyS136  ttyS145  ttyS154  ttyS163  ttyS172  ttyS181  ttyS190  ttyS27  ttyS36  ttyS45  ttyS54  ttyS63  ttyS72  ttyS81  ttyS90  urandom
shm     ttyS100  ttyS11   ttyS119  ttyS128  ttyS137  ttyS146  ttyS155  ttyS164  ttyS173  ttyS182  ttyS191  ttyS28  ttyS37  ttyS46  ttyS55  ttyS64  ttyS73  ttyS82  ttyS91  zero
stderr  ttyS101  ttyS110  ttyS12   ttyS129  ttyS138  ttyS147  ttyS156  ttyS165  ttyS174  ttyS183  ttyS2    ttyS29  ttyS38  ttyS47  ttyS56  ttyS65  ttyS74  ttyS83  ttyS92

modprobe loop and sudo modprobe loop return modprobe: FATAL: Module loop not found in directory /lib/modules/4.4.0-22621-Microsoft

ajh123 commented 1 year ago

What is the output of ls /dev/ | grep loop? Also, what is the output of modprobe loop? (this might require sudo)

For me ls /dev/ | grep loop returns

loop-control
loop0
loop1
loop2
loop3
loop4
loop5
loop6
loop7

and modprobe loop and sudo modprobe loop returns modprobe: FATAL: Module loop not found in directory /lib/modules/4.4.0-22621-Microsoft

chibicitiberiu commented 1 year ago

Are you on WSL 1? I think you need to update your container to WSL 2. Loop devices have been added to WSL 2. That would also explain why you have such an old version of mkfs.fat.

ajh123 commented 1 year ago

@chibicitiberiu

I'm on WSL2 I'm not sure if badgeminer is. Doing a sudo apt update and sudo apt install dosfstools fixed this issue for me.

Also should QEMU output image when ran?

chibicitiberiu commented 1 year ago

Yes, looks good. The FAT driver is currently broken in the C++ refactoring branch.

badgeminer commented 1 year ago

I just updated to wsl 2, libguestfs still errors and with mount I get

badgeminer2@Bm2Pc:/mnt/c/Users/badgeminer2/Downloads/nanobyte_os-master/nanobyte_os-master$ scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: `build/i686_debug/kernel/kernel-stripped.elf' is up to date.
Creating disk image...
> creating partition table...
> formatting file using fat32...
> installing stage1...
> installing stage2...
> mounting image to build/i686_debug/tmp_mount_1693093186...
Please type your username password for running mount:
> copying kernel...
> copying files...
    ... copying test.txt
    ... creating directory folder
    ... copying folder/demo.txt
> cleaning up...
scons: done building targets.

and then from VirtualBox I get:

Failed to open the disk image file C:\Users\badgeminer2\Downloads\nanobyte_os-master\nanobyte_os-master\build\i686_debug\image.img.

Could not get the storage format of the medium 'C:\Users\badgeminer2\Downloads\nanobyte_os-master\nanobyte_os-master\build\i686_debug\image.img' (VERR_NOT_SUPPORTED).

Result Code: | VBOX_E_IPRT_ERROR (0X80BB0005) -- | -- Component: | MediumWrap Interface: | IMedium {ad47ad09-787b-44ab-b343-a082a3f2dfb1} Callee: | IVirtualBox {7682d5eb-f00e-44f1-8ca2-99d08b1cd607} Callee RC: | VBOX_E_OBJECT_NOT_FOUND (0X80BB0001)


ajh123 commented 1 year ago

@badgeminer Couldn't you use scons run to run the OS with QEMU. QEMU can be installed with sudo apt install qemu-system-x86 (in WSL).

Also VirtualBox does not support .img files (hence the VERR_NOT_SUPPORTED) as seen below ... image

Instead you could follow https://superuser.com/questions/554862/how-to-convert-img-to-usable-virtualbox-format to convert the image into a .vdi. I haven't tried this yet.

buellja commented 1 year ago

@badgeminer Couldn't you use scons run to run the OS with QEMU. QEMU can be installed with sudo apt install qemu-system-x86 (in WSL).

Also VirtualBox does not support .img files (hence the VERR_NOT_SUPPORTED) as seen below ... image

Instead you could follow https://superuser.com/questions/554862/how-to-convert-img-to-usable-virtualbox-format to convert the image into a .vdi. I haven't tried this yet.

VirtualBox does support .img disk images, but you were using an optical drive attached to the VM, hence why img files were not supported.
Instead, you can add a floppy controller to the VM under the "Storage" options. Then, you can attach a virtual floppy drive to the floppy controller, and can point to your .img disk image for that virtual floppy drive :)

ajh123 commented 1 year ago

@badgeminer Couldn't you use scons run to run the OS with QEMU. QEMU can be installed with sudo apt install qemu-system-x86 (in WSL). Also VirtualBox does not support .img files (hence the VERR_NOT_SUPPORTED) as seen below ... image Instead you could follow https://superuser.com/questions/554862/how-to-convert-img-to-usable-virtualbox-format to convert the image into a .vdi. I haven't tried this yet.

VirtualBox does support .img disk images, but you were using an optical drive attached to the VM, hence why img files were not supported. Instead, you can add a floppy controller to the VM under the "Storage" options. Then, you can attach a virtual floppy drive to the floppy controller, and can point to your .img disk image for that virtual floppy drive :)

@buellja For me Virtual Box does not recognise the .img (even with a Floppy Controller). Anyway I prefer QEMU.

image

badgeminer commented 1 year ago

qemu fixed it