comingme has asked for the wisdom of the Perl Monks concerning the following question:

========================================

I run a little script that prints the available space for file system:

Code:
#!/usr/bin/perl5 sub CheckDiskSpace { use Filesys::DiskFree; my $handle = new Filesys::DiskFree; $handle->df(); $loc1 = '/dev'; $loc2 = '/var/run'; $loc3 = '/boot'; print "... $loc1, $loc2, $loc3, '/' \n"; foreach my $file ($loc1,$loc2,$loc3,'/' ) { my $bytesavailable=$handle->avail($file); print "at $file, available bits = $bytesavailable \n"; } } CheckDiskSpace();
========================================

The result is:

... /dev,/var/run,/boot,'/'

at /dev, available bits = 1028820992

at /var/run, available bits = 1028730880

at /boot, available bits =

at /, available bits =

========================================

I then type command "df -a" and get:

Code:
Filesystem 1K-blocks Used Available Use% Mounted on proc 0 0 0 - /proc /sys 0 0 0 - /sys varrun 1004736 116 1004620 1% /var/run varlock 1004736 0 1004736 0% /var/lock udev 1004736 28 1004708 1% /dev devshm 1004736 12 1004724 1% /dev/shm devpts 0 0 0 - /dev/pts tmpfs 1004736 12 1004724 1% /dev/shm securityfs 0 0 0 - /sys/kernel/se +curity gvfs-fuse-daemon 620395268 10647256 609748012 2% /root/.gvfs /dev/sda1 497829 139305 332822 30% /media/_boot
========================================

I then run "gparted" and tt shows /dev/sda3 is mounted to '/' and '/dev/.static/dev'. It's a graphic tool and I do not know how to post pictures here.

========================================

The thing I do not understand is: Why cannot perl script tell the available size of "/"? Why doesnot df command show "/" as a mount point while gparted correctly shows that? I tried to mount /dev/sda3 to '/' but it says it already exists. My system is ubuntu server. Can someone help me? Thanks.

Replies are listed 'Best First'.
Re: Help on mount of /
by matze77 (Friar) on Jan 14, 2010 at 18:21 UTC
    $ LANG=C; df -a Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda6 3842376 873884 2773304 24% / tmpfs 1557800 0 1557800 0% /lib/init/rw proc 0 0 0 - /proc ... /dev/mapper/vol1-logdeb1 5160576 4457740 440692 92% /var
    Hmm dunno what your ubuntu server does but my debian system shows "/" correct. Dont think this is standard ...

    Perl uses system tools to determine the space i think so if df is wrong Perl is too? Checked the debian Servers too they do ..:

    Dateisystem 1K-Blöcke Benutzt Verfügbar Ben% Eingehängt auf /dev/hda2 75981028 17982544 54138868 25% / tmpfs 513980 0 513980 0% /lib/init/rw proc 0 0 0 - /proc ...
    Btw: I wouldnt use a graphical interface for a server.
    It is another (possible) security hole not talking about the waste of ressources (if it is your home server without internet access it is ok ...)
      It is another (possible) security hole not talking about the waste of ressources (if it is your home server without internet access it is ok ...)

      Note that there's no need to run X server on the server in order to be able to run gparted. And in this case GUI is not a bigger security problem than e.g. libjpeg.

      Thanks for your reply. Well, I also run df command on my laptop(ubuntu 9 desktop edition), it also shows the mount point of /, similar to what you posted.

      The server (ubuntu 8 server edition) uses on SCSI hard disk. Now i see that almost all the available space of /dev/sda3 is owed by 'gvfs-fuse-daemon /root/.gvfs'. So I guess this daemon is doing some tricky thing.

      I am lost.