Announcement

Collapse
No announcement yet.

Btrfs, Snapper and apt-btrfs-snapshot

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • GreyGeek
    replied
    I'll try that. I confirmed that /mnt was mounted as rw. And, I checked several of the files that I couldn't delete becaue they were ro, but I couldn't see an "i" immuntable flag.

    Leave a comment:


  • oshunluvr
    replied
    Could be CoW causing your issue. Try mounting the root volume with nodatacow option or to change individual files/folders chattr +C <target> should stop CoW on them.

    The nodatacow option will disable copy-on-write on the entire filesystem. You might want to go that route, delete all the snaps, then remount normally or reboot.

    Leave a comment:


  • GreyGeek
    replied
    I was thinking about using kdialog with a bash script to do that.

    Snapper is nasty. I made a crucial mistake removing it. Before I purged snapper I should have used it to delete all of its snapshots. However, I ASSuMEd that a purge of snapper would remove all of its files, dependencies and constructs. It does not. To make matters worse, in the /home/.snapshots/ directory were the timeline snapshots. Snapper saved them as readonly. Even as root using mc I cannot delete them so they must have the immutable setting on them. I mounted my partition as /mnt and even from there I could not remove them. Need to do some googling and finid out how to remove immutable ro files.

    Leave a comment:


  • oshunluvr
    replied
    I bet either of us could easily write a script and cronjob that would do it better than snapper.

    You'd need a rollback script, maybe with some triggers like when you activate apt-get or how about in a service menu? Right-click on the desktop, choose "Make a snapshot", done. Hmmm, an easy GUI way to handle snaps would be very cool.

    Maybe when I retire again, I'll have time <rolls eyes>...

    Leave a comment:


  • GreyGeek
    replied
    Well, when I limit the ability of snapper to auto create snapshots I'm left with the number 0 snapshot (created when snapper was first installed) and two timeline snapshots taken during the most recent two hours. Combined with /home's snapshots the six take up 20% of my HD space. I'm going to purge snapper and its hidden subdirectories and use btrfs's snapshot command by creating a script that snapshots / and /home before any planned updates or changes. If the updates or changes work out OK then I'll delete the snapshots. If not, then I'll use them to rollback and then delete them. Like you said, Oshunlover, snapper is not ready for prime time.

    Leave a comment:


  • oshunluvr
    replied
    I've never run defrag, but balance on multi-disk filesystems helps determine actual usage. From what I've read regular system df is almost useless on a btrfs raid. I'm not sure how that reflects on a single disk system.

    Leave a comment:


  • GreyGeek
    replied
    When I deleted most of the snapshots I ran the btrfs defrager on both @ and @home, and I defraged the directory meta data, too.

    sudo btrfs filesystem defragment -v -r -f / (and /home)
    sudo find / (and /home) -xdev -type d -print -exec btrfs filesystem defragment '{}' \;


    The used space was down to 44% when there were 8 snapshots. Now, there are 10 more and the usage has climbed to 54% (Conky reports 66% free)


    Here's the current df utility and btrfs's df:
    :~$ sudo df --total
    Filesystem Type 1024-blocks Used Available Capacity Mounted on
    /dev/sda4 btrfs 353010688 101708436 234676364 31% /
    ....
    /dev/sda4 btrfs 353010688 101708436 234676364 31% /home
    total 712657668 203428968 475979804 30% -

    :~$ sudo btrfs fi df /
    Data, single: total=178.00GiB, used=95.79GiB
    ...


    31% vs 54%

    As far as auto-removal of older snapshots there is a mechanism in snapper to do that:
    Code:
      Cleanup Algorithms
           Snapper provides several algorithms to clean up old snapshots. The algorithms are executed in a daily cron-job. This can be
           configured in the corresponding configurations files along with parameters for every algorithm.
    
           number
               Deletes old snapshots when a certain number of snapshots is reached.
    
           timeline
               Deletes old snapshots but keeps a number of hourly, daily, monthly and yearly snapshots.
    
           empty-pre-post
               Deletes pre/post snapshot pairs with empty diffs.
    Here is snapper's root config:
    Code:
    :~$ sudo snapper -croot get-config
    Key                    | Value
    -----------------------+------
    ALLOW_GROUPS           |      
    ALLOW_USERS            | jerry
    BACKGROUND_COMPARISON  | yes  
    EMPTY_PRE_POST_CLEANUP | yes  
    EMPTY_PRE_POST_MIN_AGE | 1800 
    FSTYPE                 | btrfs
    NUMBER_CLEANUP         | yes  
    NUMBER_LIMIT           | 5    
    NUMBER_LIMIT_IMPORTANT | 3    
    NUMBER_MIN_AGE         | 1800 
    SUBVOLUME              | /    
    TIMELINE_CLEANUP       | yes  
    TIMELINE_CREATE        | yes  
    TIMELINE_LIMIT_DAILY   | 1    
    TIMELINE_LIMIT_HOURLY  | 0    
    TIMELINE_LIMIT_MONTHLY | 3    
    TIMELINE_LIMIT_YEARLY  | 1    
    TIMELINE_MIN_AGE       | 1800
    Snapper does do not explain the meaning of the config perameters very well. I haven't figured out what the "1800"means, but the other numbers refer to the number of snapshots. I "think" the total number of snapshots existing at any moment with the settings shown amounts to 5+3 = 8. And, with a TIMELINE_LIMIT_DAILY of 1, I see these snapshots in /.
    Code:
    :~$ sudo snapper -croot list
    Type   | #   | Pre # | Date                            | User | Cleanup  | Description | Userdata
    -------+-----+-------+---------------------------------+------+----------+-------------+---------
    single | 0   |       |                                 | root |          | current     |         
    single | 1   |       | Sun 26 Jan 2014 09:17:01 AM CST | root | timeline | timeline    |         
    single | 88  |       | Thu 30 Jan 2014 12:17:01 AM CST | root | timeline | timeline    |         
    single | 104 |       | Thu 30 Jan 2014 04:17:01 PM CST | root | timeline | timeline    |         
    single | 105 |       | Thu 30 Jan 2014 05:17:01 PM CST | root | timeline | timeline    |         
    single | 106 |       | Thu 30 Jan 2014 06:17:01 PM CST | root | timeline | timeline    |         
    single | 107 |       | Thu 30 Jan 2014 07:17:01 PM CST | root | timeline | timeline    |         
    single | 108 |       | Thu 30 Jan 2014 08:17:01 PM CST | root | timeline | timeline    |         
    single | 109 |       | Thu 30 Jan 2014 09:17:01 PM CST | root | timeline | timeline    |
    When I jump ahead of the cron task and do a manual clean up here are the results for root:
    Code:
    :~$ [FONT=courier new]sudo snapper -croot cleanup timeline[/FONT]
    jerry@jerry-Aspire-V3-771:~$ sudo snapper -croot list
    Type   | #  | Pre # | Date                            | User | Cleanup  | Description | Userdata
    -------+----+-------+---------------------------------+------+----------+-------------+---------
    single | 0  |       |                                 | root |          | current     |         
    single | 1  |       | Sun 26 Jan 2014 09:17:01 AM CST | root | timeline | timeline    |         
    single | 88 |       | Thu 30 Jan 2014 12:17:01 AM CST | root | timeline | timeline    |         
    jerry@jerry-Aspire-V3-771:~$
    which seems to agree with "NUMBER_LIMIT=3"

    EDIT: I found the meanings of the config terms:

    http://doc.opensuse.org/products/dra...snapper.limits
    Last edited by GreyGeek; Jan 30, 2014, 10:32 PM.

    Leave a comment:


  • oshunluvr
    replied
    Nice report, GG. I see many uses for snapshots, but I think the snapper tool might need some work before prime-time.

    I am surprised how much of your space was being used. Did you compare "df" to "btrfs fi df /" to verify free space was being reported correctly? Sometimes the standard df gets fooled, but maybe that's only with multi-device filesystems.

    What about auto-removal of older snaps? I would think an incremental delete would make snapshots a must-have feature. Maybe a daily cronjob snap and a snap every time certain programs were run like apt-get install, then automatic removal of the last five snaps.

    Leave a comment:


  • GreyGeek
    started a topic Btrfs, Snapper and apt-btrfs-snapshot

    Btrfs, Snapper and apt-btrfs-snapshot

    I've been playing with two CLI utilities for btrfs, snapper and apt-btrfs-snapshot.

    After playing extensively with both I decided to delete apt-btrfs-snapshot. The primary reason is that I didn't want system wide PRE & POST snapsnots eating up HD space everytime I ran apt-get or the muon updater ran. Secondarily, the apt-btrfs-snapshots were created by mounting my partition and saving them as @apt-snapshot-yyyymmddhh:mm:ss, which are not visible without mounting my active partition again.

    My Kubuntu partition is 336GB. With only Kubuntu 14.04 installed I was eating about 15% of the partition space. Over a period of five days, with the standard snapper configurations for both / (@) and /home (@home), and all the apt-get snapshots, about 60% of my partition was eaten up. Here is the root config file with my present settings:
    Code:
    # subvolume to snapshot
    SUBVOLUME="/"
    
    # filesystem type
    FSTYPE="btrfs"
    
    # users and groups allowed to work with config
    ALLOW_USERS="jerry"
    ALLOW_GROUPS=""
    
    # start comparing pre- and post-snapshot in background after creating
    # post-snapshot
    BACKGROUND_COMPARISON="yes"
    
    
    # run daily number cleanup
    NUMBER_CLEANUP="yes"
    
    # limit for number cleanup
    NUMBER_MIN_AGE="1800"
    NUMBER_LIMIT="5"                [B]  <---- initially was 50[/B]
    NUMBER_LIMIT_IMPORTANT="3"
    
    
    # create hourly snapshots
    TIMELINE_CREATE="yes"
    
    # cleanup hourly snapshots after some time
    TIMELINE_CLEANUP="yes"
    
    # limits for timeline cleanup
    TIMELINE_MIN_AGE="1800"
    TIMELINE_LIMIT_HOURLY="0"  [B]<------ Initially was 10[/B]
    TIMELINE_LIMIT_DAILY="1"      
    TIMELINE_LIMIT_MONTHLY="3"
    TIMELINE_LIMIT_YEARLY="1"
    
    # cleanup empty pre-post-pairs
    EMPTY_PRE_POST_CLEANUP="yes"
    
    # limits for empty pre-post-pair cleanup
    EMPTY_PRE_POST_MIN_AGE="1800" [B]  <----- I still don't know what the 1800 means ???[/B]
    My changes took 60 snapshots off of my btrfs installation and gave me 66% free space. / and /home now have 4 snapshots each, instead of 30+, and those 8 snapshots are taking 20% of my partition.

    I was curious to see if the /.snapshots directory snapshots contained and data in their "home" subdirectory. They did not. Likewise, my /home/.snapshots directory contained only my ~/jerry directory. So, there is a need when installing snapper to create the second /home account. When one uses snapper and does not signifiy which account to use then the action defaults to the root account. So, if one wants to create a snapshot in ones home account using snapper here is the syntax:
    sudo snapper -chome create --description "my snapshot in home"
    Without the "-chome" section your snapshot would be a snapshot of / and would be stored in /.snapshots.

    Snapper also gives you the ability to do a "pre" and "post" snapshot and include a command in between. Snapper referes to snapshots by the number it creates for them, not by the btrfs ID number. Using the "status" or "diff" switches on snapper you can use the numbers of two snapshots to compare them and see what's changed. If you want to roll back the changes between snapshot #x and snapshot #y then use this command:
    sudo -croot undochange x..y
    It is important to specifiy either root or home because they both could have the same snapshot numbers (but not the same data) and if you meant to roll back the home account to what it was before "x" you might end up rolling back root instead.

    Obviously, something like an apt-get may change both the / and /home/youracct subvolumes. So before you run apt-get sequences you'd run snapper to create a snapshot for both root and home specifying the "--pre-number". After the update you run snapper again with the same "pre" number, which snapper sees as a "post" number.
    ...
    --pre-number number
    For post snapshots the number of the pre snapshot must be provided.
    And, the part that allows you to do a command in between "pre" and "post" snapshots:
    --command command
    Create a pre and post snapshot and run command in between.
    Very powerful stuff!
    Last edited by GreyGeek; Jan 30, 2014, 05:15 PM.

Users Viewing This Topic

Collapse

There are 0 users viewing this topic.

Working...
X