2008-06-02 18:29:26

by Christian Kujau

[permalink] [raw]
Subject: e2fsck: Device or resource busy

Hi there,

I'm trying to repair a severely damaged ext4 partition. Actually, I don't
care any more for the data, I just wanted to see how far I could get,
because the "damage" here is: the partition was 1/3 of a RAID-0 setup :)

So, if you're interested, read on. If not, please ignore this one...

So, after trying to (forcefully) repair an image of the parition[0], I'm
getting this now:

--------------------------------------------------------------
# losetup /dev/loop1 /mnt/cifs/backup/sdb2.img
# losetup -a
/dev/loop1: [0013]:1715743 (/mnt/cifs/backup/sdb2.img)

# file -s /dev/loop1
/dev/loop1: , 44.1 kHz, Stereo

# /opt/e2fsprogs/sbin/e2fsck /dev/loop1
e2fsck 1.41-WIP (27-Apr-2008)
/opt/e2fsprogs/sbin/e2fsck: Superblock invalid, trying backup blocks...
/opt/e2fsprogs/sbin/e2fsck: Bad magic number in super-block while trying to open /dev/loop1

The superblock could not be read or does not describe a correct ext2
filesystem. If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193 <device>

# /opt/e2fsprogs/sbin/e2fsck -b 8193 /dev/loop1
e2fsck 1.41-WIP (27-Apr-2008)
/opt/e2fsprogs/sbin/e2fsck: Device or resource busy while trying to open /dev/loop1
Filesystem mounted or opened exclusively by another program?

# losetup -a
/dev/loop1: [0013]:1715743 (/mnt/cifs/backup/sdb2.img)

# lsof -ln | grep loop
loop1 5065 0 cwd DIR 8,5 4096 2 /
loop1 5065 0 rtd DIR 8,5 4096 2 /
loop1 5065 0 txt unknown /proc/5065/exe
--------------------------------------------------------------

Does anyone have an idea why it says "Device or resource busy" as soon as
I specify an alternate superblock? Details and strace:
http://nerdbynature.de/bits/e2fsprogs.pu/sdb2/2008-06-02/


Thanks,
Christian.

[0] http://nerdbynature.de/bits/e2fsprogs.pu/sdb2/2008-05-25/
--
BOFH excuse #47:

Complete Transient Lockout


2008-06-02 20:21:59

by Theodore Ts'o

[permalink] [raw]
Subject: Re: e2fsck: Device or resource busy

On Mon, Jun 02, 2008 at 08:29:24PM +0200, Christian Kujau wrote:
> Hi there,
>
> I'm trying to repair a severely damaged ext4 partition. Actually, I don't
> care any more for the data, I just wanted to see how far I could get,
> because the "damage" here is: the partition was 1/3 of a RAID-0 setup :)

The key thing that you need to do when trying to recover from RAID
setups where you are missing one or more disks is to align the pieces
so they are in their original places, with the missing pieces replaced
with a /dev/zero device.

There is a starting point here which you may find helpful:

http://debian.co.nz/Recovery+of+RAID+and+LVM2.html

http://tldp.org/HOWTO/LVM-HOWTO/index.html

http://www.tldp.org/HOWTO/Software-RAID-HOWTO.html

(I'm assuming here you were using software RAID; if this was a
hardware RAID setup, then you need to know what sort of low-level
format was used by your hardware RAID device.)

- Ted

2008-06-02 22:24:11

by Christian Kujau

[permalink] [raw]
Subject: Re: e2fsck: Device or resource busy

On Mon, 2 Jun 2008, Theodore Tso wrote:
> The key thing that you need to do when trying to recover from RAID
> setups where you are missing one or more disks is to align the pieces
> so they are in their original places, with the missing pieces replaced
> with a /dev/zero device.

Hm, interesting, I did not consider that yet. Thanks for the links, I'll
have a look. But again: I don't really care for the data, I was just
playing around and wondering why it reported "Device or resource busy"
when I expected something like "unable to find superblock".

> (I'm assuming here you were using software RAID; if this was a

Yes, it was software RAID.

Thanks again,
Christian.
--
BOFH excuse #112:

The monitor is plugged into the serial port

2008-06-03 00:00:52

by Theodore Ts'o

[permalink] [raw]
Subject: Re: e2fsck: Device or resource busy

On Tue, Jun 03, 2008 at 12:23:48AM +0200, Christian Kujau wrote:
> On Mon, 2 Jun 2008, Theodore Tso wrote:
>> The key thing that you need to do when trying to recover from RAID
>> setups where you are missing one or more disks is to align the pieces
>> so they are in their original places, with the missing pieces replaced
>> with a /dev/zero device.
>
> Hm, interesting, I did not consider that yet. Thanks for the links, I'll
> have a look. But again: I don't really care for the data, I was just
> playing around and wondering why it reported "Device or resource busy"
> when I expected something like "unable to find superblock".

That will only happen if someone else has opened the device with
O_EXCL. Are you sure you didn't ^Z an e2fsck or some such and then
started a second one, or some such?

Is this repeatable?

- Ted