OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 3:27 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: (Solved) Putting files on Virtual HDDs
PostPosted: Sat Dec 16, 2017 3:34 pm 
Offline
Member
Member
User avatar

Joined: Fri Aug 07, 2015 6:13 am
Posts: 1134
Does anybody know if there is a way to put a file (Stage_2.sys) on a virtual FAT32 HDD partition without using loopback devices (I tried them but they are only good for filesystem formatting and suck for everything else, especially writing files and build automation)? I need a tool of some sort that can do that (both adding and removing files ofc).
If you know a way I would be grateful to know.

_________________
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader


Last edited by Octacone on Sun Dec 17, 2017 7:42 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Putting files on Virtual HDDs
PostPosted: Sun Dec 17, 2017 5:32 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
Mtools.


Top
 Profile  
 
 Post subject: (Solved) Putting files on Virtual HDDs
PostPosted: Sun Dec 17, 2017 6:59 am 
Offline
Member
Member
User avatar

Joined: Fri Aug 07, 2015 6:13 am
Posts: 1134
iansjack wrote:
Mtools.


I know they exist but there is 0 information online.
Cannot find a way to specify a partition of a virtual HDD...
I tried editing mtools config file and adding drive d: file="...HDD.img" partition=1, but no luck, partition not aligned, other errors etc... That is definitely not the right way of doing it...

This gives me, cannot initialize target, non dos media etc...
mcopy -i HDD.img Stage_2.sys ::/ (as you can see no way to specify a partition).

Edit:
Okay so I figured it out. To anybody in the future:
Put this inside your ~/.mtoolsrc
drive c: file="/path_to_your/HDD.img" partition=1 (1-4 are valid options) (the drive doesn't need to be labeled "c":)
mtools_skip_check=1
To copy a file to your virtual HDD partition use:
sudo mcopy Output/Stage_2.sys (your file) c: (your disk)
To delete a file from your virtual HDD partition use:
sudo mdel c:Stage_2.sys (your_drive:your_file)

_________________
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader


Top
 Profile  
 
 Post subject: Re: (Solved) Putting files on Virtual HDDs
PostPosted: Mon Dec 18, 2017 3:36 am 
Offline
Member
Member
User avatar

Joined: Sun Oct 22, 2006 7:01 am
Posts: 2646
Location: Devon, UK
Octacone wrote:
I know they exist but there is 0 information online.


https://www.gnu.org/software/mtools/manual/mtools.html

Cheers,
Adam


Top
 Profile  
 
 Post subject: Re: (Solved) Putting files on Virtual HDDs
PostPosted: Mon Dec 18, 2017 9:22 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
Octacone wrote:
(I tried them but they are only good for filesystem formatting and suck for everything else, especially writing files and build automation)

Writing files is easy, all you have to do is mount the partition:
Code:
mount /dev/loop0p1 /mnt
cp file1 file2 file3 /mnt
umount /mnt


Unfortunately, I couldn't tell you if it's possible to make this happen in the context of build automation. For that, mtools may be a better solution.


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: No registered users and 27 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