You are not logged in.

#1 2010-04-06 21:09:28

Registered: 2008-03-11
Posts: 1,020

Mount multiple directories to the same partition?

So, I have separate partitions for /var and for / and I've decided that my /var partition is big enough to also hold /tmp. Can I mount both directories to that partition or do I have to split it up?

Splitting it would suck because they are both so VARiable and TEMPorary.


#2 2010-04-06 21:46:20

From: NYC
Registered: 2008-03-24
Posts: 658

Re: Mount multiple directories to the same partition?

So you mean, how can you have both /var and /tmp on a single external partition?

Here are your options.

Option 1
Boot from another system (e.g. a LiveCD) and mount your /var partition and do this as root:

cd /mnt/var
mkdir -m755 .newvar
mv * .newvar # won't try to move .newvar because it begins with a period
mv .newvar var # rename .newvar to var
mkdir -m1777 tmp # make a tmp dir

Now you'll have to specify in your /etc/fstab:
1. a mount point for the whole partition, e.g., /mnt/ignore_me
2. the following two lines:

/mnt/ignore_me/var /var none bind
/mnt/ignore_me/tmp /tmp none bind

Option 2
Keep mounting the /var partition as you are currently, but do this as root:

cd /var
mkdir -m1777 .tmpdir # make a hidden /var/.tmpdir --- notice that /var/tmp is something different

Add the following to your /etc/fstab, after the lines that mount /var:

/var/.tmpdir /tmp none bind

In either case, the directories that you "bind"-ed to another mount point will also still be available at their original locations. With the "mount" command, there's also a different option to move the directory (-o move instead of -o bind). But last time I checked, you couldn't specify "move" in an fstab file. Only bind.


Board footer

Powered by FluxBB