17

If I'm going to create a multi-device btrfs filesystem. The official recommendation from the documentation apppears to be to create it on raw devices; i.e. /dev/sdb, /dev/sdc, etc, but this is not explained.

Are there any advantages to creating a partition table on these devices first, either GPT or MBR, and then creating the filesystem on /dev/sdb1, /dev/sdc1 et cetera? Does feeding btrfs whole devices have some particular advantage, or are these basically equivalent?

4 Answers 4

8

Partitioning is just a way to split a disk up into multiple volumes which can be used independently. If you only want one volume per disk, partitioning doesn't buy you anything -- it just uses up some additional disk space (yes, it's very small), and complicates things like aligning your data on harddrives with 4K sectors or flash drives. The only other reason to have a partition table is in order to boot off that drive. If there's no reason to have a partition table it's simpler to just omit it.

1
  • "Even though Btrfs supports raw disks, it is recommended that you do have a partition table on your disk to avoid confusion with other filesystems and tools." wiki.tnonline.net/w/Btrfs/Replacing_a_disk I don't know who to believe...
    – endolith
    Apr 19, 2023 at 14:25
4

There are a number of disadvantages of partitioning. MBR wastes a whole "track". A track is number of sectors times sector size, but a real disc does have sectors and sector size is not 512o. A real disc has blocks which are 8 times larger for rotating disc and much larger for flash devices. This shifting to the next track may make it impossible to align "logical" sectors with actual blocks using stride and stripe.

In the old days you could define sector size in FAT, but MBR put an end to that.

If you are booting from the disc then BIOS needs a boot signature in the end of the first 512o so that it knows it can run this when its loaded. If you are running EFI get drunk. The file system would need to have a hole for this if it is to be used to boot the system.

XFS (mostly used on /var on rotating discs) does not have such a hole.

1
  • 2
    I am a little confused; wouldn't "(total) number of sectors times sector size" be the entire disk, if the disk is made up of sectors? Or is something other than "total" implied?
    – Glyph
    Nov 13, 2012 at 23:35
1

If I understand correctly, using whole disks will allow BTRFS to make some assumptions which allow some optimization of behavior.

Like, if granted full devices to work from, it can assume that it won't have anything challenging it for access to the device, and it can tailor its access methods instead of having to anticipate delays periodically from something else asking for data from somewhere else on the device, and having to wait for the drive to get back to it after handling the other request.

3
  • 1
    What you're describing is called the reality of disk IO in general, not anything filesystem-specific. What specifically have you seen in btrfs that optimizes or schedules IO differently based on whether or not a partition table exists? Apr 18, 2017 at 19:22
  • The filesystem doesn't do it. The OS does it if said behavior is appropriate. My uses of "it" were probably ambiguous and/or overlapping and/or exclusive of each other.
    – killermist
    Apr 20, 2017 at 2:00
  • Do you have any examples?
    – endolith
    Apr 19, 2023 at 14:26
0

Use seperate Disks to get advantages to disk read/save speed.

Basically, /dev/sda is one hard disk, and /dev/sda1, /dev/sda2 are parts of the same physical disk.

if you use /dev/sda, + /dev/sdb for your setup, you have two separate disks able to retrive at the same time.

if you use /dev/sda1 /dev/sda2 then you get the same disk trying to read both, and so it has to do one and then the other.

4
  • 1
    If you're saying that using sda is faster than sda1, where does this speed advantage come from? Jun 3, 2012 at 20:48
  • the speed advantage comes from parallel hardware storing and retrieving your data, instead of the same hardware trying to skip to multiple locations on the same disk
    – Jharwood
    Jun 3, 2012 at 20:50
  • 2
    There wasn't any mention of multiple locations or multiple partitions. The question is about a single partition covering the whole disk. Jun 3, 2012 at 21:03
  • Ahh, sorry I misunderstood the question.
    – Jharwood
    Jun 3, 2012 at 22:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .