Skip to content

Commit

Permalink
partitioning: Reduce commit mount option for btrfs and ext4 to 120
Browse files Browse the repository at this point in the history
Mount option `commit=600` (=10 minutes) seems pretty high.
Reduce it to 120 for ext4 (default for ext4 is `commit=5`)
and 120 for btrfs (default for btrfs is `commit=30`) to reduce
risk of losing data on power loss.

Sources:
- https://www.kernel.org/doc/html/latest/admin-guide/ext4.html
- https://wiki.archlinux.org/title/Btrfs#Commit_interval
- https://btrfs.readthedocs.io/en/latest/Administration.html
  • Loading branch information
ColorfulRhino authored and igorpecovnik committed Jul 9, 2024
1 parent 718aa52 commit d638276
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion config/boards/recore.csc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function post_family_config__shrink_atf() {

function format_partitions__make_boot_ro() {
display_alert "Making boot partition ro 🍰" "recore"
sed -i 's:/boot ext4 defaults,commit=600,errors=remount-ro:/boot ext4 ro,defaults:' $SDCARD/etc/fstab
sed -i 's:/boot ext4 defaults,commit=120,errors=remount-ro:/boot ext4 ro,defaults:' $SDCARD/etc/fstab
}

function extension_finish_config__enable_plymouth() {
Expand Down
8 changes: 4 additions & 4 deletions lib/functions/image/partitioning.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ function prepare_partitions() {
fi

# mkopts[fat] is empty
mkopts[ext2]=''
# mkopts[ext2] is empty
# mkopts[f2fs] is empty
mkopts[btrfs]='-m dup'
mkopts[btrfs]='-m dup' # '-m dup' is already the default https://man.archlinux.org/man/mkfs.btrfs.8#m_
# mkopts[nilfs2] is empty
# mkopts[xfs] is empty
# mkopts[nfs] is empty
Expand All @@ -78,11 +78,11 @@ function prepare_partitions() {
mkfs[xfs]=xfs
# mkfs[nfs] is empty

mountopts[ext4]=',commit=600,errors=remount-ro'
mountopts[ext4]=',commit=120,errors=remount-ro' # EXT4 default: 5 (https://www.man7.org/linux/man-pages/man5/ext4.5.html)
# mountopts[ext2] is empty
# mountopts[fat] is empty
# mountopts[f2fs] is empty
mountopts[btrfs]=',commit=600'
mountopts[btrfs]=',commit=120' # BTRFS default: 30 (https://btrfs.readthedocs.io/en/latest/ch-mount-options.html)
# mountopts[nilfs2] is empty
# mountopts[xfs] is empty
# mountopts[nfs] is empty
Expand Down
8 changes: 5 additions & 3 deletions packages/bsp/common/usr/sbin/armbian-install
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ fi
mkopts[btrfs]='-f'
mkopts[f2fs]='-f'

mountopts[ext4]='defaults,noatime,commit=600,errors=remount-ro,x-gvfs-hide 0 1'
mountopts[btrfs]='defaults,noatime,commit=600,compress=lzo,x-gvfs-hide 0 2'
# @TODO source these options from one source, this is mostly defined in partioning.sh
mountopts[ext4]='defaults,noatime,commit=120,errors=remount-ro,x-gvfs-hide 0 1'
mountopts[btrfs]='defaults,noatime,commit=120,compress=lzo,x-gvfs-hide 0 2'
mountopts[f2fs]='defaults,noatime,x-gvfs-hide 0 2'

# Create boot and root file system #
Expand Down Expand Up @@ -241,8 +242,9 @@ create_armbian()
if [[ $1 == *nand* ]]; then
echo "Finishing installation to NAND." >> $logfile
REMOVESDTXT="and remove SD to boot from NAND"
# @TODO source these fstab options from one source, this is mostly defined in partioning.sh
echo "$1 /boot vfat defaults 0 0" >> "${TempDir}"/rootfs/etc/fstab
echo "$2 / ext4 defaults,noatime,commit=600,errors=remount-ro 0 1" >> "${TempDir}"/rootfs/etc/fstab
echo "$2 / ext4 defaults,noatime,commit=120,errors=remount-ro 0 1" >> "${TempDir}"/rootfs/etc/fstab
dialog --title "$title" --backtitle "$backtitle" --infobox "\nConverting kernel ... few seconds." 5 60
mkimage -A arm -O linux -T kernel -C none -a "0x40008000" -e "0x40008000" -n "Linux kernel" -d \
/boot/zImage "${TempDir}"/bootfs/uImage >/dev/null 2>&1
Expand Down

0 comments on commit d638276

Please sign in to comment.