0

I have a volume which I believe to be btrfs, but the partition bearing it has an odd number of blocks and there is a little space left before the next partition.

I'd like to check it's type (btrfs expected) and know the exact space It occupies in my partition (When asking google, I get information about the apparent size vs real size problem related with snapshots, which I don't care about right now)

To make things clearer :

  • I'm NOT looking for the size/type of the partition itself, but for the size of the filesystem (the data structure) which should normally be smaller or equal the partition size; and
  • I'm also NOT looking for the free space inside the filesystem.

2 Answers 2

2

You can use lsblk -f or blkid -p <device> to check for the filesystem type.

To check size of the btrfs filesystem use btrfs filesystem show <mountpoint>. It prints all devices that are part of the btrfs volume and their sizes:

Label: none  uuid: 19e516b2-50bb-4130-9b6e-ee245fb45e43
        Total devices 1 FS bytes used 144.00KiB
        devid    1 size 2.00GiB used 228.75MiB path /dev/sdb

You can see the size of the filesystem on /dev/sdb is 2 GiB. If you are interested in the exact size, use --raw to print sizes in bytes:

Label: none  uuid: 19e516b2-50bb-4130-9b6e-ee245fb45e43
        Total devices 1 FS bytes used 147456
        devid    1 size 2147483648 used 239861760 path /dev/sdb

(Quick check this is really size of the filesystem and not the block device: after shrinking the filesystem with btrfs filesystem resize it now shows devid 1 size 1.90GiB used 228.75MiB path /dev/sdb.)

2
  • Didn't you make a mistake ? I do not find this info sub command, but the show sub command instead...
    – Camion
    Feb 17 at 4:07
  • 1
    Yes, btrfs filesystem show is the correct command. Feb 17 at 5:25
0

Show partition size:

parted -l <device> unit s print

You can try command above. <device> is expected to be /dev/sda, /dev/sdb, /dev/mmcblk1, etc.

  • unit s means set unit to sector
  • print shows disk information

Show filesystem usage:

df

or

df -h

h option of df command makes the format readable for humans. This option will use a unit like G or M.

for Btrfs:

btrfs filesystem df <path>

Show Btrfs filesystem usage:

btrfs filesystem usage <path>

You can replace <path> with like /.

2
  • This gives me the size of the partition. This isn't what i'm looking for. What i want to know is the size of the filesystem (the data) occupying the partition. Typically, the partition is the reserved space, but the data structure inside can be smaller or even larger in bad cases. And by the way, it doesn't give me the filesystem type (the only think I can see is that it is one of the multiples linux filesystems,
    – Camion
    Feb 16 at 4:06
  • df and btrfs filesystem usage inform me about the occupation INSIDE the file system. What I'm looking for, is the OUTSIDE information about the filesystem but inside the partition (not the partition itself).
    – Camion
    Feb 17 at 4:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.