Anatomy of a hard drive: what really goes on inside your PC's storage

If you put everything on one partition, then the OS and home directories both have access to free space.

If you put /home on a separate partition and run out of room, you can't easily take space from the OS partition (if you use LVM, the Logical Volume Manager as offered during the installation phase of many distros, you can overcome this, as it supports partition resizing).

There are plus points to the separate-partition approach, though, especially now that SSD (solid state) drives are becoming more affordable and popular.

Because they're screamingly fast in comparison to spinning hard drives, you could put the OS files on an SSD for fast system and app startup times, and then /home on a traditional hard drive (after all, you're not too bothered how long it takes your LibreOffice documents and photos to load).

For general spinning hard-drive installations for home desktops, where you're not going to be trying a new distro every other day, though, we recommend the 'putting everything in one partition' approach.

The most important directories

Have a look in the root (/) directory, and you'll see lots of directories that may be unfamiliar to you.

You may see a lot of unfamiliar directories

>The root (/) directory might look like a jumbled mess of random words to Unix newcomers, but it actually makes sense. Everything has its own place.

While most users rarely need to venture into these directories, it's worth knowing what they do:

>/bin Binary files, or more specifically executables that are used by the base system. However, this doesn't include larger desktop applications, such as Firefox (they are kept in /usr).

>/boot Files used for booting, such as the Linux kernel.

>/dev Device nodes. Here are files which can be used to access hardware devices.

>/etc Configuration files for the system (per-user settings are stored in the /home directories).

>/media Removable media, such as USB keys, are often mounted here.

>/mnt Another place for mounting drives (rather confusingly), but usually hard drives or network shares.

/opt Optional application packages.In some distros huge beasts of software, such as KDE or LibreOffice, live here.

/proc Process information. Only really useful for admins wanting to monitor a program's resource consumption.

/sbin Critical executables for running the system, but which should only be executed by the super user (root).

/usr This contains non-critical files, such as applications. Inside is /usr/lib, which contains most of the libraries used by apps.

/var Variable files - ie, data which changes a lot, such as databases, mail spools and system logs.

Cut out and keep: sync your disk

Here's something that might surprise you: when you save a file in a program, it doesn't actually get written to the disk straightaway. At least for small files (eg, less than a megabyte), anyway.

For performance reasons, operating systems don't write data to the hard drive at every request, but wait until there's a lot of data from multiple write requests.

So, the OS stores all of these write operations in a RAM buffer and then commits them all to disk in one fell-swoop. If you've ever been unlucky enough to have a power cut a few seconds after hitting Ctrl+S in a program, for instance, you'll have seen this in action.

Fortunately, there's a solution. At any time, you can enter sync in a terminal window to guarantee that all write operations are written to the physical disk.

And then there's a special key sequence you can use if the X Window System freezes, ie the graphical layer has totally locked up, but you want to sync everything to the drives and reboot safely. It's called the Magic SysRq key, enabled in most distros, and is enabled as follows:

TOPICS