Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Other Community Discussions > Tutorials & Tips
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Tutorials & Tips
The place to find Ubuntu related Tips & Tricks.

 
Thread Tools Display Modes
Old November 15th, 2006   #1
Old Pink
Dark Roasted Ubuntu
 
Old Pink's Avatar
 
Join Date: Aug 2006
Location: United Kingdom
Beans: 960
Ubuntu 7.10 Gutsy Gibbon
Send a message via MSN to Old Pink Send a message via Skype™ to Old Pink
HowTo: Change disk checking/fsck at boot frequency

Hi,

Nearly all Ubuntu users know, that every 30 boots their system performs what is know as an "fsck" to make sure your hard drive has no errors.

If you go through periods of frequent rebooting, these checks can become annoying.

To change how often these boot up checks occur, run this command in a terminal:

Code:
sudo tune2fs -c 50 /dev/hda1
The two things in bold can be modified.

First, the number "50", which chooses how often you want the check performed. 1 makes it scan at every boot, 0 stops scanning altogether, and all other numbers mean the scan will be performed every ** boots, 20 for 20, 30 for 30, 40 for 40 and so on.

Next, the "hda1" which you simply change to match the location of your hard drive, be it hda1,2,3 or even sda1,2,3.

Setting the scan to never happen isn't recommended, I'd say between 50-100 is safe.

- Matt
__________________
Remember when you were young? You shone like the sun.
Now there's a look in your eyes, like black holes in the sky.
Shine On You Crazy Diamond.
Topical Matt: home | the iphone alternatives
Old Pink is offline   Reply With Quote
Old November 16th, 2006   #2
bodhi.zazen
Ubuntu Guru
 
bodhi.zazen's Avatar
 
Join Date: Apr 2006
Location: Montana
My beans are hidden!
Xubuntu Development Release
Send a message via Yahoo to bodhi.zazen
Re: HowTo: Change disk checking/fsck at boot frequency

Nice How-to Old Pink

This thread has been added to the UDSF wiki.

Change Disk Check Frequency

I took the liberty of adding some basic information about fstab:

fstab options
/etc/fstab
is a system configuration file and is used to tell the Linux kernel which partitions (file systems) to mount and where on the file system tree.

A typical fatab entry may look like this:
Code:
/dev/hda1 / ext3 defaults 1 1
/dev/hdb1 /home ext3 defaults 1 2
The 6th column (in bold) is a fsck options.
  • 0 = Do not check.
  • 1 = First file system (partition) to check;
    • / (root partition) should be set to 1.
  • 2 = ALL OTHER file systems to be checked.

bodhi.zazen
__________________
A person with ubuntu is open and available to others, affirming of others, does not feel threatened that others are able and good, for he or she has a proper self-assurance that comes from knowing that he or she belongs in a greater whole and is diminished when others are humiliated or diminished, when others are tortured or oppressed. ~ Archbishop Desmond Tutu, 1999

bodhi.zazen is offline   Reply With Quote
Old November 21st, 2006   #3
Charles Hand
A Carafe of Ubuntu
 
Charles Hand's Avatar
 
Join Date: Jul 2006
Location: Fortuna, CA
Beans: 138
Kubuntu 6.10 Edgy
Re: HowTo: Change disk checking/fsck at boot frequency

Short of turning it off completely (not recommended) it's still going to happen by surprise and on the computer's timetable. Is there any way to tie into the mechanism that counts the boots and run a little program that says "you're going to have a forced check three boots from now"? Maybe a log file that tells how may boots are left, which could be grepped?
Charles Hand is offline   Reply With Quote
Old November 21st, 2006   #4
Sam
Dark Roasted Ubuntu
 
Sam's Avatar
 
Join Date: Feb 2005
Location: Geneva, Switzerland
Beans: 1,048
Ubuntu 9.10 Karmic Koala
Send a message via ICQ to Sam
Re: HowTo: Change disk checking/fsck at boot frequency

There is also the -i switch to set an interval before the check.
Code:
-i interval-between-checks[d|m|w]
Example combining both methods:
Code:
$ sudo tune2fs -c 50 -i 1m /dev/hda1
Sam is offline   Reply With Quote
Old November 21st, 2006   #5
Charles Hand
A Carafe of Ubuntu
 
Charles Hand's Avatar
 
Join Date: Jul 2006
Location: Fortuna, CA
Beans: 138
Kubuntu 6.10 Edgy
Re: HowTo: Change disk checking/fsck at boot frequency

Quote:
Originally Posted by Charles Hand View Post
Short of turning it off completely (not recommended) it's still going to happen by surprise and on the computer's timetable. Is there any way to tie into the mechanism that counts the boots and run a little program that says "you're going to have a forced check three boots from now"? Maybe a log file that tells how may boots are left, which could be grepped?
Here it is:
Code:
sudo dumpe2fs -h /dev/sdb1 | grep -i 'mount count'
Output:
Code:
dumpe2fs 1.38 (30-Jun-2005)
Mount count:              5
Maximum mount count:      30
Charles Hand is offline   Reply With Quote
Old December 10th, 2006   #6
kvonb
Fresh Brewed Ubuntu
 
Join Date: Apr 2006
Location: Surrounded by idiots!
Beans: 1,294
Kubuntu 4.10
Re: HowTo: Change disk checking/fsck at boot frequency

Search the forums for "bonager", it is a panel app that warns you of impending scans and lets you postpone them
kvonb is offline   Reply With Quote
Old May 8th, 2007   #7
MaineDave
First Cup of Ubuntu
 
Join Date: Mar 2007
Beans: 2
Re: HowTo: Change disk checking/fsck at boot frequency

There's also a showfsck package (I'm using Edgy in case that matters) with the command "showfsck" to show how many reboots remain before a fsck runs.
MaineDave is offline   Reply With Quote
Old July 9th, 2007   #8
lunamystry
Way Too Much Ubuntu
 
lunamystry's Avatar
 
Join Date: Jul 2007
Location: Johannesburg,South Africa
Beans: 267
Ubuntu 9.04 Jaunty Jackalope
Re: HowTo: Change disk checking/fsck at boot frequency

how do i get the Ubuntuuser icon for my website?
lunamystry is offline   Reply With Quote
Old August 1st, 2007   #9
NuK
First Cup of Ubuntu
 
NuK's Avatar
 
Join Date: Aug 2007
Location: Manresa, Catalunya
Beans: 7
Ubuntu 7.10 Gutsy Gibbon
Re: HowTo: Change disk checking/fsck at boot frequency

I'm learning bash and I wrote this script that shows the "mount count" for each partition. It works fine for me... I hope it helps!
Code:
#!/bin/bash

# this directory must exist to execute the script
if [ -d /dev/disk/by-id/ ]; then :; else echo 'ERROR: /dev/disk/by-id/ does not exist'; exit 1; fi

# root user is necessary
if [ $UID -gt 0 ]; then	echo 'ERROR: You have to be root'; exit 1; fi

# list ALL partitions and exclude the SWAP ones
declare -a SWAPS=( $(cat /proc/swaps | grep /dev/ | awk '{print$1}') )
lsParts="ls -l /dev/disk/by-id/ | grep --regexp=-part[0-9] | awk '{sub(\"../../\",\"/dev/\");"
for i in $(seq 0 $((${#SWAPS[@]} - 1))); do
	lsParts=${lsParts}' sub("'${SWAPS[$i]}'", "");'
done
lsParts=${lsParts}" print\$10}'"
declare -a PARTITIONS=(`eval $lsParts`)

# format TEMP file
for i in $(seq 0 $((${#PARTITIONS[@]} - 1))); do
	PARTITION=${PARTITIONS[$i]}
	if [ -n $PARTITION ]; then
		# first line, device name
		echo $PARTITION >> .temp.$$
		# mount info
		sudo dumpe2fs -h $PARTITION | grep 'Filesystem volume name' >> .temp.$$
		sudo dumpe2fs -h $PARTITION | grep 'Mount count' >> .temp.$$
		sudo dumpe2fs -h $PARTITION | grep 'Maximum mount count' >> .temp.$$
		sudo dumpe2fs -h $PARTITION | grep 'Last mount time' >> .temp.$$
		sudo dumpe2fs -h $PARTITION | grep 'Last checked' >> .temp.$$
		echo '-------------------------------' >> .temp.$$
	fi
done

# show and delete TEMP file
clear
cat .temp.$$
rm -f .temp.$$

# TUNE help
echo
echo 'HOWTO'
echo -e "- Change Filesystem volume name:\n\tsudo tune2fs -L NewLabel /dev/hda1\n\tsudo e2label /dev/hda1 NewLabel"
echo
echo -e "- Change Maximum mount count:\n\tsudo tune2fs -c 50 /dev/hda1"
echo
echo -e "- Modify reserved space:\n\tsudo tune2fs -m 1 /dev/hda1"
echo

exit 0
Remember that you can call the script like this:
Code:
sudo bash ./scriptname.sh
But if you want to use it more than once, it's better to change the execute permissions and call it without the "bash" command:
Code:
chmod 755 ./scriptname.sh
sudo ./scriptname.sh
NuK is offline   Reply With Quote
Old August 29th, 2007   #10
ntlam
Gee! These Aren't Roasted!
 
ntlam's Avatar
 
Join Date: Jul 2007
Beans: 161
Re: HowTo: Change disk checking/fsck at boot frequency

Quote:
Originally Posted by Old Pink View Post
Hi,

Nearly all Ubuntu users know, that every 30 boots their system performs what is know as an "fsck" to make sure your hard drive has no errors.

If you go through periods of frequent rebooting, these checks can become annoying.

To change how often these boot up checks occur, run this command in a terminal:

Code:
sudo tune2fs -c 50 /dev/hda1
The two things in bold can be modified.

First, the number "50", which chooses how often you want the check performed. 1 makes it scan at every boot, 0 stops scanning altogether, and all other numbers mean the scan will be performed every ** boots, 20 for 20, 30 for 30, 40 for 40 and so on.

Next, the "hda1" which you simply change to match the location of your hard drive, be it hda1,2,3 or even sda1,2,3.

Setting the scan to never happen isn't recommended, I'd say between 50-100 is safe.

- Matt
Nice guide
ntlam is offline   Reply With Quote

Bookmarks

Tags
disk check, fsck

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:23 PM.


vBulletin ©2000 - 2010, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. bilberry