• Post Reply Bookmark Topic Watch Topic
  • New Topic

List all Linux mounted volumes

 
Yahya Elyasse
Ranch Hand
Posts: 510
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

Is there a way to get the list of all mounted volumes on a linux system ?

I tried File.listRoots() on Linux but it gives me only "/" .

thank you for helping.
 
Martin Simons
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is because on a unix type system all mounted volumes still fall under root somewhere, so there is only one "root". To get the mounted volumes you can use the command df -k in Runtime.exec (you may wish to use df -lk so that nfs mounted volumes where the nfs server is not responding does not cause the command to hang).
 
Yahya Elyasse
Ranch Hand
Posts: 510
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.

can you tell me what is the first parameter (command/shell ?) i should use in Runtime.exec() ?

I would appreciate you post complete code statement for Runtime.exec().

thanks.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Runtime.getRuntime().exec("df") would do just fine. You'd have to read the output, of course; search the Ranch archives for zillions of Runtime.exec() examples for that.
 
Yahya Elyasse
Ranch Hand
Posts: 510
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you i will give that a try.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!