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
答案 0 :(得分:0)
想出来。当我重新格式化硬盘驱动器时,它的UUID发生了变化,使我在/ etc / fstab中的配置无效。因此驱动器是可访问的,但没有使用ntfs3g安装,所以我猜有读取它的容量的问题。当我将fstab中的行更新为新的UUID时,它开始正常工作:
UUID={newuuid} /mnt/drive ntfs-3g defaults,permissions 0 0