Announcement

Collapse
No announcement yet.

BTRFS again: This time? Let's upgrade!

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

    #16
    Possibly of interest... from this year's Linux.Conf.Au in Perth.

    Comment


      #17
      Thanks for the video, Steve!
      "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
      – John F. Kennedy, February 26, 1962.

      Comment


        #18
        The location of the play icon on the thumbnail for that video makes it look like the guy is wearing a strange hat!
        samhobbs.co.uk

        Comment


          #19
          I found this interesting. Earlier I had installed all the btrfs tools that seemed logical and applicable. One of the tools was "apt-btrfs-snapshot" A few minutes ago I decided to install htop. Here's the result:
          Code:
          :~$ sudo apt-get install htop
          [sudo] password for jerry: 
          Reading package lists... Done
          Building dependency tree       
          Reading state information... Done
          The following packages were automatically installed and are no longer required:
            freeglut3 gl-117-data libfluidsynth1 libmikmod2 libsdl-image1.2 libsdl-mixer1.2 libsdl-net1.2 micropolis-data opencity-data
          Use 'apt-get autoremove' to remove them.
          The following NEW packages will be installed:
            htop
          0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
          Need to get 68.0 kB of archives.
          After this operation, 188 kB of additional disk space will be used.
          Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/universe htop amd64 1.0.2-3 [68.0 kB]
          Fetched 68.0 kB in 0s (136 kB/s)
          Supported
          [B]Create a snapshot of '/tmp/apt-btrfs-snapshot-mp-y3us6i/@' in '/tmp/apt-btrfs-snapshot-mp-y3us6i/@apt-snapshot-2014-01-25_16:05:44'[/B]
          Selecting previously unselected package htop.
          (Reading database ... 171725 files and directories currently installed.)
          Preparing to unpack .../htop_1.0.2-3_amd64.deb ...
          Unpacking htop (1.0.2-3) ...
          Processing triggers for desktop-file-utils (0.22-1ubuntu1) ...
          Processing triggers for mime-support (3.54ubuntu1) ...
          Processing triggers for man-db (2.6.6-1) ...
          Setting up htop (1.0.2-3) ...
          jerry@jerry-Aspire-V3-771:~$
          And, since running "autoremove" was recommended, I ran it:
          Code:
          :~$ sudo apt-get autoremove
          Reading package lists... Done
          Building dependency tree       
          Reading state information... Done
          The following packages will be REMOVED:
            freeglut3 gl-117-data libfluidsynth1 libmikmod2 libsdl-image1.2 libsdl-mixer1.2 libsdl-net1.2 micropolis-data opencity-data
          0 upgraded, 0 newly installed, 9 to remove and 0 not upgraded.
          After this operation, 25.8 MB disk space will be freed.
          Do you want to continue? [Y/n] y
          Supported
          [B]Create a snapshot of '/tmp/apt-btrfs-snapshot-mp-05tfm5/@' in '/tmp/apt-btrfs-snapshot-mp-05tfm5/@apt-snapshot-2014-01-25_16:11:24'[/B]
          (Reading database ... 171732 files and directories currently installed.)
          Removing freeglut3:amd64 (2.8.1-1) ...
          Removing gl-117-data (1.3.2-2.1ubuntu1) ...
          Removing libsdl-mixer1.2:amd64 (1.2.12-10) ...
          Removing libfluidsynth1:amd64 (1.1.6-2) ...
          Removing libmikmod2:amd64 (3.1.16-1) ...
          Removing libsdl-image1.2:amd64 (1.2.12-5build2) ...
          Removing libsdl-net1.2:amd64 (1.2.8-4) ...
          Removing micropolis-data (0.0.20071228-7) ...
          Removing opencity-data (0.0.6.4stable-3) ...
          Processing triggers for libc-bin (2.18-0ubuntu6) ...
          jerry@jerry-Aspire-V3-771:~$
          And this listing shows:
          Code:
          :~$ sudo btrfs subvolume show /
          /
                  Name:                   @
                  uuid:                   70593792-0f70-7c42-8e26-f1a7cae7d28e
                  Parent uuid:            -
                  Creation time:          2014-01-21 17:09:59
                  Object ID:              257
                  Generation (Gen):       5606
                  Gen at creation:        6
                  Parent:                 5
                  Top Level:              5
                  Flags:                  -
                  Snapshot(s):
                                          @apt-snapshot-2014-01-25_16:05:44
                                          @apt-snapshot-2014-01-25_16:11:24
          jerry@jerry-Aspire-V3-771:~$
          And...
          Code:
          ~$ sudo btrfs subvolume list /
          ID 257 gen 5615 top level 5 path @
          ID 258 gen 5615 top level 5 path @home
          ID 385 gen 5586 top level 5 path @apt-snapshot-2014-01-25_16:05:44
          ID 386 gen 5596 top level 5 path @apt-snapshot-2014-01-25_16:11:24
          jerry@jerry-Aspire-V3-771:~$
          I LIKE THIS!
          Last edited by GreyGeek; Jan 25, 2014, 04:24 PM.
          "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
          – John F. Kennedy, February 26, 1962.

          Comment


            #20
            Well, I've had a chance to play with btrfs and the two tools I downloaded, "snapper" and "apt-btrffs-snapshot".

            The first thing I noticed was that I could not access the files stored in any of the "@apt-snapshot-2014-...." subvolumes either as "jerry" or as root. It was if they didn't exist.

            I read somewhere that one could work on the system they were running without leaving it by mounting it and working on that mounted "drive". My Kubuntu 14.04 installation was on /dev/sda4. So, I used sudo mount -o /dev/sda4 /mnt and it worked! I could change into /mnt and see
            @root
            @home
            @apt-snapshot-2014-... etc...

            I could cd into any of the subvolumes and see the files in them, or apply any relevant btrfs commands to them.
            So, I used sudo btrfs subvolume delete to delete all the @apt-snapshot-2014-. snapshots, and it worked. I cd'd to /home/jerry and then used sudo umount /mnt to unmount the /mnt. When I used sudo btrfs subvolume list / to show the subvolume list and saw that the only subvolumes remaining were @root and @home.

            Snapper is a CLI tool to help use the btrfs. When installed it sets up its initial configuration file:
            Code:
            [FONT=courier new][B]sudo snapper list-configs[/B][/FONT]
            Config | Subvolume
            -------+----------
            root   | /
            Snapper keeps its configs in /etc/snapper/configs/


            To create a configuration for the @home subvolume I used the following command:
            sudo snapper -c home create-config /home

            That resulted in:
            Code:
            [FONT=courier new][B]sudo snapper list-configs[/B][/FONT]
            Config | Subvolume
            -------+----------
            root   | /        
            home   | /home
            Unlike the apt-brtfs-snapshot subvolumes, one can navigate in and out of "/" or "/home" the normal way.
            I've let snapper's cron additions run for a while now, resulting in the following listings:
            Code:
            :~$ [FONT=courier new][B]sudo snapper list[/B][/FONT]
            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 | 2 |       | Sun 26 Jan 2014 10:17:01 AM CST | root | timeline | timeline    |         
            single | 3 |       | Sun 26 Jan 2014 11:17:01 AM CST | root | timeline | timeline    |         
            single | 4 |       | Sun 26 Jan 2014 12:17:01 PM CST | root | timeline | timeline    |         
            single | 5 |       | Sun 26 Jan 2014 01:17:01 PM CST | root | timeline | timeline    |         
            single | 6 |       | Sun 26 Jan 2014 02:17:03 PM CST | root | timeline | timeline    |         
            jerry@jerry-Aspire-V3-771:~$
            and

            Code:
            :~$ [FONT=courier new][B]sudo snapper -c root list[/B][/FONT]
            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 | 2 |       | Sun 26 Jan 2014 10:17:01 AM CST | root | timeline | timeline    |         
            single | 3 |       | Sun 26 Jan 2014 11:17:01 AM CST | root | timeline | timeline    |         
            single | 4 |       | Sun 26 Jan 2014 12:17:01 PM CST | root | timeline | timeline    |         
            single | 5 |       | Sun 26 Jan 2014 01:17:01 PM CST | root | timeline | timeline    |         
            single | 6 |       | Sun 26 Jan 2014 02:17:03 PM CST | root | timeline | timeline    |
            and
            Code:
            :~$[FONT=courier new][B] sudo snapper -c home list[/B][/FONT]
            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 | 2 |       | Sun 26 Jan 2014 09:21:39 AM CST | root |          | my first snapshot in home |         
            single | 3 |       | Sun 26 Jan 2014 10:17:01 AM CST | root | timeline | timeline                  |         
            single | 4 |       | Sun 26 Jan 2014 11:17:01 AM CST | root | timeline | timeline                  |         
            single | 5 |       | Sun 26 Jan 2014 12:17:01 PM CST | root | timeline | timeline                  |         
            single | 6 |       | Sun 26 Jan 2014 01:17:01 PM CST | root | timeline | timeline                  |         
            single | 7 |       | Sun 26 Jan 2014 02:17:05 PM CST | root | timeline | timeline                  |
            I can compare the status between home snapshot 6 and home snapshot 7, which are one hour apart. A "+" is added attributes and a "-" is removed attributes. -+ are modified attributes. I've forgotten what the "c" stands for.
            Code:
            :~$ [FONT=courier new][B]sudo snapper -c home status 6..7[/B][/FONT]
            +.... /home/jerry/.audacity-data
            +.... /home/jerry/.audacity-data/AutoSave
            +.... /home/jerry/.audacity-data/AutoSave/New Project - 2014-01-26 14-17-00 N-1.autosave
            +.... /home/jerry/.audacity-data/audacity.cfg
            +.... /home/jerry/.avidemux
            +.... /home/jerry/.avidemux/config
            +.... /home/jerry/.avidemux/custom
            c.... /home/jerry/.bash_history
            +.... /home/jerry/.cache/mozilla/firefox/waxnpyed.default/Cache/0/45
            +.... /home/jerry/.cache/mozilla/firefox/waxnpyed.default/Cache/0/45/3D379d01
            ....
            +.... /home/jerry/.cache/mozilla/firefox/waxnpyed.default/thumbnails/b8f24c1382c0765eaed08d7f3076627e.png
            +.... /home/jerry/.cache/mozilla/firefox/waxnpyed.default/thumbnails/c66335907a66c51d8d06699e956b3731.png
            c.... /home/jerry/.cache/mozilla/firefox/waxnpyed.default/thumbnails/d75277cdffef995a46ae59bdaef1db86.png
            -.... /home/jerry/.cache/mozilla/firefox/waxnpyed.default/thumbnails/f42bda433bdbe20e0b0c22d748536d22.png
            c.... /home/jerry/.cache/upstart/dbus.log
            c.... /home/jerry/.cache/upstart/startkde.log
            c.... /home/jerry/.config/gtk-2.0/gtkfilechooser.ini
            c.... /home/jerry/.config/pulse/6d98fa6a03d81ff63b2f497852df0220-device-volumes.tdb
            c.... /home/jerry/.config/pulse/6d98fa6a03d81ff63b2f497852df0220-stream-volumes.tdb
            +.... /home/jerry/.kde/share/apps/RecentDocuments/2014-01-26 Service.mp3.desktop
            +.... /home/jerry/.kde/share/apps/RecentDocuments/2014-01-26 Service.mp3[2].desktop
            +.... /home/jerry/.kde/share/apps/RecentDocuments/2014-01-26.mp3.desktop
            -.... /home/jerry/.kde/share/apps/RecentDocuments/WinXPfixed-flat.vmdk.desktop
            -.... /home/jerry/.kde/share/apps/RecentDocuments/WinXPfixed.vmdk.desktop
            -.... /home/jerry/.kde/share/apps/RecentDocuments/winxpfixed_uuid.txt.desktop
            c.... /home/jerry/.kde/share/apps/activitymanager/resources/database
            c.... /home/jerry/.kde/share/apps/kcookiejar/cookies
            c.... /home/jerry/.kde/share/apps/nepomuk/repository/main/data/virtuosobackend/soprano-virtuoso.db
            ...
            +.... /home/jerry/.local/share/akonadi/file_db_data/508_r0
            +.... /home/jerry/.local/share/akonadi/file_db_data/510_r0
            c.... /home/jerry/.local/share/gvfs-metadata/home
            -.... /home/jerry/.local/share/gvfs-metadata/home-d01d90d2.log
            +.... /home/jerry/.local/share/gvfs-metadata/home-f83880e6.log
            -.... /home/jerry/.local/share/local-mail/inbox/new/1390750321.R391.jerry-Aspire-V3-771
            -.... /home/jerry/.local/share/local-mail/inbox/new/1390752125.R760.jerry-Aspire-V3-771
            .....
            +.... /home/jerry/.local/share/local-mail/trash/new/1390754831.R97.jerry-Aspire-V3-771:2,S
            +.... /home/jerry/.local/share/local-mail/trash/new/1390757839.R502.jerry-Aspire-V3-771:2,S
            c.... /home/jerry/.local/share/recently-used.xbel
            c.... /home/jerry/.mozilla/firefox/waxnpyed.default/cookies.sqlite
            +.... /home/jerry/.mozilla/firefox/waxnpyed.default/cookies.sqlite-shm
            .......
            c.... /home/jerry/MCServer172/MiningParadise/data/villages.dat
            c.... /home/jerry/MCServer172/MiningParadise/level.dat
            c.... /home/jerry/MCServer172/MiningParadise/level.dat_old
            c.... /home/jerry/MCServer172/MiningParadise/region/r.-1.0.mca
            c.... /home/jerry/MCServer172/MiningParadise/region/r.0.0.mca
            c.... /home/jerry/MCServer172/MiningParadise/session.lock
            c.... /home/jerry/MCServer172/banned-ips.txt
            c.... /home/jerry/MCServer172/banned-players.txt
            +.... /home/jerry/MCServer172/logs/2014-01-25-1.log.gz
            c.... /home/jerry/MCServer172/logs/latest.log
            c.... /home/jerry/MCServer172/server.properties
            j:~$
            If I use sudo snapper -c home status 6..7 it will show me the detailed difference between snapshot 6 and 7. For example, while running my minecraft server each of the commands we gave in the game ("/weather clear", etc...) were shown in the detail. So were the html webpage code of my trip to dropbox to download an mp3 file.

            One can create their own snapshot using snapper:
            Code:
            :~$ [FONT=courier new][B]sudo snapper -c home create --description "my first snapshot in home"[/B][/FONT]
            One can also use btrfs itself.

            The actual location of the snapshots are in hidden directories in the "root" of each subvolume for which a config file was generated. The "@" (/) config is in /.snapshot (not /root/.snapshot) and the "@home" (/home) config is in /home/.snapshot. Each snapshot is given its own integer number. Snapshot 2 of @ is NOT the same as snapshot 2 in @home.

            While watching videos of snapper in action on SUSE and others, I noted that on SUSE, for example, one could run
            snapper -c home create-config /home (without sudo) and the "user" collumn in snapshot listings would show the logged in user's name, not root.
            snapper -c home create --description "some description" and when listed the snapshot would show the user's name in the "user" column.
            I'm not sure how that's being handled because in Kubuntu the user does not own /home, root does. However, when I try to create a configuration file for my home account, /home/jerry using snapper without sudo, as one would suspect ...
            Code:
            [FONT=courier new][B]snapper -c jerry create-config /home/jerry[/B][/FONT]
            I get a "no permission" error, which is because snapper is in /usr/bin and is owned by root with group root. So, I readlly don't know how my user name could every appear under the user column in any snapshot listing. But, all seems well. In the /.snapshot directory there are no entries for the /home subvolume. In the /home/.snapshot directory is a directory for my account, jerry, and the files in it have my ownership and permission.

            These snapshots are NEAT! I can see me, for example, creating a snapshot of /home just before I began an Internet browsing period. After I am done all the changes to my system caused by what ever I encountered while browsing could be undone by using the snapper "undochange" parameter, restoring my /home account (and my /home/jerry) directory to the condition it was in before I began browsing. To be extra safe I could also create a snapshot of the @ subvolume before browsing and undochange in it as well.

            As I understand it, when I installed Kubuntu 14.04 and choose btrfs, the subvolumes @ and @home were created on /dev/sda4 automatically during the install. I did not create a swap file because they are not used by btrfs. (When I installed Kubuntu on this machine a few years ago I made the boot partition on sda2, an NTFS partition, so I didn't have to create a small ext3 or ext4 partition on which to put /boot.) "@" is / and @home is /home. I can navigate them using the CLI or a client file manager.

            To create a subvolume under my account I cd'd into /home/jerry and issued:
            Code:
            sudo btrfs subvolume create data
            Because I did not give a "<dest>" the subvolume (a directory) was created in my account. BUT, it is owned by root! I can't copy or move anything into it as jerry. As root I can copy one of my own directories into /home/jerry/data but its ownership is changed to root, which is not how my stuff is stored in snapshots of my home directory, which preserves my ownership and file attributes.

            Got some learning to do.

            EDIT: Ooops! I forgot to mention apt-btrfs-snapshot, the utility which creates a snapshot just before a package is installed using apt-get (directly or with a gui client) and just after the installation is complete. The first is labled as "pre" and the second is labled as "post". THIS IS VERY HANDY! If a package messes up your system just use snapper to undochange the "post"snapshot and then delete the pre one. Snapshots labled "single" have no relationhip to any other snapshot.
            Last edited by GreyGeek; Jan 26, 2014, 04:28 PM. Reason: for got to mention apt-btrfs-snapshot
            "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
            – John F. Kennedy, February 26, 1962.

            Comment


              #21
              Yeah, the point of the subvolumes is to behave in a similar way to partitioning. Being unable to access the snaps is expected. By mounting the host as you did, you now have access to all subvolumes. With 4 installs on my btrfs, I mount the root fs to /mnt/btrfs. / and /home to subvolumes. Then I can browse to whatever I want without endangering the system OS.

              I tried the auto rollback feature back when it was very new. It didn't work all that well then. Sounds like it's come a long way. You could also use a cron job to do a daily snap and remove aged-out ones. They really don't take much space until they get really old. If you need to revert, you can "elevate" the snapshot and delete the source subvolume.

              One of the common uses - but not a hard and fast rule - is to use the @ symbol for subvolumes. That way, you can tell at a glance if you're looking at a subvolume or a regular folder.

              A good use of subvolume on a large system might be to have user homes as subvolumes. Then each user can only see their own files.

              Your data subvolume should be accessible if you create/mount it with +rx permissions just like a home folder. If you are in a location where you have write permission, you can create a subvolume without using sudo so it will, of course, have your ownership rather than root.

              Please Read Me

              Comment


                #22
                Originally posted by oshunluvr View Post
                Y.....

                Your data subvolume should be accessible if you create/mount it with +rx permissions just like a home folder. If you are in a location where you have write permission, you can create a subvolume without using sudo so it will, of course, have your ownership rather than root.
                I cycled back through my cli history and noticed that I had subconsciencly used "sudo" in front of "btrfs subvolume create data", which is why it had root permissions. Re-doing it without sudo in my home directory, it did indeed create a data subvolume with my ownership and the appropriate permissions. My bad.
                "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
                – John F. Kennedy, February 26, 1962.

                Comment

                Working...
                X