Whats the Difference between a file system and a partition in Ubuntu?
February 25, 2009 12:58 AM   Subscribe

Whats the Difference between a file system and a partition in Ubuntu?

I've recently migrated to Ubuntu from windows, but I still can't understand how the whole file structure works. What folder contains the actual ubuntu OS installation? What is a Grub? I've made a 2 partitions on my HD i think and I want to have my /home/ folder in one and all my other files in the other. But I only see one of the 23gig partitions, the rest of the HD space seems to be taken up by another folder called "file System" I assume this is where Ubuntu is installed.

I'm so confused, can anyone help explain it to someone with a mind still in windows mode?
posted by complience to Technology (13 answers total) 3 users marked this as a favorite
A partition is a logical part of the disk (think of a cake as the entire disk, a slice of that cake would be a partition)

A filesystem is a method of storing / finding files on a hard disk (its on top of the cake so would be icing)

It sounds like you a / (root) folder which has all the important OS stuff on it and /home which is your stuff. Linux uses a tree like structure starting a the / (root) and branching off. Ignore any windows based knowledge you are using in terms of this its set out totally differnently

GRUB is the small bit of software that sits at the start of the hard disk that is a link between the BIOS telling the system "use this hard disk" and then being able to start the Linux core (kernel).
posted by rus at 1:03 AM on February 25, 2009

Partitions in Ubuntu (and Linux in general) aren't like Windows partitions in that you don't have drive letters for them. Everything (boot partition, other partitions, external drives etc.) appear within a single filesystem. There is no single folder for system files; they're in a collection of folders off the root of the boot partition.

Your second partition (currently empty I would guess) will need to be mounted before you can use it. Essentinally this means telling Ubuntu to make this drive available as a folder within the filesystem. It's common to mount the partition as a directory under /media. So you counld mount your second partition as /media/home/ for example. There's some information on how to set up partitions to mount automatically here.
posted by le morte de bea arthur at 1:56 AM on February 25, 2009

Oh, and GRUB is just a boot loader; it allows you to have more than one operating system. Don't worry about it.
posted by le morte de bea arthur at 1:58 AM on February 25, 2009

Typically, your boot loader is in the first 512 bytes of your hard disk, the first 'block'. It's magic code that your PC will load the first 512k block and execute it and there's supposed to be enough there to load and boot your system. (usually it's actually the first track on your disk). That first block (512k) contains enough information about loading stuff and the layout of your disks to make things work.

A partition is a space on your disk. It can be MS-DOS, or NTFS, or EXT-3 or any other various filesystem. A partition is (block 200 - 4000), what filesystem you put on those blocks is a different matter

A partition is your disk has 10,000 blocks, block 0 is the boot block (can be changed, but the first 512k block on your disk is important and defines everything else). Partition 1 gets defined as blocks 1-500, partition 2 gets defined at blocks 501-600, partition 3 is blocks 601-9,999.

Your computer magically loads the first block of the disk, and executes the code there... (it's like built in to the computer to load the first block and run it). Usually the first block (512k) is code that lets you choose which partition you want to boot from. Under multiple OS installations, some of your partitions will have the first 'block of 512k' dedicated to loading the OS and getting things started.

I have 10 partitions...
# fdisk -l

Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x41ab2316

Device Boot Start End Blocks Id System
/dev/sda1 1 11 88326 de Dell Utility
/dev/sda2 * 12 2561 20482875 7 HPFS/NTFS
/dev/sda3 2562 2574 104422+ 83 Linux
/dev/sda4 2575 14593 96542617+ 5 Extended
/dev/sda5 2575 2697 987966 83 Linux
/dev/sda6 2698 3914 9775521 83 Linux
/dev/sda7 3915 5131 9775521 83 Linux
/dev/sda8 5132 6348 9775521 83 Linux
/dev/sda9 6349 6714 2939863+ 83 Linux
/dev/sda10 6715 11578 39070048+ 83 Linux

sda2 is marked as the boot partition, it has grub on it that defaults to mounting /dev/sda3 as root...

# mount
/dev/sda5 on / type ext3 (rw,noatime)
/dev/sda6 on /usr type ext3 (rw,noatime)
/dev/sda7 on /var type ext3 (rw,noatime)
/dev/sda8 on /home type ext3 (rw,noatime)
/dev/sda10 on /mnt/music type ext3 (rw,noatime)
(misc. deleted)

so i have like 10 partitions. sda1 is the stuff that came with my computer for testing. sda2 is my original windows installation. sda3 is my boot partition not usually mounted. sda4 is extending (original specs only allow 4 partitions, anything beyond uses one partition and makes it expanded). sda5 is '/', sda6 is '/usr', sda7 is '/var', sda8 is '/home', sda9 is swap space, sda10 is my large storage for music and movies.

So like the 'no drive letters'...
/usr is sda6 partition
/var is sda7 partition
/home is sda8 partition
everything ends up under '/'
posted by zengargoyle at 4:11 AM on February 25, 2009

The big "file System" folder seems odd to me. How large is the whole drive, 46 GB?

As others have said, a partition is a physical slice of the disk. Unlike Windows, which uses letters for drives (and network drives, etc.), Unix (including Ubuntu) just has everything spanning off of "/". The root partition stores the files in / , probably /etc , and any other directories that aren't on another partition (it sounds like /home is; /var, /tmp, and /usr commonly are as well). Where another filesystem has attached is called the "mount point" -- if you load a CD, it would probably mount somewhere like /cdrom, /mnt/cdrom, etc. (This varies from distro to distro.) I have a partition for backup stuff under /bak, but there's no reason it couldn't be mounted under /home/scott/bak. So, the / folder probably has several partitions under it.

A file system defines the way files are organized on disk, and the process for putting them there. (It's the database of files, so to speak.) Linux generally uses e.g. EXT2 and EXT3, but can also load NTFS (to read Windows filesystems), among others. Besides OS associations, file systems have different logging & cacheing mechanisms, and otherwise have slightly different efficiency tuning.

If you type "df" in the shell, it will tell you which file systems you have mounted, where, how big they are, how much space free, etc. There's probably an option to use "human-readable" numbers (e.g. "241M", not 493388 (blocks)); it's "-h" on OpenBSD, but you'll probably need to run "man df" and skim to figure out what it is on Ubuntu.

Other things that might help as search terms:
/etc/fstab - the file where mount points, etc. are defined (fstab -> "FileSystem TABle", I think)
mount / umount - the commands to load/unload filesystems
posted by silentbicycle at 4:20 AM on February 25, 2009

Unix users make a distinction: a filesystem is the programmatic scheme used to organize and find files on a partition, while the file system refers to all the files on your computer--which, as mentioned above, start at the "root" which is represented by /. So, you may have two partitions, one with an EXT3 filesystem and the other with an NTFS (windows) filesystem, but they're going to both be linked (mounted) into the filesystem at some path from /.

In the case of a pretty standard setup, you'd have one partition that's mounted as /. It's going to have /boot, /root, /etc, /bin, /usr, /lib, /dev, /proc, /var, and a couple other ones I forget. Then, you'll have another partition that's used as /home--it won't appear anywhere else, it'll just be seamlessly mounted into that location on the filesystem. All of the mount locations (along with other mount-time options) are managed in a file called /etc/mtab. The first two entries in each line are the real device/partition and the logical mount point.

So, my mtab has a couple of entries that look like: "/dev/sda2 / [buncha junk]" and "/dev/sda3 /home [buncha junk]". This means that "Serial Disk A, Parition 2" is mounted at /, and "Serial Disk A, Parition 3" is mounted at /home. If I comment out (or delete) the second line, /home shows up, but is a totally empty directory. This is because to mount a partition, you make a directory on the filesystem and then mount the partition to that directory.

The big "file system" folder in Ubuntu is coming from the graphical file browser, not from the underlying system. It's just an indication that it's the public, shared space where all of the system lives, as opposed to your user's personal, private stuff which is where all your own files live. That is, the file browser makes an assumption that most of what you're interested in lives in your own user folder (which is found at the path /home/complience) and so shows it as somehow separate from the rest of the filesystem. The truth is that your user folder is logically subordinate to the root filesystem, not apart from it.

Spare disks, assuming that they have a filesystem Ubuntu can read, usually get mounted in /media. /mnt is the historical location for everthing that gets mounted but isn't a logical part of the root filesystem. But, Ubuntu has gone with /media for stuff that users should have basically unfettered access to. However, I don't recall whether or not a spare partition on the boot drive gets mounted automatically, or if it's only removable media.
posted by Netzapper at 6:23 AM on February 25, 2009

Oh, hell... I screwed up. It's not /etc/mtab. It's /etc/fstab. I'm a dumbass (and it's real late, but that's not an excuse, only an explanation).

mtab lists the currently mounted partitions, and changes as you mount and unmount things. fstab lists the partitions that you would like to have mounted (either at boot, automatically, or on demand). fstab also has a slightly more annoying format in Ubuntu, making use of UUIDs instead of device/partition numbers. The format that mtab uses is what most people think about... the automatically-generated UUID approach just keeps your computer booting, even if you swap around some drives in the machine.
posted by Netzapper at 6:28 AM on February 25, 2009

To add to what everyone else said, if you're using regular Ubuntu (GNOME), follow these two guidelines to have a solid start for file organization:
1. Until you're really used to things, only install programs through synaptic or aptitude. This way, you won't have to worry about where to put .debs, etc.
2. Use the folders within your home folder (Music, Documents, Pictures, Videos) to organize the rest of your files accordingly. There's really no reason to go against the grain and not use these folders.
posted by PhoBWanKenobi at 7:22 AM on February 25, 2009

if you're still confused, run these two commands in the terminal and give us the output and we can explain what you're seeing:

df -h
fdisk -l

the first one shows us what disks are used by what file systems, and their size, and the second one lists the physical disks and their partitions.
posted by jrishel at 7:25 AM on February 25, 2009

OK. Start by ignoring the physical construction of the drive- that's an abstraction. (More specifically, the rest of this is an abstraction OF the physical construction of the drive.) You probably can't know how the drive is arranged inside. Is it one platter? Three? How many sides? So any talk of the edge of the disk or the inside of the disk is functionally irrelevant.

Now, the hard drive, logically, is a piece of tape. Start at the beginning, start reading bytes until you hit the end. Further, this tape is addressable. Your computer can send a command to the drive that says "please go to section 3435 and tell me whats there". (In the old school world, this was done by specifying a physical head, cylinder and sector. It is done slightly differently now, but the function is the same.)

Picture your hard drive as one of those giant cubbyhole mailbox things they have in offices. You can't change the cubby holes, they are built that way. Further, the cubbies are only numbered seqentially and you can't change that either. (It's a very logical office.) Cubby hole zero has a piece of paper in it that says "cubbies 1 through 10 are for the accounting department, 11-25 are purchasing and 26-30 are sales." That's the partition table.

Each department has their own system for ordering files. That's the filesystem. Each department even has pet names for the sections in the cubbies. Accounting might call them A: B: and C:. Purchasing might call them /dev/sda1 /dev/sda2 and /dev/sda3. That doesn't change what's in the cubbies, that's just the names for them. The table in cubby zero is still the same.

If you reorganize (repartition), you either have to take all the papers out and start from scratch, or you have to carefully shift them around so that you don't mess up the order they are in. You don't know how the other departments have their shit set up. You just have to make sure that when they come in and look at that partition table and see that their area starts at cubby x, all their data is in the same order as it was before. That's why "live" repartitioning is risky- if you screw something up, the papers get in the wrong order and Jenkins from accounting starts screaming at you.

*nix is slightly confusing in that they use "filesystem" to mean two things. Filesystem generically is how data is ordered and accessed on the storage medium. *nix also uses it to name how data is presented by the OS. So *nix has a filesystem of filesystems. Further confusing, but ultimately quite logical, is that its slightly recursive. That's why the Windows drive letter stuff is easier. The data on drive /dev/sda1 is "mounted" at / So you start at / navigate to /dev and then /dev/sda1 and you can see the raw data that you are already in. I like to think of the *nix / filesystem as the "tree" onto which filesystems are mounted, just like the "my computer" tree in Windows. Understanding the difference between the virtual tree the data is presented as versus the actual locations of the stuff took me a long time to get straight in my head.

Think of the computer at its very basic level. Bytes come from an input --> get processed --> are output in some other way. The operating system is really just a giant application that helps you make sense out of it all. So the operating system fires itself up, reads various files and memory locations and figures out where all of the input output locations are, and presents all of this to you as "the filesystem". That filesystem comprises both the raw IO devices, like /dev and /proc AND a translated picture of that stuff in a usable manner, all overlayed ontop of itself. The "root" filesystem or "/" is the translated contents of the root partition on the drive. If you mounted the hard drive from one OS to another, you'd see these places, but nothing inside some of them. That's because when the operating system application starts up, it overlays stuff onto its own "places".

I found it easier to figure out if I thought of it like this: think of the operating system as a separate thing. You stick a Linux floppy in the drive. All it contains is the operating system application, a "map" of the computer environment, which it calls the filesystem, and a few files that tell it how to configure itself (fstab). That map has / /boot /etc /var /dev and the rest. But there is nothing in those places- just the map. As the operating system starts up, it reads fstab, and starts taking all the raw devices in the computer and attaching or mounting them onto that map. It sees that you have hard drives and serial ports, and mounts them on the /dev folder. It sees its own memory and environment locations, and loads that onto /proc. Next, it reads fstab and sees that you want to take the raw data on /dev/sda2 and "display" it as files and folders mounted on /home. And maybe you have a second hard drive, and you want to see its contents on /pub. Further, it sees that on /dev/sda1, you have data that you want those presented on the computer as /etc /bin /sbin /var /root. It "mounts" them on to those virtual spots on the map and it translates the raw data on the drives so you can use the data. Once it does all that, it starts loading other programs into memory that provide various translation services for the raw data on the devices to information you can use.

(In practice, this doesn't happen in quite this order. And instead of having a separate startup disk, this map and setup files are on the same drive that later gets mounted as /)

So, you could have a simple system that has the map AND your data all in one big partition which would be /. Or you can get complicated, like *nix likes to do, and separate all that stuff out to different partitions, or virtual drives.

See? Easy. Ugh...
posted by gjc at 8:06 AM on February 25, 2009 [1 favorite]

A hopefully windows-user-oriented explanation:

Linux uses a bunch of subfolders in the root ("/") directory. In windows, if you wanted to have multiple hard drives, you just have two hard drives and put different folder in each. In linux, you always have the same folders, but you can tell the computer "put the /home folder on a different hard drive (or a different partition of the same hard drive)". In principle, you can put every single subfolder on a different hard drive, and it will work just fine (in practice, usually /home is the one that most people put elsewhere, so that if they bork the OS they won't lose any data).

If it's set up correctly, it's something you'll never notice as the end-user: when you put files in your /home directory or its subfolders, they'll just automatically go to one hard drive, when you install programs, they'll automatically go onto the other (or partitions, in your case).

In practice, the /home folder will always exist whether you've set it up correctly or not, but it might write to the same partition as all the system files, which is not what you want. There are various GUI programs that will work, but you can use the "df" command in a terminal window (mentioned above). That will get you a list on the left of each hard drive or partition (in the form "/dev/sda1" where the last letter is the drive number, and the number is the partition number). On the right, it will have a "Mounted on" listing, which tells you which folder the partition is associated with. What you should see is something like:

Filesystem Mounted on
/dev/sda1 /
/dev/sda2 /home

Which says that partition one of disk a is the root directory (i.e., where everything goes unless specifically told to go elsewhere, while partition two of disk a is /home, so everything put in /home or its subfolders will go to the second partition.
posted by Dr.Enormous at 8:22 AM on February 25, 2009

In DOS (and Windows) every partition has a name to prefix all the files on it. C:\WINDOWS\system32\cmd.exe, explicitly referred to a partition, directory, subdirectory and file name. UNIX has a unified file name space. There is a single root folder ( "/"), and file systems can be grafted on at any point.

In the Windows world, splitting out an install across multiple partitions or disks is maddening. Even after you decide all program files will be stored on D:\Program Files, they'll still default to C:\Program Files in the launchers, look for other programs there etc. In Linux you just configure it to mount the drive to /Program Files and none of the programs concern themselves with which drive letter prefix is appropriate.

So, an Ubuntu OS install lies in "/", because everything is in "/" somewhere. If you see "/etc", "/bin", "/home" and so on, that's a root directory you're probably looking at. GNOME's GUI file manager stupidly calls it "filesystem". I can't think of a better name; perhaps this is a Gordian knot that should be cut. What you'll do is move the contents of /home to the empty partition, edit /etc/fstab (is there a GUI for this yet?), and never think about it again.
posted by pwnguin at 6:39 PM on February 25, 2009

And GRUB is the short for "GRand Unified Bootloader", a boot loader. The windows equivalent is NTLDR, but I imagine someone who doesn't grasp partitions versus filesystems had a superb grasp of Windows internals either. Grub comes into the picture because of the fstab problem. You have a record of which disks go where... on disk.

Grub has to be configured to break that loop by being told which partition is the the root partition. Ubuntu should have set this up already for you. Of course, it's been a while since I did an Ubuntu install; it's possible there's some flaw related to your extra partition intended for /home that needs to be fixed. In general, if you can boot up fine don't touch grub.
posted by pwnguin at 6:47 PM on February 25, 2009

« Older What branch of biology studies the environment to...   |   Diagnosing a faulty hard drive Newer »
This thread is closed to new comments.