问题:df 显示文件系统满了但还有2G空间未用
sles11sp1-x64:/opt # ls
coreutils-6.12-32.39.1.x86_64.rpm coreutils-lang-6.12-32.39.1.x86_64.rpm kde3 vmware_time
sles11sp1-x64:/opt # rpm -Uvh coreutils-*
Preparing... ########################################### [100%]
1:coreutils-lang ########################################### [ 50%]
2:coreutils ########################################### [100%]
sles11sp1-x64:/opt # df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 29G 27G 0 100% /
devtmpfs 1.5G 112K 1.5G 1% /dev
tmpfs 1.5G 0 1.5G 0% /dev/shm
sles11sp1-x64:/opt # mount
/dev/sda2 on / type ext3 (rw,acl,user_xattr)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
debugfs on /sys/kernel/debug type debugfs (rw)
devtmpfs on /dev type devtmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,mode=1777)
devpts on /dev/pts type devpts (rw,mode=0620,gid=5)
fusectl on /sys/fs/fuse/connections type fusectl (rw)
securityfs on /sys/kernel/security type securityfs (rw)
sles11sp1-x64:/opt # df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 29451020 28102340 0 100% /
devtmpfs 1512400 112 1512288 1% /dev
tmpfs 1512400 0 1512400 0% /dev/shm
sles11sp1-x64:/opt # df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda2 1872304 411579 1460725 22% /
devtmpfs 0 0 0 - /dev
tmpfs 378100 1 378099 1% /dev/shm
根因分析:
strace df /dev/sda2 发现结果是 statfs的结果,其中
statfs("/", {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=7362755, f_bfree=335618, f_bavail=0, f_files=1872304, f_ffree=1460461, f_fsid={-412611788, 800243945}, f_namelen=255, f_frsize=4096}) = 0
sles11sp1-x64:/opt # strace -o df.txt df /dev/sda2
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 29451020 28103356 0 100% /
statfs("/", {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=7362755, f_bfree=336916, f_bavail=0, f_files=1872304, f_ffree=1460725, f_fsid={-412611788, 800243945}, f_namelen=255, f_frsize=4096}) = 0
struct fs_usage
{
uintmax_t fsu_blocksize; /* Size of a block. */
uintmax_t fsu_blocks; /* Total blocks. */
uintmax_t fsu_bfree; /* Free blocks available to superuser. */
uintmax_t fsu_bavail; /* Free blocks available to non-superuser. */
bool fsu_bavail_top_bit_set; /* 1 if fsu_bavail represents a value < 0. */
uintmax_t fsu_files; /* Total file nodes. */
uintmax_t fsu_ffree; /* Free file nodes. */
};
available 字段域显示的是 fsu_bavail , 就是非root用户可用的空闲空间。
以普通用户身份登录上去,发现果然如此:
hujun@jun:~/Desktop> ssh hujun@192.168.101.40
Password:
Last login: Fri Mar 14 16:23:13 2014 from jun.dnsdhcp.apac.novell.com
hujun@sles11sp1-x64:~> ls
bin
hujun@sles11sp1-x64:~> df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 29G 27G 0 100% /
devtmpfs 1.5G 112K 1.5G 1% /dev
tmpfs 1.5G 100K 1.5G 1% /dev/shm
df: `/root/.gvfs': Permission denied
hujun@sles11sp1-x64:~> touch a.txt
hujun@sles11sp1-x64:~> df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 29451020 28108548 0 100% /
devtmpfs 1512400 112 1512288 1% /dev
tmpfs 1512400 100 1512300 1% /dev/shm
hujun@sles11sp1-x64:~> dd if=/dev/zero of=bigfile bs=512 count=1
dd: writing `bigfile': No space left on device
1+0 records in
0+0 records out
0 bytes (0 B) copied, 0.000199858 s, 0.0 kB/s
hujun@sles11sp1-x64:~> echo "abcd" > hello
-bash: echo: write error: No space left on device
hujun@sles11sp1-x64:~> df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 29G 27G 0 100% /
devtmpfs 1.5G 112K 1.5G 1% /dev
tmpfs 1.5G 100K 1.5G 1% /dev/shm
df: `/root/.gvfs': Permission denied
以root用户身份登录上去,是可以的。
hujun@sles11sp1-x64:~> su -
Password:
sles11sp1-x64:~ # df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 29G 27G 0 100% /
devtmpfs 1.5G 112K 1.5G 1% /dev
tmpfs 1.5G 100K 1.5G 1% /dev/shm
sles11sp1-x64:~ # dd if=/dev/zero of=bigfile bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 378.163 s, 2.8 MB/s
阅读(4096) | 评论(0) | 转发(0) |