Understanding the Mounting of a Filesystem

Solution 1:

Q1) are all of the contents of /home now accessible under /var/www/ (i.e. /home/username -> /var/www/username)?

yes, the directories will now be /var/www/username instead of /home/username

Q2) Are all of the permissions from the /home filesystem kept intact in this new location?

as long as it is remounted on the same system, the file ownership will be the same, and the permissions will be the same, even on a different system. ownership depends on /etc/passwd and /etc/groups to turn the numeric UIDs to human readable values, and if bob is uid 1000 on system x, but uid 1050 on system y, bob won't have ownership of the files on the new system.

unless you remake the user directories in /home once you do this, it will mess up how users can log in, since their home directory will be non-existent. none of their login scripts will be executed, and so forth.

to migrate the partition to /var/www/ you'll want to do;

mkdir /home2/
cp -R /home/* /home2/
umount /home/
mv /home2/* /home/
rm -rf /home2/      # be VERY careful with this command
mount -t ext3 /dev/sda5 /var/www/

then add something like:

/dev/sda5       /var/www            ext3    defaults        0       2

to /etc/fstab

Solution 2:

The Specific Questions:
1.Yes, they should be assuming the person has the directory permissions needed to make it to that directory. (More on directory permissions in this answer of mine).
2.Yes, the should be intact since the ownership is a uid/gid number stored on that particular filesystem.

Single Tree Vs a Forest:
As far as coming from Windows, the main difference is one big tree vs. a forest. In windows, the root of each drive, a letter, is its own tree structure. Since there can be multiple drives, you end up with a "forest" (many trees). In Unix / is the root of a single tree, and on each machine there is only one tree.

Some other (maybe random) things to keep in mind:

  • In Unix, there is the "Everything is file" philosophy. So devices, directories, and sockets are all represented as files.
  • A name, such as "foo" that represents a file is actually a link to that file. You can have multiple names (links) mapped to that file. These come in to types, hard and symbolic links. Hard links can only point to files that exist on that same filesystem, symbolic links can point to files on other filesystems.
  • You can actually mount a filesystem on a non-empty directory (although things probably throw warnings about this these days). These end up "hiding" (not overwriting) the files that you mounted over, but they won't be overwritten. These are called "overlay mounts".
  • This is just to confuse you a little :-) You can actually create a file that is itself a filesystem and mount it as a new filesystem somewhere else using the loopback device. This is kind of like using daemon tools in Windows to mount an ISO image.

Lastly, as an aside, sounds like you are putting in a good solid effort to learn *nix from a Windows background, which I think is a respectable thing to do (Same for other way around as well).

Solution 3:

You can do that kind of moving, but then /home will be empty which would break a number of things. For example, the home directories in /etc/passwd would be missing.