So I was experimenting with my first-ever attempt to set up a chroot, fortunately working on a test 12.04 LTS server install. I used bindfs to experimentally figure out which parts of the filesystem needed to be duplicated within my chroot directory and successfully got chroot launched with the application working properly.
bindfs takes up a fair chunk of memory and my production server is fairly limited memory-wise, so I umounted those folders and proceeded with trying to get it working by copying only the necessary files over to the chroot directory, using the approach described in the GNU documentation of running "ldd" on the executable to find out which libraries it needs.
I got half of them copied over and then got to the point of running this command:
when the ssh connection dropped suddenly. I went to the server's console and tried to log in but entering the username resulted in this error
cp /lib/i386-linux-gnu/libdl.so.2 /my/chroot/dir/lib/i386-linux-gnu
and now during a reboot it hangs while running mountall with the same error about the same .so file. Googling the error seems to indicate that the "too short" bit is a complaint that it doesn't see an ELF header when it begins to load the file.
/bin/login: error while loading shared libraries: /lib/i386-linux-gnu/libdl.so.2: file too short
Since this is just a test server I don't really care about fixing the problem, I'm sure I'll find a workaround with a more conventional way of setting up a chroot, but what I'm really curious about is: what happened? How did simply copying this file apparently make it unreadable?