All of lore.kernel.org
 help / color / mirror / Atom feed
* btrfs filesystem show _exact_ freaking size?
@ 2014-11-18 10:39 Robert White
  2014-11-18 10:59 ` Hugo Mills
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Robert White @ 2014-11-18 10:39 UTC (permalink / raw)
  To: Btrfs BTRFS

Howdy,

How does one get the exact size (in blocks preferably, but bytes okay) 
of the filesystem inside a partition? I know how to get the partition 
size, but that's not useful when shrinking a partition...

So, for example, you successfully do

btrfs filesystem resize -32G /dev/sdz2

now you've got "some space" zero idea how many sectors can be trimmed 
off the end of the partition, you can do the math but thats a little 
iffy, especially if the file system didn't originally fill the partition 
to begin with.

The current methodology for most such actions is to way over-trim the 
file system, then reallocate the space using your partition tool of 
choice, then re-grow the filesystem to fit. This has been the way of 
things forever and it blows...

There needs to be an option to btrfs filesystem show that will tell you 
XXXXXblocks, not Y.ZZ terabytes.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: btrfs filesystem show _exact_ freaking size?
  2014-11-18 10:39 btrfs filesystem show _exact_ freaking size? Robert White
@ 2014-11-18 10:59 ` Hugo Mills
  2014-11-18 11:26 ` Gabriel de Perthuis
  2014-11-18 12:41 ` Duncan
  2 siblings, 0 replies; 4+ messages in thread
From: Hugo Mills @ 2014-11-18 10:59 UTC (permalink / raw)
  To: Robert White; +Cc: Btrfs BTRFS

[-- Attachment #1: Type: text/plain, Size: 1552 bytes --]

On Tue, Nov 18, 2014 at 02:39:48AM -0800, Robert White wrote:
> Howdy,
> 
> How does one get the exact size (in blocks preferably, but bytes
> okay) of the filesystem inside a partition? I know how to get the
> partition size, but that's not useful when shrinking a partition...
> 
> So, for example, you successfully do
> 
> btrfs filesystem resize -32G /dev/sdz2
> 
> now you've got "some space" zero idea how many sectors can be
> trimmed off the end of the partition, you can do the math but thats
> a little iffy, especially if the file system didn't originally fill
> the partition to begin with.
> 
> The current methodology for most such actions is to way over-trim
> the file system, then reallocate the space using your partition tool
> of choice, then re-grow the filesystem to fit. This has been the way
> of things forever and it blows...
> 
> There needs to be an option to btrfs filesystem show that will tell
> you XXXXXblocks, not Y.ZZ terabytes.

   The 3.17 userspace tools should now support flags to select the
display units in some detail, including bytes.

   Even without that, though, for your use case, I would recommend
shrinking the FS by *more* than you wanted to shrink, resizing the
partition, and then resizing the FS back up to fit the partition
exactly (with btrfs fi resize n:max).

   Hugo.

-- 
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
  PGP key: 65E74AC0 from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
                 --- Stick them with the pointy end ---                  

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: btrfs filesystem show _exact_ freaking size?
  2014-11-18 10:39 btrfs filesystem show _exact_ freaking size? Robert White
  2014-11-18 10:59 ` Hugo Mills
@ 2014-11-18 11:26 ` Gabriel de Perthuis
  2014-11-18 12:41 ` Duncan
  2 siblings, 0 replies; 4+ messages in thread
From: Gabriel de Perthuis @ 2014-11-18 11:26 UTC (permalink / raw)
  To: Robert White; +Cc: Btrfs BTRFS

Le 18/11/2014 11:39, Robert White a écrit :
> Howdy,
> 
> How does one get the exact size (in blocks preferably, but bytes okay)
> of the filesystem inside a partition? I know how to get the partition
> size, but that's not useful when shrinking a partition...

dev_item.total_bytes in brtfs-show-super's output is what you're after.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: btrfs filesystem show _exact_ freaking size?
  2014-11-18 10:39 btrfs filesystem show _exact_ freaking size? Robert White
  2014-11-18 10:59 ` Hugo Mills
  2014-11-18 11:26 ` Gabriel de Perthuis
@ 2014-11-18 12:41 ` Duncan
  2 siblings, 0 replies; 4+ messages in thread
From: Duncan @ 2014-11-18 12:41 UTC (permalink / raw)
  To: linux-btrfs

Robert White posted on Tue, 18 Nov 2014 02:39:48 -0800 as excerpted:

> How does one get the exact size (in blocks preferably, but bytes okay)
> of the filesystem inside a partition? I know how to get the partition
> size, but that's not useful when shrinking a partition...

> There needs to be an option to btrfs filesystem show that will tell you
> XXXXXblocks, not Y.ZZ terabytes.

While having a btrfs fi show option for that would be nice, take a look 
at the output of btrfs-show-super.

The dev_item.total_bytes line appears to be the total filesystem bytes -- 
at least here on my exactly-8-GiB partitions, that's /exactly/ what it 
shows, 8589934592, which is 8*1024*1024*1024, and my /exactly/ 256 MiB 
partition shows 268435456, /exactly/ 256 MiB, as well.

The total_bytes line is the full /filesystem/ size, which should be the 
same as the dev_item.total_bytes number on a single-device-filesystem.  
Of course on my two-device btrfs filesystems here it's showing double the 
single-device size, which is as it should be.

But you're correct, having a btrfs fi show option for that would be more 
end-user friendly.  The btrfs-show-super output is rather low-level for 
that, but it does work.

-- 
Duncan - List replies preferred.   No HTML msgs.
"Every nonfree program has a lord, a master --
and if you use the program, he is your master."  Richard Stallman


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-11-18 12:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-18 10:39 btrfs filesystem show _exact_ freaking size? Robert White
2014-11-18 10:59 ` Hugo Mills
2014-11-18 11:26 ` Gabriel de Perthuis
2014-11-18 12:41 ` Duncan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.