No, you can't do what you're asking. As you've noted, you can't reference a file in a filesystem you haven't mounted yet.[*]
However, there is a scheme that might work for you: a filesystem-in-file on the donor partition, mounted via the loop device. Consider:
# cd /mnt/temphome
# chmod 700 .
# chown root.root .
# dd if=/dev/zero of=temphome bs=4k count=1M
# mke2fs -j temphome
(answer yes to the annoying question)
# mount temphome /home -o loop
What this does is creates a 4 GiB /home
filesystem that lives in a file at the root of the /mnt/temphome
partition. You still have to mount the donor partition and leave it mounted, but only root can mount it or change its contents directly, including mounting /home
via the loop device. Once you've mounted the new /home
, however, normal users can write to that new filesystem because they're doing so through the kernel, which has the power to do that, a power controlled by the permissions in the loop filesystem.
If for some reason that still exposes the /mnt/temphome
partition to more risk than you wish to accept, the best alternative I can think of is to use gparted to shrink the donor partition and use the space opened up to create a new temporary /home
partition. When you're done using it, pop back into gparted, delete the temp partition, and re-expand the donor partition to use the freed space. This has its own risks, though: modifying partitions isn't 100% safe.
[*] Well, that's not entirely true. Occasionally you see trickery involving knowledge of the exact disk location (sector, head, track) of files in other filesystems. This is most common in low-level activities: hibernation, swap, booting... For this to work, you need a completely contiguous file (i.e. no fragmentation) that never moves, so that you can just start reading and writing raw sectors from and to an unmounted partition.
If you watch the trend of such things over time, though, you notice that they tend to become less popular over time, because of the various consequences. For one thing, defraggers tend to break such schemes. It's one reason /boot
and swap
are usually separate partitions under Linux.
/mnt/temphome
may be world-readble or -writable, or that some of its contents may be.