15

I'd like to install Ubuntu on two drives, one with / and the other with /opt and /home. But I do not want /opt and /home to reside on separate partitions but on the same one. Is it possible to do during the installation?

3 Answers 3

14

This is what I would do. Make a home partition, tell the installer to mount it to /home. After install and on first boot create a directory called /home/opt. Then mount bind it to /opt.

Make sure /opt is empty before you do this. I would think so if it's just after a fresh install.

mount -o bind /home/opt /opt

for a manual mount.

For mounting on boot, edit /etc/fstab it would look something like this. Make sure you add below your home mount, which the installer should have added.

/home/opt /opt none bind 0 0
0
3

It's pretty easy with bind mounts. That way, you can mount a subdirectory from one location on another location.

Just make "opt" a subdirectory in your "home" partition, then mount the partition to /home and bind mount /home/opt to /opt:

sudo mount /dev/sda4 /home
sudo mount --bind /home/opt /opt

Or it can be made permanent by adding them to /etc/fstab like this:

/dev/sda4   /home   ext4   defaults   0 2
/home/opt   /opt    none   bind       0 0

And if you prefer using UUIDs, replace /dev/sda4 with UUID=<your UUID>

2
  • What makes your answer different from the one of @strings? And I fail to see how this relates to the installation.
    – gertvdijk
    Jan 11, 2013 at 2:40
  • Not much, from the looks of it. I'm afraid I wrote that before looking at the other answers very thoroughly. At any rate, maybe explaining the same thing 2 different ways isn't such a bad thing on askubuntu.com Jan 15, 2013 at 2:07
1

The LVM way

If you don't mind it being two different volumes, on one partition.

Create an Physical Volume on the drive you want to put the /home and /opt on. Create a Volume Group with just this partition as the single member of it. Give it a name, e.g. myvg. Then create two Logical Volumes, e.g. homes and opt, both will have a filesystem and the obvious mount points.

Advantages:

  • You can do snapshotting.
  • Resizing Logical Volumes is a piece of cake compared to resizing partitions.
  • Create more volumes without even touching the partition table on a running system.

In order to profit from this, you'll have to keep some free space in the Volume Group.

How?

The installer will allow you to do this quite easily in the GUI. For 12.04 you'll need the alternative image, for 12.10 and onwards, this is included in the regular images.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .