LinuxQuestions.org
Visit Jeremy's Blog.
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, 12: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, 01:56 AM   #2
svinoba
Member
 
Registered: Nov 2007
Distribution: Debian, Ubuntu MATE/LXQt, Slackware
Posts: 33

Rep: Reputation: 20
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, 03:44 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,384

Rep: Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191
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, 04:35 AM   #4
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,639

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, 03: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, 04:45 AM   #6
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,639

Rep: Reputation: Disabled
You're welcome. But what did you actually do and how did it play out eventually?
 
Old 01-14-2010, 09: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, 02:31 AM   #8
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,639

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-15-2010, 11:12 PM   #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, 02:00 AM   #10
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,639

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, 03:54 AM   #11
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora40
Posts: 6,153

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
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, 04:22 AM   #12
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,639

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, 04:57 AM   #13
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora40
Posts: 6,153

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
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 11:40 AM
parttion gives an error that it is readonly when it mounted as rw jabka Linux - General 1 07-08-2006 09:03 PM
FSCK on mounted partition xdiman Linux - Software 3 12-05-2005 01:28 PM
mounted fat32 filesystem becomes readonly after sometime, wierd? koodoo Linux - Newbie 6 11-23-2005 11:34 PM
Possible rootkit, any readonly way to run check? tekhead2 Linux - Security 4 10-27-2004 01:48 AM

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

All times are GMT -5. The time now is 01:35 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