FG

Emacs hangs for seconds when writing file, to do with kjournald and VirtualBox

Freshabout 19 hours ago
Mar 15, 2026866 views
Confidence Score0%
0%

Problem

I run on When saving files, emacs sometimes takes 3 seconds to write a small file to disc. I ran iotop and found that kjournald seems to be responsible for the delay: This process sits there on 99 percent while emacs hangs, sometimes for a few seconds. It looks like the writing delay issue has to d…

Error Output

GNU Emacs 23.2.1 (x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
of 2010-12-12 on brahms, modified by Debian

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Optimize Disk I/O for Emacs with kjournald in VirtualBox

Medium Risk

The delay in Emacs when saving files is caused by kjournald, which is the journaling process for ext3/ext4 filesystems. When running in a VirtualBox environment, disk I/O can be slower due to the virtualized nature of the disk access, leading to contention between Emacs and kjournald, especially when multiple write operations are queued.

Awaiting Verification

Be the first to verify this fix

  1. 1

    Adjust VirtualBox Disk I/O Settings

    Increase the disk I/O performance by changing the VirtualBox settings. Ensure that the virtual disk is set to use 'Host I/O Cache' to improve write performance.

    bash
    VBoxManage modifyhd <disk_image.vdi> --cache=writeback
  2. 2

    Change Emacs Buffer Saving Behavior

    Modify Emacs to use a different saving strategy that minimizes the frequency of writes. You can set the 'auto-save' interval to a longer duration.

    emacs-lisp
    (setq auto-save-timeout 300)
  3. 3

    Optimize Filesystem Mount Options

    Edit the /etc/fstab file to include options that reduce the frequency of journaling. Adding 'data=writeback' can help improve performance.

    bash
    UUID=<your-uuid> / ext4 defaults,data=writeback 0 1
  4. 4

    Monitor Disk I/O Performance

    Use iotop to monitor the disk I/O usage after making the above changes. This will help confirm if kjournald's activity has decreased during Emacs file saves.

    bash
    iotop -o

Validation

After applying the above steps, save a file in Emacs and monitor the time taken for the operation. If the delay is significantly reduced and kjournald's CPU usage is lower during the save operation, the fix is successful.

Sign in to verify this fix

Environment