OSDev.org
https://forum.osdev.org/

(Solved) Putting files on Virtual HDDs
https://forum.osdev.org/viewtopic.php?f=11&t=32640
Page 1 of 1

Author:  Octacone [ Sat Dec 16, 2017 3:34 pm ]
Post subject:  (Solved) Putting files on Virtual HDDs

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.

Author:  iansjack [ Sun Dec 17, 2017 5:32 am ]
Post subject:  Re: Putting files on Virtual HDDs

Mtools.

Author:  Octacone [ Sun Dec 17, 2017 6:59 am ]
Post subject:  (Solved) Putting files on Virtual HDDs

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)

Author:  AJ [ Mon Dec 18, 2017 3:36 am ]
Post subject:  Re: (Solved) Putting files on Virtual HDDs

Octacone wrote:
I know they exist but there is 0 information online.


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

Cheers,
Adam

Author:  Octocontrabass [ Mon Dec 18, 2017 9:22 am ]
Post subject:  Re: (Solved) Putting files on Virtual HDDs

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.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/