- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: how can i get size of block device (perl, shel...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-20-2011 04:14 AM
тАО09-20-2011 04:14 AM
i can't find any perl-func which shows the size of a block device ?
does a perl-func exist ?
Example: LVOL Size of /dev/vgfs/filesystem is 256 MB.
or other ways to parse one of the following commands in a SHELL ?
commands easy to parse are "/usr/sbin/fstyp -v" or "df -g" ?
# bdf /filesystem
Filesystem kbytes used avail %used Mounted on
/dev/vgfs/filesystem
2097152 30912 2050104 1% /filesystem
# df -g /dev/vgfs/filesystem
/filesystem (/dev/vgfs/filesystem) :
8192 file system block size 8192 fragment size
262144 total blocks 258280 total free blocks
256263 allocated free blocks 74816 total i-nodes
64544 total free i-nodes 64544 allocated free i-nodes
1073807412 file system id vxfs file system type
0x11 flags 255 file system name length
/filesystem file system specific string
# df -i /dev/vgfs/filesystem
/filesystem (/dev/vgfs/filesystem) : 74816 total i-nodes
64544 free i-nodes
10272 used i-nodes
13 % i-nodes used
# df -P /dev/vgfs/filesystem
Filesystem 512-blocks Used Available Capacity Mounted on
/dev/vgfs/filesystem 4162032 61824 4100208 2% /filesystem
# /usr/sbin/fstyp -v /dev/vgatvmv3tfs/io_src_test_s
vxfs
version: 7
f_bsize: 8192
f_frsize: 8192
f_blocks: 262144
how can i dectect, if LVOL SIZE differs from BLOCK SIZE ?
- lvdisplay
- fstyp -v
- compare the results ?
regards
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-20-2011 05:04 AM
тАО09-20-2011 05:04 AM
Re: how can i get size of block device (perl, shell script)
@support_billa wrote:
i can't find any perl-func which shows the size of a block device ?
does a perl-func exist ?
<snip>
# /usr/sbin/fstyp -v /dev/vgatvmv3tfs/io_src_test_s
vxfs
version: 7
f_bsize: 8192
f_frsize: 8192
f_blocks: 262144
how can i dectect, if LVOL SIZE differs from BLOCK SIZE ?
- lvdisplay
- fstyp -v
- compare the results ?
It appears that you are interested in comparing the VxFS preferred system block size ('bsize') versus the fundamental block size ('frsize').
I can think of two options: (1) query and compare the results in a script, yourself; or (2) use the Perl 'Filesys::Statvfs' module from CPAN which leverages the underlying system call 'statvfs(2)'.
See the 'statvfs(2)' manpages for more information, too.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-20-2011 05:19 AM
тАО09-20-2011 05:19 AM
Re: how can i get size of block device (perl, shell script)
i want to get the size of a block_device , maybe in KB
i found in this forum now , that "bdf" and "df" differs , right ?
LVOL SIZE of /dev/vgfs/filesystem is maybe 512 MB but
the TOTAL BLOCK SIZE is 256 MB (anybody forget to extend filesystem ).
so i found to find out , what is the size of the block device.
in the example:
bdf shows output over 2 lines :
# bdf /filesystem
Filesystem kbytes used avail %used Mounted on
/dev/vgfs/filesystem
2097152 30912 2050104 1% /filesystem
# df -g /dev/vgfs/filesystem
262144 total blocks 258280 total free blocks
then i compare "TOTAL BLOCK SIZE" and "LV_SIZE" ?
- but how can i get the "TOTAL BLOCK SIZE" ?
- also how can i get free usage in percent ?
regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-20-2011 06:15 AM
тАО09-20-2011 06:15 AM
Re: how can i get size of block device (perl, shell script)
hello,
what i am now detect, when "fragment size" and "file system block size " are equal, "bdf" and "df" differs :
here "bdf" and "df" differs :
df -g /filesystem
/filesystem (/dev/vgfilesystem/filesystem) :
8192 file system block size 8192 fragment size
262144 total blocks 258280 total free blocks
256263 allocated free blocks 74816 total i-nodes
64544 total free i-nodes 64544 allocated free i-nodes
1073807412 file system id vxfs file system type
0x11 flags 255 file system name length
/filesystem file system specific string
bdf /filesystem
Filesystem kbytes used avail %used Mounted on
/dev/vgfilesystem/filesystem
2097152 30912 2050104 1% /filesystem
here "bdf" and "df" is ok :
df -g /dev/vgfilesystem/filesystem_ok
/filesystem_ok (/dev/vgfilesystem/filesystem_ok) :
8192 file system block size 1024 fragment size
524288 total blocks 287654 total free blocks
269777 allocated free blocks 75892 total i-nodes
71912 total free i-nodes 71912 allocated free i-nodes
1073807364 file system id vxfs file system type
0x10 flags 255 file system name length
/filesystem_ok file system specific string
bdf /dev/vgfilesystem/filesystem_ok
Filesystem kbytes used avail %used Mounted on
/dev/vgfilesystem/filesystem_ok
524288 236634 269676 47% /filesystem_ok
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-20-2011 07:45 AM
тАО09-20-2011 07:45 AM
Re: how can i get size of block device (perl, shell script)
@support_billa wrote:
- but how can i get the "TOTAL BLOCK SIZE" ?
- also how can i get free usage in percent ?
Hi:
You can use the output of 'bdf to get the total block size in kbytes. You can also use 'df -k' to see the KB allocated and the percentage used. The free usage percentage is ( 100 - percent_used ).
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-20-2011 07:52 AM
тАО09-20-2011 07:52 AM
Solution
@support_billa wrote:what i am now detect, when "fragment size" and "file system block size " are equal, "bdf" and "df" differs
No, you are misreading this.
For your filesystem with 8192 for the fragment size:
262144*8192/1024 = 2097192
....which is exactly what 'bdf' reports.
For your filesystem with a 1024 fragment size:
there are 524,288 total blocks shown which is exactly what 'bdf' reports.
1024 = 1KB, or the units used by 'bdf'
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-20-2011 11:03 PM
тАО09-20-2011 11:03 PM
Re: how can i get size of block device (perl, shell script)
There are perl modules to do that, but they may be too old to do it very accurate:
тАв Filesys::Df ( https://metacpan.org/module/Filesys::Df )
тАв Filesys::DiskFree ( https://metacpan.org/module/Filesys::DiskFree )
тАв HPUX::FS ( https://metacpan.org/module/HPUX::FS )
тАв HPUX::LVM ( https://metacpan.org/module/HPUX::LVM )
but they might be too old to be accurate enough. YMMV
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-21-2011 12:56 AM
тАО09-21-2011 12:56 AM
Re: how can i get size of block device (perl, shell script)
about :
For your filesystem with 8192 for the fragment size:
262144*8192/1024 = 2097192
...which is exactly what 'bdf' reports.
For your filesystem with a 1024 fragment size:
there are 524,288 total blocks shown which is exactly what 'bdf' reports.
1024 = 1KB, or the units used by 'bdf'
for my understanding :
when "fragment size" and "file system block size " are equal :
i have to use : 262144*8192/1024 = 2097192 ( 1024 = 1KB )
when "fragment size" and "file system block size "differs :
the "file system block size " is the exact value !
regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-21-2011 01:39 AM
тАО09-21-2011 01:39 AM
Re: how can i get size of block device (perl, shell script)
more questions :
1. best way to parse "bdf", when it reports is over 2 lines :
2. questions to "df" and "bdf"
1. best way to parse "bdf", when it reports is over 2 lines :
example of "bdf"
Filesystem kbytes used avail %used Mounted on
/dev/vgfilesystem/filesystem_ok
524288 236634 269777 47% /filesystem_ok
/dev/vg00/lvol6 2097152 835448 1253024 40% /tmp
AWK, when it reports is over 2 lines:
local_fs=/tmp
bdf ${local_fs} | awk -v FSYS="${local_fs}" '
NF>=6 && $6 ~ FSYS { printf "%-26s %10s %10s %10s %5s %s\n",$1,$2,$3,$4,$5,$6 }
NF==1 { l=$1 }
NF==5 && $5 ~ FSYS { printf "%-26s %10s %10s %10s %5s %s\n",l,$1,$2,$3,$4,$5 }'
2. questions to "df" and "bdf"
i have a large fs and "df" reports 100 % usage , "bdf" 99 % usage :
Filesystem kbytes used avail %used Mounted on
/dev/vgfsdepot/lvol1
227540992 225622902 1802529 99% /filesystem_large
questions to the output below:
df -P should show the size of the file system, but it is not the value of "bdf", must i know the block_size ?
only df -g reports the same value of "bdf".
what is the best way to parse informations of filesystem ? "bdf" or "df" or to install the perl modules ?
for my issue , i need 2 functions like "get_size_of_fs" and "get_percent_of_fs_usage"
man of "df -P"
-P Report the name of the file system, the size of
the file system, the number of blocks used, the
number of blocks free, the percentage of blocks
used and the directory below which the file system
hierarchy appears.
# df -P /filesystem_large
Filesystem 512-blocks Used Available Capacity Mounted on
/dev/vgfsdepot/lvol1 454850862 451245804 3605058 100% /filesystem_large
# df -Pk /filesystem_large
Filesystem 1024-blocks Used Available Capacity Mounted on
/dev/vgfsdepot/lvol1 227425431 225622902 1802529 100% /filesystem_large
man of "df -g"
-g Report the entire structure described in statvfs(2).
df -g /filesystem_large
/filesystem_large (/dev/vgfsdepot/lvol1) :
8192 file system block size 1024 fragment size
227540992 total blocks 1918090 total free blocks
1802529 allocated free blocks 2495396 total i-nodes
479522 total free i-nodes 479522 allocated free i-nodes
1074069505 file system id vxfs file system type
0x10 flags 255 file system name length
/filesystem_large file system specific string
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-21-2011 02:20 AM
тАО09-21-2011 02:20 AM
Re: how can i get size of block device (perl, shell script)
Hello H.Merijn ,
i installed for tests all your listed perl modules :
@ Filesys::Df ( https://metacpan.org/module/Filesys::Df )
works perfect
@ Filesys::DiskFree ( https://metacpan.org/module/Filesys::DiskFree )
works ok, but shows a lot of warnings !
@ HPUX::FS ( https://metacpan.org/module/HPUX::FS )
@ HPUX::LVM ( https://metacpan.org/module/HPUX::LVM )
HPUX::LVM doesn't work , because show error of "vgdisplay -v" ...
so Filesys::Df is ok and i find about to install it !
regards