Php disk_free_space()始终从启动分区读取

时间:2022-10-24 17:47:00

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:

我正在尝试检索连接到我的服务器的usb硬盘上的可用空间(使用php),但是disk_free_space()总是返回启动分区上的可用空间。以下是我的服务器设置的摘要:

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

1 个解决方案

#1


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发生了变化,使我在/ etc / fstab中的配置无效。所以驱动器是可访问的,但没有使用ntfs3g安装,所以我猜有读取它的容量的问题。当我将fstab中的行更新为新的UUID时,它开始正常工作:

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

#1


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发生了变化,使我在/ etc / fstab中的配置无效。所以驱动器是可访问的,但没有使用ntfs3g安装,所以我猜有读取它的容量的问题。当我将fstab中的行更新为新的UUID时,它开始正常工作:

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