Running FSCK in single-user mode

Posted on 2006-04-04
Last Modified: 2013-12-16
I have a FC3 system that is giving me disk errors. I'm new to linux and I know I need to run FSCK. I tried to do this by SSH'ing in, but then got the error that if I don't run FSCK in single-user mode I could corrupt the disk and/or files. So my question is, how do I start the system in runlevel1 ~ i.e. single-user mode.
I know that currently I'm using runlevel 5 (with the gui) how do I switch to single-user mode so I can run FSCK and repair any errors that there may be.
Thanks in advance!
Question by:chunkyshu
    LVL 7

    Accepted Solution

    use the init command:

    1) open a terminal as root (su root)
    2) type init 1
    The system will shut down to a single command prompt.,  now you can run your disk commands.
    WHen finished, type init 5 to restore the GUI

    By the way, running fsck on mounted filesystems is a bad idea, try this instead

    1) umount -a                   # unmount all filesystems except rootfs
    2) mount / -oremount,ro   # now even root is ro, this is safe to use fsck on
    3) fsck -a -f                      # force fsck to run on all drives
    4) mount / -oremount,rw   # remount the rootfs again
    5) mount -a                       # bring rest of filesystems back online
    6) init 5 (or even better init 3)

    Note:  if fsck says ** REBOOT LINUX **, always obey.

    One final comment, I always prefer a integral system over a fast booting one, so add the following to the
    file "/etc/sysconfig/autofsck", this file does not exist by default:

    # Force autofsck in case of system failure

    Now if the system reboots on you and the drives were not unmounted, an fsck is done by default.
    Why this is not the builtin behavior is beyond me.

    LVL 22

    Expert Comment

    Might be easier to do it from the consol instead of via ssh as in run mode 1, (init 1), you may find that ssh will not run (or at least is a lot of hassle to get running!) Also, if you need to run fsck on the partition that contains the operating system, you need to unmount the partition before you can carry out the fsck process.

    To that end, I will normally boot from CD1 and usse rescue mode, or you could run a 'live distro' such as Knoppix and type:


    at the linux: prompt. This will boot the live distro in single mode from which you can run fsck on the unmounted discs that you need to check/repair.



    Author Comment

    This worked perfectly... thanks for the help.

    My disk showed now errors after running FSCK. Is there anything else I can try to check for "bad" things happening on the system?

    Again, Thanks!
    LVL 7

    Expert Comment

    fsck -f does a more thorough check than the boot fsck does, so you've got the filesystem checked

    Check dmesg and /var/log/messages for
    - IDE errors, DMA timeouts, etc.   (Check for bad cables)
    - paging errors (bad ram)

    check netstat -antp | more
    start looking for ports open that you are not aware of, in particular if you see some ports without processes check pmap_dump and match up your extra ports with this list.

    add to hosts.deny
    sshd : all
    add to hosts.allow
    sshd: [dont do this, use YOUR ip address]

    check by using ssh before closing your connection or you won't get back in if you make a mistake


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator …
    Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now