LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Put 'partition free space' value into file on CIFS share (https://www.linuxquestions.org/questions/linux-newbie-8/put-partition-free-space-value-into-file-on-cifs-share-4175493860/)

BeachHead 02-05-2014 04:54 PM

Put 'partition free space' value into file on CIFS share
 
Hallo,
i have a debian based internet router running on a 16GB CompactFlash Card. It contains a 15GB partition for CIFS that gets accessed by windows systems.

The problem is i don't see (on the windows client side) how much space is left on the share so i thought about creating a file on the share that always includes the free space value by creating a cron job that updates that file every second or so but i guess it would be much better if it only gets updated after actual I/O writes.

Any ideas how to do that in bash?

Additionally, i once stumbled upon some kind of 'mini http server' with curl, wget or something. But i can't remember anymore. Getting the 'free space' by http would be nice as well.

Any ideas about that?

Doc CPU 02-06-2014 11:21 AM

Hi there,

Quote:

Originally Posted by BeachHead (Post 5112380)
i have a debian based internet router running on a 16GB CompactFlash Card. It contains a 15GB partition for CIFS that gets accessed by windows systems.

The problem is i don't see (on the windows client side) how much space is left on the share

you don't?? Usually Windows Explorer displays the free capacity of a partition in the status line, or in the properties dialog.
However, it does that only if the network share is mapped to a drive letter. But that's a flaw of Windows.

Quote:

Originally Posted by BeachHead (Post 5112380)
so i thought about creating a file on the share that always includes the free space value by creating a cron job that updates that file every second or so but i guess it would be much better if it only gets updated after actual I/O writes.

Apart from creating additional CPU load on the small box, that would mean duplicating a feature on application level which is already available on the protocol level.

Quote:

Originally Posted by BeachHead (Post 5112380)
Any ideas how to do that in bash?

You get the total/used/available capacity of a mounted file system with 'df'. Probably have to 'grep' or 'awk' a little bit on the output to extract the information you want, or leave the output of 'df' as it is.

Quote:

Originally Posted by BeachHead (Post 5112380)
Additionally, i once stumbled upon some kind of 'mini http server' with curl, wget or something. But i can't remember anymore. Getting the 'free space' by http would be nice as well.

You're really going around in circles to re-invent the wheel. Btw, curl and wget are client-side components. I can't imagine how you could get them to act as a server. But there are quite a few light HTTP servers available for Linux.

[X] Doc CPU

BeachHead 02-06-2014 12:33 PM

Even though curl and wget can send raw http requests it is ncat i was actually searching for. It can listen on a port and send back the free space value. That's what i meant by simple httpd.

Regarding the 'free space' solution i'm currently looking into a wear-level friendly method. To place a file into ramdisk and use its name as descriptor like '200MB free'. That file should be linked to a file in the CIFS share in a way it also reflects/links the filename so there should be no I/O writes on the CompactFlash card but i'm not sure if ext4 supports that at all (having two files linked in a way that renaming one leads to renaming the 2nd as well).


All times are GMT -5. The time now is 03:35 AM.