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
Latest in Storage & Backup
SAMSUNG T7 Portable SSD in gray on magenta pink background with price cut text on it
This spacious 2TB Samsung Portable SSD drops to its lowest price in over a year
SanDisk portable SSD on a blue background
Get a 2TB portable SSD for less than $0.07 per GB in this limited-time deal at Amazon
An Orico O7000 SSD on a table with its retail packaging
Orico O7000 SSD review: high-end PCIe 4.0 storage without the frills
A PC Gamer looking happy sat in front of their desktop monitor
Looking at buying an SSD? Hold fire for now – prices are predicted to drop (and on top of that, Black Friday is on the horizon)
External hard drive
How to fix an external hard drive that's not showing up
Staples Task Chair in a home office
This budget office chair gets a massive discount, dropping below $50
Latest in News
Helly and Mark standing on an artificial hill surrounded by goats in Severance season 2 episode 3
New Apple teaser for Severance season 2 finale suggests we might finally find out what Lumon is doing with those goats, and I don't think it's anything good
Marvel Rivals
Marvel Rivals' next update will add two new hero skins for Iron Man and Spider-Man mains this week
Nvidia Isaac GROOT N1
“The age of generalist robotics is here" - Nvidia's latest GROOT AI model just took us another step closer to fully humanoid robots
Lego Pokemon
Pokemon and Lego announce the most electrifying collaboration of all time and I’m going to be first in line
Apple Watch app health
Apple Watch blood pressure monitoring tech revealed in patent
Using Zipped files and folders in Windows 11
Hidden clues suggest Microsoft is moving another part of Windows 11’s Control Panel to the Settings app – and this time it’s mouse options