LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-04-2015, 11:33 AM   #1
ITareliteralyMyInitials
LQ Newbie
 
Registered: Aug 2015
Posts: 17

Rep: Reputation: Disabled
Question Fsck related questions


Hello All,

I have put a very generic title to my question because i have a number of questions related to it I hope that would be fine.

So the idea is that I would like to check the fragmentation on my Linux server witch is in production mode (CentOs), So after googling for a while I ended up thinking that the best/easiest way to run fsck would be by restarting the machine with fsck on :
Code:
shutdown -Fr now
Since the server is in production mode I couldn't take the risk.
So I tried the same command above but on a test server (Ubuntu), the server was restarted correctly .
My questions :

  • I read in many posts that fragmentation is not a problem on linux based systems , But i still would like to see that information anyhow (I mean i would like to see how fragmented my server is)does this make sens ?
  • After I run the command
    Code:
    shutdown -Fr now
    On Ubuntu , I wanted to check the status, So i was hoping for something like 'This was fixed ....that was fixed ....' is this possible ? How can I do it ?
  • After I run the command
    Code:
    shutdown -Fr now
    On Ubuntu , I tried to validate that fsck was run and i figured out (from google) that it could be checked by executing the following command :
    Code:
    sudo tune2fs -l /dev/devname | grep "Last checked"
    which returned:
    Last checked: Fri Aug 21 18:56:37 2015 (I run the check today)
    Does this mean that It was not run ? why ?
  • I would like to know from you guys if you have tried this before , is it totally a safe operation to do , whats the best practice in this case ? Do i have to have a failover server in case something goes wrong ?
  • Does it make any difference to execute this command on Ubuntu or Centos ?
    Code:
    shutdown -Fr now
  • If we say i run the command above, how can i after the restart check that a defragmentation was run and correctly
  • Last question, when I restarted the test machine the down time was minutes does it depend on the machine ? i mean should i expect it to take more time on a different machine ?

Finally, I hope that there are some hero's on the other side to enlighten my understanding.
 
Old 11-04-2015, 11:43 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
By no means am I an expert on file systems, but you may wish to install and try out S.M.A.R.T. tools. There's one which scans your drive and gives information about the integrity of it from a hardware perspective. Recent hard drives contain SMART technology which allows these programs to interact with the drive and understand the points of problems, or not. I also believe in "defense in depth". Things like a NAS array storage device for data and some form of reliable, recall-able backup of system and user information.
 
Old 11-04-2015, 02:53 PM   #3
DangerMonkey
LQ Newbie
 
Registered: Mar 2014
Posts: 3

Rep: Reputation: Disabled
Linux doesn't need a fragmentation tool, really. Unlike Windows, which writes files across sectors all over the disk, Linux writes the files in contiguous space, with some room to grow. When the disk gets to 85 or 90 full, some fragmentation may occur, but it still handles it more intelligently than Windows.

When you reboot a linux machine, there is a script that runs and looks for a file called "forcefsck" in the root of the file system. If it exists, it does an fsck before the disk is mounted.
 
Old 11-04-2015, 03:35 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,125

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
You rarely need to shutdown to achieve a result in Linux - not unknown, but unlikely. There is always another way to do it as the perl folks remind us.
First things first - read my sigline.

"fsck" is different for each fileystem, even between ext3 and ext4. Generally it is best to allow the "system" to decide when/if it needs to run. For ext[234] the mount count is now ignored, and fsck will run automagically if needed at mount time (i.e. the decision is made every boot).
"shutdown" parameters (particularly -F) are handled differently by different systems - Ubuntu vs CentOS. Even differs between CentOS 6 and CentOS 7 (where it will be handled much differently by systemd). So you need to be careful with Internet searches.

As for fragmentation, it exists, but again you shouldn't carry worries over from Windoze. Linux ain't Windoze.
To allay your concerns, for ext4 filesystems as root/sudo try "e4defrag -c <filesystem device>"
Where <filesystem device> will be a partition or lv.

Basically relax, and find some real problem(s) to worry about ....
 
1 members found this post helpful.
Old 11-04-2015, 04:03 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,358

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
As per syg00.

I'd also point out that, as per the fsck man page
Code:
fsck is used to check and optionally repair one or more Linux file systems.
This has nothing to do with defragmentation of a disk.
 
1 members found this post helpful.
Old 11-04-2015, 05:12 PM   #6
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
As others have pointed out, fsck doesn't defrag a filesystem. For ext4, there is a tool named e4defrag, but fragmentation seems to be one of the least worries of Linux sysadmins.

fsck checks the root filesystem at boot time only under one or more of the following conditions:
  1. the system hasn't been shut down in a clean way, thus the filesystem wasn't unmounted before reboot
  2. a certain time has passed since the last check (180 days? It's configurable with tunefs)
  3. the system has rebooted a certain number of times (again, configurable)
  4. the file /forcefsck exists (Debian- and Redhat-basd systems prior to systemd it would seem)
So, the easiest way to force fsck is point 4 - just create that file.

Edit: Whether the /forcefsck works depends on the particular distro. See http://www.cyberciti.biz/faq/linux-f...boot-sequence/.

Last edited by berndbausch; 11-04-2015 at 05:19 PM.
 
1 members found this post helpful.
Old 11-04-2015, 06:54 PM   #7
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
There is some space reserved for root. This free space actually is needed to keep fragmentation low.
 
Old 11-05-2015, 03:53 AM   #8
ITareliteralyMyInitials
LQ Newbie
 
Registered: Aug 2015
Posts: 17

Original Poster
Rep: Reputation: Disabled
Thanks all for your output here,And for the valuable information, I have choose to go with syg00 suggestion, and on a Ubuntu with ext4 file system this command : "e4defrag -c <filesystem device>" worked like a charm, It said that the system was fine .
Now the other Linux server I mainly wanted to defragment have 'ext3' File system, So i could not run that tool on it, I decided to postpone this operation for now as it apparently will demand more research and testing.
(On the bright side i, at least know how to do it on 'ext4' with an online system, pretty fair for me)

Last edited by ITareliteralyMyInitials; 11-05-2015 at 03:54 AM.
 
  


Reply

Tags
centos, fsck, ubuntu



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
FSCK related query tuxianD Solaris / OpenSolaris 1 02-28-2011 05:23 AM
I am so fscking mad (fsck-related) SentralOrigin General 2 11-05-2010 08:58 PM
fsck (e2fsck) questions JohnE1 Linux - Server 4 08-15-2009 01:27 AM
basic questions on hostname and domain name + related postfix questions Moebius Linux - Newbie 7 09-04-2007 11:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration