PDA

View Full Version : Don't trust mount!



fozner
25th November 2007, 01:17 PM
Don't trust mount command!

Scenario: I wanted to back up my drive, so I hooked up a blank drive to another controller cable in my machine and booted up. To see which drive had the data and which drive was blank, I ran mount:

$ mount
/dev/sda2 on / type ext3 (rw)

So naturally I figured since mount said so that /dev/sda was mounted, /dev/sdb was blank, right?

Then I went like this:

$ dd if=/dev/sda of=/dev/sdb bs=8225280 count=7296

The result? two blank hard disks and a day's work down the drain!

Don't trust mount

I don't know if this is a bug, whether it is a bug in mount, mtab or init, but something is reporting not right the status of mounted devices. Maybe if I could find what done it, I would file a bug report.

Wayne
25th November 2007, 01:26 PM
Did you partition/format sdb?

Edit: Also, did you create a mount point? For example, I have a mount point:

/mnt/drive

and when I want to mount partitions that are on sda (my boot drive is sdb) I use:

mount /dev/sdaX /mnt/drive

Where X is the partition I want to see. No problems so far.

Wayne

fozner
25th November 2007, 01:34 PM
Even better. I copied the blank drive over the good one, blanking it. Turns out / was actually mounted on /dev/sdb not /dev/sda as mount said. I know my glasses are a few years old but I don't miss details like that.

What I think happened is my system was used to booting to /dev/sda but the drive was actually connected to the second controller so when I hooked up the new drive the old one was automatically changed to /dev/sdb and booted to /dev/sdb only for some reason when this happens it still reports that it is mounted on /dev/sda. Confusing!

glennzo
25th November 2007, 01:46 PM
Hmmmm... Somehow I don't think the problem lies with the mount command :eek:

PilotJLR
25th November 2007, 02:23 PM
This is not a bug, and it has nothing to do with mount.
/dev assignments are not permanent unless you make udev entries... so when you add or remove devices, they may get new /dev assignments, as you saw.
The solution to this is to make udev entries to statically map them, or use filesystem labels. Labels are easy, and that's what the default fedora install does.

fozner
25th November 2007, 02:45 PM
Yeah I didn't think it was a bug. Just a little something that makes you stand up and take notice. mount, /etc/mtab and friends aren't necessarily accurate in their reporting of what goes where. This used to be a FC3 install and I don't believe it was using labels. On the bright side, it's now a brand new F8 install, since I wiped it and started fresh, with data files from yesterday. No big deal. I will find some way blame it on Steve.

Brian1
25th November 2007, 03:23 PM
Here is a thought if connected to a second cable then would the drive not be seen as /dev/sdc if the only drive attached to it. Is there two harddrives on the first cable?

Brian

CD-RW
25th November 2007, 09:35 PM
as a side note regarding mount. Sometimes in the past it has not reported disks I have manually mounted, as actually being mounted, when they are. So I use df -m which seems to give a more accurate report of currently mounted drives/partitions.

Reason being I like to mount my backup partition, do backups, then unmount it right away. I don't like to leave it permanently mounted.