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
    The saga continues: The "btrfs device add" command.

    My main partition, on which I have installed Kubuntu 14.04 with the btrfs FS, is on /dev/sda

    I inserted an 8GB flash drive and attempted to format it with kparted. However, kparted did NOT have the btrfs as an option. XFS was there, but not btrfs.
    So, I resorted to the CLI and mkfs.btrfs to format the 8GB stick. The "-f" switch was needed to forced the overwrite of the 500MB Verbatin_Store'n_GO partition, the first time I did it. After that, I did not have to.
    Code:
    :~$ sudo mkfs.btrfs /dev/sdb
    WARNING! - Btrfs v3.12 IS EXPERIMENTAL
    WARNING! - see http://btrfs.wiki.kernel.org before using
    
    Turning ON incompat feature 'extref': increased hardlink limit per file to 65536
    fs created label (null) on /dev/sdb
            nodesize 16384 leafsize 16384 sectorsize 4096 size 7.46GiB
    I mounted it using
    Code:
    sudo mount /dev/sdb /mnt
    and was able to copy files to it using Dolphin, but they were stored with root ownership.
    I umounted and mounted and umounted several times to see that the files I copied on it remained.
    Code:
    [FONT=courier new]:~$ sudo mount /dev/sdb /mnt[/FONT]
    :~$ [FONT=courier new]vdir /mnt[/FONT]
    total 0
    and copies some files to it using Dolphin. The results are:
    Code:
    :~$ [FONT=courier new]vdir /mnt[/FONT]
    total 64
    -rw-rw-r-- 1 root root  1312 Jan 24 12:08 brtfs-find-root.txt
    -rw-rw-r-- 1 root root  2268 Jan 24 12:11 brtfs-image.txt
    -rw-rw-r-- 1 root root  1339 Jan 24 12:12 brtfs-map-logical.txt
    -rw-rw-r-- 1 root root  1358 Jan 24 12:16 btrfsck-dont-use.txt
    -rw-rw-r-- 1 root root  1431 Jan 24 12:07 btrfs-convert.txt
    -rw-rw-r-- 1 root root  1104 Jan 24 14:10 btrfs-create.txt
    -rw-rw-r-- 1 root root  1414 Jan 24 12:13 btrfs-show-super.txt
    -rw-rw-r-- 1 root root  1217 Jan 24 12:16 btrfstune.txt
    -rw-rw-r-- 1 root root 24800 Jan 24 12:04 btrfs.txt
    -rw-rw-r-- 1 root root  1119 Jan 24 12:14 btrfs-zero-log.txt
    
    :~$[FONT=courier new] sudo umount /mnt[/FONT]
    :~$ [FONT=courier new]sudo mount /dev/sdb /mnt[/FONT]
    :~$[FONT=courier new] vdir /mnt[/FONT]
    total 64
    -rw-rw-r-- 1 root root  1312 Jan 24 12:08 brtfs-find-root.txt
    -rw-rw-r-- 1 root root  2268 Jan 24 12:11 brtfs-image.txt
    -rw-rw-r-- 1 root root  1339 Jan 24 12:12 brtfs-map-logical.txt
    -rw-rw-r-- 1 root root  1358 Jan 24 12:16 btrfsck-dont-use.txt
    -rw-rw-r-- 1 root root  1431 Jan 24 12:07 btrfs-convert.txt
    -rw-rw-r-- 1 root root  1104 Jan 24 14:10 btrfs-create.txt
    -rw-rw-r-- 1 root root  1414 Jan 24 12:13 btrfs-show-super.txt
    -rw-rw-r-- 1 root root  1217 Jan 24 12:16 btrfstune.txt
    -rw-rw-r-- 1 root root 24800 Jan 24 12:04 btrfs.txt
    -rw-rw-r-- 1 root root  1119 Jan 24 12:14 btrfs-zero-log.txt
    :~$ sudo umount /mnt
    However, I believe that the files were being saved in that 500MB XFAT Verbatin_Store'N Go partiton, as you'll see later.
    So, don't expect to use btrfs on a flash drive the way you would EXT4.


    Then I started exploring the "btrfs device add" command, which complained of an existing filesystem. Adding the "-f" switch forced the process.
    Code:
    :~$ sudo  btrfs device add /dev/sdb /home -f
    Two devices were now shown:
    Code:
    :~$ sudo btrfs fi show /
    Label: none  uuid: ddf94bee-0a35-4c66-87b7-857db8d21a0c
            Total devices 2 FS bytes used 90.90GiB
            devid    1 size 336.66GiB used 129.06GiB path /dev/sda4
            devid    2 size 7.46GiB used 0.00 path /dev/sdb
    The show command does not total the size of the devid's.

    I didn't want to run a balance operation because I didn't want to take the time.
    When I mounted /dev/sdb I saw the two standard subvolumes, @ and @home:
    Code:
    :~$ [FONT=courier new]sudo mount  /dev/sdb /mnt[/FONT]
    jerry@jerry-Aspire-V3-771:~$ vdir /mnt
    total 0
    drwxr-xr-x 1 root root 262 Feb  1 08:49 @
    drwxr-xr-x 1 root root  66 Feb  4 14:43 @home
    When I look into /mnt/@ and /mnt/@home I saw my entire filesystem!

    The btrfs space and usage command showed:
    Code:
    :~$[FONT=courier new] sudo btrfs fi df /[/FONT]
    Data, single: total=121.00GiB, used=90.50GiB
    System, DUP: total=32.00MiB, used=16.00KiB
    Metadata, DUP: total=4.00GiB, used=411.53MiB
    and the subvolume list command showed:
    Code:
    :~$[FONT=courier new] sudo btrfs subvolume list /[/FONT]
    ID 257 gen 25251 top level 5 path @
    ID 258 gen 25251 top level 5 path @home
    ID 1021 gen 21638 top level 257 path .snapshots
    ID 1022 gen 25177 top level 5 path @home/.snapshots
    
    :~$ sudo btrfs subvolume list /home
    ID 257 gen 25251 top level 5 path @
    ID 258 gen 25251 top level 5 path @home
    ID 1021 gen 21638 top level 5 path @/.snapshots
    ID 1022 gen 25177 top level 258 path .snapshots
    My assumption is that the addtional 8GB of flash drive was added to the /home space.

    The fi show command still showed the same devid's.
    Code:
    :~$ [FONT=courier new]sudo btrfs fi show /[/FONT]
    Label: none  uuid: ddf94bee-0a35-4c66-87b7-857db8d21a0c
            Total devices 2 FS bytes used 90.90GiB
            devid    1 size 336.66GiB used 129.06GiB path /dev/sda4
            devid    2 size 7.46GiB used 0.00 path /dev/sdb
    
    Btrfs v3.12
    
    :~$ [FONT=courier new]sudo btrfs fi show /home[/FONT]
    Label: none  uuid: ddf94bee-0a35-4c66-87b7-857db8d21a0c
            Total devices 2 FS bytes used 90.90GiB
            devid    1 size 336.66GiB used 129.06GiB path /dev/sda4
            devid    2 size 7.46GiB used 0.00 path /dev/sdb
    
    Btrfs v3.12
    I used the device delete command and the second device is gone:
    Code:
    :~$ [FONT=courier new]sudo  btrfs device delete /dev/sdb /home[/FONT]
    :~$ [FONT=courier new]sudo btrfs fi show /home[/FONT]
    Label: none  uuid: ddf94bee-0a35-4c66-87b7-857db8d21a0c
            Total devices 1 FS bytes used 90.90GiB
            devid    1 size 336.66GiB used 129.06GiB path /dev/sda4

    The device add command destroys the existing device formatting and replaces it. The device delete command removes the formatting:
    Code:
    :~$[FONT=courier new] sudo mount /dev/sdb /mnt[/FONT]
    NTFS signature is missing.
    Failed to mount '/dev/sdb': Invalid argument
    The device '/dev/sdb' doesn't seem to have a valid NTFS.
    Maybe the wrong device is used? Or the whole disk instead of a
    partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?
    The files I had saved in that 500MB partiton are gone.

    I have a 7 port active USB device that could hold SEVEN 128GB flash drives!
    Or, I have a 350GB USB HD that hasn't been used in a while.... mmmm ....
    Last edited by GreyGeek; Feb 04, 2014, 04:27 PM.

    Leave a comment:


  • GreyGeek
    replied
    Originally posted by oshunluvr View Post
    Exactly!

    Each install has grub pointing to a disk other than my actual boot disk. That way each install has grub and all it's files, but they don't take over my main MBR.
    Then I am in luck. Here are my partitions. As you can see, my boot disk is the 100MB Windows partition:
    Code:
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1            2048    33556479    16777216   27  Hidden NTFS WinRE
    /dev/sda2   *    33556480    33761279      102400    7  HPFS/NTFS/exFAT
    /dev/sda3        33761280   759126015   362682368    7  HPFS/NTFS/exFAT
    /dev/sda4       759126016  1465147391   353010688   83  Linux
    I have 336GB on my sda4 partition so I can employ the same scheme you are using!

    Leave a comment:


  • oshunluvr
    replied
    Exactly!

    Each install has grub pointing to a disk other than my actual boot disk. That way each install has grub and all it's files, but they don't take over my main MBR.

    Leave a comment:


  • GreyGeek
    replied
    So, when you install a new version you select the btrfs partition and install without formatting. The install then installs @ and @home, which you rename after the install to @KubuntuXX_YY and @KubuntuXX_YY_home, or something like that, and then edit the grub.conf and fstab so they point to the right subvolume?

    Leave a comment:


  • oshunluvr
    replied
    If I understand your question correctly, the answer is no. When I boot to @Kubuntu_12_10, that subvolume is mounted in fstab as root. Thus all other subvolumes are not accessible. I can (and often do) mount the root device somewhere and then access all the above.

    I manage my grub menus a little differently than standard also. On startup, I boot the the @grub install. The grub menu there has os_prober turned off (as do all my grubs) and I have a 40_custom that points to the grub menus for each install, like this:

    Code:
    menuentry 'Kubuntu 13.04' {
    insmod gzio
    insmod btrfs
    search --no-floppy --fs-uuid --set=root 8f0c1661-4e84-4512-b875-23bcfd5be1d8
    configfile /@Kubuntu_13_04_140120105600/boot/grub/grub.cfg
    }
    
    
    menuentry 'Kubuntu 14.04' {
    insmod gzio
    insmod btrfs
    search --no-floppy --fs-uuid --set=root 8f0c1661-4e84-4512-b875-23bcfd5be1d8
    configfile /@Kubuntu_14_04/boot/grub/grub.cfg
    }
    That's just part of it, but you get the idea. Then each install manages it's own grub menu and none of them effect the "master" grub menu. This way I can add and delete installs without risking removing the grub host install - the main boot menu always survives. All I have to do is edit the 40_custom once in awhile. If I was smart, I would just use generic names like; Linux1, Linux2, Linux3, etc. Then I wouldn't even have to edit 40_custom. Another neat feature of doing it this way is the grub menus are automatically nested. If I select a submenu and change my mind, a simple ESC puts me right back to the main grub menu. I set the timeouts at 3 secs and have my current "daily" install set as the default so I can boot up unattended.

    Leave a comment:


  • GreyGeek
    replied
    Originally posted by oshunluvr View Post
    .....

    You now have two version of Kubuntu on the same filesystem!

    repeat ad nauseum.

    Here's my subvolume list:
    Code:
    stuart@office:~$ sudo btrfs su li /
    ID 258 gen 683679 top level 5 path @grub
    ID 261 gen 690090 top level 5 path @Kubuntu_12_10_home
    ID 262 gen 683625 top level 5 path @Kubuntu_12_10
    ID 306 gen 691245 top level 5 path @Kubuntu_14_04
    ID 307 gen 691245 top level 5 path @Kubuntu_14_04_home
    ID 400 gen 683562 top level 5 path @Neptune_31_home
    ID 401 gen 683589 top level 5 path @Neptune_31
    ID 484 gen 685217 top level 5 path @Kubuntu_13_04_home_140120105600
    ID 485 gen 683625 top level 5 path @Kubuntu_13_04_140120105600
    stuart@office:~/Downloads$
    All of this fit on a single 256GB drive.
    So, IF I follow you correctly, you choose the version of Kubuntu you will boot into on the grub menu during bootup, BUT, you have access to all of the volumes regardless of which version you boot into?

    Leave a comment:


  • GreyGeek
    replied
    I thought I needed to add one more detail to this rambling prose: How to roll back, after some bad event, to a specific snapshot.

    This is taken from a document in one of Ubuntu's "AksUbuntu" pages, but I don't remember which. Also note that it is a btrfs system that also contains its own /boot subdirectory, so btrfs contains all the stuff under /boot. And, I am merely acting as an aggregator of info. I have not yet done a roll back.
    How to work with snaphots in Ubuntu's layout

    In order to work with snapshots of / or /home in the Ubuntu layout mount the btrfs filesystem at a separate location, and work from the top of the btrfs tree, rather than from the mounted subvolumes you are running on.

    First, mount the btrfs system you are currently on to the /mnt device
    sudo mount /dev/sdX# /mnt

    It seemed strange to me to mount the filesystem I was currently on and running AGAIN, to the very partition I was on, in my case sda4, which contained my entire kubuntu 14.04 system under btrfs.

    To create a snapshot use this syntax:
    sudo btrfs subvolume snapshot /mnt/@ /mnt/@_snapshot

    Notice that when refering to @ or @home while running in the systm you use "/" and "/home", but when mounted separately you use "@" and "@home".


    This will create a snapshot, created this way, of the @ subvolume named @_snapshot located also in the top of the btrfs tree. Since it is in the top of the tree, it will not show up when listing subvolumes in the subvolume you are currently running in.

    To roll back to a snapshot, you simply need to change its name to the name that ubuntu mounts and reboot.
    Code:
      [FONT=courier new]sudo mv /mnt/@   /mnt/@_badroot[/FONT]
    Code:
    [FONT=courier new]
    [B]sudo mv /mnt/@_snapshot   /mnt/@[/B][/FONT]
    then reboot!

    To delete a snapshot while /mnt is mounted use:
    Code:
      [FONT=courier new][B]sudo btrfs subvolume delete /mnt/@_badroot[/B][/FONT]
    btrfs snapshots are subvolumes in themselves, and self-contained, deleting the old @ subvolume like this is fine, provided we have a replacement.

    NOTE: The btrfs-tools command ''set-default'' will break Ubuntu's layout. Don't use it!
    It is entirely possible to create a snapshot of "/" or "/home" without mounting your btrfs filesystem on /mnt and working there.
    One could create a hidden subvolume called ".snapshots" in both the "/" and the "/home" subvolumes:
    sudo btrfs subvolume create /.snapshots
    sudo btrfs subvolume create /home/.snapshots
    and then create snapshots and save them under those subvolumes:
    sudo btrfs subvolume snapshot / /.snapshots/snapYYYYMMDDHHMM
    sudo btrfs subvolume snapshot / /home/.snapshots/snapYYYYMMDDHHMM


    Since these snapshots are created from within the working system they can be listed. Those snapshots created on a mounted /mnt cannot be seen from within the system, exceept for @ and @home, which are bound to "/" and "/home" in /etc/fstab:
    Code:
    # <file system> <mount point>   <type>  <options>       <dump>  <pass>
    # / was on /dev/sda4 during installation
    UUID=ddf94bee-0a35-4c66-87b7-857db8d21a0c [B]/  [/B]             btrfs   defaults,[B]subvol=@[/B] 0       1
    # /home was on /dev/sda4 during installation
    UUID=ddf94bee-0a35-4c66-87b7-857db8d21a0c[B] /home[/B]           btrfs   defaults,[B]subvol=@home[/B] 0       2
    In order to roll back "/" or "/home" one must mount the device to /mnt (or some other mounting point) and use mv command and then reboot.

    Leave a comment:


  • oshunluvr
    replied
    I haven't yet ventured into "send" and "receive" territory, but they're definitely on my short list.
    Code:
    [COLOR=#333333]I have a thick skull. You'll need to explain a little more how you can get btrfs to give you multiple boots and homes on a single drive (or partition?). [/COLOR]
    While I totally disagree with the former portion of that statement, to the latter I have a post here outling how I did that. But here's an abridged version:

    Create a btrfs filesystem.
    Install Kubuntu to it.
    Rename the @ (root) and @home (/home) subvolumes to unique names; i.e. @Kubuntu_12.04 and @Kubuntu_12.04_home.
    Edit fstab entries to match the new subvolumes and run update-grub.

    You now have a single Kubuntu installed to a single filesystem. Now install 13.04 to the same file system (obviously without formatting!).

    Rename the @ (root) and @home (/home) subvolumes to unique names; i.e. @Kubuntu_13.04 and @Kubuntu_13.04_home.
    Edit fstab entries to match the new subvolumes and run update-grub.

    You now have two version of Kubuntu on the same filesystem!

    repeat ad nauseum.

    Here's my subvolume list:
    Code:
    stuart@office:~$ sudo btrfs su li /
    ID 258 gen 683679 top level 5 path @grub
    ID 261 gen 690090 top level 5 path @Kubuntu_12_10_home
    ID 262 gen 683625 top level 5 path @Kubuntu_12_10
    ID 306 gen 691245 top level 5 path @Kubuntu_14_04
    ID 307 gen 691245 top level 5 path @Kubuntu_14_04_home
    ID 400 gen 683562 top level 5 path @Neptune_31_home
    ID 401 gen 683589 top level 5 path @Neptune_31
    ID 484 gen 685217 top level 5 path @Kubuntu_13_04_home_140120105600
    ID 485 gen 683625 top level 5 path @Kubuntu_13_04_140120105600
    stuart@office:~/Downloads$
    All of this fit on a single 256GB drive.

    Leave a comment:


  • GreyGeek
    replied
    Originally posted by oshunluvr View Post
    The only point GG made above I would differ slightly with is the utility of btrfs on a single disk.
    Thus my "escape clause":
    ... unless that HD or partition is TWICE OR 3X as big as the maximum size of your anticipated storage needs


    Originally posted by oshunluvr View Post
    IMO, btrfs has many benefits for smaller single-drive users but snapshots is not one of them. For example, if you have a small drive but want to multi-boot, you are stuck splitting your drive up into multiple partitions and thus waste a tremendous amount of space. With btrfs in the same scenario, you would need only a single file system and all your free space would be available to all your installs and your home all the time without managing partition sizes.
    I have a thick skull. You'll need to explain a little more how you can get btrfs to give you multiple boots and homes on a single drive (or partition?).

    Originally posted by oshunluvr View Post
    Regardless of filesystem size, snapshots require paying close attention to their maintenance. Snapshots are not a set-it-and-forget-it function as GG learned with his experiments. Under certain conditions; one-off upgrades like me or risky things like compiling from an little-known source, the ability is awesome. But you must return to the snapshot and remove it as soon as it is no longer needed. In theory, over time a snapshot could grow to the same size as the subvolume it was made from. Take 4 snapshots and you have the potential to use a lot of filesystem space! With a larger amount of free space and a heavier work load, a scheduled series of snapshots - with included removal of same as they age - is a very large benefit.
    Indeed. From what I've observed just creating two subvolumes (.snapshots) and then creating one snapshot each for @ and @home could, eventually, eat your entire partition or drive whereas in an EXT4 system your files and data build up may eat only half your storage.

    Originally posted by oshunluvr View Post
    A snapshot is not a backup and should not be used to replace one. Rather, it's a "photograph" of your system that can be used to "remember" it previous state. Once that remembrance is no longer needed, chuck that snapshot like you would pictures of your ex-girlfriend.
    That's one of the three most useful reasons to use btrfs. The second is the ability to add or remove storage space easily. The third is the use of btrfs's "send" and "receive" to move one or more subvolues to a remote btrfs system, as described here:
    Let's say you've got another computer with a btrfs filesystem and you want to back up your home directory from this computer to the other one. We'll use btrfs' built-in asynchronous replication for this. First, let's create a new subvolume underneath /home to contain the snapshots:
    me@virtual-machine:~$ sudo btrfs sub create /home/.snapshots
    Create subvolume '/home/.snapshots' Now, let's take our first snapshot:
    me@virtual-machine:~$ sudo btrfs sub snapshot -r /home /home/.snapshots/myfirstsnapshot
    Create a readonly snapshot of '/home' in '/home/.snapshots/myfirstsnapshot' We can see the new structure with another btrfs subvolume list:
    me@virtual-machine:~$ sudo btrfs sub list /
    ID 256 gen 199294 top level 5 path @
    ID 257 gen 199294 top level 5 path @home
    ID 849 gen 199310 top level 5 path @home/.snapshots
    ID 850 gen 199311 top level 5 path @home/.snapshots/myfirstsnapshot
    Now, let's replicate the snapshot to our second machine, which has convenient subvolumes named /backup and /backup/home and /backup/home/.snapshots.
    me@virtual-machine:~$ sudo btrfs send /home/.snapshots/myfirstsnapshot | ssh second-machine sudo btrfs receive /backup/home/.snapshots
    In its simplest possible form, this demonstrates sending the snapshot—which contains the entire /home subvolume at the time it was taken, remember—and tunneling it through ssh to the btrfs filesystem on the other end. There's nothing too special about this yet. Sure, you're replicating the entire subvolume all at once, which is kind of neat, but you could accomplish this in all kinds of ways. Where this gets cool is when we take and send a second snapshot:
    me@virtual-machine: sudo btrfs sub snapshot -r /home /home/.snapshots/mysecondsnapshot
    me@virtual-machine: sudo btrfs send -p /home/.snapshots/myfirstsnapshot /home/.snapshots/mysecondsnapshot | ssh second-machine btrfs receive /backup/home/.snapshots
    What we did here was send only the data that has changed on-disk between "myfirstsnapshot" and "mysecondsnapshot." What's especially awesome about this is that the system doesn't have to laboriously scan the disks to find things that have changed. It already knows what has or hasn't changed, so it can just immediately start spitting data out to the receive process on the other end. If you have a few text files to replicate, this might not matter. But if you have a terabyte or five of database binaries or virtual machine storage, this is a huge deal. Backups that would have taken hours or days and generated a tremendous amount of system load with older technologies can now complete in minutes with little or no extra load.

    I have systems that routinely replicate a terabyte or more of data across cheap 3Mbps and slower Internet connections using this technology... sometimes, replicating several times per day. There is literally no other technology that can accomplish this. If you have a six-figure SAN that replicates off-site several times a day, incremental snapshot replication is how it does it.
    That is neat!
    Last edited by GreyGeek; Feb 01, 2014, 07:42 PM.

    Leave a comment:


  • dibl
    replied
    Nice work, GG -- and nice writeup -- thanks for that. My impressions of BTRFS, after 3 years of use, pretty much agrees with yours. I don't see it as a meaningful improvement over ext4 for the single-user desktop or laptop system for everyday use, and I don't see anything indicating that the BTRFS developers had that target market in mind in the first place. I take oshunluvr's point that for the habitual upgrader, it does have a nice built in answer to the perpetual linux user's question "how do I go back?". But beyond that, there's nothing special for the OS filesystem.

    Where BTRFS really shines and outperforms ext4 in numerous ways is its multi-device filesystem implementation for large data storage. I only use 2 drives, 1 TB each, for my data. But I can imagine a small or mid-size enterprise that happens to be in a line of business that generates lots of data, like the engineering firm that I retired from in 2010, really benefitting from a Linux-based server implementation with multi-drive BTRFS for main data storage and backup. Never mind RAID controllers and proprietary drivers -- you could simply start buying consumer-grade server motherboards and SATA hard drives and don't stop until you have enough terabytes, and some spares, to support your data storage requirements. Very, very economical and yet very secure and easy to support.
    Last edited by dibl; Feb 01, 2014, 05:11 PM.

    Leave a comment:


  • GreyGeek
    replied
    I recreated the /.snapshots subvolume and the /home/.snapshots subvolume. Then I created snapshots in both of them using the same name:
    snap201402011310 (Feb 1, 2014 at 13:10PM).
    Later, I ran sudo btrfs sub show / and sudo btrfs sub show /home and noticed the following, in bold print:
    Code:
    :~$ [FONT=courier new]sudo btrfs sub show /[/FONT]
    /
            Name:                   @
            uuid:                   70593792-0f70-7c42-8e26-f1a7cae7d28e
            Parent uuid:            -
           [B] Creation time:          2014-01-21 17:09:59[/B]
            Object ID:              257
            Generation (Gen):       21115
            Gen at creation:        6
            Parent:                 5
            Top Level:              5
            Flags:                  -
            Snapshot(s):
                                  [B]  .snapshots/snap201402011310[/B]
    
    :~$ [FONT=courier new]sudo btrfs sub show /home[/FONT]
    /home
            Name:                   @home
            uuid:                   c4055db3-93f1-cc4a-833d-d8d8e516ac0b
            Parent uuid:            -
            [B]Creation time:          2014-01-21 17:10:00[/B]
            Object ID:              258
            Generation (Gen):       21114
            Gen at creation:        9
            Parent:                 5
            Top Level:              5
            Flags:                  -
            Snapshot(s):
                                    [B].snapshots/snap201402011310[/B]
    I first thought that btrfs resurrected the old snapshots subvolumes that I created with snapper, but my Muon history shows that I didn't install snapper until 1/23/14, two days after the creation date given for those two subvolums, both of which I created earlier this afternoon! Muon's history shows that my first update on this system was 1/20/14. So, I have no clue where btrfs got its 1/21/14 creation date.

    BTW, usage rose from 89.96GB to 90.45GB. The two snapshots were created in milliseconds.

    Leave a comment:


  • oshunluvr
    replied
    The only point GG made above I would differ slightly with is the utility of btrfs on a single disk.

    IMO, btrfs has many benefits for smaller single-drive users but snapshots is not one of them. For example, if you have a small drive but want to multi-boot, you are stuck splitting your drive up into multiple partitions and thus waste a tremendous amount of space. With btrfs in the same scenario, you would need only a single file system and all your free space would be available to all your installs and your home all the time without managing partition sizes.

    Regardless of filesystem size, snapshots require paying close attention to their maintenance. Snapshots are not a set-it-and-forget-it function as GG learned with his experiments. Under certain conditions; one-off upgrades like me or risky things like compiling from an little-known source, the ability is awesome. But you must return to the snapshot and remove it as soon as it is no longer needed. In theory, over time a snapshot could grow to the same size as the subvolume it was made from. Take 4 snapshots and you have the potential to use a lot of filesystem space! With a larger amount of free space and a heavier work load, a scheduled series of snapshots - with included removal of same as they age - is a very large benefit.

    A snapshot is not a backup and should not be used to replace one. Rather, it's a "photograph" of your system that can be used to "remember" it previous state. Once that remembrance is no longer needed, chuck that snapshot like you would pictures of your ex-girlfriend.

    Leave a comment:


  • Snowhog
    replied
    I hope/anticipate that you will write up a clear and concise report on your observations and provide it to the btrfs development team. It's quality 'testers' like yourself that development teams need to hear from.

    Leave a comment:


  • GreyGeek
    replied
    I got it sorted out. I reinstalled snapper and using it I could delete all the / snapshots except "0". It wouldn't let me delete the /home snapshots because my messing around trying to delete them probably deleted the info.xml file.

    So, I tried booting into a LiveCD and mounting my /dev/sda4 and using mc again, but the results were the same. While I was usiing the LiveCD I umounted /dev/sda4 and ran the btrfs check against it. No errors were reported. I googled for "snapper can't delete snapshot" and found a post by the guy who wrote snapper. He said that only the parts of the path named "snapshot" are subvolumes. The ".snapshots" and the numbered parts regular directories. So, I tried
    sudo btrfs subvolume delete /home/.snapshots/114/snapshot
    and it worked! I quickly deleted all the remaining snapshots on both / and /home. I used rmdir to remove /home/.snapshots/114 and the rest of the leftovers. Then I defraged / and /home and the meta data and then ran scrub.

    I am back up to 70% free according to df and I've USED 73% (89GB out of 121GB on a 336GB partition) according to btrfs fi df / the remaining "unused" portion being reserved for the potential creation of a snapshot of the entire system.

    LESSONS LEARNED:
    1) The btrfs filesystem is very stable. And, it does not need swap partitions, so don't waste your disk space on swap if you want to use btrfs. Considering all the violence I did to it, it while learning how to use it, it never misbehaved and the btrfs check /dev/sda4 on the unmounted volume showed no errors. The documentation, however, is sparse. Btrfs is still is in such rapid development that writing extensive documentation at the current time would be mostly a wasted effort. Fortunately, if you use Google Search's time limitations to restrict your search to recent documents, and to Ubuntu or debian based documentation, information is not hard to find.

    2) Btrfs is, IMO, not meant for single HDs or a single partition unless that HD or partition is TWICE OR 3X as big as the maximum size of your anticipated storage needs. My 336GB partition barely qualifies, IMO. After Kubuntu and all of my favorite apps are installed, and with NO snapshots, the size of @ and @home combined uses 90GB out of 121GB. IF I read "btrfs fi /" right, I have only 31GB of unused space left on which to install more apps or save more data before my btrfs filesystem becomes full. By comparison, a 336GB EXT4 partition would show about 30GB taken with Kubuntu and about 300GB remaining for additional applications and data, which is 10X as much as btrfs makes available with the same installs. However, the ability to easily add or remove other storage devices with relative ease, and the ability to make snapshots of your system and to roll back if adversity hits, makes it a worthwhile install, IMO. Certainly a lot easier than making tar backups of critical files and/or copyng them to other devices or locations and then doing the OS reinstall and copy routine. I have an active 7 port USB device plugged into my Acer. I could plug in 7 64GB USB sticks (448GB, of which about 120GB woudl be usable) and add them to my storage pool. Or, I could plug in my 350GB USB HD and get the same usable space. With development proceeding things can only get better. One caution: if you do something like that, and come close to filling up that additional space, you will have to add even more devices to give you working room while you trim down your stored files. Also, If you boot off of an EXT4 /boot partition be advised that snapshots do not apply, so rollbacks of Muon updates will not revert to the previous kernel, but the current kernel's headers in /usr/src will be gone.

    3) Snapper , as Oshunlover said, is NOT ready for primetime. And, I doubt it will ever be because of design flaws, one of which is too many snapshots automatically created. True, one can change the snapper config settings, but then it becomes a matter of which ones are critical and how do you specifically tell snapper to do only those? Snapper isn't that fine grained, which is why it appears to me that custom shell scripts will do better. Snapshots can quickly eat up your disk space. It would be a LOT easier and more compatible to use btrfs commands in a shell script to do activities similar to that which snapper does, and have those scipts tailered exactly to your needs, and run ONLY when you need them. Snapper allows one to manually create "pre" and "post" snapshots and execute a command in between, which is something that one might want to do when using apt-get or when the Muon updater runs. The pre and post numbers which snapper uses to identify its snapshots can be used to remove changes made between then before they are deleted. Thus, "snapper -croot delete nn..mm" and "snapper delete -chome nn..mm" is supposed to remove any changes to the system caused by any commands run between those two snapshots. Enter apt-btrfs-snapshots.

    4) The package apt-btrfs-snapshots is supposed to automatically make pre and post snapshots when ever apt-get is run, either in a console or by use of a wrapping gui. That's when I thought about snapper and apt-btrfs-snapshot busily churing away, breeding children automatically. The number of automatic snapshots being created on my system was eating my free space alive! Limiting snapper's snapshots to 4 each for @ and @home, but not being able to limit apt-btrfs-snapshots it became clear that after a few Muon updates and some apt-get update & apt-get upgrades of my own I realized that I had less than a week's worth of disk space remaining. I quickly purged apt-btrfs-snapshots but, to my dismay, it did NOT delete the snapshots it made! Fortunately, all of them were created as unmounted subvolumes, i.e., "@apt-snapshot-yyyymmddhh:mm:ss" on the partition my system was running on. It was easy to mount /dev/sda4 to /mnt and use "btrfs subvolume delete @apt-snapshot-yyyymmddhh:mm:ss", then umount.

    5) Btrfs by itself is adequate. Be sparse with your snapshots. To give you and example of the power of btrfs on Kubuntu read the following article about making backups of your home account using "btrfs sub create": http://arstechnica.com/information-t...filesystems/3/
    Last edited by GreyGeek; Feb 01, 2014, 11:33 AM.

    Leave a comment:


  • GreyGeek
    replied
    mounting it nodatacow did not work. When I use mc to view the file permissions that I can't remove they are shown as rw, but when I try to delete them using mc it complains that they are ro.
    The lsattr does not show ro on any file, nor does it show the immutible attribute set on any of the files that I can't delete. Strange.
    Last edited by GreyGeek; Jan 31, 2014, 02:03 PM.

    Leave a comment:

Users Viewing This Topic

Collapse

There are 0 users viewing this topic.

Working...
X