LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 07-08-2004, 09:40 AM   #1
tuxfood
Member
 
Registered: Aug 2003
Location: kerala , India
Distribution: RH9 , FC1 ,
Posts: 141

Rep: Reputation: 15
tried to make bootfloppy manually ..... but failed HELP


hi..

i tried to make a bootfloppy manually but failed.here is how i proceeded..

i first made a bootfloppy using /sbin/mkbootdisk

then i copied the contents of the floppy to a dir

i took another floppy and executed the following code

--------------------------------------------------------------------------

#include<stdio.h>
#include<unistd.h>
#include<fcntl.h>
(one more was there .. i forgot ..sorry)

main()
{

char boot_buff[2000*2000];
int by,file_desc,floppy_desc;

file_desc= open("floppy/vmlinuz");

by = lseek(file_desc,0,SEEK_END); //to know length of vmlinuz

int by1 = -1*by;

lseek(file_desc,by1,SEEK_CUR); //to go to beginning of vmlinuz

read(file_desc,boot_floppy,by);

floppy_desc = open("/dev/fd0",O_RDWR);

write(floppy_desc,boot_buff,by);

close(file_desc);
close(floppy_desc);

}

//i stopped at vmlinuz itself.. as it was not working
--------------------------------------------------------------------------------------------
the code doesnot work

i have a few doubts regarding this

doubts
----------

1) making a bootfloppy means that the contents of kernel image be copied from the first sector itself rite? doesn't this code ensure that?

2)there is a option in the function "fopen()" where a new file with the name supplied is created if the file doesn't exist...

does open() have a simillar option?

3)how can i make this code work?

4)are there methods to copy from the first sector onwards in DOS?

i.e functions lllr to open() read() etc?


plz reply

thnks

tuxfood
 
Old 07-08-2004, 10:51 AM   #2
kilgoretrout
Senior Member
 
Registered: Oct 2003
Posts: 2,333

Rep: Reputation: 144Reputation: 144
I haven't looked at any C++ code for a long time but your underlying premise:

Quote:
making a bootfloppy means that the contents of kernel image be copied from the first sector itself rite?
I believe is wrong. All boot floppies have a boot loader. In linux it's almost always syslinux. You write it to a floppy with this command:

# syslinux -s /dev/fd0

It puts a file on the floppy called ldlinux.sys at the appropriate place for the bios to find it on boot. The kernel image(vmlinuz) can be put anywhere on the floppy. Syslinux needs a text configuration file, syslinux.cfg, to tell it the name of the kernel to load and, if there is one, the name of the initrd file. There is usually another text config file for the initial text to display when the floppy first boots. In the booting process, the bios finds the syslinux boot loader and loads into into ram. The bootloader then runs loading the kernel per the settings in the config file.

I guess the short answer is linux(any OS really) needs a boot loader to boot; a kernel can't boot by itself no matter where you put it on the floppy. Also, I don't think it's possible to get a linux kernel small enough to fit on one sector. So I'm kind of puzzled by what your trying to do. Perhaps I've totally missed the point.
 
Old 07-09-2004, 07:38 AM   #3
tuxfood
Member
 
Registered: Aug 2003
Location: kerala , India
Distribution: RH9 , FC1 ,
Posts: 141

Original Poster
Rep: Reputation: 15
hi..

thnks for the reply ...

i think i have confused u a little..

in a word what i am trying to do is to achieve the work of /sbin/mkbootdisk

uising my own code.. (i hope u get the pic now)

anymore help greatly appreciated

thnks

tuxfood
 
Old 07-09-2004, 12:27 PM   #4
kilgoretrout
Senior Member
 
Registered: Oct 2003
Posts: 2,333

Rep: Reputation: 144Reputation: 144
See this post re how to make a boot floppy by hand:

http://www.mandrakeusers.org/index.p...topic=4324&hl=

You should be able to adapt that to your needs.
 
Old 07-12-2004, 07:57 AM   #5
tuxfood
Member
 
Registered: Aug 2003
Location: kerala , India
Distribution: RH9 , FC1 ,
Posts: 141

Original Poster
Rep: Reputation: 15
hi...

tnks for the reply ... it finally worked...

but what abt the other questions ... u know analogous functions in DOS for read() and open()

thks

tuxfood
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Boot error fsck.reiserfs failed Run Manually anerusmc Linux - Newbie 5 11-03-2009 08:34 PM
Fsck failed. Please repair manually and reboot. jginger Suse/Novell 4 10-23-2005 02:44 PM
how to make Linux router by creating Initrd manually and from scratch nikhilpavithran Linux - Software 1 07-29-2005 09:25 PM
How do I manually install NIC and How do I make lilo work? Dryfter Slackware 4 05-01-2005 06:06 PM
Boot error fsck.reiserfs failed Run Manually anerusmc Linux - Software 0 02-21-2004 10:49 PM


All times are GMT -5. The time now is 06:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration