How to install /home dir on a different partition?

GTaudiophile

Lifer
Oct 24, 2000
29,767
33
81
Despite the fact I am playing with Ubuntu Server 5.10, I can't help but go back and read the excellent documentation provided by the Gentoo folks.

If you read their Gentoo Security Handbook, one of the things they list under "Partitioning Schemes" is...

Any directory tree a user should be able to write to (e.g. /home, /tmp) should be on a separate partition and use disk quotas. This reduces the risk of a user filling up your whole filesystem.

This has the added advantage of being able to re-install the OS without losing your data if it's all located on a different partition.

Is the following an example of a partition table that would satisfy this security requirement?

Filesystem Type Size Used Avail Use% Mounted on
/dev/hda5 ext3 509M 132M 351M 28% /
/dev/hda2 ext3 5.0G 3.0G 1.8G 63% /home
/dev/hda7 ext3 7.9G 6.2G 1.3G 83% /usr
/dev/hda8 ext3 1011M 483M 477M 51% /opt
/dev/hda9 ext3 2.0G 607M 1.3G 32% /var
/dev/hda1 ext2 51M 17M 31M 36% /boot
/dev/hda6 swap 516M 12M 504M 2% <not mounted>
(Unpartitioned space for future usage: 2 GB)


The next question would be, how do you do this in Ubuntu? I saw during the installation you could edit partition tables. So I suppose you can.

 

sourceninja

Diamond Member
Mar 8, 2005
8,805
65
91
you can do it with the partition manager in the ubuntu setup, or if its already setup, just get the new partition ready (new drive or using a partition resizing program) then mount the drive as /mnt/newhome or something like that, copy over everything that is in home then edit fstab to have home

/dev/hdb1 /home ext2 defaults 1 2

you can use the gentoo guide for this even on ubuntu. The fstab is perty self explanitory. Plus just google fstab and you will get tons of info.

Anyways, then you can just delete what is in your old home folder then reboot and home will be mounted properly, or you can just mount it yourself and save the reboot.
 

nweaver

Diamond Member
Jan 21, 2001
6,813
1
0
Source hit this one right out of the park. Make new partition, mount, copy old data, edit FSTAB to add the entry for /home, reboot.
 

GTaudiophile

Lifer
Oct 24, 2000
29,767
33
81
sourceninja: Great response!

I'd still be interested in knowing how to achieve the same during the installation process.
 

GTaudiophile

Lifer
Oct 24, 2000
29,767
33
81
Originally posted by: sourceninja
you can do it with the partition manager in the ubuntu setup, or if its already setup, just get the new partition ready (new drive or using a partition resizing program) then mount the drive as /mnt/newhome or something like that, copy over everything that is in home then edit fstab to have home

/dev/hdb1 /home ext2 defaults 1 2

you can use the gentoo guide for this even on ubuntu. The fstab is perty self explanitory. Plus just google fstab and you will get tons of info.

Anyways, then you can just delete what is in your old home folder then reboot and home will be mounted properly, or you can just mount it yourself and save the reboot.

Any why use ext2 instead of ext3 as the file system? :p

<--- n00b
 

sourceninja

Diamond Member
Mar 8, 2005
8,805
65
91
oh i just copied that from an old system. I wouldn't use ext2 for /home (although I would use it for small drives and partitions where the data doesnt' change all that often and the journal would just be wasted space). I would use ext3 or reiser.

Durring the ubuntu install, just use the partition manager manually. You can tell it what size in megs or percent to make the partition then what the filesystem is to be and what the mount point is. Its very straight foward.

I usually go / = 15-20 gig, swap - 1gig, home - rest of drive for desktops and I break out tmp and /var and a few others sometimes for servers. And on gentoo boxes I always keep /boot on its own parttion (just an old habbit, and you never mount it exccept for kenel upgrades anyways).
 

sourceninja

Diamond Member
Mar 8, 2005
8,805
65
91
You will need to make some blank space.

I would delete all those partitions and remake them.
 

GTaudiophile

Lifer
Oct 24, 2000
29,767
33
81
Of course, the partition sizes I would use would be a lot differen than the drive pictured...mine is 400GB unformatted.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Any directory tree a user should be able to write to (e.g. /home, /tmp) should be on a separate partition and use disk quotas. This reduces the risk of a user filling up your whole filesystem.

The thing is though, that a user filling up a filesystem isn't a big deal in most cases. It can be inconvenient if they fill up /tmp as some things will fail to run without any tmp space or /var as it'll stop syslog from logging and f' with whatever else you have writing to /var. But the system will keep working and you'll be able to fix it without much hassle.

Filesystem Type Size Used Avail Use% Mounted on
/dev/hda5 ext3 509M 132M 351M 28% /
/dev/hda2 ext3 5.0G 3.0G 1.8G 63% /home
/dev/hda7 ext3 7.9G 6.2G 1.3G 83% /usr
/dev/hda8 ext3 1011M 483M 477M 51% /opt
/dev/hda9 ext3 2.0G 607M 1.3G 32% /var
/dev/hda1 ext2 51M 17M 31M 36% /boot
/dev/hda6 swap 516M 12M 504M 2% <not mounted>
(Unpartitioned space for future usage: 2 GB)

My main question would be why did you waste space on /opt and leave 2G unpartitioned? /opt is a holdover from commercial unixes that pretty much nothing in the OSS world uses and leaving 2G unpartitioned is a waste, you know you can resize most filesystems, right?

Oh and 2G for /var might not be enough for Ubuntu, like Debian it caches the packages it installs in /var/cache/apt/archives and unless you clean that up regularly it'll grow infinitely. Hell that directory on my home machine is ~4G right now because I never touch it so that I can have old copies of packages around "just in case".
 

GTaudiophile

Lifer
Oct 24, 2000
29,767
33
81
Nothinman: That is not my personal partion table. I borrowed it from the Gentoo site simply as an example of how I thought one could install /home to a different partition.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Ah, makes sense then that some Gentoo user/dev would come up with such a f'd up partition table =)
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
If Ubuntu supports it, use LVM to manage logical volumes instead of partitions. It's just much easier and sane to do.
What was suggested by Gentoo seems like a management nightmare to me.

I mean with LVM setup you can unmount, resize, then remount 'partitions'. Do snapshots, move volumes around to different physical hardware and even do raid-like setups by striping across physical disks. Lots of other usefull stuff.

On everything I do nowadays I make 3 partitions. One for the /boot, one for swap, then one for my LVM's logical group.

edit:

as for howto to do it.. it's usually done at install time. You setup whatever and specify mounts for different partitions or whatever. If you do it after install then you have to create the volume or partition for your /home directory, format it, then edit your /etc/fstab file so that it gets mounted and checked at boot up time. Then you move your home directory to something like /home.backup/ and then mkdir /home, mount the volume, then use 'cp' command with the proper switches to copy everything over while perserving permissions.