Strange issue with root partition

I have a strange issue with my root partition.
  • Each time my box reboot I get this error:
    Code:
    ...
    Starting file system checks:
    /dev/ada0s2a: NO WRITE ACCESS
    /dev/ada0s2a: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.
    ...
  • In that moment the partition is mounted in / in read-write mode.
  • Then, I go to single mode, mount the partition in read-only mode and run fsck:
    Code:
    [cmd=#]mount -r /dev/ada0s2a[/cmd]
    [cmd=#]fsck /dev/ada0s2a[/cmd]
    ...
    USE JOURNAL ? [yn] <---- "y"
    ...
    RECOVER ? [yn] <---- "y"
    ...
    *** FILE SYSTEM MARKED CLEAN ***
  • Then, exit from single mode and the system boots normally.
 
wblock@ said:
Don't mount the partition. Just run fsck(8) on it:
# fsck -tufs -y /dev/ada0s2a

Hi,

ada0s2a is my root partition, not mounting is not a option.

I find more information about this issue: FreeBSD try to check my root partition (read-write mounted) with -p (preen mode) . The man page says: In preen mode, only a restricted class of innocuous file system inconsistencies will be corrected. If unexpected inconsistencies caused by hardware or software failures are encountered, the check program will exit with a failure.

The questions are:
  1. Why does FreeBSD try to check my root partition in "preen mode"?
  2. Why not just enter in "Fast mode"?
  3. Is the message "UNEXPECTED INCONSISTENCY" just a generic message?
Thanks.
 
cahimira said:
Hi,

ada0s2a is my root partition, not mounting is not a option.

It is already mounted read-only. Don't assume that you need to mount it again. Just run fsck(8) on it with as little messing with it as possible.
 
wblock@ said:
It is already mounted read-only. Don't assume that you need to mount it again. Just run fsck(8) on it with as little messing with it as possible.

Hi,

That is the point. When FreeBSD drops me to single mode, the root partition is mounted in "read-write" mode. FreeBSD mount the root partition in "read-write" mode and then try to do a fsck -p on that partition.

Thanks.
 
After booting in single user mode:
Code:
# mount
/dev/gpt/tinyfs on / (ufs, local, read-only)
devfs on /dev (devfs, local, multilabel)

If single user mode starts with a read/write mount, something has been changed from the defaults. fsck(1) is used after a power loss in multiuser mode, but that can be disabled in /etc/rc.conf.
 
Try with the GENERIC kernel. Maybe you don't have soft updating enabled (if you use a custom kernel), and so each reboot is giving you this problem. In this case, make sure you have the following options enabled (uncommented) in your kernel configuration file:
Code:
options FFS           # Berkeley Fast Filesystem
options SOFTUPDATES   # Enable FFS soft updates support
options UFS_GJOURNAL  # Enable gjournal-based UFS journaling

If you have all the defaults enabled and you are indeed running the GENERIC kernel (which means you already have soft updates enabled), you could try to use the live media, from which you installed FreeBSD, for maintenance.
  1. Boot from LiveCD/LiveUSB.
  2. Choose LiveCD when prompted by installer.
  3. When prompted for a user name, log in as `root'. There is no password.
  4. Don't mount anything.
  5. Run # fsck -t ufs -fy /dev/ada0s2 for your root (/) partition. Optionally you can do it for each of them (except for swap).
  6. Reboot your computer, and start from your system (not from your live medium).
  7. fsck -fy might break some shared libraries -- if you see errors like, vim cannot find this shared library, or musicpd cannot start because of that, simply rebuild those ports with all dependencies (for the following example I will demonstrate with editors/vim and audio/musicpd). I would suggest using ports-mgmt/portupgrade to do that, e.g.
    Code:
    # portupgrade -Rf editors/vim audio/musicpd
    or if you prefer ports-mgmt/portmaster:
    Code:
    # portmaster -R /usr/ports/editors/vim /usr/ports/audio/musicpd
Step `5)' will rebuild your journal (that's what the -f flag does) even if your filesystem has been marked clean, so it may take a while (OK, not that long, I have to wait around 1-2 minutes).

I hope this will help.

Cheers!
 
Ok,

I run this test:
  1. Power on my box.
  2. I choose 'boot in single mode'.
  3. FreeBSD boots and shows:
    Code:
    Enter full pathname of shell...
    then I press ENTER and get shell as root.
  4. I run mount, and get:
    Code:
    /dev/ada0s2a on / (ufs, local, noatime, read-only)
    devfs on /dev (devfs, local, multilabel)
  5. Then, I press ^D and enter in multiuser mode.
  6. FreeBSD shows
    Code:
    Fast boot: skipping disk checks. ... Starting background file system checks in 60 seconds.
    and get the login prompt.
  7. Then, I log in as root and get the shell and run reboot and my box reboots.
    (all normal here)
  8. My box boots in the default multiuser mode.
  9. Then I get this message:
    Code:
    Starting file system checks:
    /dev/ada0s2a: NO WRITE ACCESS
    ...
    Enter full pathname of shell...
  10. I press ENTER and get the shell.
  11. Run mount and get:
    Code:
    /dev/ada0s2a on / (ufs, local, noatime, journaled soft-updates)
    devfs on /dev (devfs, local, multilabel)
I don't understand why if I boot in multiuser FreeBSD tries to check my root partition, but if I boot in single user mode first, then in multiuser the filesystem check is skipped.

Thanks.
 
jozze said:
Try with the GENERIC kernel. Maybe you don't have soft updating enabled (if you use a custom kernel), and so each reboot is giving you this problem. In this case, make sure you have the following options enabled (uncommented) in your kernel configuration file:
Code:
options FFS           # Berkeley Fast Filesystem
options SOFTUPDATES   # Enable FFS soft updates support
options UFS_GJOURNAL  # Enable gjournal-based UFS journaling

If you have all the defaults enabled and you are indeed running the GENERIC kernel (which means you already have soft updates enabled), you could try to use the live media, from which you installed FreeBSD, for maintenance.

No luck :(

I boot with my FreeBSD LiveUSB, run fsck and I get the same. I use a GENERIC kernel.

Thanks.
 
An important thing to realize is that in single user mode, the normal startup scripts do not run. Look at /etc/rc.d/fsck.

Some people disable the background checks in rc.conf:
Code:
background_fsck="NO"

I think that the background checks fail at repairing the filesystem but manage to mark it as okay. A full fsck(8) in single user mode actually fixes it.
 
wblock@ said:
An important thing to realize is that in single user mode, the normal startup scripts do not run. Look at /etc/rc.d/fsck.

Some people disable the background checks in rc.conf:
Code:
background_fsck="NO"

I think that the background checks fail at repairing the filesystem but manage to mark it as okay. A full fsck(8) in single user mode actually fixes it.

No luck :(

I disable background checks in rc.conf. I do a full fsck(8) in single user mode. But the issue persists. Each time I boot FreeBSD it tries to check my root device.

Thanks.
 
I have more information:
  • Filesystem check is executed because a variable $autoboot has a "YES" has value.
  • fsck exit status: 8
 
There is a resume:
  • If I boot FreeBSD in multiuser mode from loader (default boot option), fsck always will be executed in preen mode (in foreground or background based on $background_fsck). That is totally normal.
  • Ok, the problem (for me) is the "preen mode". If I execute fsck in "preen mode" ( fsck -p), it always fails.
  • There is the tests:

    TEST 1 - Preen mode, root device mounted as read-only

    Code:
    # mount -r /
    # fsck -p
    /dev/ada0s2a: FILE SYSTEM CLEAN; SKIPPING CHECKS

    TEST 2 - Preen mode, root device mounted as read-write

    Code:
    # mount -w /
    # fsck -p
    /dev/ada0s2a: NO WRITE ACCESS
    /dev/ada0s2a: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY
    (Exit status = 8)

    TEST 3 - Full test, root device mounted as read-only

    Code:
    # mount -r /
    # fsck /
    ** /dev/ada0s2a
    
    USE JOURNAL [yn] y
    
    ** SU+J Recovering /dev/ada0s2a
    ** Reading 33554432 byte journal from inode 4.
    
    RECOVER [yn] y
    
    ** Building recovery table.
    ** Resolving unreferenced inode list.
    ** Processing journal entries.
    
    ***** FILE SYSTEM MARKED CLEAN *****

    TEST 4 - Full test (again), root device mounted as read-only

    Code:
    # fsck /
    ** /dev/ada0s2a
    
    USE JOURNAL [yn] y
    
    ** SU+J Recovering /dev/ada0s2a
    Journal timestamp does not match fs mount time
    ** Skipping journal, falling through to full fsck
    
    ** Las Mounted on /
    ** Root file system
    ** Phase 1 - Check Blocks and Sizes
    ** Phase 2 - Check Pathnames
    ** Phase 3 - Check Connectivity
    ** Phase 4 - Check Reference Counts
    ** Phase 2 - Check Cyl groups
    14094 files, 131293 used, 3675042 free (762 frags, 456285 blocks, 0.0% fragmentation)
    
    ***** FILE SYSTEM IS CLEAN *****
    
    ***** FILE SYSTEM WAS MODIFIED *****
 
Back
Top