Results 1 to 10 of 10

Thread: Btrfs balance

  1. #1

    Default Btrfs balance

    I had a problem with this last week the btrfs-balance ran for two days. I think I know why it was i problem. The disk space was low, so I have tidied up the disk, and this time the balance ran in five minutes and was finished. I would like to see the log so I can understand a little more about what have been done and so on. But when i run:

    Code:
    dagr@opensuse:~> systemctl status btrfs-balance.timer 
    ● btrfs-balance.timer - Balance block groups on a btrfs filesystem
       Loaded: loaded (/usr/lib/systemd/system/btrfs-balance.timer; enabled; vendor preset: enabled)
      Drop-In: /etc/systemd/system/btrfs-balance.timer.d
               └─schedule.conf
       Active: active (waiting) since Sun 2020-01-12 16:04:31 CET; 16h ago
      Trigger: Mon 2020-01-20 00:00:00 CET; 6 days left
         Docs: man:btrfs-balance
    
    Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
    It seems the log output is not possible to read. Is it anything to do to get those logs?

    Dag R

  2. #2
    Join Date
    Sep 2012
    Posts
    5,326

    Default Re: Btrfs balance

    Quote Originally Posted by dagring View Post
    Code:
    dagr@opensuse:~> systemctl status btrfs-balance.timer
    Timers only start other services. You probably want output of btrfs-balance.service instead.
    Code:
    Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
    By default Leap 15.1 does not use persistent journal, so you only get information since last boot (and even this may be truncated if there is not enough space). You need to check /var/log/messages* that get copy of journal output.

  3. #3
    Join Date
    Feb 2010
    Location
    Germany
    Posts
    2,761

    Default Re: Btrfs balance

    @dagring:

    If you execute “systemctl status xxx” with a “normal” user then, you'll often see the message
    Warning: Journal has been rotated … ”.
    If, however, you execute the command with either the user “root” or, by means of “sudo”, the warning message, due to a lack of system privilege, will not occur.

  4. #4
    Join Date
    Feb 2010
    Location
    Germany
    Posts
    2,761

    Default Re: Btrfs balance

    @dagring:

    With the user “root”, execute “journalctl | grep 'btrfs-balance' ” to inspect for all the entries related to the systemd btrfs-balance service and timer in the systemd journal.
    Code:
     # journalctl | grep 'btrfs-balance'
    Dez 23 21:55:46 xxx btrfs-balance.sh[1463]: Dumping filters: flags 0x6, state 0x0, force is off
    Dez 23 21:55:46 xxx btrfs-balance.sh[1463]:   METADATA (flags 0x2): balancing, usage=30
    Dez 23 21:55:46 xxx btrfs-balance.sh[1463]:   SYSTEM (flags 0x2): balancing, usage=30
    Dez 23 21:55:46 xxx btrfs-balance.sh[1463]: Done, had to relocate 2 out of 24 chunks
    Dez 23 21:55:46 xxx btrfs-balance.sh[1463]: After balance of /
    Dez 23 21:55:46 xxx btrfs-balance.sh[1463]: Data, single: total=20.01GiB, used=19.66GiB
    Dez 23 21:55:46 xxx btrfs-balance.sh[1463]: System, DUP: total=32.00MiB, used=16.00KiB
    Dez 23 21:55:46 xxx btrfs-balance.sh[1463]: Metadata, DUP: total=1.00GiB, used=558.12MiB
    Dez 23 21:55:46 xxx btrfs-balance.sh[1463]: GlobalReserve, single: total=54.86MiB, used=0.00B
    Dez 23 21:55:46 xxx btrfs-balance.sh[1463]: Dateisystem    Größe Benutzt Verf. Verw% Eingehängt auf
    Dez 23 21:55:46 xxx btrfs-balance.sh[1463]: /dev/sda3        86G     23G   63G   27% /
     .
     .
     .
    Jan 13 19:43:23 xxx btrfs-balance.sh[14036]: Dumping filters: flags 0x6, state 0x0, force is off
    Jan 13 19:43:23 xxx btrfs-balance.sh[14036]:   METADATA (flags 0x2): balancing, usage=30
    Jan 13 19:43:23 xxx btrfs-balance.sh[14036]:   SYSTEM (flags 0x2): balancing, usage=30
    Jan 13 19:43:23 xxx btrfs-balance.sh[14036]: Done, had to relocate 2 out of 26 chunks
    Jan 13 19:43:23 xxx btrfs-balance.sh[14036]: After balance of /
    Jan 13 19:43:23 xxx btrfs-balance.sh[14036]: Data, single: total=22.01GiB, used=21.05GiB
    Jan 13 19:43:23 xxx btrfs-balance.sh[14036]: System, DUP: total=32.00MiB, used=16.00KiB
    Jan 13 19:43:23 xxx btrfs-balance.sh[14036]: Metadata, DUP: total=1.00GiB, used=614.95MiB
    Jan 13 19:43:23 xxx btrfs-balance.sh[14036]: GlobalReserve, single: total=58.36MiB, used=0.00B
    Jan 13 19:43:23 xxx btrfs-balance.sh[14036]: Dateisystem    Größe Benutzt Verf. Verw% Eingehängt auf
    Jan 13 19:43:23 xxx btrfs-balance.sh[14036]: /dev/sda3        86G     24G   62G   29% /
     #

  5. #5
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    11,862
    Blog Entries
    2

    Default Re: Btrfs balance

    Whenever possible,
    The usual parsing tools like grep, tail and head should be avoided because when invoked, the entire journal file(s) need to be loaded and only then parsed.
    When you use the "journalctl" commands, the operation is performed as the log file(s) are streamed.

    So, for instance if you wanted to search for all log entries that are generated by btrfs-balance.service during the previous (not current) boot, the following can be run
    Code:
    journalctl -u btrfs-balance.service -b -1
    And of course, if you wanted entries specific to the btrfs-balance.timer service, you would run the expected modified command.

    You might also like to know that the journalctl command is applied to all accessible log file(s, so as long as you haven't moved any log files you won't have to be concerned that they've been rotated.

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  6. #6

    Default Re: Btrfs balance

    Quote Originally Posted by arvidjaar View Post
    Timers only start other services. You probably want output of btrfs-balance.service instead.

    By default Leap 15.1 does not use persistent journal, so you only get information since last boot (and even this may be truncated if there is not enough space). You need to check /var/log/messages* that get copy of journal output.
    Thanks for telling me.

    Dag R

  7. #7

    Default Re: Btrfs balance

    Quote Originally Posted by tsu2 View Post
    Whenever possible,
    The usual parsing tools like grep, tail and head should be avoided because when invoked, the entire journal file(s) need to be loaded and only then parsed.
    When you use the "journalctl" commands, the operation is performed as the log file(s) are streamed.

    So, for instance if you wanted to search for all log entries that are generated by btrfs-balance.service during the previous (not current) boot, the following can be run
    Code:
    journalctl -u btrfs-balance.service -b -1
    And of course, if you wanted entries specific to the btrfs-balance.timer service, you would run the expected modified command.

    You might also like to know that the journalctl command is applied to all accessible log file(s, so as long as you haven't moved any log files you won't have to be concerned that they've been rotated.

    TSU
    When I ran this command, I got
    Code:
    sudo journalctl -u btrfs-balance.service -b -1
    [sudo] passord for root: 
    -- Logs begin at Wed 2020-01-08 01:06:28 CET, end at Sun 2020-01-19 17:53:19 CET. --
    -- No entries --
    It seems the logs is not there. Or I have misunderstood how to run the code? I have reboooted av couple of times because I thought the box was hanging in loop some how, when the btrfs-balance was running more than a day.

    DagR

  8. #8
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    11,862
    Blog Entries
    2

    Default Re: Btrfs balance

    Quote Originally Posted by dagring View Post
    When I ran this command, I got
    Code:
    sudo journalctl -u btrfs-balance.service -b -1
    [sudo] passord for root: 
    -- Logs begin at Wed 2020-01-08 01:06:28 CET, end at Sun 2020-01-19 17:53:19 CET. --
    -- No entries --
    It seems the logs is not there. Or I have misunderstood how to run the code? I have reboooted av couple of times because I thought the box was hanging in loop some how, when the btrfs-balance was running more than a day.

    DagR
    I had not noticed the change arvidjaar describes(My main system is an upgrade which seems to have retained the older setting), with a little research it looks like the change was made upstream in the main branch of systemd. I also don't remember this being an issue with 15.1 when it first launched, I suspect this is a very recent new "feature."
    Boy, would I like to somehow find whatever discussion led to changing logging to be non-persistent, IMO it violates very common and well-known principles of both security and regular maintenance. I can't even remember in my personal experience if I've ever come across any discussion that didn't highlight the importance of collecting historical system data.

    Anyway,
    It looks like current LEAP documentation describes how to fix this, which I consider very, very bad setting

    https://doc.opensuse.org/documentati...ctl-persistent

    The documentation is a little hard to understand because IMO it's written poorly(why all that unnecessary chaff above and below the setting that needs to be changed, and incidentally includes the next line which is not relevant?),
    Just do as described which is to uncheck the following line
    Code:
    #Storage=auto
    which can then be modified to the following instead
    Code:
    Storage=persistent
    And then restart systemd-journald.service
    Code:
    systemctl restart systemd-journald.service
    If you only have access to the current boot log,
    Then just run the command without the "-b -1" option.

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  9. #9
    Join Date
    Feb 2010
    Location
    Germany
    Posts
    2,761

    Default Re: Btrfs balance

    Quote Originally Posted by dagring View Post
    When I ran this command, I got
    Code:
    sudo journalctl -u btrfs-balance.service -b -1
    [sudo] passord for root: 
    -- Logs begin at Wed 2020-01-08 01:06:28 CET, end at Sun 2020-01-19 17:53:19 CET. --
    -- No entries --
    It seems the logs is not there.
    The “journalctl” option ‘-b -1’ means “Read the journal for the boot with the index -1”.

    Either, omit the “-b [ID][±offset]” {--boot=[ID][±offset]} option, to search the entire systemd Journal or, list the boots in the systemd Journal with “journalctl --list-boots” and then, choose the boot, via ID or offset, to be inspected.

    BTW, the option “-u UNIT or PATTERN” {--unit=UNIT|PATTERN} means “Show messages for the specified systemd unit UNIT (such as a service unit), or for any of the units matched by PATTERN.”

    Also, despite the systemd Journal automatically taking care of it's disk usage by means of system parameters, it pays to occasionally execute “journalctl --disk-usage” and “journalctl --verify” to check the Journal is behaving as expected – if not then, the option “--vacuum-time=” is useful cleaning up any misbehaviour which may have occurred …

  10. #10

    Default Re: Btrfs balance

    Thanks for all help on this topic. I have learned a lot on how to check in on this process. I have changed the setting in journald.conf to get persistent logs. Btrfs-balance now runs some minutes, so it seems to function as it should.

    Dag R

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •