# Ruby extension to get mount information in Linux

**URL:** <https://rubytalk.org/t/ruby-extension-to-get-mount-information-in-linux/5108>\
**Category:** ruby-talk\
**Created:** [11 March 2003 19:31 UTC](https://rubytalk.org/t/ruby-extension-to-get-mount-information-in-linux/5108 "2003-03-11T19:31:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonimous](https://avatars.discourse-cdn.com/v4/letter/a/fbc32d/32.png) [@anonimous](https://rubytalk.org/u/anonimous)\
**Post date:** [11 March 2003 19:31 UTC](https://rubytalk.org/t/ruby-extension-to-get-mount-information-in-linux/5108/1 "2003-03-11T19:31:45Z")

</div>

Is there a library for getting information in drives that can be mounted and  
can then mount or unmount those drives in Linux/Unix, I can write my  
program to read the /etc/fstab file but then I would have to go to extra  
trouble to find out if the drives are mounted or not so I would preffer  
having a library to do the work for me.

---

<div class="post-metadata">

**Author:** ![anonimous](https://avatars.discourse-cdn.com/v4/letter/a/fbc32d/32.png) [@anonimous](https://rubytalk.org/u/anonimous)\
**Post date:** [11 March 2003 20:32 UTC](https://rubytalk.org/t/ruby-extension-to-get-mount-information-in-linux/5108/2 "2003-03-11T20:32:17Z")

</div>

anonimous wrote:

> Is there a library for getting information in drives that can be mounted  
> and can then mount or unmount those drives in Linux/Unix, I can write my  
> program to read the /etc/fstab file but then I would have to go to extra  
> trouble to find out if the drives are mounted or not so I would preffer  
> having a library to do the work for me.

I’m not getting any replies so I’ll try explaining what I am asking again in  
case the silence is related to people not understanding what I was asking.

Basically what I would like to know is if there is a ruby library or  
extension for the mount command in Linux, I also need it to be able to get  
information on the drives that can be mounted.

---

<div class="post-metadata">

**Author:** ![Lyle\_Johnson6](https://avatars.discourse-cdn.com/v4/letter/l/bb73d2/32.png) [@Lyle\_Johnson6](https://rubytalk.org/u/Lyle_Johnson6)\
**Post date:** [11 March 2003 20:52 UTC](https://rubytalk.org/t/ruby-extension-to-get-mount-information-in-linux/5108/3 "2003-03-11T20:52:21Z")

</div>

anonimous wrote:

> I’m not getting any replies so I’ll try explaining what I am asking again in  
> case the silence is related to people not understanding what I was asking.
> 
> Basically what I would like to know is if there is a ruby library or  
> extension for the mount command in Linux, I also need it to be able to get  
> information on the drives that can be mounted.

See what happens if you search the Ruby Application Archive  
([http://raa.ruby-lang.org](http://raa.ruby-lang.org)) for the keyword “mount”.

---

<div class="post-metadata">

**Author:** ![Sam\_Roberts1](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@Sam\_Roberts1](https://rubytalk.org/u/Sam_Roberts1)\
**Post date:** [12 March 2003 04:32 UTC](https://rubytalk.org/t/ruby-extension-to-get-mount-information-in-linux/5108/4 "2003-03-12T04:32:12Z")

</div>

/etc/fstab are the drives that can be mounted

/etc/mtab are the drives that ARE mounted.

Sam

Quoteing [n.thomp@roadrunner.nf.net](mailto:n.thomp@roadrunner.nf.net), on Wed, Mar 12, 2003 at 05:32:17AM +0900:

> **···**
>
> > anonimous wrote:
> > 
> > > Is there a library for getting information in drives that can be mounted  
> > > and can then mount or unmount those drives in Linux/Unix, I can write my  
> > > program to read the /etc/fstab file but then I would have to go to extra  
> > > trouble to find out if the drives are mounted or not so I would preffer  
> > > having a library to do the work for me.
> > 
> > I’m not getting any replies so I’ll try explaining what I am asking again in  
> > case the silence is related to people not understanding what I was asking.
> > 
> > Basically what I would like to know is if there is a ruby library or  
> > extension for the mount command in Linux, I also need it to be able to get  
> > information on the drives that can be mounted.

---

<div class="post-metadata">

**Author:** ![anonimous](https://avatars.discourse-cdn.com/v4/letter/a/fbc32d/32.png) [@anonimous](https://rubytalk.org/u/anonimous)\
**Post date:** [12 March 2003 22:36 UTC](https://rubytalk.org/t/ruby-extension-to-get-mount-information-in-linux/5108/5 "2003-03-12T22:36:26Z")

</div>

Lyle Johnson wrote:

> anonimous wrote:
> 
> > I’m not getting any replies so I’ll try explaining what I am asking again  
> > in case the silence is related to people not understanding what I was  
> > asking.
> > 
> > Basically what I would like to know is if there is a ruby library or  
> > extension for the mount command in Linux, I also need it to be able to  
> > get information on the drives that can be mounted.
> 
> See what happens if you search the Ruby Application Archive  
> ([http://raa.ruby-lang.org](http://raa.ruby-lang.org)) for the keyword “mount”.

I found something that I think will tell me if a certain folder is a mounted  
device, but there was nothing there for extracting the information from  
/etc/fstab , I’d write something for it myself but I am a newbie at Ruby  
and I’ve only read tutorials so far os I don’t know much yet. I find it  
easier to learn from books, its much easier to read when the text is on  
paper rather then on a monitor.

---

<div class="post-metadata">

**Author:** ![Lyle\_Johnson6](https://avatars.discourse-cdn.com/v4/letter/l/bb73d2/32.png) [@Lyle\_Johnson6](https://rubytalk.org/u/Lyle_Johnson6)\
**Post date:** [12 March 2003 22:56 UTC](https://rubytalk.org/t/ruby-extension-to-get-mount-information-in-linux/5108/6 "2003-03-12T22:56:29Z")

</div>

anonimous wrote:

> I found something that I think will tell me if a certain folder is a mounted  
> device, but there was nothing there for extracting the information from  
> /etc/fstab.

If you search the RAA for the keyword “mount”, one of the few matches is  
for the “FileSystem” extension:

```
http://raa.ruby-lang.org/list.rhtml?name=filesystem

```

If you download, build and install this extension, you can then write a  
little script like this one to extract information from /etc/fstab:

```
 require 'filesystem'

 FileSystem.mounts("/etc/fstab") { |m|
   puts m.device
   puts m.mount
   puts m.fstype
   puts m.options
   puts m.dump_interval
   puts m.check_pass
   puts "----------------------"
 }

```

HTH,

Lyle
