Skip to contentSkip to conversation

Free space left

DISCUSSION Michael Niederle 4 participants 8 messages Jan 16, 2010 Btrfs file system

lore
Share & tools
lore
#0 lore raw

How can I detect how much free space is left on a btrfs-volume?

As I read (and learned in practice!) "df" reports cannot be trusted if used on btrfs-volumes.

Greetings, Michael

#1 lore raw
Quoted 3 lines · Michael Niederle

How can I detect how much free space is left on a btrfs-volume?

As I read (and learned in practice!) "df" reports cannot be trusted if used

on

Quoted 1 line

btrfs-volumes.

Try btrfs-show

$ btrfs-show
Label: bar  uuid: ec2918cd-ad47-4eac-9e85-5604b02fd922
        Total devices 1 FS bytes used 302.25MB
        devid    1 size 964.81MB used 614.50MB path /dev/sdc1

Label: debian-root uuid: 6e2a647f-5da2-4bd0-a7d7-9b13d13a47cc
Total devices 1 FS bytes used 23.52GB
devid 1 size 232.11GB used 118.03GB path /dev/sdc3

Btrfs Btrfs v0.19

BR
G.Baroncelli

Signature · 2 lines
gpg key@ keyserver.linux.it: Goffredo Baroncelli (ghigo) <[email protected]>
Key fingerprint = 4769 7E51 5293 D36C 814E  C054 BF04 F161 3DC5 0512
#2 lore raw

Hi, Goffredo!

Quoted 1 line

Try btrfs-show

Thanks for your advice!

btrfs-show works but it displays a lot of error message for non-btrfs devices:

Quoted 1 line

btrfs-show

failed to read /dev/sdg
failed to read /dev/sdg1
failed to read /dev/sdg2
failed to read /dev/sdg3
failed to read /dev/sdg4
failed to read /dev/md1
failed to read /dev/fd0
failed to read /dev/fd0u1440
failed to read /dev/fd1
failed to read /dev/hda
failed to read /dev/hda1
failed to read /dev/hda10
failed to read /dev/hda11
failed to read /dev/hda12
...
failed to read /dev/sr0
failed to read /dev/sr1
failed to read /dev/sr2
failed to read /dev/sr3
...
Label: Alpha4 uuid: 63b82dad-ed81-41f4-910f-7b358ceb77ba

	Total devices 1 FS bytes used 11.81GB
	devid    1 size 20.01GB used 20.01GB path /dev/sda3

Btrfs v0.19-4-gab8fb4c

Even if I try

btrfs-show /dev/sda3

I get the same output.

Greetings, Michael

#3 lore raw
Quoted 7 lines · you (Dipl.-Ing. Michael Niederle)

Hi, Goffredo!

Quoted 1 line

Try btrfs-show

Thanks for your advice!

btrfs-show works but it displays a lot of error message for non-btrfs

devices:

Quoted 28 lines
Quoted 2 lines

btrfs-show

failed to read /dev/sdg
failed to read /dev/sdg1
failed to read /dev/sdg2
failed to read /dev/sdg3
failed to read /dev/sdg4
failed to read /dev/md1
failed to read /dev/fd0
failed to read /dev/fd0u1440
failed to read /dev/fd1
failed to read /dev/hda
failed to read /dev/hda1
failed to read /dev/hda10
failed to read /dev/hda11
failed to read /dev/hda12
...
failed to read /dev/sr0
failed to read /dev/sr1
failed to read /dev/sr2
failed to read /dev/sr3
...
Label: Alpha4 uuid: 63b82dad-ed81-41f4-910f-7b358ceb77ba

	Total devices 1 FS bytes used 11.81GB
	devid    1 size 20.01GB used 20.01GB path /dev/sda3

Btrfs v0.19-4-gab8fb4c

Quoted 8 lines

Even if I try

btrfs-show /dev/sda3

I get the same output.

Greetings, Michael

Yes they search in every block devices a btrfs file-system. It may be smarter/faster skipping the floppy and the cd-rom..

BR
G.Baroncelli

Signature · 2 lines
gpg key@ keyserver.linux.it: Goffredo Baroncelli (ghigo) <kreijackATinwind.it>
Key fingerprint = 4769 7E51 5293 D36C 814E  C054 BF04 F161 3DC5 0512
#4 lore raw
In reply to Goffredo Baroncelli
Quoted 2 lines · Goffredo Baroncelli

Try btrfs-show

Ok:

$ mount
/dev/sdc on /media/452f782b-738a-4699-abfa-588eecab07ea type btrfs (rw,nosuid,nodev,uhelper=devkit)
$ df
/dev/sdc              932G  6.7G  925G   1% /media/452f782b-738a-4699-abfa-588eecab07ea
$ btrfs-show
failed to read /dev/sdb1
failed to read /dev/sdc
failed to read /dev/sdb
failed to read /dev/sda5
failed to read /dev/sda1
failed to read /dev/sda6
failed to read /dev/sda2
failed to read /dev/sda
failed to read /dev/sr0
failed to read /dev/loop1
failed to read /dev/ram2
failed to read /dev/ram10
failed to read /dev/ram11
failed to read /dev/loop7
failed to read /dev/ram1
failed to read /dev/loop0
failed to read /dev/loop5
failed to read /dev/loop2
failed to read /dev/loop3
failed to read /dev/loop4
failed to read /dev/loop6
failed to read /dev/ram12
failed to read /dev/ram4
failed to read /dev/ram13
failed to read /dev/ram5
failed to read /dev/ram8
failed to read /dev/ram14
failed to read /dev/ram15
failed to read /dev/ram0
failed to read /dev/ram3
failed to read /dev/ram6
failed to read /dev/ram9
failed to read /dev/ram7
Btrfs Btrfs v0.19

The drive used is a Seagate FreeAgent 1Tb USB drive under Ubuntu 9.10

$ uname -a
Linux ebrostig-laptop 2.6.31-18-generic-pae #55-Ubuntu SMP Fri Jan 8 16:13:23 UTC 2010 i686 GNU/Linux

Erik

#5 lore raw
Quoted 11 lines · you (Svein Erik Brostigen)
Quoted 2 lines · Goffredo Baroncelli

Try btrfs-show

Ok:

$ mount
/dev/sdc on /media/452f782b-738a-4699-abfa-588eecab07ea type btrfs 
(rw,nosuid,nodev,uhelper=devkit)
Quoted 7 lines
$ df
/dev/sdc              932G  6.7G  925G   1% 
/media/452f782b-738a-4699-abfa-588eecab07ea
$ btrfs-show
failed to read /dev/sdb1
failed to read /dev/sdc

^^^^^^^^^

It seems that you don't have the right to read /dev/sdc.

Retry as super user.
[...]

Quoted 11 lines

Btrfs Btrfs v0.19

The drive used is a Seagate FreeAgent 1Tb USB drive under Ubuntu 9.10

$ uname -a
Linux ebrostig-laptop 2.6.31-18-generic-pae #55-Ubuntu SMP Fri Jan 8 
16:13:23 UTC 2010 i686 GNU/Linux

Erik

Signature · 2 lines
gpg key@ keyserver.linux.it: Goffredo Baroncelli (ghigo) <[email protected]>
Key fingerprint = 4769 7E51 5293 D36C 814E  C054 BF04 F161 3DC5 0512
#6 lore raw
In reply to Goffredo Baroncelli

Hello,

Quoted 2 lines · [email protected] (Goffredo Baroncelli) writes:

Try btrfs-show
[...]

How do you read this then:

Label: none uuid: 27fafa43-7ad0-4e8a-ada8-36f73ef8984c

        Total devices 2 FS bytes used 79.63GB
        devid    2 size 111.79GB used 111.01GB path /dev/sdb
        devid    1 size 111.79GB used 111.03GB path /dev/sda

I'm pretty sure I created this fs with -d raid1 -m raid1! Speaking of which, is there a way to read a FS configuration: how can I tell this FS really uses raid1 for both data and metadata?

The used column is surprising: if it's a mirror why 111.01 and 111.03? And why all the space is being used anyway: I mean what's the difference between the 79.63GB and 111.0[13]?

And the output of df is confusing too:
/dev/sdb 234441648 83501968 150939680 36% /space

It's reporting twice the total space but I think I remember looking it up and that should be fixed in a future kernel version.

Signature · 3 lines
Mathieu Chouquet-Stringer                           [email protected]
            The sun itself sees not till heaven clears.
	             -- William Shakespeare --
#7 lore raw
Quoted 8 lines · Mathieu Chouquet-Stringer

Hello,

Quoted 2 lines · [email protected] (Goffredo Baroncelli) writes:

Try btrfs-show
[...]

How do you read this then:

Quoted 8 lines

Label: none uuid: 27fafa43-7ad0-4e8a-ada8-36f73ef8984c

        Total devices 2 FS bytes used 79.63GB
        devid    2 size 111.79GB used 111.01GB path /dev/sdb
        devid    1 size 111.79GB used 111.03GB path /dev/sda

I'm pretty sure I created this fs with -d raid1 -m raid1! Speaking of which, is there a way to read a FS configuration: how can I tell this FS really uses raid1 for both data and metadata?

Even tough the raid mode is set per filesystem, btrfs has (will have) the capability to set the raid level per file. So it is no simple to estimate the free space: if every file is raid1 the real free space is half of the physical free space. But if some file are in raid1 (for examples /etc) and others are in raid0 (for example the ones under /usr which may be re-downloaded) the used space and the free space are difficult to estimate.

There are some efforts to fix this kind of situation (see the thread "[PATCH]
Btrfs-progs: add btrfsctl -i to print space info").

Quoted 14 lines

The used column is surprising: if it's a mirror why 111.01 and 111.03? And why all the space is being used anyway: I mean what's the difference between the 79.63GB and 111.0[13]?

And the output of df is confusing too:
/dev/sdb 234441648 83501968 150939680 36% /space

It's reporting twice the total space but I think I remember looking it up and that should be fixed in a future kernel version.

Signature · 3 lines
Mathieu Chouquet-Stringer                           [email protected]
            The sun itself sees not till heaven clears.
	             -- William Shakespeare --
Signature · 2 lines
gpg key@ keyserver.linux.it: Goffredo Baroncelli (ghigo) <kreijackATinwind.it>
Key fingerprint = 4769 7E51 5293 D36C 814E  C054 BF04 F161 3DC5 0512