Solved How to set /home on a dedicated "partition"?

( Disclaimer: Not a native-english speaker, and totally newbie, I do my best )

Hello, world. First thread so I hope to make it right:

The concrete question is: Can I have the /home directory (which as I understand, contains my personal data) on a different partition?

To help you understand what I want, I'm going to clarify some terms:
-I'm talking about one physical hard disk drive.
-By partition I understand the windows-partition concept, which I think in *BSD it's called...slice?
-My idea it's to have the system data in one "partition" and my personal data in another so in that way I can use the system without worrying about deleting my things.

If there's already a thread or article that covers this subject, I would like to read it ( 'cause I couldn't fine any ).

Thanks in advance.
 
In other systems (I'm a FreeBSD newbie), I have moved /home to another partition and updated /etc/passwd for the userid's home folder location in order to separate the system from configuration/user data. However a appropriate backup strategy can serve as equally as well even if /home is with the rest of the system. Generally your data is the most valuable/irreplaceable. System files are easily and inexpensively replaced, some personal files might be invaluable. Accordingly backing up your personal data files is the highest priority, ideally to disconnected devices and even storing off-site. Corruption/loss of system files by contrast is a inconvenience/annoyance - nice to have backed up in order to minimise that annoyance, but not critical.
 
I am assuming you are talking about of already running system, and it would be better to do using the boot/installation media.

If you are using UFS:
  1. add the new disk, and format it;
  2. move the /home directory to that new disc/partition. However would be safer to first copy it (cp -Rp), or even better use net/rsync, and later delete the old data;
  3. update your /etc/fstab accordingly;
  4. Boot the system.

If you are using ZFS:
  1. add the new disk, and create the new pool;
  2. set the mount point to that new pool: newpool/home;
  3. you may need to import the new pool, but I am not 100% certain about it. However, it is safe anyway;
  4. now, I think you do not need to do anything more, ZFS should take care of everything.

You may need those tools: cp(1), gpart(8), zfs(8), zpool(8).

EDIT: as people often experience problems when using disks which already has GPT partitions (mean used disks) of others filesystems when they do create new ZFS pools, because it (ZFS) does not use the last (backup) GPT partititon, and so it end up in the situation of mismatch, and some annoying error messages returns during boot.

I personally like to use sysutils/gdisk to burn all old GPT data before creating the new ZFS pool:

Code:
gdisk /dev/DISK
x [extra functionality (experts only)]
z [zap (destroy) GPT data structures and exit]
 
The concrete question is: Can I have the /home directory (which as I understand, contains my personal data) on a different partition?
Yes, and it's even recommended because this will make it much easier on you to backup your data. Of course there's more: it will also ensure that if you run out of personal diskspace then this won't have any affect on the rest of your system.

Generally speaking you can pretty much take the whole FreeBSD hierarchy apart (but.. not all). It's not uncommon to put /, /var, /usr and /usr/local on separate slices as well. Basically you can use whatever setup suits you best.

In contrary to Linux the manualpages on FreeBSD actually mean something. I'm not trying to be negative towards Linux here, but it's a well known fact that documentation is basically a mixture between man and info. So to get a good understanding of the FreeBSD hierarchy you might want to check out the hier(7) manualpage (follow the link). It'll explain some of the basic locations and what they do.

Also... you mentioned that you looked into documentation and such, have you found the FreeBSD handbook yet? That is a very solid source of information. To specifically address your questions here I'd say chapter 3.5 and chapter 3.6 are well worth reading.

Hope this can help you out a bit.
 
I am assuming you are talking about of already running system, and it would be better to do using the boot/installation media.

If you are using UFS:
  1. add the new disk, and format it;
  2. move the /home directory to that new disc/partition. However would be safer to first copy it (cp -Rp), or even better use net/rsync, and later delete the old data;
  3. update your /etc/fstab accordingly;
  4. Boot the system.
Actually, I was talking about a fresh new system. Right now I'm testing freeBSD in a Virtual Machine before installing in a laptop, but forgot to clarify that.
Anyway, I read what you and ShelLuser said and maybe I have an idea.
My /etc/fstab have the following:
# Device..........Mount point......FStype......Options.....Dump.....Pass #
/dev/ada0p2....../.............................ufs.................rw.................1...............1
/dev/ada0p3......none......................swap..............sw................0...............0


...and the output of pwd is: /usr/home/MyName


So, with what you said and what ShelLuser gave me I should:

-First of all, have another slice to copy /home (I do that in the installation).
-Copy /usr/home/MyName to /dev/ada0p4 (Not so sure about the destination path. Maybe use mount previously).
-If everything it's ok, delete /usr/home/MyName
-Add to my /etc/fstab/:
Device...............Mount point......FStype......Options.....Dump.....Pass #
/dev/ada0p4........./home....................ufs.................rw.................1...............1

-Reboot the system.


If anything it's wrong (and I'm pretty sure it is), please make me notice. Thanks for your patience.
 
Excellent idea

( Disclaimer: Not a native-english speaker, and totally newbie, I do my best )

Your english is perfectly understandable, and your question is sensible.

Can I have the /home directory (which as I understand, contains my personal data) on a different partition?
Yes you can, and yes it is a good idea. Other than quick throw-away installs, I always have /home separated out, and usually also /var and /usr (sometimes more).

But: You need to explain really why you are wanting to do it, because you need to have good reasons for it: it is not free, and has tradeoffs.

Pro: Mostly mentioned above. Although your argument:
I can use the system without worrying about deleting my things.
needs to be thought through. The normal way to use a Unix system is to do most tasks as a normal unprivileged user, and only become the superuser (root) for system administration tasks, as little as possible. The normal user can typically delete his own files (you can use file permissions and ACLs to prevent that, but that's uncommon), but can not delete anything owned by "root", meaning stuff that's necessary for the system to operate. So don't worry about breaking the system. On the other hand, root can delete anything they want. Whether /home is on a separate file system (on a separate partition or on a separate disk) or not makes no difference to the ownership- and permission-based design of who can delete or modify what file. So I think this is a particularly weak arguments.

Here are some of the tradeoffs: More complexity, more stuff to administer, more opportunity for things to go wrong. For example: If either the /home file system or the "other" (root...) file system are full, the system will fundamentally stop working, so twice the chance of a screwup. Another thing: If you move (rename) a file from one directory to another, and you are crossing file system boundaries (for example you're moving large amount of data from /var/... into your home directory), then with separate file systems this requires a slow copy; if you're on one file system, the data stays in place. Another thing: You need to make an educates guess of how big to make the two partitions; if you guess wrong, one is going to run out of room, while the other one has a lot of spare space.

Still, on balance it's a good idea. In particular since today performance and capacity considerations are less important, with modern computers and disks.
 
Tu_Vieja if you will use UFS you can easily do it from the installer (you just need to use the "manual" mode, instead of the guided one), without the need to change anything more later.

Just follow the Handbook and you will be good.
 
Actually, I was talking about a fresh new system. Right now I'm testing freeBSD in a Virtual Machine before installing in a laptop, but forgot to clarify that.
Anyway, I read what you and ShelLuser said and maybe I have an idea.
My /etc/fstab have the following:
# Device..........Mount point......FStype......Options.....Dump.....Pass #
/dev/ada0p2....../.............................ufs.................rw.................1...............1
/dev/ada0p3......none......................swap..............sw................0...............0


...and the output of pwd is: /usr/home/MyName


So, with what you said and what ShelLuser gave me I should:

-First of all, have another slice to copy /home (I do that in the installation).
-Copy /usr/home/MyName to /dev/ada0p4 (Not so sure about the destination path. Maybe use mount previously).
-If everything it's ok, delete /usr/home/MyName
-Add to my /etc/fstab/:
Device...............Mount point......FStype......Options.....Dump.....Pass #
/dev/ada0p4........./home....................ufs.................rw.................1...............1

You said you are creating this system from scratch? If so, don't create any regular users during the installation process. Do set your mount point as you have above (with a separate slice/partition mouting to /home

When the system comes up for the first time, edit /etc/addusers.conf and change the homeprefix directive to /home.

Then, remote the /usr/home directory (make sure it is empty, it should be). After that add a link to /home from /usr/home (so applications with hard-coded /usr/home work).

You should be able to use the adduser command to create all the new regular users you need and their home directories should show up in /home.
 
Tu_Vieja if you will use UFS you can easily do it from the installer (you just need to use the "manual" mode, instead of the guided one), without the need to change anything more later.

Just follow the Handbook and you will be good.

You said you are creating this system from scratch? If so, don't create any regular users during the installation process. Do set your mount point as you have above (with a separate slice/partition mouting to /home

When the system comes up for the first time, edit /etc/addusers.conf and change the homeprefix directive to /home.

Then, remote the /usr/home directory (make sure it is empty, it should be). After that add a link to /home from /usr/home (so applications with hard-coded /usr/home work).

You should be able to use the adduser command to create all the new regular users you need and their home directories should show up in /home.

Ok, I'm taking your suggestions and then I tell you (probably at the weekend). Thanks!
 
Ok, people...I think that my objective was achieved.
-In my "first" install of the system, I create a slice that mounted to /home like lebarondemerde said (I learn that I could set that editing /etc/fstab, more on that later...)
-I created a series of different files in /home to test the persistence of data through multiple re-installs of the OS (THAT's what I wanted, my original question wasn't 100% clear, but actually kind of vague with my true intentions, sorry).
-Then I do the following: ln -s /home /usr/home to create a symlink to my dedicated and mounted slice. (NOTE: I didn't have any other user besides root)
-When adding a new user, I set my home directory to /usr/home/MyName, which creates a directory in /home called...MyName.
-I create new files to keep testing my objective, and finally re-install the system, but in the installer I don't set my dedicated partition to /home ('cause I'm pretty sure that deletes my data, gonna test it later). And I don't create any users in the installation.
- Before exiting, I edit /etc/fstab to mount ada0p3 to /home, and then I can create a new user, whose directory lies in /home, with my old files still there.

It could sound like a mess but to me it was pretty clear after days of trying, reading and re-reading. From your suggestions, the only thing I couldn't do was to edit /etc/adduser.conf like ekingston said, simply because I don't find it there.

So, what did you think guys?
It's this the way to have my data safe in a dedicated partition, and through re-installs of the OS?
(in the worst case scenario).
Would you do something different?

Any suggestions will be well receive.
 
You have some ways to change your $HOME prefix. However, you can set that during the user creation, if you create the user by the adduser command, but it does not matter anymore as you already created the user.

The most straight forward way to change the $HOME prefix is running (as root) chpass YOURUSER, and modify it in there. But also there is pw, or even changing /etc/passwd directly (what I do not like).

You do not need a symlink to /usr/home.

I never head about an /etc/adduser.conf. :rolleyes:
 
Just want to re-confirm what lebarondemerde said up there. If you keep your home set to /home then that's all you really need. No need to cling onto /usr/home.


Check adduser(8). It's not there by default, but when created it allows you to override specific settings for new users.

So, let me see if I understand. When using adduser at the moment it ask for a home directory path it says /home/MyName.
So, if I have my partition mounted to /home, and accept that default on adduser, everything will be ok? If that's so, I just overcomplicated things and like lebarondemerde said, the symlink it's not necessary.
 
Correct. You can have all your users (or one user) have their home directory in /home. That seems to be the default in adduser anyhow. If all your users have their home directory in /home, then you can get rid of /usr/home.

One of your questions is: You want the home directories in /home and not /usr/home, and in a separate file system (in a separate partition or slice) so that they survive re-installing the OS. Clearly, having the home directories not inside the /usr file system will help with that. But it is not guaranteed to preserve them: An OS install can also re-partition the disk. Fortunately, if I remember the FreeBSD installs (I don't do them that often), they don't do anything like re-partition or re-format file systems without asking for permission first, so all this relies on the operator paying attention, and you can always use manual file system setup to accomplish what you want.

Personally, I have never liked having both /home and /usr/home: One of them should be superfluous, if the system is well managed. Soft-linking them to each other just allows such sloppiness to continue existing. On the other hand, if local traditions or existing bad software requires both to exist, so be it.
 
The "home" directory (containing all users' directories) is not even mentioned in hier(7). The only one mentioned there is root's standard home directory /root/.

/usr/home/ only exists if you decided not to create a separate partition to store home directories. One of the operations performed during the setup is the extraction of distribution files (base, kernel, etc.) If you check the contents of base.txz, you will actually see neither of the two directories (/home/ and /usr/home/).

The current user's directory is set as an environment variable ($HOME) by the shell using (I guess) the information found in /etc/passwd. You're practically free to set it to anything and the system will adapt itself.

FreeBSD's setup will only touch the partitions you mount. If memory serves me well, there's an option to disable newfs(8) on these. So simply having the contents of /home/ on a separate partition ensures they will be preserved. You don't even need to have them on a separate slice (if using the MBR scheme).

Whatever you decide to do, always have reliable backups of your data anyway before doing anything with your disks/partitions or reinstalling the system.
 
All of you have been a great help, your explanations were clear and I agree with the "redundancy" of having both /home and /usr/home. And I will have a reliable backup when the time to re-install the system comes (as I already said, worst case scenario), 'cause it's better to have it and don't need it than need it and not having it.

I will mark the thread as Solved, but if you would like to said anything else, be my guest.

I must say, what a nice start in this community.
 
If you are planning to have a NAS for backup, but also even a external drive, you should consider to use ZFS instead of UFS as you can use the replication feature (zfs send | zfs receive). Indeed, you can even automate it using something like sysutils/zap. Not to say the others advantages of zfs(8).

However, you can also simplify backups when using UFS (or anything) using sysutils/rsnapshot.

Cheers! :beer:
 
I found this tread read it 3 times already
Ok I hope I'will not pissoff some of you folks with that.
I don't want to duplicate the thread or the question.
That's why I'm digging up the thread

FreeBSD directory structure or bsd dir structure in general is
OSX more or less included for obvious reasons.
Linux structure as unix like system is almost identical its most notable / conspicuous difference is separate /home dir so any personal data are separated completely from a system (system files).

In BSD lots of stuff goes to /usr/ with /usr/home/IMUSER if created.
There is no separate /home slice , home is embedded in /usr which is simultaneously logical and makes no sense.
Its logical because there goes libs and bins and "stuff" that is used by user directly or indirectly.
It is nonsense because if my /usr slice or logical partition (whatever we chose call it) goes south then /usr/home/IMUSER data goes south with it.
And that sucks. I always have backup so it suck much less ;)

This tread It is a fine recipe for moving your existing personal data from /usr/home/IMUSER to /home/IMUSER

The question is can /home be created during clean install process as default user personal data dir?
So that way I don't have to edit fstab because it is set in a proper manner from a start point or
it is always a postinstall case where this thread is fully applicable.
PS im greenhorn in terms of bsd sorry for noobie questions
 
The question is can /home be created during clean install process as default user personal data dir?
Choose to do the partitioning by hand and you can make it as simple or complex as you like. The "default" automatic partitioning is a good start for most people that don't know what they want. You're free to partition it in any way you like.
 
I found this tread read it 3 times already
Ok I hope I'will not pissoff some of you folks with that.
I don't want to duplicate the thread or the question.
That's why I'm digging up the thread
I get tired of people saying, this is an old thread, why are you bringing it back up, did you know this is an old thread. I know that, and I choose to continue it.
In BSD lots of stuff goes to /usr/ with /usr/home/IMUSER if created.
There is no separate /home slice , home is embedded in /usr which is simultaneously logical and makes no sense.
Its logical because there goes libs and bins and "stuff" that is used by user directly or indirectly.
It is nonsense because if my /usr slice or logical partition (whatever we chose call it) goes south then /usr/home/IMUSER data goes south with it.

This tread It is a fine recipe for moving your existing personal data from /usr/home/IMUSER to /home/IMUSER

The question is can /home be created during clean install process as default user personal data dir?
So that way I don't have to edit fstab because it is set in a proper manner from a start point or
it is always a postinstall case where this thread is fully applicable.
PS im greenhorn in terms of bsd sorry for noobie questions
I haven't successfully installed /usr/home from an install media. It definitely doesn't let you make/set the whole directory /usr/home from the option menu (that install will fail for that). It might let you partition it simply as /home, then you edit fstab afterwards to make that mount as /usr/home.

I prefer to install the user manually afterwards, because if the install fails (which is usually something that happens on a boot cd, if I get the options wrong, or if I set it up wrong when I'm learning to where I have to reinstall it), I can get it right before wasting time setting up the user, then it failing. Choose a partition to simply be /home, then use /etc/fstab to make that partition to be /usr/home, then simply use that, and copy your files there.

You're going to have to edit fstab anyway, and that's the best, and at times only way to set desired configurations. Many times, installs disks have errors that aren't debugged which show when different uncommonly used options are chosen. This applies to install mediums for varying opensource operating systems.

I like having my custom files on a separate disk. So when I install FreeBSD from CD, I can use one whole harddisk for the base install, then have my file directories on another harddisk, where I have to worry less about overwriting it.
 
This can easily be done with the installer, using manual partitioning mode as others have mentioned. Also, the installer walks you through the process of adding a user. I actually use an entire disc for my user's /home. Couldn't be easier this way. Using the installer, you can also set the file system options, like soft updates, journaling, and trim.
 
FreeBSD directory structure or bsd dir structure in general is
And in "man hier" with more details (see hier(7).

Linux structure as unix like system is almost identical its most notable / conspicuous difference is separate /home dir so any personal data are separated completely from a system (system files).
Note that neither the handbook page nor "man hier" ever mention the home directories of users.

Its logical because there goes libs and bins and "stuff" that is used by user directly or indirectly.
As is all the rest of all file systems. Take away /bin or /etc or /root, and the system will become unusable (sooner or later, in the case of /root because the administrator can no longer log in, meaning the system will rot away and fail). Everything on a Unix system exists because users (potentially) need it. So this is not an argument.

It is nonsense because if my /usr slice or logical partition (whatever we chose call it) goes south then /usr/home/IMUSER data goes south with it.
And this is also not an argument. There is no law that /usr/home has to be on the same file system as /usr, nor is there a law that /home has to be in a particular file system. If I were crazy, I could define /home/ to be a soft-link to /etc/foo or /var/bar or /tmp/blatz, and it would work (albeit it would confuse the heck out of people, and that would cause it to croak sooner).

The question is can /home be created during clean install process as default user personal data dir?
You are free to do that when you install. You are free to create new users with /home/USERID as their home directory. You are also free to leave them in /usr/home. And you can make the risk-benefit tradeoff of location, and of using a separate file system yourself. That tradeoff will depend on your use case, your disk tolerance, your administration skill, and perhaps other factors.
 
On my next install, perhaps when 12.1 has an RC released. I'm going to partition by slices: 5GB for /, >35BG for /usr, and the /home partition will be unchanged from the other disk. Then through fstab, I'll mount the existing home partition later as /usr/home.

/var will get its own slice based on a few times the current use (>20GB), but that's another topic. Swap will get under 2GB of the remainder of the primary disk: dedicated swap is also on the other disk. When there's too much swap on a disk, most doesn't get used, it gives harmless errors and it operates inefficiently.

5GB may be a little excessive for /, when other /usr directories get their own partition. 5BG is a little over the size of a DVD, and this is the number I based that on. In this case, 1 or 2GB would do, but having a relatively low amount of extra GB wouldn't hurt. Then on future installs, I may be able to leave the partitioning alone, while just installing within them.

I'm going to remove journaling and use soft updates for all or most slices/partitions. It will reduce excessive writing to disk, and improve data retention in case of crashes. When my computer crashed earlier, I kept losing whole usually open and configuration files: this problem stopped. /usr/home now has its own partition with softupdates, which should already help with preserving open files in case of crashes. I rather lose a few minutes of work, than whole files. Separate other partitions/slices under soft updates should help improve efficiency.
 
Back
Top