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 think I got myself into a pickle. I decided to remove my new drive from /home and issued:
    Code:
    :~$ [FONT=courier new][B]sudo btrfs device delete /dev/sdb /home[/B][/FONT]
    ERROR: error removing the device '/dev/sdb' - unable to go below two devices on raid1
    Opps!
    Now to figure out how to remove RAID1 from /home...

    Code:
    :~$ sudo btrfs filesystem balance start -f -dconvert=single -mconvert=single /home
    is now running, but there is a warning about doing this causing loss of metadata integrity. (i,e., the small files.)

    EDIT:
    The conversion from RAID1 to Single worked OK, and the "delete device /dev/sdb /home" took about an hour to complete. Now to do a scrub.
    Last edited by GreyGeek; Feb 19, 2014, 10:00 PM.

    Leave a comment:


  • GreyGeek
    replied
    Btrfs send/received and device add

    The USB 3.0 500GB HD came today and I began experimenting with btrfs send/receive.
    Code:
    [FONT=courier new]btrfs send [-v] [-p <parent>] [-c <clone-src>] [-f <outfile>] <subvol>
    
    btrfs receive [-ve] [-f <infile>] <mount>[/FONT]
    The results were not good. Here is a small snippet of the typical results.
    I used
    sudo mkfs.btrfs -f /dev/sdb
    to format the external HD, and mounted it on /mnt. That didn't work. Then I mounted it on /home/jerry/mnt because that path isn't under the "/" subvolume.

    Code:
    :~$ [FONT=courier new][B]sudo btrfs send / | btrfs receive /home/jerry/mnt[/B][/FONT]
    ERROR: failed to open destination directory /home/jerry/mnt. Operation not permitted
    ERROR: / is not read-only.
    One can't run inside a read-only system. I thought about mounting "/" on /mnt and trying
    sudo btrfs send /mnt/ | btrfs receive /home/jerry/mnt
    but didn't because it didn't make sense.

    Then I tried using a file:
    Code:
    :~$ [FONT=courier new][B]sudo btrfs send -f /mnt/sent_file /[/B][/FONT]
    ERROR: / is not read-only.
    Then I tried to use a read-only snapshot as the source.
    Code:
    ~$[FONT=courier new][B] sudo btrfs subvolume snapshot -r / /.snapshots/backup_0[/B][/FONT]
    Create a readonly snapshot of '/' in '/.snapshots/backup_0'
    :~$ [B][FONT=courier new]sync[/FONT][/B]
    :~$ [FONT=courier new][B]sudo mkdir /mnt/backupvol[/B][/FONT]
    :~$[FONT=courier new][B] sudo btrfs send /.snapshots/backup_0 | btrfs receive /mnt/backupvol[/B][/FONT]
    ERROR: failed to open destination directory /mnt/backupvol. Operation not permitted
    At subvol /.snapshots/backup_0
    ERROR: open @/.snapshots/backup_0 failed. No such file or directory
    
    :~$ [FONT=courier new][B]sudo btrfs send @.snapshots/backup_0 | btrfs receive /mnt/backupvol[/B][/FONT]
    ERROR: failed to open destination directory /mnt/backupvol. Operation not permitted
    ERROR: unable to resolve @.snapshots/backup_0
    
    :~$[FONT=courier new][B] sudo btrfs send /.snapshots/backup_0 | btrfs receive /mnt/backupvol/[/B][/FONT]
    At subvol /.snapshots/backup_0
    ERROR: open @/.snapshots/backup_0 failed. No such file or directory
    If send/receive is supposed to work I have more to learn on how to use it.

    So then I turned to adding the device to my /home subvolume.
    Code:
    :~$ [FONT=courier new][B]sudo btrfs device add -f /dev/sdb /home[/B][/FONT]
    :~$ [FONT=courier new][B]sudo btrfs filesystem balance start -d -m /home[/B][/FONT]
    Done, had to relocate 170 out of 170 chunks
    
    
    :~$[FONT=courier new][B] sudo btrfs subvolume show /home[/B][/FONT]
    /home
            Name:                   @home
            uuid:                   c4055db3-93f1-cc4a-833d-d8d8e516ac0b
            Parent uuid:            -
            Creation time:          2014-01-21 17:10:00
            Object ID:              258
            Generation (Gen):       47830
            Gen at creation:        9
            Parent:                 5
            Top Level:              5
            Flags:                  -
            Snapshot(s):
    
    :~$[FONT=courier new][B] sudo btrfs filesystem df /home[/B][/FONT]
    Data, single: total=102.00GiB, used=101.28GiB
    System, RAID1: total=32.00MiB, used=48.00KiB
    Metadata, RAID1: total=48.00GiB, used=540.69MiB
    
    
    :~$[FONT=courier new][B] sudo btrfs filesystem show /home[/B][/FONT]
    Label: none  uuid: ddf94bee-0a35-4c66-87b7-857db8d21a0c
            Total devices 2 FS bytes used 101.81GiB
            devid    1 size 336.66GiB used 48.03GiB path /dev/sda4
            devid    2 size 465.73GiB used 150.03GiB path /dev/sdb
    So, I now have a "Data, single" on /home, which is almost all used.
    And, both System and Metadata are RAID1, with 540.69GB used.
    The fs show /home command says I've used 48GB out of 337GB on sda4 and 150GB out of 466GB on sdb.
    Last edited by GreyGeek; Jul 03, 2014, 03:23 PM.

    Leave a comment:


  • GreyGeek
    replied
    That's what I found out. But I doubt nice things would happen with crossed volumes. I used KParted and deleted all partititons. Then I ran

    Code:
    :~$ [FONT=courier new][B]sudo mkfs.btrfs -f -LBtrfs8GB /dev/sdb
    [/B][/FONT]
    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 [COLOR=#ff0000]Btrfs8GB[/COLOR] on[COLOR=#ff0000] /dev/sdb[/COLOR]
            nodesize 16384 leafsize 16384 sectorsize 4096 size 7.46GiB
    
    ~$[FONT=courier new][B] sudo fdisk -l[/B][/FONT]
    
    Disk /dev/sda: 750.2 GB, 750156374016 bytes
    255 heads, 63 sectors/track, 91201 cylinders, total 1465149168 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    Disk identifier: 0x040a05fb
    
       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
    
    Disk [COLOR=#ff0000]/dev/sdb[/COLOR]: 8006 MB, 8006926336 bytes
    247 heads, 62 sectors/track, 1021 cylinders, total 15638528 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000
    
    [COLOR=#ff0000]Disk /dev/sdb doesn't contain a valid partition table[/COLOR]
    
    ~$ [FONT=courier new][B]sudo mount /dev/sdb /mnt[/B][/FONT]
    
    ~$ [B][FONT=courier new]sudo btrfs filesystem show --all-devices[/FONT][/B]
    Label: none  uuid: ddf94bee-0a35-4c66-87b7-857db8d21a0c
            Total devices 1 FS bytes used 101.57GiB
            devid    1 size 336.66GiB used 169.06GiB path /dev/sda4
    
    Label: '[COLOR=#ff0000]Btrfs8GB[/COLOR]'  uuid: c83be28a-c757-4939-9b98-057d8dbb2ad4
            Total devices 1 FS bytes used 192.00KiB
            devid    1 size 7.46GiB used 799.50MiB path[COLOR=#ff0000] /dev/sdb[/COLOR]
    
    
    ~$ [B][FONT=courier new]sudo btrfs filesystem df /mnt[/FONT][/B]
    Data, single: total=8.00MiB, used=64.00KiB
    System, DUP: total=8.00MiB, used=16.00KiB
    System, single: total=4.00MiB, used=0.00
    Metadata, DUP: total=381.75MiB, used=112.00KiB
    Metadata, single: total=8.00MiB, used=0.00
    
    ~$ [FONT=courier new][B]sudo btrfs filesystem show /mnt[/B][/FONT]
    Label: Btrfs8GB  uuid: c83be28a-c757-4939-9b98-057d8dbb2ad4
            Total devices 1 FS bytes used 192.00KiB
            devid    1 size 7.46GiB used 799.50MiB path [COLOR=#ff0000]/dev/sdb[/COLOR]
    
    
    ~$ [FONT=courier new][B]vdir /mnt[/B][/FONT]
    total 0
    
    ~$ [FONT=courier new][B]sudo  btrfs subvolume show /mnt[/B][/FONT]
    /mnt is btrfs root
    
    ~$ [FONT=courier new][B]sudo  btrfs subvolume show /[/B][/FONT]
    /
            Name:                   @
            uuid:                   70593792-0f70-7c42-8e26-f1a7cae7d28e
            Parent uuid:            -
            Creation time:          2014-01-21 17:09:59
            Object ID:              257
            Generation (Gen):       45243
            Gen at creation:        6
            Parent:                 5
            Top Level:              5
            Flags:                  -
            Snapshot(s):

    Leave a comment:


  • oshunluvr
    replied
    You can label an entire device.

    sudo mkfs.btrfs -f -LBtrfs8GB /dev/sdb

    Would have worked. From my blkid:
    Code:
    device                 fs_type   label      mount point                UUID
    ------------------------------------------------------------------------------------------------------------
    ~~~
    /dev/sdb               btrfs     data1      (in use)                   ff5136d4-33e1-418e-80ca-d616b37bc70f
    /dev/sdg               btrfs     data1      (in use)                   ff5136d4-33e1-418e-80ca-d616b37bc70f
    /dev/sdi               btrfs     red        (in use)                   dce8ff64-d316-40df-9425-961963d8c42d
    /dev/sdj               btrfs     ssd840pro  (in use)                   8f0c1661-4e84-4512-b875-23bcfd5be1d8
    /dev/sdk               btrfs     ssd840pro  (in use)                   8f0c1661-4e84-4512-b875-23bcfd5be1d8
    I don't know what to expect from the overlapping devices.

    Leave a comment:


  • GreyGeek
    replied
    I was doing some experimenting with external btrfs devices using one of my 8GB flash drives. It is a Verbatim "Store'nGo", which reserves a 500MB partition with a label of that name that cannot be deleted. KParted cannot delete it or re-lable it, but it can reformat the remaining partition of 7.45 GB that is created when a new partition table is created. However, KParted does not offer a btrfs format option!.

    I had previously used sudo mkfs.btrfs -f /dev/sdb to format that stick and that command appeared to work. KParted shows an unformatted partition. Seems like KParted isn't useful for btrfs systems.

    I used sudo mkfs.btrfs -f -LBtrfs8GB /dev/sdb1 to force a label on the sdb1 partititon amd format it using btrfs.
    Code:
    ~$ [FONT=courier new][B]sudo btrfs filesystem show /[/B][/FONT]
    Label: none  uuid: ddf94bee-0a35-4c66-87b7-857db8d21a0c
            Total devices 1 FS bytes used 101.57GiB
            devid    1 size 336.66GiB used 169.06GiB path /dev/sd[B]a[/B]4
    
    
    ~$ [FONT=courier new][B]sudo btrfs filesystem show /mnt[/B][/FONT]
    Label: Btrfs8GB  uuid: 4545f82f-6e16-4f24-b53d-4727ff8936ca
            Total devices 1 FS bytes used 192.00KiB
            devid    1 size 7.45GiB used 799.12MiB path /dev/sdb1
    
    ~$ [FONT=courier new][B]sudo btrfs filesystem df /mnt[/B][/FONT]
    Data, single: total=8.00MiB, used=64.00KiB
    System, DUP: total=8.00MiB, used=16.00KiB
    System, single: total=4.00MiB, used=0.00
    Metadata, DUP: total=381.56MiB, used=112.00KiB
    Metadata, single: total=8.00MiB, used=0.00
    There are TWO block devices created on the 8GB flashdrive, one for sdb and one for sdb1. They both have the same label. THe green uuid is my main HD partition, on sda4. The red ones are on the 8GB flashdrive. Except for the uuid they look almost identical, as if that flashdrive were a 16GB flashdrive.
    Code:
    ~$ [FONT=courier new][B]sudo btrfs filesystem show --all-devices[/B][/FONT]
    Label: [B]none[/B]  uuid: [COLOR=#008000]ddf94bee-0a35-4c66-87b7-857db8d21a0c[/COLOR]
            Total devices 1 FS bytes used 101.57GiB
            devid    1 size 336.66GiB used 169.06GiB path /dev/sda4
    
    Label: '[B]Btrfs8GB[/B]'  uuid:[COLOR=#ff0000] 0e5c129b-46ac-4921-9972-a1b1f7dd23d0[/COLOR]
            Total devices 1 FS bytes used 112.00KiB
            devid    1 size 7.4[B]6[/B]GiB used 799.[B]50[/B]MiB path /dev/[B][COLOR=#ff0000]sdb[/COLOR][/B]
    
    Label: '[B]Btrfs8GB[/B]'  uuid: [COLOR=#ff0000]4545f82f-6e16-4f24-b53d-4727ff8936ca[/COLOR]
            Total devices 1 FS bytes used 192.00KiB
            devid    1 size 7.4[B]5[/B]GiB used 799.[B]12[/B]MiB path /dev/[B][COLOR=#ff0000]sdb1[/COLOR][/B]
    I'm able to overlap a btrfs partitions with no complaints? I've got some more playing to do to sort this out.
    Last edited by GreyGeek; Feb 18, 2014, 06:03 PM.

    Leave a comment:


  • GreyGeek
    replied
    I've done some research about storage mediums. I was looking at 128/256GB space on USB 3 drives, SDXC cards or external USB 3.0 HDs. In my price range on Amazon most USB and SDXC devices had about 10% failure rates, according to their respective comment sections. One's with better quality were 3X my budget allowance. I have a 320GB external USB 2..0 HD, but it has backup info on it. And, as a USB 2.0 device its I/O speed isn't the greatest. So, I decided to get a $59 320GB USB 3.0 HD, exactly like my other external drive except that it uses USB 3.0, which is supposed to be faster. I have a 7 port active USB hub into which I plug all my USB devices except my duplex printer, so I rarely use the single USB 3.0 port on this Acer. My new HD will plug in to it, and I will put the HD between the plates of my clamshell laptop support. (I was really intrigued by the 128GB USB 3.0 flash drives that protude only ¼ inch out from the port, but they were too expensive and their 10% of their ratings were 1 start.)

    So, when that HD arrives I will begin my btrfs experimentation! Fun, fun, fun!!!

    Leave a comment:


  • GreyGeek
    replied
    Originally posted by oshunluvr View Post
    Well, let me say: If your lovely bride knew btrfs was in your thoughts during your walk (isn't it freezing there?) instead of her, and the day before Valentine's day no less, well I don't know what she'd say...

    ...likely not much as she's known you for quite a spell! Not to worry - I won't tell!


    Anyway: I'm honestly not sure if the send command follows the subvolume or the mounted file structure. I'd like to know the answer.
    My bride of 52 years knows me better than I know myself!

    I have two paths to try out. If I bust something I cal always re-install!

    Leave a comment:


  • oshunluvr
    replied
    Well, let me say: If your lovely bride knew btrfs was in your thoughts during your walk (isn't it freezing there?) instead of her, and the day before Valentine's day no less, well I don't know what she'd say...

    ...likely not much as she's known you for quite a spell! Not to worry - I won't tell!


    Anyway: I'm honestly not sure if the send command follows the subvolume or the mounted file structure. I'd like to know the answer.

    Leave a comment:


  • GreyGeek
    replied
    Originally posted by dibl View Post
    I would invite you to reconsider -- this is not an "either / or" decision. The default BTRFS configuration for multi-device filesystem provides BOTH RAID 1 striping (of the data) and Raid 2 mirroring (of the metadata). That's what I have on my system, for my user data.

    https://btrfs.wiki.kernel.org/index....ltiple_Devices
    Your citation has exactly what I want to do! Thanks!
    Conversion

    A non-raid filesystem is converted to raid by adding a device and running a balance filter that will change the chunk allocation profile.
    For example, to convert an existing single device system (/dev/sdb1) into a 2 device raid1 (to protect against a single disk failure):

    mount /dev/sda4 /mnt
    btrfs device add /dev/sdb1 /mnt
    btrfs balance start -dconvert=raid1 -mconvert=raid1 /mnt
    If the metadata is not converted from the single-device default, it remains as DUP, which does not guarantee that copies of block are on separate devices. If data is not converted it does not have any redundant copies at all.

    Using my 320GB USB HD I could create a two device system using RAID1. The question I would have is "would the external USB drive boot up the btrfs system?

    Oshunluver's suggestion to use "send" & "receive" looks like it could work to make a duplicate of / and /home on an external HD without having to be connected all the time.

    At least I now have two well defined plans of attack, and I'm looking forward to the experimentation!

    Leave a comment:


  • GreyGeek
    replied
    Originally posted by oshunluvr View Post
    I believe that is how it's supposed to work. I don't know if you have to send /home separately since your source is the mounted /. I think it's possible that since /home is mounted under / that it might send it all with the first command. It would be an interesting experiment.

    http://docs.oracle.com/cd/E37670_01/E37355/html/ol_sendrecv_btrfs.html
    Aren't "/" and "/home" (@ & @HOME) separate subvolumes? Otherwise, wouldn't a snapshot of / also include /home? When I made a snapshot of "/" I checked specfiically to see if it included /home. It did not.

    I was thinking about this "send" situation while my wife and I were taking our walk ... mounting /dev/sda4 to /mnt and then doing a send of / and /home to /mnt, which is under /. It seems to me that this would create an infinite loop. However, "send" doesn't have any parameters to exclude /mnt, or any other part of /, and the examples you gave don't indicate any looping occurs. Looks like I'll be doing some experimenting.

    Leave a comment:


  • dibl
    replied
    Originally posted by GreyGeek View Post
    Enter the RAID system. We can use RAID0 (striping mode), RAID1 (mirror mode) or RAID10 (stripping and mirroring mode). I want RAID1.I have not done any of the followiing. I'm sort of "thinking out loud".
    I would invite you to reconsider -- this is not an "either / or" decision. The default BTRFS configuration for multi-device filesystem provides BOTH RAID 1 striping (of the data) and Raid 2 mirroring (of the metadata). That's what I have on my system, for my user data.

    https://btrfs.wiki.kernel.org/index....ltiple_Devices
    Last edited by dibl; Feb 13, 2014, 04:48 PM.

    Leave a comment:


  • oshunluvr
    replied
    I believe that is how it's supposed to work. I don't know if you have to send /home separately since your source is the mounted /. I think it's possible that since /home is mounted under / that it might send it all with the first command. It would be an interesting experiment.

    http://docs.oracle.com/cd/E37670_01/E37355/html/ol_sendrecv_btrfs.html

    Leave a comment:


  • GreyGeek
    replied
    Ah, I forgot about the "-send" feature. So, would something like this work if I use a pipe and mount the external drive, previously formatted with btrfs and mounted as /mnt?
    sudo btrfs send / | btrfs recieve /mnt
    sudo btrfs send /home | btrfs receive /mnt/home
    Then umount /mnt.

    Leave a comment:


  • oshunluvr
    replied
    Snapshots aren't really backups. You can do a btrfs --send to copy a filesystem to another drive, but it's a new feature and I've not messed with it. I usually do full backups the old-fashioned way. Alternately, RAID1 or RAID10 are also available if you have enough devices.

    Only downside to the RAID1 with an external drive; if you remove the external (or it doesn't attach at boot time) you have to mount in degraded mode and "fix" the issue.

    Yes, you can migrate your current install to another drive. You add the new device (not as RAID, just as additional space, aka "single"), delete the old device, and the files move to the new drive automatically. When the move ("balance" in btrfs lingo) is done, the old drive is removed from the file system. I know this works because I've done it. btrfs fi sh will show the progress - as the files move, the available space will change and eventually the "deleted" device will disappear from the device list. I did have to re-mkfs.btrfs the old device to generate a new UUID. The software expects you will pull the old device, and so it might re-appear in the device list eventually if you don't.

    Converting a single device to RAID1 is simple. Add the second device first, then run the balance command using -dconvert. Meta will default to raid1.

    Leave a comment:


  • GreyGeek
    replied
    Have you ever noticed the time delay between when you flip a switch and when the flouresencent bulb actually lights up? My brain works that way. I hear an explanation but it may take awhile for the eaning to soke in. Snapshots and backups on a btrfs system is my latest delayed reaction.

    One can mount an external EXT4 formatted HD and copy files from one's computer onto the external drive, then umount it. IF the computer HD goes down the it can be replaced and files restored from the external backup HD.

    Btrfs snapshots on non-raid systems do not allow that. If one makes a snapshot of /, for example, that snapshot is still on the primary btrfs system. If the HD goes down so does the backup. Disaster.

    Attaching a second btrfs device, say /dev/sdb,
    mkfs.btrfs -f /dev/sdb1
    btrfs device add [-Kf] /dev/sdb1 /somepath
    and creating a snapshot of / on it
    sudo mkdir /somepath/.snapshots
    btrfs subvolume snapshot / /somepath/.snapshots/snapshotname
    only creates links to the files on the primary HD.

    No actual data is written to snapshotname, only links to the original data. Copy on Write dictates that when a file changes on the primary system the original file, before the change was made, is copied to the snapshot. If all the files on the primary device, say /dev/sda, changes then eventually the snapshot will contain a complete copy of the original files on the primary system before any changes were made. This is why a btrfs system can eat twice the HD space of an EXT4 system. More snapshots eats up more space. IF, after creating a snapshot on /dev/sdb, that device is umounted, the links to the files on the primary system areno longer active. Any original copies of any changed files on the primary system are not copied to the snapshot. No ability to rollback exists.

    This still leaves the old fashon method of just copying the original files to an EXT4 external HD, or even a btrfs external HD, and then copying them back if necessity requires it. But, this method isn't really entirely sastisfactory because one usually does not copy all the files, just the data files and important config files.

    Enter the RAID system. We can use RAID0 (striping mode), RAID1 (mirror mode) or RAID10 (stripping and mirroring mode). I want RAID1.
    I have not done any of the followiing. I'm sort of "thinking out loud".

    I have a 350GB external USB HD and I have a seven port USB2.0 active hub, into which I can plug several flash drives, either 64GB or 128GB.
    But, can I convert my brtfs single drive to a RAID1 in conjuction with an external drive?

    First, mount my active btrfs system:
    sudo mount /dev/sda4 /mnt
    Convert it to a RAID1 system
    btrfs fi balance start -dconvert=raid1 -mconvert=raid1 /mnt
    but this won't work because there isn't a second device that has already been spanned, which would have happened if we did this:
    mkfs.btrfs /dev/sda4 /dev/sdb1
    in other words, if multiple devices are specified, btrfs is created spanning across the specified devices. The balance command above merely converts both the data (-d) and the metadata (-m) to RAID1, which would mirror /dev/sda4 on /dev/sdb1, assuming /dev/sdb1 is as big or bigger than /dev/sda4.

    If I use
    sudo btrfs device add /dev/sdb1 /somepath
    I haven't done anything except to add space to my existing btrfs filesystem.

    So, at this point, I am assuming there are no btrfs tricks to convert my single btrfs system into a RAID1 by adding a second device.

    I think I could reinstall Trusty Tahr, and from a LiveCD format both my /dev/sda4 and an external HD (/dev/sdb1) together and convert them to RAID1, and then install Trusty on /dev/sda4, which would mirror it to /dev/sdb1. Yes? No?

    Leave a comment:

Users Viewing This Topic

Collapse

There are 0 users viewing this topic.

Working...
X