OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 9:53 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: "mcopy" command says "Disk full" when copying kernel.elf
PostPosted: Fri Jul 02, 2021 11:20 am 
Offline

Joined: Thu Jul 01, 2021 3:24 pm
Posts: 16
Hello! I've encountered a problem that stumps me. When creating a disk image for x86-64 UEFI, the "mcopy" command keeps saying "Disk full" whenever I try to copy the kernel.elf to its root directory. This only happened a few hours ago and it was working fine for the last few days. It started happening after I used -mcmodel=kernel, but I don't know if that is what is causing it. The ELF file is only 2 MB, and the disk is 48MB, so there shouldn't be a problem of lack of space.
Below are the commands I'm running to make the disk:
Code:
dd if=/dev/zero of=$(BUILDDIR)/$(OSNAME).img bs=512 count=93750
   mformat -i $(BUILDDIR)/$(OSNAME).img -f 1440 ::
   mmd -i $(BUILDDIR)/$(OSNAME).img ::/EFI
   mmd -i $(BUILDDIR)/$(OSNAME).img ::/EFI/BOOT
   mcopy -i $(BUILDDIR)/$(OSNAME).img $(BOOTEFI) ::/EFI/BOOT
   mcopy -i $(BUILDDIR)/$(OSNAME).img startup.nsh ::
   mcopy -i $(BUILDDIR)/$(OSNAME).img $(BUILDDIR)/kernel.elf ::

I reiterate, this only started happening after I cross compiled my gcc and ld for x86_64 and used -mcmodel=kernel. Any ideas on how to fix this?


Top
 Profile  
 
 Post subject: Re: "mcopy" command says "Disk full" when copying kernel.elf
PostPosted: Fri Jul 02, 2021 11:24 am 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 1584
What does
Code:
du -hs *.elf *.img
say?

Have you tried mounting the image through a loopback device and copying kernel.elf as usual? Does that work?

Cheers,
bzt


Top
 Profile  
 
 Post subject: Re: "mcopy" command says "Disk full" when copying kernel.elf
PostPosted: Fri Jul 02, 2021 12:13 pm 
Offline

Joined: Thu Jul 01, 2021 3:24 pm
Posts: 16
bzt wrote:
What does
Code:
du -hs *.elf *.img
say?

It says 8 KB for the kernel and 48 MB for the disk.

bzt wrote:
Have you tried mounting the image through a loopback device and copying kernel.elf as usual? Does that work?

Yeah I did that just now, but the kernel wouldn't boot.

So the disk gets made properly with the elf generated from my native gcc, but not from my cross compiled one. So there lies the problem.
Thanks for your help!


Top
 Profile  
 
 Post subject: Re: "mcopy" command says "Disk full" when copying kernel.elf
PostPosted: Fri Jul 02, 2021 12:43 pm 
Offline

Joined: Thu Jul 01, 2021 3:24 pm
Posts: 16
Okay I figured out the problem, I was not using the -no-red-zone flag with ld smh.


Top
 Profile  
 
 Post subject: Re: "mcopy" command says "Disk full" when copying kernel.elf
PostPosted: Mon Jul 05, 2021 7:00 pm 
Offline
Member
Member

Joined: Mon Jul 05, 2021 6:57 pm
Posts: 118
Code:
  mformat -i $(BUILDDIR)/$(OSNAME).img -f 1440 ::


You are trying to copy a 2Mb kernel to a filesystem formatted as 1.44Mb :wink:


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Majestic-12 [Bot] and 70 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group