0

I've setup a chroot environment for sftp access (sftp only, no shell).

The sftp user needs rw access to a host directory. I mounted it via /etc/fstab
/var/www/html /home/sftp-user/jail/html none bind 0 0

When I do df -h I get the following output:

Filesystem      Size  Used Avail Use% Mounted on
[...]
/dev/sda1        75G   65G  7,7G  90% /
[...]

For du -sh I get the following:

# du -sh /* 2> /dev/null | sort -h
0   /bin
0   /dev
0   /initrd.img
0   /lib
0   /lib32
0   /lib64
0   /libx32
0   /proc
0   /sbin
0   /sys
0   /vmlinuz
4,0K    /mnt
4,0K    /opt
4,0K    /srv
8,0K    /media
16K /lost+found
44K /tmp
4,4M    /etc
52M /boot
81M /run
1,4G    /usr
13G /root
15G /home
36G /var

But the 15GB in home only come from the jail

# du -sh /home/sftp-user/jail/* 2> /dev/null | sort -h
15G /home/sftp-user/jail/html

My understanding of the mount was, that it was more like a symlink, so the disk space is not really used. Is it?

I'm pretty sure I tried to solve that with a symlink first, but something wasn't working that's why I'm using mount now. Unfortunately I forgot what exactly the problem with a symlink was. I think the sftp user had no access to the host folder through that symlink.

Is there a better solution either to get the symlink to work or to show the real used disk space?

Edit for clarification: I don't get why /dev/sda1 seems so full. /var/www/html and /home/sftp-user/jail/html are both on /dev/sda1. I have nothing else in my /home, only that mount. So practically the real size of it should be only some bytes.

So when adding up the sizes of /usr, /root, /home and /var (1,4+13+15+36) I get ~65G. But the actual location of the 15GB of the /home-files is in /var, so the used disk space which df shows should only be ~50G (1,4+13+36).

RafaelKr
  • 101
  • 4

1 Answers1

0

I am not quite sure what your question is. You seem to be surprised that /home has 15GB. That is so because by default, du doesn't care for mount points. It just goes down the filesystem tree until the leaves (i.e., regular files) and sums up their sizes. You can try the -x option; it should make it stop at mount points.

You also seem to be worried or surprised about the space usage on /dev/sda1. You can remove files or extend that partition (if there is room on /dev/sda), but the information you provide is not sufficient to help you.

I think your bind mount is a good solution.

berndbausch
  • 1,033
  • 8
  • 12
  • Hi berndbausch, thanks for your fast answer. I added an edit to my OP. `-x` is described as "skip directories on different file systems", but it's both on `/dev/sda1`. That was probably the missing piece in my question. – RafaelKr Feb 03 '21 at 16:46