LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Reusing /home partition (https://www.linuxquestions.org/questions/linux-general-1/reusing-home-partition-642116/)

JMJ_coder 05-14-2008 08:11 AM

Reusing /home partition
 
Hello,

During the installation process for Unix/Linux systems, you can partition the hard disk to have a separate /home. So the disk might look something like this:

Code:

/    - hda0 - 50 MB
swap  - hda1 -  2 MB
/home - hda2 - 10 MB

The general premise of this structure is that if you need, for whatever reason, to reinstall the system, you can reuse your /home partition and preserve your own data.



My question is, how do you do this? Assuming you have the drive partitioned as above and you are reinstalling the system - how do you install the system without it re-formatting your /home partition?

MS3FGX 05-14-2008 08:26 AM

The installer should give you the option to mount other partitions to various parts of the filesystem, in which case you tell it to mount that partition as the new /home but don't format it.

Alternately, you could tell the installer nothing about that partition so that it installs everything to the first partition, and then manually set up /home on the other partition after the system is installed.

b0uncer 05-14-2008 08:41 AM

Just like MS3FGX described. I'll add to it only that even though the installation programs may differ in their outlook, they all (if they do allow you to do manual partition, which all should) provide you with two things to do in the "partitioning step": first create the partitions to use, then map the partitions to mount points. Sometimes partitioning is done first and "marking partitions to mountpoints" later (Slackware setup, for example), sometimes they are done in the same place (Ubuntu alternate disc setup, for example).

Slackware for example asks you to partition your disk prior to running the setup program, using fdisk or cfdisk, and this step you do as you'd usually do, but just leave the partition where your /home used to be, intact. Then you proceed to setup and set up swap, then set up root partition and then set the partition that contains home directories to be mounted under /home - Slackware's setup says at this point something like "select any extra partitions you want to use and choose their mountpoints". Simply set it to be mounted under /home then, and the setup does as wanted. The partition won't get formatted, because you didn't format it prior to setup, and when setup asks, you say "no thanks, don't format".

Or if the partitioning tool has something like one window for selecting the filesystem for a given partition and the other options including mount point, you fill the information as needed (but don't change filesystem - that forces you to format the partition) and make sure the box "format partition" is not checked. And continue.

The same applies to other mount points than home as well; they are simply partitions that contain a filesystem and data, and the setup wants to know where (in the filesystem tree) you want to mount them and possibly if you'd like to format them to use some filesystem, which is not necessary. It's just the same if you would do it after the setup yourself, add entries to /etc/fstab, but easier during the setup..and if you start thinking about it, you could mount the home partition as /stuff, then set the necessary configurations (like $HOME variable and such) to point there and you could have your "home" called "stuff" instead, and it would probably work - unless some programs have hard-wired path for /home, which they shouldn't have. I think only root partition must be selected (and set a mount point of /) during setup, so the system knows where root is, but the rest are up to you to add.

Don't forget to reuse swap partition either, if you want. It's small compared to nowadays' disk spaces, but reusing is always saving space.

salasi 05-14-2008 12:57 PM

Code:

/    - hda0 - 50 MB
swap  - hda1 -  2 MB
/home - hda2 - 10 MB

It might look something very like that, but with the 'M' replaced by a 'G'?

The previous answers were correct, but I'd just like to add one thing: remember that the Unix-y way of doing things stores the configuration files for the various programs that you use in the home directory as hidden files (files whose name starts with a '.'). The potential issue here is that if you are upgrading from one verion to another of your distro, or, more likely, if you are distro hopping, there is an issue whether these configuration files should be stored or blown away and a fresh set installed.

I'm not sure that there is an 'algorithmic solution' that is guaranteed to always work, but if you have difficulties with a certain app after the process, you might try blowing away the old config file manually and re-installing.


All times are GMT -5. The time now is 10:55 AM.