LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to determine filesystem size on a device? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-determine-filesystem-size-on-a-device-4175581232/)

fanoflq 06-01-2016 09:40 PM

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.

Doug G 06-01-2016 09:58 PM

On Fedora anyway df will show logical volumes as well as disk partitions.

malekmustaq 06-01-2016 10:05 PM

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.

syg00 06-01-2016 10:29 PM

Quote:

Originally Posted by fanoflq (Post 5554329)
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.

rknichols 06-01-2016 10:37 PM

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.

fanoflq 06-01-2016 11:18 PM

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?

rknichols 06-02-2016 08:09 AM

Quote:

Originally Posted by rknichols (Post 5554344)
"fsadm -v -n resize {device}" will report both the current and maximum size for the filesystems it supports.

Quote:

Originally Posted by fanoflq (Post 5554356)
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.


All times are GMT -5. The time now is 02:28 PM.