LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   creating floppy images from directory (https://www.linuxquestions.org/questions/linux-newbie-8/creating-floppy-images-from-directory-643267/)

vadkutya 05-19-2008 11:11 AM

creating floppy images from directory
 
i am trying to create floppy images from a given directory. like e.g. the slackware rootdisk images. how do i do it?

i found a lot of stuff about making images from a floppy disk. or copying an image to a floppy disk but nothing about creating floppy images from directories. is it the same as with cd images. what's the fs type?

thx vadkutya

jailbait 05-19-2008 01:25 PM

You create a floppy image by copying a floppy using dd:

dd if=/dev/fd0 of=/tmp/floppy.image

If your data is currently in a file in a directory then copy the file to a clean floppy using the cp command and then use the dd command to copy the floppy to a floppy image file.

You can also make a floppy image directly from a data file without using a floppy intermediate. Mount a file on a loopback device and then use mkfs and dd to create a floppy partition on the loopback device. Then copy the data file to the loopback device.

Using a floppy intermediate is easier.

---------------------
Steve Stites

vadkutya 05-19-2008 01:40 PM

thx jailbait,

the floppy intermediate solution is quite obviouse. no wonder it didn't come to my mind ;). the second solution though would be more interesting. i know how to mount iso as loop device but the rest is beyond me? care to enlight me?

vadkutya

i92guboj 05-19-2008 01:59 PM

Quote:

Originally Posted by vadkutya (Post 3158228)
thx jailbait,

the floppy intermediate solution is quite obviouse. no wonder it didn't come to my mind ;). the second solution though would be more interesting.

You can mount any file which holds a filesystem as a loopback device. So, the trick would basically be the following:

1.- create a file full of zeroes which is exactly the same size of a floppy, you use dd for this (man dd). Tip: use /dev/zero as input source.

2.- format the file with the relevant filesystem. This can be any filesystem of your choice. It depends on what you are doing to do with the floppy. If you are going to create a linux disk, you probably want mkfs.ext2 or mkfs.ext3. If you want to use it in windows or dos, then you have many options, like mkfs.vfat or mkfs.msdos

3.- mount -o loop it.

4.- put anything you want into it.

5.- dump the image (with dd again) into the relevant device if you want.

vadkutya 05-19-2008 02:35 PM

thank you very much :)

vadkutya

vadkutya 05-19-2008 03:11 PM

i spoke to soon. i have problems with point 2 "format the file with the relevant filesystem". ok, first i created a file full of zeros with:
Code:

dd if=/dev/zero ibs=10 count=144 of=~/a0_bin.img
144+0 records in
2+1 records out

worked just fine:
Code:

ls -l a0_bin.img
-rw-r--r--  1 as users 1440 2008-05-19 21:43 a0_bin.img

but when i try to format the file as suggested:
Code:

# mke2fs -c -v a0_bin.img
mke2fs 1.38 (30-Jun-2005)
a0_bin.img is not a block special device.
Proceed anyway? (y,n) y
a0_bin.img: Invalid argument passed to ext2 library while setting up superblock

google search on "Invalid argument passed to ext2 library while setting up" is too much about bad superblock of hd's. read the man page of mke2fs. didn't find anything file specific. am i missing an option?

vadkutya

i92guboj 05-20-2008 02:42 AM

Quote:

Originally Posted by vadkutya (Post 3158317)
google search on "Invalid argument passed to ext2 library while setting up" is too much about bad superblock of hd's. read the man page of mke2fs. didn't find anything file specific. am i missing an option?

vadkutya

Well, I think that the problem is that the file is way too small (1.5kb). It can't even hold the basic ext2 structures.

You need to do the first step this way to get a bigger file:

Code:

dd if=/dev/zero ibs=1024 count=1440 of=~/a0_bin.img

vadkutya 05-20-2008 04:47 AM

thanks a lot, man. all steps work flawlessly. i am most greatful

vadkutya

vadkutya 05-21-2008 09:18 AM

i thought i write the whole procedure down with all the commands involved just in case i forget them ;):

1. creating a file of 1.44 MB full of zeros which will later serve as image file:
Code:

$ dd if=/dev/zero ibs=1024 count=1440 of=$IMGFILE
2. creating a filesystem in it (e.g. ext2) with mke2fs or mkfs.ext2:
Code:

# mke2fs $IMGFILE
3. mounting the file on a loop device:
Code:

# mount -o loop -t ext2 $IMGFILE /mnt
4. copy data
5. unmount the file:
Code:

# umount /mnt
EOP

vadkutya


All times are GMT -5. The time now is 04:32 PM.