简体   繁体   中英

Php disk_free_space() always reads from boot partition

I'm trying to retrieve the free space on a usb hard disk attached to my server (using php), however disk_free_space() always returns the space available on the boot partition. Here is a summary of my server setup:

Rasbperry Pi 2 running rasbian.
php version: 5.4.39-0+deb7u2
booting from 32 gb sd card with about 24 gb free
3TB ntfs gpt usb hard drive mounted 
ntfs-3g installed on system

test code:

<?
echo ":".disk_free_space("")."\n";
echo "/".disk_free_space("/")."\n";
echo "/mnt/drive:".disk_free_space("/mnt/drive")."\n";
?>

output

PHP Warning:  Module 'apc' already loaded in Unknown on line 0
PHP Warning:  PHP Startup: apc.shm_size now uses M/G suffixes, please update your ini files in Unknown on line 0
PHP Warning:  disk_free_space(): No such file or directory in /home/pi/test.php on line 2
:
/24991305728
/mnt/drive:24991305728

Figured it out. When I reformatted the hard-drive, the UUID for it changed, invalidating my config in /etc/fstab. So the drive was accessible, but not being mounted with ntfs3g, so I guess there were issues reading it's capacity. When I updated the line in fstab to the new UUID it started working correctly:

UUID={newuuid} /mnt/drive ntfs-3g defaults,permissions 0 0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM