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.

In windows, we have C drives where all the softwares are installed and other partitions e.g; D, E etc to store our data. Now once we reinstall the windows for some reason, we install everything again on C and our data is kept safe and can access it without any problem.

Now in Unix type OS, each user is given a home directory (I believe Windows also has something like that) and we can only put our data in that part of the system (this is what I think). Now how can someone can get the effect of windows, where at a certain part of hard drive, a user can put his/her data and when reinstalling the Unix/Linux system, reclaim that data?

share|improve this question

4 Answers 4

You have various devices on UNIX/Linux that represent physical drives so for example on Linux:

/dev/sda  -  Would designate SCSI drive with ID of 0 or lately more commonly ID:0 on SATA.
/dev/sdb  -  Would be secondary device, etc

Linux when it installs will ask you where to install it on and you can designate /dev/sda as your OS drive and you can designate /dev/sdb as the location for /home which will be formatted and mounted if you choose it to be.

You will create partitions on the OS drive designating one for swap, /boot, / filesystems, which will basically create devices like /dev/sda1, 2, 3 which will look to your system as physical devices and they will be made accessible to the OS in forms of directories.

So in this set up /dev/sda would be Windows equivalent of C:\ drive and /dev/sdb would be the equivalent of the data drive, whatever letter designation you choose.

So if you choose to reinstall Linux all you will have to be careful of is actually not reformatting /dev/sdb or the partitions that you set up on it so that the data you have on that driver remains intact.

Now similar concept can be applied if there is only one drive on the system, but this will be a little more complex of a concept that Windows also support but most commonly not being used.

share|improve this answer
    
so when I reinstall the linux, I have to say use /dev/sdb as /home location and make sure I use the same username as I was using before? –  itsaboutcode Mar 23 '12 at 19:23
    
@itsaboutcode It's actually has to be the same userid rather then username but as root you can change ownership of files if the userid mismatches but that's a lengthy discussion all on its own. –  Karlson Mar 23 '12 at 19:34
    
is there any guide on this whole process? –  itsaboutcode Mar 23 '12 at 19:38
    
@itsaboutcode There may be a question already here on this if anyone wants to provide the link otherwise you can post it here and someone will either find it or put one together, myself included at the moment I am having difficulty finding a procedure. –  Karlson Mar 23 '12 at 19:44
2  
But C: isn't a drive, it's a filesystem on a drive — the Linux equivalent would be, e.g., /dev/sda1. The drive is /dev/sda, but DOS-based OSs have no concept of a the raw, unpartitioned drive as a device (outside of the APIs). In the BIOS ‘API’ they're numbered, not lettered. 0x80 (128) is the first hard drive in BIOS-speak. C: is the first readable filesystem on drive 0x80, and so on. Note: on post-NT Windows, things are very different under the hood. –  Alexios Mar 26 '12 at 13:54

On unix, all the files are presented under a single hierarchy. To make files on a volume (a disk or partition) accessible, the volume is mounted at a location in the file hierarchy, i.e. at a directory.

The filesystem containing operating system (or at least a key part of it) is mounted on the directory /, the root directory. This filesystem is called the root filesystem.

It is fairly common to store user data in a separate volume. This volume is mounted on /home. If you want this configuration, request a separate /home partition when you install the system (most installers make this easy).

The historical reason for the different design choice is that unix was designed with fixed disks and multiuser systems in mind, whereas Windows inherited this aspect from DOS (and before it CP/M) which ran on computers with only floppy disks. Adding or removing a disk on a unix system, or moving data around, was performed by system administrators; it would have been painful if changing the disk organization changed the paths through which the files were accessed. On a floppy-only system, it was important to know which drive your file was on, so paths like a:myfile.txt made sense.

See also What is meant by mounting a device in Linux? and What mount points exist on a typical Linux system?

share|improve this answer
    
I'm far from convinced that there is a relationship between fixed disks and the notion of mounting. The notion of a single hierarchical name space is quite unique to Unix and its descendant (and perhaps Multics which ISTR introduced the directory hierarchy, I don't know if it was unique). Other OSes I know (TOPS-10, TOPS-20, VMS) use structured names with a device designator, even when they have a notion of directory hierarchy. And Unix uses names in the directory hierarchy to refer to mountable devices (tapes and mountable hard disks). –  AProgrammer Mar 26 '12 at 14:42

I'm just adding stuff here — other people have already answered better, but I couldn't fit the additional info in comments.

You're operating under a slight (if very common) misconception which makes your life a bit harder than it should be.

‘Drive C:’ is essentially a CP/M term (CP/M was an 8-bit operating system that DOS heavily, ahem, borrowed from). In the days of floppies, ‘drive’ and ‘filesystem’ were equivalent: either your drive held a floppy disk with exactly one filesystem, or it was unformatted (or empty). Easy to make the link and think the two are synonyms.

In fact, C: is the first readable partition on the first drive. Drives D:, E:, F: etc are other filesystems on the same disk drive, or on others. An exception is made for removable devices, which you can address with special software (e.g. FORMAT, FDISK).

Raw drives weren't exposed to the user directly in DOS, and this tradition remains today. You only ever see the physical drives using special software (or if they're removable devices like DVD drives).

This drive letter → partition paradigm works as a ‘forest’ data structure. Each letter is one separate tree in a group. This is what it looks like:

  • Drive 128 (first hard drive — invisible to you)
    • Partition 1, C:
    • Files and Folders under C:\*
    • Partition 2, D:
    • Files and Folders under D:\*
  • Drive 129 (second hard drive — also invisible)
    • Partition 3, E:
    • Files and Folders under E:\*
  • Drive 2 (some sort of removable medium drive)
    • Drive letter F:
    • (if a formatted medium is in the drive) Files and Folders under F:\*

The Unix filing system operates as a single tree. One partition is the root of the tree (hence the term), and other partitions are mounted (grafted) on ‘mount points’ below that and become parts of the same filing tree. This is a simplified view of what it looks like (note the single root):

  • Root filesystem (/)
    • Shared stuff (/usr)
    • Local stuff (/usr/local)
    • Users' home directories (/usr)
    • More local stuff (/var)
    • Even more local stuff (/opt)
    • Mounted devices (/mnt — this is where removable devices would go by convention)

To answer your question: a Unix always separates programs and data (doesn't have to, but experience has shown it's a Very Good Idea, and now the directory structure is standardised). It also separates (for computers sharing an installation over the network) network-shared programs and data (under /usr) and computer*-local* programs and data (under /usr/local, /var, /opt, etc), as well as user programs and data (often under /home).

You can either choose to ignore the distinctions, or to put some (or all) of these directories in separate filesystems (think ‘drive letters’).

If you want to be able to reinstall a Unix and keep your own files, you ensure that /home is mounted as a separate filesystem (separate partition), and instruct the new OS installer not to touch that partition while installing.

We also use the same trick to make our home directories available to multiple distributions of Linux on the same computer (if, e.g., we're testing them out), or to altogether different Unices. I once ran OpenBSD, FreeBSD and Linux on the same disk, with the same /home filesystem shared between all three.

share|improve this answer

Just quickly:

Concept of "mount": http://fosswire.com/post/2007/04/unix-fundamentals-mount-points/

Linux directory (or folder) structure: http://www.thegeekstuff.com/2010/09/linux-file-system-structure/

I'm sure someone else will come up with a much better and detailed answer, but that may be of some help.

Answering your question more specifically, when you install your Linux system, you may wanna create an extra partition and mount it in the /home folder. That way, when someone writes something into the /home folder (or in any of its sub folders), it will be stored in said extra partition.

Welcome to Linux!

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.