LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-01-2016, 09:40 PM   #1
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Rep: Reputation: Disabled
How to determine filesystem size on a device?


Code:
[user1@localhost myvg]$ sudo lvdisplay
... ... 

  --- Logical volume ---
  LV Path                /dev/myvg/mylv
  LV Name                mylv
  VG Name                myvg
  LV UUID                7lpeKo-RVPK-Q7TK-NOpM-3NGr-4ve8-EIQOEu
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2016-06-01 21:37:21 -0400
  LV Status              available
  # open                 0
  LV Size                60.00 MiB
  Current LE             15
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:2

[user1@localhost myvg]$ sudo lvextend -L +10M /dev/myvg/mylv
  Rounding size to boundary between physical extents: 12.00 MiB
  Size of logical volume myvg/mylv changed from 60.00 MiB (15 extents) to 72.00 MiB (18 extents).
  Logical volume mylv successfully resized.

[user1@localhost myvg]$ sudo resize2fs /dev/myvg/mylv 72M
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/myvg/mylv to 73728 (1k) blocks.
The filesystem on /dev/myvg/mylv is now 73728 blocks long.
If I want to look up size of filesystem attached to logical volume at /dev/myvg/mylv later, what command do I use?


Note: The filesystem size attached to logical volume, /dev/myvg/mylv, is NOT necessary the same as the attached filesystem on the mylv. For example, I can shrink the filesystem on mylv like so:
sudo resize2fs /dev/myvg/mylv 60M

I could use this:
Quote:
[user1@localhost myvg]$ sudo dumpe2fs /dev/myvg/mylv | grep -i "block count"
dumpe2fs 1.42.9 (28-Dec-2013)
Block count: 73728
Reserved block count: 3686

But I am looking for generic command that can self-discover the filesystem type and spit out filesystem info.
 
Old 06-01-2016, 09:58 PM   #2
Doug G
Member
 
Registered: Jul 2013
Posts: 749

Rep: Reputation: Disabled
On Fedora anyway df will show logical volumes as well as disk partitions.
 
Old 06-01-2016, 10:05 PM   #3
malekmustaq
Senior Member
 
Registered: Dec 2008
Location: root
Distribution: Slackware & BSD
Posts: 1,669

Rep: Reputation: 498Reputation: 498Reputation: 498Reputation: 498Reputation: 498
Quote:
If I want to look up size of filesystem attached to logical volume at /dev/myvg/mylv later, what command do I use?
You can even inquire all volumes by parted editor.
Code:
parted -l
or you may query by way of df
Code:
df -ahT
use the commands as root.

Hope that helps. Good luck.

m.m.
 
Old 06-01-2016, 10:29 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Quote:
Originally Posted by fanoflq View Post
But I am looking for generic command that can self-discover the filesystem type and spit out filesystem info.
That is specific to each filesystem. Mount (then "df" as mentioned above) is the obvious answer - fsadm is an attempt at generic APIs, and may help somewhat; you should have it with LVM.
 
Old 06-01-2016, 10:37 PM   #5
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
The total block count reported by df is the number of allocatable data blocks in the filesystem. It does not include the metadata overhead, and will be smaller than the "Block count:" reported by tune2fs, which is truly the total size.

"fsadm -v -n resize {device}" will report both the current and maximum size for the filesystems it supports.

Last edited by rknichols; 06-01-2016 at 10:42 PM. Reason: Add fsadm suggestion
 
Old 06-01-2016, 11:18 PM   #6
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Original Poster
Rep: Reputation: Disabled
Quote:
sudo fsadm -v -n resize /dev/sda5
requires device to be mounted.
Same goes for: df -ahT

And command: parted -l
show raw size of partition.

How do I determine filesystem allocated size
on a partition or device without
the device being mounted?
 
Old 06-02-2016, 08:09 AM   #7
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by rknichols View Post
"fsadm -v -n resize {device}" will report both the current and maximum size for the filesystems it supports.
Quote:
Originally Posted by fanoflq View Post
requires device to be mounted.
Not on my system. And, using fsadm to shrink a filesystem would require that the filesystem be unmounted, so that doesn't seem to be a likely restriction.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to determine filesystem on usb drive? woomia *BSD 2 12-22-2014 03:17 AM
How to determine if a filesystem is compressed kaplan71 Linux - General 5 09-04-2012 11:35 AM
Cannot determine filesystem type of partition Kenny_Strawn Linux - General 5 03-01-2011 01:13 AM
Method to determine if a device is a usb device (RHEL5 / RHEL6) mholden64 Linux - Kernel 4 08-15-2009 07:45 PM
cant determine filesystem lynch Linux - Software 3 02-21-2002 01:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration