I have an SD card with an official FreeBSD image on it.
A few days ago the filesystem got corrupted because the power supply was interrupted before I could do a clean shutdown.
I tried to repair the filesystem: I put the SD card in a card reader and attached it to my desktop. The slice with the root
filesystem shows up as /dev/da1s2a. I tried running
fixed but at the end the filesystem was still dirty. I ran the command several times but I always got the same errors
again and again.
So I mounted the filesystem and did a backup with
untar all the files back to the SD. If the system boots, I want to reinstall all packages, in case some files have
been deleted or got corrupted. With some luck, I hope this will give me my previous system back.
In order to reformat the slice, I ran
which produced:
If I understand correctly, this command should format the slice with exactly the same parameters as before.
I then ran the command and got the output:
I was a bit surprised that the command ran very fast, as if it did not do anything at all. So I mounted the filesystem and, indeed, the whole old content is still there. If I run
So my question are: why does
A few days ago the filesystem got corrupted because the power supply was interrupted before I could do a clean shutdown.
I tried to repair the filesystem: I put the SD card in a card reader and attached it to my desktop. The slice with the root
filesystem shows up as /dev/da1s2a. I tried running
fsck -y /dev/da1s2a
. Several errors werefixed but at the end the filesystem was still dirty. I ran the command several times but I always got the same errors
again and again.
So I mounted the filesystem and did a backup with
tar
. My plan is now to reformat the slice anduntar all the files back to the SD. If the system boots, I want to reinstall all packages, in case some files have
been deleted or got corrupted. With some luck, I hope this will give me my previous system back.
In order to reformat the slice, I ran
sudo dumpfs -m /dev/da1s2a > ../fmt.sh
which produced:
newfs -L rootfs -O 2 -U -a 4 -b 32768 -d 32768 -e 4096 -f 4096 -g 16384 -h 64 -i 8192 -k 2576 -m 8 -o time -s 15636352 /dev/da1s2a
If I understand correctly, this command should format the slice with exactly the same parameters as before.
I then ran the command and got the output:
/dev/da1s2a: 7634.9MB (15636352 sectors) block size 32768, fragment size 4096
using 13 cylinder groups of 626.09MB, 20035 blks, 80256 inodes.
with soft updates
super-block backups (for fsck_ffs -b #) at:
192, 1282432, 2564672, 3846912, 5129152, 6411392, 7693632, 8975872, 10258112, 11540352, 12822592, 14104832, 15387072
I was a bit surprised that the command ran very fast, as if it did not do anything at all. So I mounted the filesystem and, indeed, the whole old content is still there. If I run
fsck
, all the old errors are still there.So my question are: why does
newfs
do nothing on this filesystem? Is there a way to force it to create a new filesystem, overwriting the old one?