Page 1 of 1

Hard disk drive vs USB flash drive

Posted: Tue Jan 26, 2010 2:24 pm
by 0x90
Hello.

I have recently decided that I would like to attempt to develop an operating system. I am very much still in the designing/planning phase. I would like my operating system to reside and be able to run executables residing on some sort of data storage device. I have more or less decided on EXT2 as the associated filesystem. I am having difficulty deciding on the precise type of the storage device. I must choose between an usb flash drive and my machine's hard disk. lspci (pciutils 3.1.5) on Linux 2.6.32 reports it as being:

Code: Select all

IDE interface: Intel Corporation 82801GBM/GHM (ICH7 Family) SATA IDE Controller (rev 01)
In other words, let ChosenDSD be the data storage device of choice, with ChosenDSD being either hard disk drive (of the type mentioned above) or usb flash drive. Then:

- bootloader (GRUB) resides on ChosenDSD
- operating system (kernel image) resides on ChosenDSD
- userspace files (executables, etc.) reside on ChosenDSD
- filesystem used is EXT2

I plan to write everything from scratch, and that is the main cause of my dilemma. Generally I would prefer it if ChosenDSD is hard disk drive, however, the OSDev wiki seems to point out that SATA is difficult to work with. Just in case I am getting the wrong impression, or I am missing something, I decided I would ask here. I would also like to know if usb flash drive would be a poor choice for the ChosenDSD, given the usage scenario described above.

Various other information which may help in one way or the other:

The operating system will be very simple and minimalistic (no GUI, not portable accross various architectures, etc.), and I am not interested in "getting the most" out of the hardware involved. Despite the fact that I will be developing the o.s. in order to expand my knowledge, it would give me other benefits should I be able to make it successfuly run GCC, and various generated executables within ~ a year and a half from now.

I am very experienced in C and have fairly good knowledge of x86 assembly, the two being my languages of choice for this particular poject.

Re: Hard disk drive vs USB flash drive

Posted: Tue Jan 26, 2010 2:54 pm
by Owen
SATA is somewhat difficult to work with in native (AHCI) mode, but almost all SATA controllers start off behaving like nice old ATA drives.

(The exceptions tend to be 64 port SAS controllers and such :P )

Re: Hard disk drive vs USB flash drive

Posted: Tue Jan 26, 2010 3:02 pm
by pcmattman
however, the OSDev wiki seems to point out that SATA is difficult to work with
Well, for a start, the SATA specification isn't actually free. That already makes it a no-go for most people. Some also give up after reading the AHCI spec too ;)
but almost all SATA controllers start off behaving like nice old ATA drives
Will therefore be just fine for your purposes.

Re: Hard disk drive vs USB flash drive

Posted: Tue Jan 26, 2010 3:04 pm
by Combuster
Some SATA drives can be configured to emulate IDE (which is not guaranteed without problems - e.g. linux doesn't work on my laptop without the correct SATA driver, even when IDE emulation is enabled), and some bioses don't boot from USB (or it is picky about the USB's configuration). Neither way is thus guaranteed success. If regular ATA works, its by far the easiest. If it doesn't, USB is much better supported among the forum members, and probably the better choice because of that.

If you are however willing to stay in real mode (which makes using C rather difficult), you can ask the BIOS to read the disk in question for you, so you don't have to bother with your own drivers. You can also use that method to just pump the contents of the drive into RAM and don't bother with disk drivers at all - If you tell it to, GRUB can help you with that.

Since that doesn't really help in making a choice, I suggest you grab a IDE-enabled OS from somewhere and see if it can read an ext2 partition off your SATA drive. Pedigree likes to choke on my SATA controller, so if that happens to work for you, you can be fairly sure that the IDE interface is working decently enough.

In any case, good luck.

Re: Hard disk drive vs USB flash drive

Posted: Wed Jan 27, 2010 12:36 am
by 0x90
Thank you very much for the replies. I will give Pedigree a shot.