7

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:

HDD1:

/
  /usr
  /bin
  /boot
  /var


HDD2:

  /tmp
  /home

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

3 Answers3

8

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 will 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).

Eliah Kagan
  • 119,640
1

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.

Peachy
  • 7,235
  • 10
  • 40
  • 47
Ben
  • 11
0

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:

UUID=unique-partition-id[TAB-HERE]/home[TAB-HERE]ext4[TAB-HERE]defaults[TAB-HERE]0[TAB-HERE]2

(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.

cpit
  • 105
jackweirdy
  • 3,520
  • 5
  • 27
  • 42