Filesystem https://tech.feedyourhead.at/ en Btrfs: Turning a mdadm-array into a btrfs https://tech.feedyourhead.at/content/btrfs-turning-mdadm-array-btrfs <span class="field field--name-title field--type-string field--label-hidden">Btrfs: Turning a mdadm-array into a btrfs</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p><img alt="" src="http://tech.feedyourhead.at/sites/tech.feedyourhead.at/files/pictures/Btrfs_logo.png" /></p> <p>Btrfs is supposed to be the "better filesystem". It is easy to use and has a nice feature-list. Since I had some troubles with a raid1 using mdadm in the past, I will try to turn my private raid-array in a btrfs. In this article I will not post the mdadm-commands(and lvm2 commands)...</p> <p>First I just remove one disk from my array and format it with btrfs:</p> <pre> <code> mkfs.btrfs /dev/sdc </code></pre> <p>Now I have a single disk in my btrfs. The cool thing about btrfs is, that I can convert my btrfs to any supported raid during runtime. This feature I want to test. So first I will mount mount btrfs but I want to use compression on my filesystem. It's super easy to use compression since it's just a mount-option. I just created an entry in my /etc/fstab:</p> <pre> <code> /dev/sdc /mnt/Raid btrfs compress=zlib,defaults 0 0 </code></pre> <p>Now I can mount my btrfs:</p> <pre> <code> mount /mnt/Raid </code></pre> <p>Now I can easily copy(for example using rsync) my data from the old mdadm-raid to my btrfs. Once this is done, I will just delete my mdadm-array and destroy the raid-meta-data using --zero-superblock(<strong>I made a backup of all my data before!</strong>). After that I have a plain disk(/dev/sdb) and I will add this disk to my btrfs:</p> <pre> <code> btrfs device add /dev/sdb /mnt/Raid/ </code></pre> <p>Finally I was very courious if I can convert the btrfs into a raid1 using the following command:</p> <pre> <code> btrfs balance start -dconvert=raid1 -mconvert=raid1 /mnt/Raid </code></pre> <p>This job runs in foreground so I would recommend using screen for it. It might take a long time. If you want to monitor the progress you can just use this command:</p> <pre> <code> watch -n1 btrfs fi df /mnt/Raid </code></pre> <p>The following one-shot-command gives a good overview about your btrfs:</p> <pre> <code> btrfs fi show; btfs fi df /mnt/Raid </code></pre> <p>It really worked like expected. I just converted my single btrfs to a raid1 using 2 disks. But I have one problem: the filesystem is mounted using this fstab-entry:</p> <pre> <code> /dev/sdc /mnt/Raid btrfs compress=zlib,defaults 0 0 </code></pre> <p>What if /dev/sdc gets broken? Then I would have to manually mount /dev/sdb. It does not matter which device I do mount since both get synchronized but if the device doesn't exist, the system would not be able to mount my filesystem. So I created a filesystem-label:</p> <pre> <code> btrfs filesystem label /mnt/Raid/ RAIDBUTTER </code></pre> <p>And I changed my fstab-entry into:</p> <pre> <code> LABEL=RAIDBUTTER /mnt/Raid btrfs compress=zlib,defaults 0 0 </code></pre> <p>It's not the end for me. Until now, I mounted my mdadm-raid and on this partition I had a directory for all my home-directories. This directory I mounted using bind-mount into /home. It was good enough for me, but it just feels like a dirty hack. Btrfs gives me the opportunity to create subvolumes. Those subvolumes I can mount wherever I want and it is just a directory in my normal btrfs. I created my subvolume using this command:</p> <pre> <code> btrfs subvolume create /mnt/Raid/Home </code></pre> <p>At last I can mount it using this fstab-line:</p> <pre> <code> LABEL=RAIDBUTTER /home btrfs subvol=Home,compress=zlib,auto,user 0 0 </code></pre> <p>Great, isn't it? In summary I can say that I really like the btrfs. It is very easy to use and has a nice feature list.</p> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/users/hoti" typeof="schema:Person" property="schema:name" datatype="">Hoti</span></span> <span class="field field--name-created field--type-created field--label-hidden">Aug 30 2015</span> <div class="field field--name-field-tagies field--type-entity-reference field--label-above"> <div class="field__label">Tags</div> <div class='field__items'> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/filesystem" hreflang="en">Filesystem</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/Linux" hreflang="en">Linux</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/sysadmin" hreflang="en">Sysadmin</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/btrfs" hreflang="en">Btrfs</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/software-raid" hreflang="en">Software-Raid</a></div> </div> </div> <section class="field field--name-comment-node-blog field--type-comment field--label-hidden comment-wrapper"> </section> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class='title comment-form__title'> <i class="fa fa-comments-o"></i> Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=102&amp;2=comment&amp;3=comment" token="F9wTP5enL8AmVIRvOmgO7TVSiZzXEZgCZECe7Mia3jg"></drupal-render-placeholder> </section> Sun, 30 Aug 2015 18:58:12 +0000 Hoti 102 at https://tech.feedyourhead.at