Solved [Solved]Corrupted partition with wrong filesystem (UFS) size

First of all, I'm not an English speaker, so sorry for my bad English.

Here is the case:

This machine had a corrupted 10 GB partition and it had another 117 GB partition free, so I removed this bigger partition (with gpart(8)) and created two partitions: one of them with 15 GB and the other with 102 GB and then dump(8)ed the corrupted partition and restore(8)d it to the 15 GB one.

But I have done something wrong, as it seems, because the 15 GB partition is shown as a 117 GB partition on df(1). gpart(8) shows the right size, though. I didn't run newfs(8) on the new 15 GB partition before the dump(8) restore(8) procedure (I don't know if this is the problem).

Now, the system doesn't boot normally (but if I just exit single user mode it loads ok) because this partition is reported as corrupt (even though it's not) and when I run fsck_ufs(8) (with -b 160, otherwise it doesn't work) it finds a bunch of invalid bad blocks (at the 100 GB final part of the disk (of course, it doesn't exist!)).

I searched all over the Internet and I was unable to find a way to fix it without reformatting it. Maybe you can help. Thanks.
 
Re: Corrupted partition with wrong filesystem (UFS) size

restore(8) works at the filesystem level. It's somewhat surprising it would restore to an unformatted partition. It would be best to restore to a second disk or a USB memory stick to avoid unintentional damage to the original. Either way, use newfs(8) on the new partition, and remember to cd to it before starting the restore.
 
Re: Corrupted partition with wrong filesystem (UFS) size

leoreiss said:
But I have done something wrong, as it seems, because the 15 GB partition is shown as a 117 GB partition on df(1). gpart(8) shows the right size, though. I didn't run newfs(8) on the new 15 GB partition before the dump(8) restore(8) procedure (I don't know if this is the problem).
Could be. Since you didn't newfs(8) the partition, the system is just interpreting whatever metadata used to be there, which doesn't reflect the new partition. This can cause all sorts of problems, such as writing past the end of the partition and corrupting data elsewhere on the disk.
 
Re: Corrupted partition with wrong filesystem (UFS) size

So, there's no solution except to format this partition and run dump/restore again? I don't want to cause another outage period.
 
Re: Corrupted partition with wrong filesystem (UFS) size

Again: don't use the same disk, it is just too easy to blow away the only copy. And there doesn't have to be an outage, dump(8) can back up mounted filesystems. Although that can miss changes to files that were open.
 
Re: Corrupted partition with wrong filesystem (UFS) size

I created a new partition at another disk and ran dump(8), but it didn't work (because of read errors at the end of the disk), so I did
Code:
cd /old
cp -axR * /mnt/new
(copied the content to the new partition), edited fstab, rebooted and all went ok.

Thanks! Solved.
 
Back
Top