I've attached an EBS block and mounted it at "/data" on my EC2 instance, which runs Ubuntu 12.04. There is a backup script which runs okay but after I move the script to "/data/backup" folder, it cannot be executed, with error:
-bash: ./db_backup.sh: Permission denied
The permission is:
-rwxr-xr-x 1 ubuntu ubuntu 2.3K Nov 22 03:25 db_backup.sh
If I run it with "sudo", there is no error and no output, but there should be some thing echo to console.
And I also try use "strace" to follow the excecution, got:
execve("./db_backup.sh", ["./db_backup.sh"], [/* 19 vars */]) = -1 EACCES (Permission denied)
dup(2) = 3
fcntl(3, F_GETFL) = 0x8002 (flags O_RDWR|O_LARGEFILE)
fstat(3, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 1), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f354f010000
lseek(3, 0, SEEK_CUR) = -1 ESPIPE (Illegal seek)
write(3, "strace: exec: Permission denied\n", 32strace: exec: Permission denied
) = 32
close(3) = 0
munmap(0x7f354f010000, 4096) = 0
exit_group(1) = ?
But if I put this script somewhhere, say "/tmp", it works no problem. To narrow down the root cause, I also created a test script:
#!/bin/bash
echo "hello"
Sadly, this doesn't work too if I put it in the /data folder.