Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Target and System filesystem must be same type #2065

Closed
toncho11 opened this issue Oct 7, 2024 · 9 comments · Fixed by #2067
Closed

Target and System filesystem must be same type #2065

toncho11 opened this issue Oct 7, 2024 · 9 comments · Fixed by #2067
Labels
bug Defect in the product

Comments

@toncho11
Copy link
Contributor

toncho11 commented Oct 7, 2024

Continuing from: #2062 (comment)

Problem on fat where I get the error: Target and System filesystem must be same type
It is here:

fstype = get_fstype(fd);

So filesystem type is checked by reading 512 bytes from disk. It is only checking for Minix. This is not transparent in my opinion. I was thinking it is checking partition IDs for example. Why are these 512 bytes not overwritten (with fdisk or mkfat)? Sometimes by chance they get overwritten and problem is hidden. I did fdisk with 'w', mkfat, sync and still I could not overwrite this 512b block ... it should not be a guessing job which step is supposed to overwrite it. In my case it is either fdisk or mkfat not overwriting these 512 bytes or my new partition is somehow a bit after the old one leaving this 512 bytes untouched (where it was Minix indeed).

@ghaerr
Copy link
Owner

ghaerr commented Oct 7, 2024

Can you give me the exact command you're using which gives this error? I am not sure I fully understand the problem.

When a partitioned device such as /dev/hda2 is specified, the MBR is never checked, as that block is not accessible from the specified device. If on the other hand a partitioned device is specified via /dev/hda, then the partition table is the first block on the device, but a filesystem will be accessible only if the first block is not an MBR, indicating a "flat" filesystem.

So filesystem type is checked by reading 512 bytes from disk.

Yes, in order to determine the filesystem that is on a specified partition, such as /dev/hda1, the first block ("super block" on MINIX, reserved sectors on FAT) is read. If that block contains the MINIX magic number, it is assumed the filesystem is MINIX, otherwise FAT. FAT doesn't have a superblock and usually has reserved sectors instead, depending on type of FAT.

It is only checking for Minix.

Yes, if its not MINIX, it is assumed FAT. When makeboot runs directly or via sys, if the filesystem is not FAT or MINIX the mount will fail so there are no issues assuming FAT if not MINIX.

Why are these 512 bytes not overwritten (with fdisk or mkfat)?

The first block may not be overwritten on FAT filesystems because there is no superblock - these are likely reserved sectors and thus not written via mkfat etc.

In my case it is either fdisk or mkfat not overwriting these 512 bytes or my new partition is somehow a bit after the old one leaving this 512 bytes untouched (where it was Minix indeed).

So I'm not really following you here, exactly what is the bug/problem?

@toncho11
Copy link
Contributor Author

toncho11 commented Oct 7, 2024

mkfat -fat32 /dev/hda1 33000 and the sys /dev/hda1 and I can not make it think that /dev/hda1 is fat now.

@ghaerr
Copy link
Owner

ghaerr commented Oct 7, 2024

Ok let me try that right now, thanks.

@toncho11
Copy link
Contributor Author

toncho11 commented Oct 7, 2024

Yes, but maybe it should be after a minix install so that you have the minix 512 bytes already.

@ghaerr you must be in some other timezone today? :)

@ghaerr
Copy link
Owner

ghaerr commented Oct 7, 2024

mkfat -fat32 /dev/hda1 33000 and the sys /dev/hda1

Running QEMU, I used the following line in qemu.sh to boot from FAT floppy and then mount /dev/hda1 from the hd32mbr-fat.img:

IMAGE="-boot order=a -fda image/fd1440-fat.img -drive file=image/hd32mbr-fat.img,format=raw,if=ide"

I then ran the above mkfat and sys and it worked. So there must be something else happening. I suggest you run fdisk then 'l' command and screenshot to show the layout of the HD and FAT type. Then, directly after running mkfat on /dev/hda1, try mount /dev/hda1 /mnt and ls -l /mnt to see that works. I am not really sure what is going on yet on your system.

you must be in some other timezone today? :)

Yes, I am traveling currently in southern Spain and enjoying it :)

@ghaerr
Copy link
Owner

ghaerr commented Oct 7, 2024

but maybe it should be after a minix install so that you have the minix 512 bytes already.

Maybe it should be what?

It seems perhaps this is an issue where the HD was previously MINIX, then you ran mkfat on the partition but did or did not change use fdisk? Not sure what exactly is going on.

@toncho11
Copy link
Contributor Author

toncho11 commented Oct 7, 2024

It is a specific issue where it was previously minix and the 512 bytes of minix are always there.
How would you proceed in this case to make sure that the 512 bytes are overwritten?
What is the "correct" procedure in this case?

@ghaerr
Copy link
Owner

ghaerr commented Oct 7, 2024

It is a specific issue where it was previously minix and the 512 bytes of minix are always there.

I see. So the first block in the partition (not MBR) still has the MINIX magic signature, while after you have used mkfat to change the filesystem type to FAT, those sectors are not written since they are likely FAT reserved, and thus the magic signature is still there when makeboot reads it. I finally understand.

Yes, this is a bug - not sure what to do yet. IIRC only FAT32 uses reserved sectors by default (at least with our mkfat). So I'm thinking that, for our mkfat it should probably write that first block with zeros when it is a reserved sector. Let me look at mkfs.c to see if this might work.

Thank you!

@ghaerr
Copy link
Owner

ghaerr commented Oct 7, 2024

@toncho11, this is fixed in #2067. You should be good to go using the mkfat -fat32 /dev/hda1 33000 as before, followed by a sys /dev/hda1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Defect in the product
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants