What does `stat -c '%B' *` mean? [duplicate]

Clash Royale CLAN TAG#URR8PPP
up vote
-1
down vote
favorite
This question already has an answer here:
file block size - difference between stat and ls
3 answers
stat -c '%B' * reports the same number 512 for each file. What does %B mean? I don't understand the manual:
%B - The size in bytes of each block reported by âÂÂ%bâÂÂ
Is it related to my block size:
$ sudo blockdev --getbsz /dev/sda1
4096
Thanks.
linux files stat
marked as duplicate by muru, G-Man, Tomasz, Rui F Ribeiro
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Jun 17 at 8:28
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
up vote
-1
down vote
favorite
This question already has an answer here:
file block size - difference between stat and ls
3 answers
stat -c '%B' * reports the same number 512 for each file. What does %B mean? I don't understand the manual:
%B - The size in bytes of each block reported by âÂÂ%bâÂÂ
Is it related to my block size:
$ sudo blockdev --getbsz /dev/sda1
4096
Thanks.
linux files stat
marked as duplicate by muru, G-Man, Tomasz, Rui F Ribeiro
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Jun 17 at 8:28
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
This question already has an answer here:
file block size - difference between stat and ls
3 answers
stat -c '%B' * reports the same number 512 for each file. What does %B mean? I don't understand the manual:
%B - The size in bytes of each block reported by âÂÂ%bâÂÂ
Is it related to my block size:
$ sudo blockdev --getbsz /dev/sda1
4096
Thanks.
linux files stat
This question already has an answer here:
file block size - difference between stat and ls
3 answers
stat -c '%B' * reports the same number 512 for each file. What does %B mean? I don't understand the manual:
%B - The size in bytes of each block reported by âÂÂ%bâÂÂ
Is it related to my block size:
$ sudo blockdev --getbsz /dev/sda1
4096
Thanks.
This question already has an answer here:
file block size - difference between stat and ls
3 answers
linux files stat
edited Jun 15 at 8:59
ilkkachu
47.5k668130
47.5k668130
asked Jun 15 at 0:36
Tim
22.5k61222401
22.5k61222401
marked as duplicate by muru, G-Man, Tomasz, Rui F Ribeiro
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Jun 17 at 8:28
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by muru, G-Man, Tomasz, Rui F Ribeiro
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Jun 17 at 8:28
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
2
down vote
There are two allocation sizes that matter when looking at a file system: the filesystem's block size and the disk's sector size. Most SATA drives have 512-byte sectors, although there are exceptions: drives with 4KB sectors are not uncommon. You can get this information with hdparm:
# hdparm -I /dev/sdb|grep Sector
Logical/Physical Sector size: 512 bytes
When mapped to filesystem blocks, however, 512 bytes imposes a fair amount of overhead when naming blocks if the drive is large enough (the metadata required to store allocation information is space that can't be used to store data.) Generally, the block size is determined automatically by the format program, but you can usually override it. For example, the method used for ext3/4 is as follows:
-T usage-type[,...]
Specify how the filesystem is going to be used, so that
mke2fscan
choose optimal filesystem parameters for that use. The usage types
that are supported are defined in the configuration file
/etc/mke2fs.conf(5). The user may specify one or more usage types
using a comma separated list.
If this option is is not specified,
mke2fswill pick a single
default usage type based on the size of the filesystem to be created.
If the filesystem size is less than or equal to 3 megabytes,mke2fs
will use the filesystem typefloppy. If the filesystem size is greater
than 3 but less than or equal to 512 megabytes,mke2fs(8) will use
the filesystemsmall. Otherwise,mke2fs(8) will use the default
filesystem typedefault.
The defaults indicate that 4KB blocks are the default, as my /etc/mke2fs.conf shows:
[defaults]
base_features = sparse_super,large_file,filetype,resize_inode,dir_index,ext_attr
default_mntopts = acl,user_xattr
enable_periodic_fsck = 0
blocksize = 4096
inode_size = 256
inode_ratio = 16384
So, %B is showing you the size of the physical sectors, which when multiplied by the number of sectors used %b gives you the total number of bytes allocated on disk. It's usually of no relevance at all, as no filesystem allocation will be smaller than the block size, but it does help you determine that all allocations of physical sectors will be multiples of 8 (4KB/512 bytes=8):
# stat test.img
File: test.img
Size: 536870912 Blocks: 1048584 IO Block: 4096 regular file
So, with this information, you can determine the number of bytes allocated on-disk and unused allocated space for this file:
Number of blocks * block size = 1048584 blocks * 512 bytes/block = 536875008 bytes.
Amount of unused allocated space: 536875008-536870912 bytes = 4096 bytes unused.
1
See Gilles's answer on the dupe; even if the disk had 4KB sectors,%Bwould be 512 on Linux.
â muru
Jun 15 at 3:33
@muru Interesting: I hadn't realized that. You've got to love backwards compatibility!
â ErikF
Jun 15 at 3:37
See my answer for the background...
â schily
Jun 15 at 8:10
add a comment |Â
up vote
0
down vote
If the stat command behaves as documented in the man page, %B would return the value of DEV_BSIZE from the include file param.h.
This value is 512 on most systems, but 1024 on HP-UX.
BTW: This value is not related to the sector size of the drives.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
There are two allocation sizes that matter when looking at a file system: the filesystem's block size and the disk's sector size. Most SATA drives have 512-byte sectors, although there are exceptions: drives with 4KB sectors are not uncommon. You can get this information with hdparm:
# hdparm -I /dev/sdb|grep Sector
Logical/Physical Sector size: 512 bytes
When mapped to filesystem blocks, however, 512 bytes imposes a fair amount of overhead when naming blocks if the drive is large enough (the metadata required to store allocation information is space that can't be used to store data.) Generally, the block size is determined automatically by the format program, but you can usually override it. For example, the method used for ext3/4 is as follows:
-T usage-type[,...]
Specify how the filesystem is going to be used, so that
mke2fscan
choose optimal filesystem parameters for that use. The usage types
that are supported are defined in the configuration file
/etc/mke2fs.conf(5). The user may specify one or more usage types
using a comma separated list.
If this option is is not specified,
mke2fswill pick a single
default usage type based on the size of the filesystem to be created.
If the filesystem size is less than or equal to 3 megabytes,mke2fs
will use the filesystem typefloppy. If the filesystem size is greater
than 3 but less than or equal to 512 megabytes,mke2fs(8) will use
the filesystemsmall. Otherwise,mke2fs(8) will use the default
filesystem typedefault.
The defaults indicate that 4KB blocks are the default, as my /etc/mke2fs.conf shows:
[defaults]
base_features = sparse_super,large_file,filetype,resize_inode,dir_index,ext_attr
default_mntopts = acl,user_xattr
enable_periodic_fsck = 0
blocksize = 4096
inode_size = 256
inode_ratio = 16384
So, %B is showing you the size of the physical sectors, which when multiplied by the number of sectors used %b gives you the total number of bytes allocated on disk. It's usually of no relevance at all, as no filesystem allocation will be smaller than the block size, but it does help you determine that all allocations of physical sectors will be multiples of 8 (4KB/512 bytes=8):
# stat test.img
File: test.img
Size: 536870912 Blocks: 1048584 IO Block: 4096 regular file
So, with this information, you can determine the number of bytes allocated on-disk and unused allocated space for this file:
Number of blocks * block size = 1048584 blocks * 512 bytes/block = 536875008 bytes.
Amount of unused allocated space: 536875008-536870912 bytes = 4096 bytes unused.
1
See Gilles's answer on the dupe; even if the disk had 4KB sectors,%Bwould be 512 on Linux.
â muru
Jun 15 at 3:33
@muru Interesting: I hadn't realized that. You've got to love backwards compatibility!
â ErikF
Jun 15 at 3:37
See my answer for the background...
â schily
Jun 15 at 8:10
add a comment |Â
up vote
2
down vote
There are two allocation sizes that matter when looking at a file system: the filesystem's block size and the disk's sector size. Most SATA drives have 512-byte sectors, although there are exceptions: drives with 4KB sectors are not uncommon. You can get this information with hdparm:
# hdparm -I /dev/sdb|grep Sector
Logical/Physical Sector size: 512 bytes
When mapped to filesystem blocks, however, 512 bytes imposes a fair amount of overhead when naming blocks if the drive is large enough (the metadata required to store allocation information is space that can't be used to store data.) Generally, the block size is determined automatically by the format program, but you can usually override it. For example, the method used for ext3/4 is as follows:
-T usage-type[,...]
Specify how the filesystem is going to be used, so that
mke2fscan
choose optimal filesystem parameters for that use. The usage types
that are supported are defined in the configuration file
/etc/mke2fs.conf(5). The user may specify one or more usage types
using a comma separated list.
If this option is is not specified,
mke2fswill pick a single
default usage type based on the size of the filesystem to be created.
If the filesystem size is less than or equal to 3 megabytes,mke2fs
will use the filesystem typefloppy. If the filesystem size is greater
than 3 but less than or equal to 512 megabytes,mke2fs(8) will use
the filesystemsmall. Otherwise,mke2fs(8) will use the default
filesystem typedefault.
The defaults indicate that 4KB blocks are the default, as my /etc/mke2fs.conf shows:
[defaults]
base_features = sparse_super,large_file,filetype,resize_inode,dir_index,ext_attr
default_mntopts = acl,user_xattr
enable_periodic_fsck = 0
blocksize = 4096
inode_size = 256
inode_ratio = 16384
So, %B is showing you the size of the physical sectors, which when multiplied by the number of sectors used %b gives you the total number of bytes allocated on disk. It's usually of no relevance at all, as no filesystem allocation will be smaller than the block size, but it does help you determine that all allocations of physical sectors will be multiples of 8 (4KB/512 bytes=8):
# stat test.img
File: test.img
Size: 536870912 Blocks: 1048584 IO Block: 4096 regular file
So, with this information, you can determine the number of bytes allocated on-disk and unused allocated space for this file:
Number of blocks * block size = 1048584 blocks * 512 bytes/block = 536875008 bytes.
Amount of unused allocated space: 536875008-536870912 bytes = 4096 bytes unused.
1
See Gilles's answer on the dupe; even if the disk had 4KB sectors,%Bwould be 512 on Linux.
â muru
Jun 15 at 3:33
@muru Interesting: I hadn't realized that. You've got to love backwards compatibility!
â ErikF
Jun 15 at 3:37
See my answer for the background...
â schily
Jun 15 at 8:10
add a comment |Â
up vote
2
down vote
up vote
2
down vote
There are two allocation sizes that matter when looking at a file system: the filesystem's block size and the disk's sector size. Most SATA drives have 512-byte sectors, although there are exceptions: drives with 4KB sectors are not uncommon. You can get this information with hdparm:
# hdparm -I /dev/sdb|grep Sector
Logical/Physical Sector size: 512 bytes
When mapped to filesystem blocks, however, 512 bytes imposes a fair amount of overhead when naming blocks if the drive is large enough (the metadata required to store allocation information is space that can't be used to store data.) Generally, the block size is determined automatically by the format program, but you can usually override it. For example, the method used for ext3/4 is as follows:
-T usage-type[,...]
Specify how the filesystem is going to be used, so that
mke2fscan
choose optimal filesystem parameters for that use. The usage types
that are supported are defined in the configuration file
/etc/mke2fs.conf(5). The user may specify one or more usage types
using a comma separated list.
If this option is is not specified,
mke2fswill pick a single
default usage type based on the size of the filesystem to be created.
If the filesystem size is less than or equal to 3 megabytes,mke2fs
will use the filesystem typefloppy. If the filesystem size is greater
than 3 but less than or equal to 512 megabytes,mke2fs(8) will use
the filesystemsmall. Otherwise,mke2fs(8) will use the default
filesystem typedefault.
The defaults indicate that 4KB blocks are the default, as my /etc/mke2fs.conf shows:
[defaults]
base_features = sparse_super,large_file,filetype,resize_inode,dir_index,ext_attr
default_mntopts = acl,user_xattr
enable_periodic_fsck = 0
blocksize = 4096
inode_size = 256
inode_ratio = 16384
So, %B is showing you the size of the physical sectors, which when multiplied by the number of sectors used %b gives you the total number of bytes allocated on disk. It's usually of no relevance at all, as no filesystem allocation will be smaller than the block size, but it does help you determine that all allocations of physical sectors will be multiples of 8 (4KB/512 bytes=8):
# stat test.img
File: test.img
Size: 536870912 Blocks: 1048584 IO Block: 4096 regular file
So, with this information, you can determine the number of bytes allocated on-disk and unused allocated space for this file:
Number of blocks * block size = 1048584 blocks * 512 bytes/block = 536875008 bytes.
Amount of unused allocated space: 536875008-536870912 bytes = 4096 bytes unused.
There are two allocation sizes that matter when looking at a file system: the filesystem's block size and the disk's sector size. Most SATA drives have 512-byte sectors, although there are exceptions: drives with 4KB sectors are not uncommon. You can get this information with hdparm:
# hdparm -I /dev/sdb|grep Sector
Logical/Physical Sector size: 512 bytes
When mapped to filesystem blocks, however, 512 bytes imposes a fair amount of overhead when naming blocks if the drive is large enough (the metadata required to store allocation information is space that can't be used to store data.) Generally, the block size is determined automatically by the format program, but you can usually override it. For example, the method used for ext3/4 is as follows:
-T usage-type[,...]
Specify how the filesystem is going to be used, so that
mke2fscan
choose optimal filesystem parameters for that use. The usage types
that are supported are defined in the configuration file
/etc/mke2fs.conf(5). The user may specify one or more usage types
using a comma separated list.
If this option is is not specified,
mke2fswill pick a single
default usage type based on the size of the filesystem to be created.
If the filesystem size is less than or equal to 3 megabytes,mke2fs
will use the filesystem typefloppy. If the filesystem size is greater
than 3 but less than or equal to 512 megabytes,mke2fs(8) will use
the filesystemsmall. Otherwise,mke2fs(8) will use the default
filesystem typedefault.
The defaults indicate that 4KB blocks are the default, as my /etc/mke2fs.conf shows:
[defaults]
base_features = sparse_super,large_file,filetype,resize_inode,dir_index,ext_attr
default_mntopts = acl,user_xattr
enable_periodic_fsck = 0
blocksize = 4096
inode_size = 256
inode_ratio = 16384
So, %B is showing you the size of the physical sectors, which when multiplied by the number of sectors used %b gives you the total number of bytes allocated on disk. It's usually of no relevance at all, as no filesystem allocation will be smaller than the block size, but it does help you determine that all allocations of physical sectors will be multiples of 8 (4KB/512 bytes=8):
# stat test.img
File: test.img
Size: 536870912 Blocks: 1048584 IO Block: 4096 regular file
So, with this information, you can determine the number of bytes allocated on-disk and unused allocated space for this file:
Number of blocks * block size = 1048584 blocks * 512 bytes/block = 536875008 bytes.
Amount of unused allocated space: 536875008-536870912 bytes = 4096 bytes unused.
answered Jun 15 at 2:49
ErikF
2,6711413
2,6711413
1
See Gilles's answer on the dupe; even if the disk had 4KB sectors,%Bwould be 512 on Linux.
â muru
Jun 15 at 3:33
@muru Interesting: I hadn't realized that. You've got to love backwards compatibility!
â ErikF
Jun 15 at 3:37
See my answer for the background...
â schily
Jun 15 at 8:10
add a comment |Â
1
See Gilles's answer on the dupe; even if the disk had 4KB sectors,%Bwould be 512 on Linux.
â muru
Jun 15 at 3:33
@muru Interesting: I hadn't realized that. You've got to love backwards compatibility!
â ErikF
Jun 15 at 3:37
See my answer for the background...
â schily
Jun 15 at 8:10
1
1
See Gilles's answer on the dupe; even if the disk had 4KB sectors,
%B would be 512 on Linux.â muru
Jun 15 at 3:33
See Gilles's answer on the dupe; even if the disk had 4KB sectors,
%B would be 512 on Linux.â muru
Jun 15 at 3:33
@muru Interesting: I hadn't realized that. You've got to love backwards compatibility!
â ErikF
Jun 15 at 3:37
@muru Interesting: I hadn't realized that. You've got to love backwards compatibility!
â ErikF
Jun 15 at 3:37
See my answer for the background...
â schily
Jun 15 at 8:10
See my answer for the background...
â schily
Jun 15 at 8:10
add a comment |Â
up vote
0
down vote
If the stat command behaves as documented in the man page, %B would return the value of DEV_BSIZE from the include file param.h.
This value is 512 on most systems, but 1024 on HP-UX.
BTW: This value is not related to the sector size of the drives.
add a comment |Â
up vote
0
down vote
If the stat command behaves as documented in the man page, %B would return the value of DEV_BSIZE from the include file param.h.
This value is 512 on most systems, but 1024 on HP-UX.
BTW: This value is not related to the sector size of the drives.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
If the stat command behaves as documented in the man page, %B would return the value of DEV_BSIZE from the include file param.h.
This value is 512 on most systems, but 1024 on HP-UX.
BTW: This value is not related to the sector size of the drives.
If the stat command behaves as documented in the man page, %B would return the value of DEV_BSIZE from the include file param.h.
This value is 512 on most systems, but 1024 on HP-UX.
BTW: This value is not related to the sector size of the drives.
edited Jun 15 at 8:09
answered Jun 15 at 7:42
schily
8,57421435
8,57421435
add a comment |Â
add a comment |Â