is it possible to mount the root file system '/' on one hard drive (where folders like /usr, /boot, etc will be stored) and mount /tmp and /home to another hard drive on the same partition?

Something like this:





I know LVM is possible for creating a single large volume but that is not what I want

  • This is on an existing install. But it was just set up so there isnt a whole lot of stuff to move around – arcyqwerty Jun 10 '12 at 17:59
  • You should be able to use these instructions for creating a separate /home partition for both, though for moving /tmp, you might not be able to do that without booting from a live CD (or at least using rescue mode). Hopefully someone who has done this can write an answer presenting this information in detail (that documentation is also licensed CC-BY-SA, so with proper attribution, pieces of it can even be included in an answer). – Eliah Kagan Jun 10 '12 at 18:03
  • well. I already have a partition on each drive. I would like to keep /tmp and /home on the same partition if possible (like how mounting HDD1 as / puts all /usr /var and /boot on the same partition) such that the space is shared – arcyqwerty Jun 10 '12 at 18:09
  • Ah, I see, you want /tmp and /home to be on a separate partition from / but on the same partition as each other. This is slightly less trivial to achieve. I'll post an answer about how to do this (and then someone more experienced moving system directories while they're in use can weigh in as well). – Eliah Kagan Jun 10 '12 at 18:11
  • right now I have HDD1 partitioned as /dev/sda5 (swap), /dev/sda6 (/), /dev/sda7 (/vm -- to store virtual machines); HDD2 is currently formatted as /dev/sdb5 (swap, /dev/sdb6 (/tmp); I'd like to have /dev/sdb6 store both /tmp and /home – arcyqwerty Jun 10 '12 at 18:12

To have /tmp and /home on the same partition as each other but a different partition from /, you'll need to do this:

  1. Make tmp and home the two top-level directories on the partition you want to contain them. So if right now that partition is itself /tmp, you'll need to move its entire contents to a tmp directory in its root.

  2. Give the partition that contains tmp and home its own mount point. A reasonable name for this is tmp+home (unless you plan to use that partition for other stuff too) and reasonable locations for it are /, /mnt, and /media. I recommend putting it directly in / and the rest of this answer assumes that's where it is.

  3. Give /tmp+home its own entry in /etc/fstab. (You'll see /tmp has its own entry

  4. Make /tmp and /home symbolic links to /tmp+home/tmp and /tmp+home/home.

Please note that this will not involve using these instructions for creating a separate /home partition, because in this configuration, /home will be a symbolic link into a separate partition, rather than a mount point for a separate partition.

Furthermore, you'll have to unconfigure your separate /tmp directory (including removing or, better, commenting out its entry in /etc/fstab), since /tmp will no longer be a mount point for a separate partition, but will instead be a symbolic link into a separate partition.

This answer doesn't provide extremely specific instructions (though it should be sufficient, combined with the available documentation). If someone who has experience moving /tmp can weigh in on whether or not it's possible/safe to move /tmp while in the installed system, that would be helpful. I can give detailed instructions for doing this from the installed system or from a live CD, but I don't want to give directions that are ineffective or unsafe (nor directions that are unnecessarily difficult and time-consuming).

| improve this answer | |
  • I can't think of any risks with moving /tmp besides the idea that if you unmount it and a process wants to access it then it might (extremely worst case scenario) cause a kernel panic. If fstab hadn't been changed then you could restart and try again later. If it had, and the mount point was invalid or non existent yet, the OS could fail to boot, or it could chug on without it. In any case, better safe than sorry. Likely as not though there wouldn't be a panic in the first place, the process would just end or carry on regardless. – jackweirdy Jun 10 '12 at 18:47
  • @jackweirdy An app finding it can't access data won't cause a kernel panic, but I'm worried that if important apps or services need /tmp and it's moved under them, the system might not remain functional while the other steps are followed. Furthermore, in general any file or directory in /tmp is considered eligible for deletion anytime when it's not actively in use by some process, so if the contents of /home go into a partition that's still mounted as /tmp... You can definitely use a live CD, but I'm hoping someone whose done it in a running system can comment (or edit my answer). – Eliah Kagan Jun 10 '12 at 18:53
  • Just tried following your instructions (only to a new partition though). Went fine :) – jackweirdy Jun 11 '12 at 11:06
  • Upvote and marked as answer since it works and there doesnt seem to be a better way to do it without an extra mount point. Thanks! – arcyqwerty Jun 11 '12 at 21:42

The easy way would be to make another / partition with an install disk then reboot, and mount that partition temporarily in /media or whatever then copy the /home and /tmp folders in the new / root partition you mounted under media. Unmount it and reboot.

| improve this answer | |

Note - Follow instructions at your own peril! I'm confident they will work, but I don't want to be responsible for losing all your stuff

As someone who has /home on a dedicated partition (but not hard drive) I can say its possible, although it's much easier to do with the ubuntu installer when you first install ubuntu.

However, if you need to do this without reinstalling ubuntu I would say it's best to put a small linux OS or livecd (I recommend Puppy Linux due to its small size) onto a USB stick or CD and use that to adjust your Hard Disk setup and /etc/fstab file, which contains the list of which partitions and Hard Drives hold which folders. I'll continue assuming you use puppy linux to do this, but the steps are easy to follow if you use - for example - an ubuntu livecd.

Once puppy linux is installed (use unetbootin to do this if you are using a USB stick) first need to use Gparted (the graphical partition editor included with puppy linux) to ensure the new hard drive is formatted correctly. It isn't crucial, but it is helpful to use the same filesystem across the two hard drives. I would also suggest you create a partition for /tmp and a partition for /home. The reasoning for this will become clear.

Once you have these partitions created you need to mount the HDD containing the Ubuntu installation, and copy the contents of the home folder to the partition you have created for it. There shouldn't be anything in /tmp.

Next, open the file etc/fstab for text editing.

Note - ensure you open the file within the ubuntu drive, otherwise you'll be editing the mount details for the livecd/puppy linux

The layout of the fstab file is like this:


(The tabs weren't rendered so I put where they go in square brackets. They aren't strictly necessary but they make the file a hell of a lot easier to read)

append this line twice, once for the home directory, and once for tmp. Ensure that the ext4 line is changed to match the filesystem used by the partition, and that the unique-partition-id field is changed to match the UUID of the partition. that value can be found in gparted (or the ubuntu disk management utility on a livecd).

Delete the contents of the original home directory - ensuring all files copied across - then save the changes to etc/fstab and restart.

| improve this answer | |
  • The OP is asking specifically about how to put /tmp and /home on a different partition from / but the same partition as each other. This can be done. – Eliah Kagan Jun 10 '12 at 18:31
  • I noticed that, but that would include mounting / twice in the fstab. This specific requirement has caused me problems before (admittedly in the 2.20s of the kernel) but I wouldn't want to risk it again. – jackweirdy Jun 10 '12 at 18:34
  • You don't have to (and indeed you're right, you should never) have two fstab entries for /. You should never try to use one directory as a mount point for more than one partition. Instead, just make /tmp and /home directories in the root of their partition, mount the root of their partition on its own mount point, and make /tmp and /home symbolic links to the respective subdirectories of that mount point. See my answer for details. – Eliah Kagan Jun 10 '12 at 18:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.