2

its quite possible I didn't understand what I was doing when I set it up, but...

OK, I bought three 2TB drives that I wanted to use for media storage. I didn't want to deal with figuring out which files to put in which drive, so I Googled "how to span disks" and discovered lvm. Fine, easy enough... so now I have one 6TB "drive" mounted as a ext4 filesystem at /mnt/bigdisk

Everything seems fine, but as I'm now approaching 2TB usage, I started to wonder the following:

1) How is the data being allocated? Does each drive now have 1/3 of 2TB? Or is one almost full? How can I see it?

2) What happens when one (or more) disk is getting near the limit and I add a file large enough that it has to cross disks? An error, or does it just "handle it"?

Thanks.

bcsteeve
  • 1,289

1 Answers1

2

It depends on how you set it up. The default is to fill one up and then the next, which is handled transparently. When creating a logical volume with lvcreate, you can specify the --stripes nn flag to stripe the data across nn drives. This allows faster access to data since it is simultaneously accessed on all drives in parallel. You can see the current layout with lvdisplay -m and if you want to change it to striped, you can use lvconvert --stripes 3 vg/lv where vg and lv are the names of the volume group and logical volume. This can take a long time if you allocated all of the space to the volume already. Also for media storage, speed isn't really important and if you want the drives to be able to spin down to save power, then leaving it not striped may be better since only the drive that has the data you are accessing will need to wake up instead of all 3.

As for how to see how much space is used on each disk, there is not a good way of doing that.

psusi
  • 37,551
  • Thanks. I'll trust the "transparently" part to work well :) I'd still like to know what happens at that point, but I guess if it just serves to satisfy curiosity, then its not that important. I'm taking it that if I have 99.9% full and the next file is > 0.1% that it will either span that file across both drives, or otherwise it will know its larger than the available space and it will put it in the next drive. If the latter, then is that 0.1% permanently "wasted"? Or will the next file that fits get allocated there? – bcsteeve Nov 17 '13 at 03:14
  • 1
    @bcsteeve, it is done on a block level, not a file level, so if the filesystem chooses to put a file ( or part of a file ) on blocks that are mapped to the next drive, then that is where they go. This may very well happen before all of the blocks on the first drive are used. – psusi Nov 17 '13 at 04:38