Skip to contentSkip to conversation

"dd" collapsed the loop device

DISCUSSION Michael Zhu 2 participants 4 messages Jan 14, 2002

lore
Share & tools
lore
#0 lore raw

Hello,everyone,I have a problem when I used the loop device. I don't know whether is a loop device bug. I used the following commands to connect the loop device with the floppy disk device.

losetup -e xor /dev/loop0 /dev/fd0
mke2fs /dev/loop0
mount /dev/loop0 /floppy

Then I copy something to the floppy and read it back. Everything is OK. It works perfectly.

The problem was happened when I try to copy something directly from the /dev/fd0. I use the following demand.

dd if=test.c of=/dev/fd0

The output of the upper command is:
50+1 records in
50+1 records out

Then I used the "ls /floppy". I found nothing copied to the floppy. Then I used "umount /floppy" to umount the floppy disk device. After that I used the following command to try to mount the floppy disk again.

mount /dev/loop0 /floppy

It returned an error. Say:

mount: wrong fs type. bad option. bad superblock on /dev/loop0. or too many mounted file systems

It seemed that the "dd if=test.c of=/dev/fd0" corrupted the data on the floppy disk. What is wrong? What happened to the floppy disk? Is it a bug of the loop device?

Thanks

Michael

______________________________________________________________________
Web-hosting solutions for home and business! http://website.yahoo.ca

#1 lore raw
Quoted 2 lines · Michael Zhu

Hello,everyone,I have a problem when I used the loop device. I don't know whether is a loop device bug.

User bug.

Quoted 9 lines

I used the following commands to connect the loop device with the floppy disk device.

losetup -e xor /dev/loop0 /dev/fd0
mke2fs /dev/loop0
mount /dev/loop0 /floppy

Then I copy something to the floppy and read it back. Everything is OK. It works perfectly.

Great.

Quoted 4 lines

The problem was happened when I try to copy something directly from the /dev/fd0. I use the following demand.

Quoted 8 lines

dd if=test.c of=/dev/fd0

The output of the upper command is:
50+1 records in
50+1 records out

Then I used the "ls /floppy". I found nothing copied to the floppy.

Well, this is wrong for several reasons:
1) don't access /dev/fd0 when you use it via loopback, use /dev/loop0
2) don't use "dd" to copy a file, use "cp"
3) don't write into the device, but the filesystem instead:
cp test.c /floppy

Quoted 6 lines

Then I used "umount /floppy" to umount the floppy disk device. After that I used the following command to try to mount the floppy disk again.

mount /dev/loop0 /floppy

Quoted 7 lines

It returned an error. Say:

mount: wrong fs type. bad option. bad superblock on /dev/loop0. or too many mounted file systems

It seemed that the "dd if=test.c of=/dev/fd0" corrupted the data on the floppy disk. What is wrong?

Because test.c is not a filesystem, and you have overwritten the filesystem on /dev/fd0 with junk. This is not a bug in the loop driver.

Cheers, Andreas
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/

#2 lore raw

That means that I couldn't access /dev/fd0 directly when I use it via loopback? Is there any way that I can use to avoid this accident erase?

Michael

Quoted 68 lines · --- Andreas Dilger
Quoted 1 line · Michael Zhu

Hello,everyone,I have a problem when I used the

loop

Quoted 1 line

device. I don't know whether is a loop device bug.

User bug.

Quoted 1 line

I used the following commands to connect the loop

device

Quoted 7 lines

with the floppy disk device.

losetup -e xor /dev/loop0 /dev/fd0
mke2fs /dev/loop0
mount /dev/loop0 /floppy

Then I copy something to the floppy and read it

back.

Quoted 1 line

Everything is OK. It works perfectly.

Great.

Quoted 1 line

The problem was happened when I try to copy

something

Quoted 10 lines

directly from the /dev/fd0. I use the following
demand.

dd if=test.c of=/dev/fd0

The output of the upper command is:
50+1 records in
50+1 records out

Then I used the "ls /floppy". I found nothing

copied

Quoted 1 line

to the floppy.

Well, this is wrong for several reasons:
1) don't access /dev/fd0 when you use it via loopback, use /dev/loop0
2) don't use "dd" to copy a file, use "cp"
3) don't write into the device, but the filesystem instead:
cp test.c /floppy

Quoted 1 line

Then I used "umount /floppy" to umount the floppy

disk

Quoted 1 line

device. After that I used the following command to

try

Quoted 7 lines

to mount the floppy disk again.

mount /dev/loop0 /floppy

It returned an error. Say:

mount: wrong fs type. bad option. bad superblock

on

Quoted 4 lines

/dev/loop0. or too many mounted file systems

It seemed that the "dd if=test.c of=/dev/fd0"
corrupted the data on the floppy disk. What is

wrong?

Because test.c is not a filesystem, and you have overwritten
the filesystem on /dev/fd0 with junk. This is not a bug
in the loop driver.

Quoted 6 lines

Cheers, Andreas
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/

______________________________________________________________________
Web-hosting solutions for home and business! http://website.yahoo.ca