-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Run fsck filesystem check support prior mounting filesystem #4431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -340,4 +340,10 @@ if [ -f $FIRST_BOOT_FILE ]; then | |
| firsttime_exit | ||
| fi | ||
|
|
||
| # Copy the fsck log into syslog | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Why copy to syslog? #Closed
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. syslog being the unified way of seeing system messages, we thought that its was more appropriate to hold the fsck log messages instead of a compressed file under the /var/log directory |
||
| if [ -f /var/log/fsck.log.gz ]; then | ||
| gunzip -d -c /var/log/fsck.log.gz | logger -t "FSCK" | ||
| rm -f /var/log/fsck.log.gz | ||
| fi | ||
|
|
||
| exit 0 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| #!/bin/sh | ||
|
|
||
| case $1 in | ||
| prereqs) | ||
| exit 0 | ||
| ;; | ||
| esac | ||
|
|
||
| # Extract kernel parameters | ||
| root_val="" | ||
| set -- $(cat /proc/cmdline) | ||
| for x in "$@"; do | ||
| case "$x" in | ||
| root=*) | ||
| root_val="${x#root=}" | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| # Check the filesystem we are using | ||
| if [ ! -z $root_val ]; then | ||
| fstype=$(blkid -o value -s TYPE $root_val) | ||
| case "$fstype" in | ||
| ext4) | ||
| cmd="fsck.ext4 -v -p" | ||
| ;; | ||
| ext3) | ||
lguohan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| cmd="fsck.ext3 -v -p" | ||
| ;; | ||
| esac | ||
| if [ ! -z "$cmd" ]; then | ||
| $cmd $root_val 2>&1 | gzip -c > /tmp/fsck.log.gz | ||
| fi | ||
| fi | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,5 +85,12 @@ then | |
| mount -t tmpfs -o rw,nosuid,nodev,size=${varlogsize}M tmpfs ${rootmnt}/var/log | ||
| [ -f ${rootmnt}/host/disk-img/var-log.ext4 ] && rm -rf ${rootmnt}/host/disk-img/var-log.ext4 | ||
| else | ||
| [ -f ${rootmnt}/host/disk-img/var-log.ext4 ] && fsck.ext4 -v -p ${rootmnt}/host/disk-img/var-log.ext4 2>&1 \ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Is there an option
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The -p option that we use here will prevent interactive prompt. |
||
| | gzip -c >> /tmp/fsck.log.gz | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Why append instead of overwrite? #Closed
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you only gzip 2 files, use 2 names and In reply to: 409184727 [](ancestors = 409184727)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are actually two ext3/ext4 filesystems that need to be checked:
|
||
| [ -f ${rootmnt}/host/disk-img/var-log.ext4 ] && mount -t ext4 -o loop,rw ${rootmnt}/host/disk-img/var-log.ext4 ${rootmnt}/var/log | ||
| fi | ||
|
|
||
| ## fscklog file: /tmp will be lost when overlayfs is mounted | ||
| if [ -f /tmp/fsck.log.gz ]; then | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only need to mv inside above
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we leave here? |
||
| mv /tmp/fsck.log.gz ${rootmnt}/var/log | ||
| fi | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How slow is the fsck? any impact on fast-reboot or warm-reboot?
If it is slow, can we only check and log, but expect user to repair it later? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is no error on the filesystem (i.e not marked as dirty), the command execution is immediate, So, on a clean filesystem, there is no impact on either fast-reboot or warm-reboot.
But if the filesystem is marked as dirty, there is no guarantee that the filesystem can be mounted as R/W. Or worse, if it still mounted, some files can be truncated or corrupted. Therefore, we strongly advise to repair a filesystem marked as dirty to avoid potential issues later on.