-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Filesystems - eMMC wearout mitigation #2774
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 1 commit
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 |
|---|---|---|
|
|
@@ -11,8 +11,22 @@ case $1 in | |
| ;; | ||
| esac | ||
|
|
||
| # Extract kernel parameters | ||
| set -- $(cat /proc/cmdline) | ||
| for x in "$@"; do | ||
| case "$x" in | ||
| loop=*) | ||
| image_dir=`echo $x | sed -e 's/.*loop=\(\S*\)\/.*/\1/'` | ||
| ;; | ||
| varlog_size=*) | ||
| varlog_size="${x#varlog_size=}" | ||
| ;; | ||
| *mmc_host*) | ||
| eMMC=1 | ||
| esac | ||
| done | ||
|
|
||
| ## Mount the overlay file system: rw layer over squashfs | ||
| image_dir=$(cat /proc/cmdline | sed -e 's/.*loop=\(\S*\)\/.*/\1/') | ||
| mkdir -p ${rootmnt}/host/$image_dir/rw | ||
| mkdir -p ${rootmnt}/host/$image_dir/work | ||
| mount -n -o lowerdir=${rootmnt},upperdir=${rootmnt}/host/$image_dir/rw,workdir=${rootmnt}/host/$image_dir/work -t overlay root-overlay ${rootmnt} | ||
|
|
@@ -26,5 +40,9 @@ mount --bind ${rootmnt}/host/$image_dir/{{ DOCKERFS_DIR }} ${rootmnt}/var/lib/do | |
| ## Mount the boot directory in the raw partition, bypass the overlay | ||
| mkdir -p ${rootmnt}/boot | ||
| mount --bind ${rootmnt}/host/$image_dir/boot ${rootmnt}/boot | ||
| ## Mount loop device for /var/log | ||
| [ -f ${rootmnt}/host/disk-img/var-log.ext4 ] && mount -t ext4 -o loop,rw ${rootmnt}/host/disk-img/var-log.ext4 ${rootmnt}/var/log | ||
| ## Mount loop device for /var/log or a tmpfs device if the flash is eMMC | ||
| if [ -z ${eMMC+1} ]; then | ||
|
Contributor
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. What is the purpose of the "+1" here?
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. I originaly left it out but got pointed to https://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash where it is stated that its a safer check |
||
| [ -f ${rootmnt}/host/disk-img/var-log.ext4 ] && mount -t ext4 -o loop,rw ${rootmnt}/host/disk-img/var-log.ext4 ${rootmnt}/var/log | ||
| else | ||
| mount -t tmpfs -o size=${varlog_size}M,mode=0755 tmpfs ${rootmnt}/var/log | ||
| fi | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,9 @@ for x in "$@"; do | |
| case "$x" in | ||
| varlog_size=*) | ||
| varlog_size="${x#varlog_size=}" | ||
| ;; | ||
| *mmc_host*) | ||
|
Contributor
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. So this change depends on a "mmc_host" kernel command line parameter. I agree with your description that this is a crude check. Is there a way for a vendor to override this for their platform (or for an end-user building an image, for that matter) in the case it is not desired? What is populating the "mmc_host" kernel command line parameter?
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. On my device the actual kernel command line parameter is:
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. as for your question on overriding: maybe introduce a rules/config variable and check on that? |
||
| eMMC=1 | ||
| esac | ||
| done | ||
|
|
||
|
|
@@ -32,5 +35,7 @@ if [ -e "${rootmnt}/host/disk-img/var-log.ext4" ]; then | |
| fi | ||
| fi | ||
|
|
||
| # create varlog disk | ||
| mkdir -p ${rootmnt}/host/disk-img && ${rootmnt}/usr/bin/fallocate -l "$varlog_size"M ${rootmnt}/host/disk-img/var-log.ext4 && mkfs.ext4 -q -F ${rootmnt}/host/disk-img/var-log.ext4 | ||
| # create varlog disk only if we are not running eMMC flash | ||
| if [ -z ${eMMC+1} ]; then | ||
| mkdir -p ${rootmnt}/host/disk-img && ${rootmnt}/usr/bin/fallocate -l "$varlog_size"M ${rootmnt}/host/disk-img/var-log.ext4 && mkfs.ext4 -q -F ${rootmnt}/host/disk-img/var-log.ext4 | ||
| fi | ||
Uh oh!
There was an error while loading. Please reload this page.