mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: "dd" collapsed the loop device
@ 2002-01-14 18:09 Jesse Pollard
  0 siblings, 0 replies; 5+ messages in thread
From: Jesse Pollard @ 2002-01-14 18:09 UTC (permalink / raw)
  To: mylinuxk, linux-kernel

---------  Received message begins Here  ---------

> 
> 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?

Nope. User error....

A mounted floppy has a file system on it. The first block is boot block,
super block... inode list.... ( or whatever M$ uses ).

A dd to the DEVICE starts writing at block 0. replaces the bootblock, for
as many blocks as are in the file.

This, naturally, destroys the filesystem.

-------------------------------------------------------------------------
Jesse I Pollard, II
Email: pollard@navo.hpc.mil

Any opinions expressed are solely my own.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: "dd" collapsed the loop device
  2002-01-14 18:40   ` Michael Zhu
@ 2002-01-14 20:06     ` Andreas Dilger
  0 siblings, 0 replies; 5+ messages in thread
From: Andreas Dilger @ 2002-01-14 20:06 UTC (permalink / raw)
  To: Michael Zhu; +Cc: linux-kernel

On Jan 14, 2002  13:40 -0500, Michael Zhu wrote:
> 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?

Now that you know it is bad, don't do that.

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: "dd" collapsed the loop device
  2002-01-14 18:18 ` Andreas Dilger
@ 2002-01-14 18:40   ` Michael Zhu
  2002-01-14 20:06     ` Andreas Dilger
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Zhu @ 2002-01-14 18:40 UTC (permalink / raw)
  To: Andreas Dilger; +Cc: linux-kernel

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


--- Andreas Dilger <adilger@turbolabs.com> wrote:
> On Jan 14, 2002  12:54 -0500, Michael Zhu wrote:
> > Hello,everyone,I have a problem when I used the
> loop
> > device. I don't know whether is a loop device bug.
> 
> User 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. 
> 
> Great.
> 
> > 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.
> 
> 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
> 
> > 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?
> 
> 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/
> 


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: "dd" collapsed the loop device
  2002-01-14 17:54 Michael Zhu
@ 2002-01-14 18:18 ` Andreas Dilger
  2002-01-14 18:40   ` Michael Zhu
  0 siblings, 1 reply; 5+ messages in thread
From: Andreas Dilger @ 2002-01-14 18:18 UTC (permalink / raw)
  To: Michael Zhu; +Cc: linux-kernel

On Jan 14, 2002  12:54 -0500, Michael Zhu wrote:
> Hello,everyone,I have a problem when I used the loop
> device. I don't know whether is a loop device bug.

User 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. 

Great.

> 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.

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

> 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?

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/


^ permalink raw reply	[flat|nested] 5+ messages in thread

* "dd" collapsed the loop device
@ 2002-01-14 17:54 Michael Zhu
  2002-01-14 18:18 ` Andreas Dilger
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Zhu @ 2002-01-14 17:54 UTC (permalink / raw)
  To: linux-kernel

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-01-14 20:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-14 18:09 "dd" collapsed the loop device Jesse Pollard
  -- strict thread matches above, loose matches on Subject: below --
2002-01-14 17:54 Michael Zhu
2002-01-14 18:18 ` Andreas Dilger
2002-01-14 18:40   ` Michael Zhu
2002-01-14 20:06     ` Andreas Dilger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®