15

There are a lot of posts to show to create a virtual floppy image file as a super user or users can run sudo command. The basic steps are:

  1. create empty 1.44MB image file by dd command
  2. format the image file by mkfs.msdos
  3. mount the image file to some mount point
  4. copy something to the mount point
  5. umount the virtual floppy image file

my question is, in case I am just a common user who cannot run sudo command, how can I follow above steps to create a virtual floppy image and write something in it?

Thanks a lot.

1 Answer 1

30

Yes, of course you can do this. Use mtools for the FAT and e2tools or genext2fs for the ext2 filesystems.

$ dd if=/dev/zero of=/tmp/disk1.img count=1440 bs=1k 
1440+0 records in
1440+0 records out
1474560 bytes (1.5 MB) copied, 0.00569719 s, 259 MB/s

$ /sbin/mkfs.msdos /tmp/disk1.img 
mkfs.msdos 3.0.12 (29 Oct 2011)

$ mdir -i /tmp/disk1.img
 Volume in drive : has no label
 Volume Serial Number is 9913-BFF6
Directory for ::/

No files
                          1 457 664 bytes free

$ mcopy -i /tmp/disk1.img /etc/issue.net ::/
$ mdir -i /tmp/disk1.img
 Volume in drive : has no label
 Volume Serial Number is 9913-BFF6
Directory for ::/

issue    net        28 2012-06-26  10:49 
        1 file                   28 bytes
                          1 457 152 bytes free

And of course, I have no root rights.

6
  • Although mdir command not works for me, mcopy does work. Thank you. Commented Jul 4, 2012 at 8:57
  • 1
    Very elegant and simple solution. It worked very well to make an image for use in VirtualBox image of DOS 6.22.
    – kuzavas
    Commented Jun 15, 2015 at 10:24
  • how do I make this bootable?
    – Blub
    Commented Oct 5, 2017 at 16:28
  • @Blub: Use for example FreeDOS for that Commented Oct 7, 2017 at 11:14
  • For a DOS filesystem, you can combine the image/filesystem create with mkfs.msdos -C /tmp/disk1.img 1440. Where -C will "Create the file given as device on the command line." Commented Dec 17, 2017 at 21:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.