Your message dated Sat, 10 Aug 2024 23:15:05 +0200
with message-id <[email protected]>
and subject line Re: Bug#704664: bash: erases history when disk is full
has caused the Debian Bug report #704664,
regarding bash: erases history when disk is full
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
704664: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=704664
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: bash
Version: 4.2+dfsg-0.1
Severity: grave
Justification: causes non-serious data loss

Dear Maintainer,

I ran out of disk space last night. Today I'm greeted with an (almost) empty
bash history. The only commands left in ~/.bash_history start with the command
that caused the full-disk situation.

The only explanation I can think of as being the cause of this behaviour is
that bash is trying to overwrite ~/.bash_history rather than writing to a
temporary file and renaming it appropriately (as would have been good practice
I believe). Naively trying to overwrite will lose data in a wide variety of
situations including but not limited to loss of power, over-quota and full-disk
situations.

Severity set to grave as this causes data loss and, in my case, losing a year
of history is clearly not fun (TM).

Cheers,

Rene



-- System Information:
Debian Release: 7.0
  APT prefers testing
  APT policy: (650, 'testing'), (600, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 3.2.0-4-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages bash depends on:
ii  base-files   7.1
ii  dash         0.5.7-3
ii  debianutils  4.3.2
ii  libc6        2.13-38
ii  libtinfo5    5.9-10

Versions of packages bash recommends:
ii  bash-completion  1:2.0-1

Versions of packages bash suggests:
pn  bash-doc  <none>

-- no debconf information

--- End Message ---
--- Begin Message ---
Version: 5.2.21-2.1

On Thu, 04 Apr 2013 10:50:37 +0200 Rene Wagner <[email protected]> wrote:
I ran out of disk space last night. Today I'm greeted with an (almost) empty
bash history. The only commands left in ~/.bash_history start with the command
that caused the full-disk situation.

The only explanation I can think of as being the cause of this behaviour is
that bash is trying to overwrite ~/.bash_history rather than writing to a
temporary file and renaming it appropriately (as would have been good practice
I believe). Naively trying to overwrite will lose data in a wide variety of
situations including but not limited to loss of power, over-quota and full-disk
situations.

Bash version 5.2.21 overwrites the history file in a more careful way, so that its content is not lost when the history files is being written with a full disk.

This can be tested in the following way:

1. Copy a lot of lines into the clipboard:

    $ cat /usr/share/dict/words | grep -E '^[a-z]+$' |
    head -n 10000 | xclip -selection clipboard

2. Set up a Debian VM with very little free space:

$ debvm-create -- --customize-hook='echo tmpfs /root tmpfs defaults,mode=0755,size=10k >> "$1/etc/fstab"'

3. Log into the VM, fill up the space, update .bash_history:

    $ debvm-run
    # echo hello
    # history -a
    # cat .bash_history
    echo hello
    history -a
    # cat /dev/random > foo
    (paste lines into terminal and press enter)
    # history -a

4. Check that .bash_history is still there and not empty:

    # head .bash_history -n 20
    echo hello
    history -a
    cat .bash_history
    cat /dev/random > foo
    history -a
    a
    aardvark
    aardvarks
    abaci
    aback
    abacus
    [...]

The file is truncated (most of the words have not been saved), but it is still there and contains at least the older history entries.

--
Gioele Barabucci

--- End Message ---

Reply via email to