should I put my multi-device btrfs filesystem on disk partitions or raw devices?

17

2

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?

Glyph

Posted 2012-06-03T19:50:47.757

Reputation: 538

Answers

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 removes some 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.

mgorven

Posted 2012-06-03T19:50:47.757

Reputation: 2 539

3

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.

Andrew Buckeridge

Posted 2012-06-03T19:50:47.757

Reputation: 39

1I 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 – 2012-11-13T23:35:31.223

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.

killermist

Posted 2012-06-03T19:50:47.757

Reputation: 1 886

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? – Brian Cline – 2017-04-18T19:22:57.490

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 – 2017-04-20T02:00:21.693

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.

Jharwood

Posted 2012-06-03T19:50:47.757

Reputation: 409

1If you're saying that using sda is faster than sda1, where does this speed advantage come from? – user1686 – 2012-06-03T20:48:07.827

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 – 2012-06-03T20:50:05.297

2There wasn't any mention of multiple locations or multiple partitions. The question is about a single partition covering the whole disk. – user1686 – 2012-06-03T21:03:03.220

Ahh, sorry I misunderstood the question. – Jharwood – 2012-06-03T22:11:01.280