LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 12-04-2009, 01:06 AM   #1
gr4nt
LQ Newbie
 
Registered: Feb 2009
Posts: 14

Rep: Reputation: 0
What the fsck? How to check a partition that is mounted as readonly?


Reading the manpage for fsck, it cautions against doing a filecheck on a partition that is already mounted. Or that you shouldn't attempt it unless you really know your stuff. Or that if you did attempt fsck on a read-only filesystem, it could be unpredictable.

Yet I'm sure the rootfs get checked sometimes during system initialization. So there obviously is a safe way to do it, I'm just not sure how.

My intention here is not to fsck the rootfs. But if for some reason, another partition besides the rootfs is mounted ro by the initrd, then it may possibly NEVER get checked. e2fsck isn't included in the initrd's busybox environment. And the main rootfs's initialization scripts won't fsck it, coz its already mounted.

So before I dabble, I need to know the safest way to do this.

Thanks.
 
Old 12-04-2009, 02:56 AM   #2
svinoba
LQ Newbie
 
Registered: Nov 2007
Location: Bengaluru, India
Distribution: Debian, Fedora, Slackware
Posts: 29

Rep: Reputation: 17
I'm not very knowledgeable in these matters but one can safely guess 'rootfs' must be getting 'fsck'ed before it gets mounted. To do 'fsck' on another partition during boot up, you need to edit /etc/fstab. Its the last column.
 
Old 12-04-2009, 04:44 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 14,838

Rep: Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822
Mounting ro will have no effect - the fsck will still go ahead.
The fsck warnings are there for you and me - don't do it if there is the possibility of someone accessing the filesystem. Even if they are only reading it. If you have to manually fsck, do it from single user, or (better) from a liveCD.
 
1 members found this post helpful.
Old 12-04-2009, 05:35 AM   #4
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 42.1_64+Tumbleweed-KDE, Mint 17.3
Posts: 3,951

Rep: Reputation: Disabled
Code:
shutdown -r -F now
will force a fsck on all partitions during reboot, i.e. when it is not dangerous.
 
1 members found this post helpful.
Old 12-28-2009, 04:54 PM   #5
gr4nt
LQ Newbie
 
Registered: Feb 2009
Posts: 14

Original Poster
Rep: Reputation: 0
Thank you all for your help.
 
Old 01-04-2010, 05:45 AM   #6
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 42.1_64+Tumbleweed-KDE, Mint 17.3
Posts: 3,951

Rep: Reputation: Disabled
You're welcome. But what did you actually do and how did it play out eventually?
 
Old 01-14-2010, 10:20 PM   #7
gr4nt
LQ Newbie
 
Registered: Feb 2009
Posts: 14

Original Poster
Rep: Reputation: 0
My original question was regarding a scenario where the initrd mounts a partition as read-only. Where if for some reason, I haven't listed that partition in my fstab, then it isn't automatically fscked. I have been dabbling with a custom initrd for mounting the rootfs as type aufs, so I will spare you the dubious details as to the why...

I guess the helpful answer given was that it is safe enuf to fsck a read-only partition, provided that no other processes are accessing that partition at the same time. Such that fsck is best done by the init-scripts, well before any service daemons get started up.

That said, I settled onto a different solution:- I just changed my partition type to xfs. A helpful post on slax-forums mentioned that xfs partitions are automatically filechecked at mount-time, without needing to use a separate fsck util. Very convenient :-)

But in any case, my current initrd for aufs is now mounting the base partition as read-write. So for filechecking the base partition, I will resort to either using the fstype xfs, or I will need to find myself a busybox for initrd that provides the e2fsck util. So alas, the original question has now become less important, but I am still very grateful for all your helpful responses.
 
Old 01-15-2010, 03:31 AM   #8
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 42.1_64+Tumbleweed-KDE, Mint 17.3
Posts: 3,951

Rep: Reputation: Disabled
Hmm. With "tune2fs -c 1" you can change the intervals between checks for the ext file system family. Thus you can force a check during every boot in analogy to my "shutdown -F now" suggestion. The boot sequence (i.e. init) will do it at the right time, too (I think when the partition is not mounted at all, you'd have to verify that, though).

This is not meant to criticize your solution, just a comment...
 
Old 01-16-2010, 12:12 AM   #9
gr4nt
LQ Newbie
 
Registered: Feb 2009
Posts: 14

Original Poster
Rep: Reputation: 0
I liked your suggestion on doing the fsck during shutdown...
I think my problem with that is I am doing aufs here. Trying to avoid writing pages of detail here, but the shutdown script for aufs is very different, and makes that plan un-doable.

During startup, I am using a ramdisk-based initrd. Such that even after the main rootfs inits, the initrd is still attached to the filesystem. Not deallocated the way that the cpio-based initramfs does. And this is done intentionally, because I need to use that initrd again during shutdown.

My rc.6 shutdown script is modified, such that instead of halting at the end, a pivot_root call is made back to the initrd. Once back in the initrd busybox system, another cleanup script then umounts the aufs, umounts all the squashfs modules, which were stored on my base partition, and only then, finally, can I actually umount the base partition.

So the shutdown for aufs+squashfs has an extra step that gets in the way of a shutdown-fsck. And my base partition that stores the squashfs modules is actually the very last partition to get umounted. I've basically borrowed the shutdown method used by Slax, and it is quite elegant. But there are other aufs methods out there that use a cpio-based initramfs instead, and must the shutdown differently, but I haven't looked into them yet.
 
Old 01-18-2010, 03:00 AM   #10
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 42.1_64+Tumbleweed-KDE, Mint 17.3
Posts: 3,951

Rep: Reputation: Disabled
I see (though I don't understand the details ).

Just to make sure there is no misunderstanding: "shutdown -h -F now" makes the system do the fsck during the next (re)-boot, not during shutdown. So if you want to implement (at an other time) fsck during shutdown please keep in mind that this is not the way to do it...
 
Old 01-18-2010, 04:54 AM   #11
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,085

Rep: Reputation: 398Reputation: 398Reputation: 398Reputation: 398
Quote:
shutdown -r -F now
You need to be aware that the -F option to shutdown was removed from the 'buntus in about 2008, and now does not force a fsck at the next boot.

The same may be true for other distributions. If I need to run fsck, I now have do it from a live CD or USB stick.
 
Old 01-18-2010, 05:22 AM   #12
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 42.1_64+Tumbleweed-KDE, Mint 17.3
Posts: 3,951

Rep: Reputation: Disabled
Quote:
Originally Posted by tredegar View Post
You need to be aware that the -F option to shutdown was removed from the 'buntus in about 2008, and now does not force a fsck at the next boot.The same may be true for other distributions. ...
Interesting. SuSE 11.0 still has it, I'll have to check in 11.2. Do you know the reason for that removal?

Quote:
Originally Posted by tredegar View Post
...If I need to run fsck, I now have do it from a live CD or USB stick.
You could also change the count number or the interval using tune2fs and thus still force a fsck during the next boot.
 
Old 01-18-2010, 05:57 AM   #13
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,085

Rep: Reputation: 398Reputation: 398Reputation: 398Reputation: 398
Quote:
Interesting. SuSE 11.0 still has it, I'll have to check in 11.2. Do you know the reason for that removal?
No, I don't, but it caught me by surprise! -F is no longer referred to by man shutdown, and is ignored if used. No warning about "-F is no longer supported" either
Quote:
You could also change the count number or the interval using tune2fs and thus still force a fsck during the next boot.
Yes, that would be another option.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How to Mount bin and sbin directories as readonly mounted file systems Larry James Fedora 8 10-21-2008 12:40 PM
parttion gives an error that it is readonly when it mounted as rw jabka Linux - General 1 07-08-2006 10:03 PM
FSCK on mounted partition xdiman Linux - Software 3 12-05-2005 02:28 PM
mounted fat32 filesystem becomes readonly after sometime, wierd? koodoo Linux - Newbie 6 11-24-2005 12:34 AM
Possible rootkit, any readonly way to run check? tekhead2 Linux - Security 4 10-27-2004 02:48 AM


All times are GMT -5. The time now is 09:06 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration