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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
12-04-2009, 12:06 AM
|
#1
|
LQ Newbie
Registered: Feb 2009
Posts: 14
Rep:
|
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.
|
|
|
12-04-2009, 01:56 AM
|
#2
|
Member
Registered: Nov 2007
Distribution: Debian, Ubuntu MATE/LXQt, Slackware
Posts: 33
Rep:
|
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.
|
|
|
12-04-2009, 03:44 AM
|
#3
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,384
|
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.
|
12-04-2009, 04:35 AM
|
#4
|
Senior Member
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,639
Rep: 
|
will force a fsck on all partitions during reboot, i.e. when it is not dangerous.
|
|
1 members found this post helpful.
|
12-28-2009, 03:54 PM
|
#5
|
LQ Newbie
Registered: Feb 2009
Posts: 14
Original Poster
Rep:
|
Thank you all for your help.
|
|
|
01-04-2010, 04:45 AM
|
#6
|
Senior Member
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,639
Rep: 
|
You're welcome. But what did you actually do and how did it play out eventually?
|
|
|
01-14-2010, 09:20 PM
|
#7
|
LQ Newbie
Registered: Feb 2009
Posts: 14
Original Poster
Rep:
|
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.
|
|
|
01-15-2010, 02:31 AM
|
#8
|
Senior Member
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,639
Rep: 
|
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...
|
|
|
01-15-2010, 11:12 PM
|
#9
|
LQ Newbie
Registered: Feb 2009
Posts: 14
Original Poster
Rep:
|
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.
|
|
|
01-18-2010, 02:00 AM
|
#10
|
Senior Member
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,639
Rep: 
|
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...
|
|
|
01-18-2010, 03:54 AM
|
#11
|
LQ 5k Club
Registered: May 2003
Location: London, UK
Distribution: Fedora40
Posts: 6,153
|
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.
|
|
|
01-18-2010, 04:22 AM
|
#12
|
Senior Member
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,639
Rep: 
|
Quote:
Originally Posted by tredegar
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
...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.
|
|
|
01-18-2010, 04:57 AM
|
#13
|
LQ 5k Club
Registered: May 2003
Location: London, UK
Distribution: Fedora40
Posts: 6,153
|
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.
|
|
|
All times are GMT -5. The time now is 01:35 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|