Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I usually install Linux on a single partition since I only use it as a personal desktop.

However every now and then I reinstall the box and what I simply do is to move my files around with an external hard disk.

So, how could I prevent that when reinstalling my box (e.g. switching to another distro)?

share|improve this question

6 Answers 6

up vote 20 down vote accepted

Keep your /home on a separate partition. This way, it will not be overwritten when you switch to another distro or upgrade your current one. It's also a good idea to have your swap on its own partition. But that should be done automatically by your distro's installer.

The way my laptop is setup, I have the following partitions:

/ 
/home 
/boot 
swap 
share|improve this answer
3  
+1 on the swap partition. Actually, the theory behind swap and boot being separate is that if you make those partitions close to the zero cylinder, they'll be on the disk tracks closest to the spindle, and will be slightly faster on disk seeks. So having your page file space and your boot loader closest to center can mean performance increases. Unless you're using solid-state, then never mind. –  Milner Aug 10 '10 at 19:53
1  
+1 separate /home. You can encrypt all your personal files (entire /home partition), and not unnecessarily slowing down access to non-private system files and libraries. –  Alex B Aug 11 '10 at 4:54
2  
You have a swap*file* on a separate partition?? Don't you mean you have a swap*partition*? –  wzzrd Aug 16 '10 at 11:54
1  
/swp ? A swap partition is not mounted anywhere, so your answer is somewhat misleading. –  Denilson Sá Aug 17 '10 at 23:49
2  
I think you should just write swap instead of /swp in order to prevent any confusions as others have already mentioned. –  Cristian Ciupitu Aug 31 '10 at 1:07

Rather than relying just on partitions, under Linux I usually recommend using LVM. This allows you to grown and shrink filesystems as needed later (though growing tends to be easier than shrinking), even wile the file system is active in the case of ext2/3/4 (I've successfully increased the size of filesystems while they were active, though I've never tried to decrease the size of one this way).

Obviously this still leaves you to decide how to apportion the space, but you don't have to get it exactly right from the get go because rearranging things later is easier. I usually give each volume as much space as I think it will need plus a chunk for good luck, and leave the remaining space for adding new filesystems or expanding existing ones into later.

share|improve this answer
    
Even if you use LVM, you still have to decide what logical volumes (LVs) to create. As a side note I still remember the disappointment I had last year when I discovered that the desktop Ubuntu installer didn't have support for LVM. –  Cristian Ciupitu Aug 31 '10 at 1:11
    
Yes the default Ubuntu installer is a pain in this regard, but you can get a LVM and/ro RAID setup out of the alternate (text based) installer. And while you still have to make some choices to start with when using LVM, changing you mind later and shuffing space allocations and/or creating new volumes is easier. –  David Spillett Sep 2 '10 at 20:25

The minimum setup should have / and /home in separate partitions. / should have at least 18GB, in my experience. I usually have a third partition called /code where I keep all my work code, and use /home for downloads, documents and other non-code related things. When I reinstall, I just backup whatever I have in /home that I want to keep to /code.

share|improve this answer
    
why so much? I have a 10G / and 2.8G to spare. But I suppose it can be so small because I have a 10G /var and a 1G /tmp –  xenoterracide Aug 10 '10 at 20:28
1  
I always have at least 14G used on / alone. It's a consequence of instaling a lot of -devel and -debug packages, basically. My /var is taking only 1.2G out of that, and /tmp takes up a few measly 100Mb. With hard drive sizes these days, no use restricting the size of /,you never know when you suddenly need to install something big. –  Andreia Gaita Aug 18 '10 at 16:36

No one seems to have mentioned /usr/local. I often make this a separate partition. If you're in the habit of installing software compiled from source or other 3rd party software that isn't part of your distro, having it in /usr/local means two things:

  1. You can share /usr/local over nfs and have "installed once, installed everywhere" functionality if you have more than one system with the same OS version
  2. You can keep this partition across re-installs and then you don't need to re-install everything here. Note: when you upgrade the OS some of your libraries may change and you might have to recompile some things. But not always.

Besides /usr/local I also keep a separate /home for obvious reasons and a separate /Files which is where I put stuff that is meant to be "shared", such as the family MP3 and video collection. Depending on your usage /home might be a better place for your music, but if it's in a separate partition it's easy to have it on a separate hard disk even if you don't use LVM.

share|improve this answer

Depends on the usage, and the OS really.

On my main desktop I have the space split between / and another partition I keep my documents/music etc. Since /home will have user configuration and stuff in there I wouldn't keep it intact between installs, just symlink my document/music folders into my homedir.

share|improve this answer
    
But user configuration (and thus home) should stay around between installs. Or do you reconfigure everything after a OS install? Some of my files (.emacs, .cshrc) have bits that have been around for 15 years. –  KeithB Aug 10 '10 at 20:14

There are a number of guides that can help with this, and as theotherreceive pointed out, it can be OS specific. What Solaris suggests may not be what Ubuntu suggests. For instance, Solaris (and maybe HP-UX) use /export/home as the mount point for home dirs, Linux uses /home.

There's no real magic to it, in fact what I'd say is you've hit the nail on the head. One partition doesn't cut it for your needs. So make a change. Use the guides as an example (you can even learn why /etc is /etc and other neat trivia with the right document). Here's an example (pulled at random from a Google search):

http://content.hccfl.edu/pollock/aunix1/partitioning.htm

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.