Tuesday, June 21, 2011

Cool Shit I've Done with Linux 1

Whenever someone's computer crashes, I can barely contain the "If it had been Linux!" fits. Fact is, Linux allows you to do any number of things to protect yourself from software failures, hardware failures, and user error. I guess I'll start by explaining some of that first.

The first and simplest thing you can do to prepare for Windows breaking (aside from backing up) is to keep a linux live disc around. Maybe just download an Ubuntu install CD and never actually install it. If Windows breaks, you can use it to sift through the rubble before rebuilding. Just because you deleted Win32 doesn't mean anything's happened to your vids, pics, and docs.

Onto techniques for if you're actually using Linux...

Partitioning! One of the coolest fucking things. Basically the act of splitting your hard drive into sections and saying, "This is for this, and this is for this." Software sees these partitions as completely separate drives. Now, the basic idea to protect your shit from a broken operating system, is to put your /home directory on it's own partition. Gets kind of complicated...

Unix systems use a filesystem heirarchy standard that basically dictates how the system should be arranged. You have the top directory, called / (pronounced root). This is basically C: on windows. Everything goes in here. Under /, there is a directory called home, which contains the various users' home folders. All your personal shit goes in there, including most configuration files for programs, and usually media, etc. So, /home/user is just about the same as C:\\Users\user (or whatever it is).

So, what you want to do is put the usual contents of / (or C:)on one partition and the contents of /home (or C:\\Users) on another, so that when the OS breaks, you can just reinstall to the same partition, and all the users' stuff is completely untouched. All you have to do is recreate the users with the same names (probably just your own).

This is usually given as an option at install. In the widely used Debian installer simply tell it where you want your partitions, how big you want them, and what you want them to be used for. This is also how you get a system with multiple operating systems. You just make sure it will NOT format the partitions that have the data you want to keep.

When making partitions, I'd say allot 10GB for / at the beginning of the disk (or empty space thereon), and something like twice your ram in a swap partition at the end of the disk, then fill in what's left between with the /home. Don't worry, the options are there and will make sense when you're looking at it. The swap partition is used when your RAM is full, and that size is some general rule of thumb I read, but I honestly don't think I've ever filled my 2GB of RAM.

There! That's the basic scheme! Separate / and /home partitions.

Now! I find the /home partition tends to get quite cluttered with configuration files, and it can be frustrating when some fucked up setting has caused you to reinstall in desparation, but which still persists because it's in some config file in your home directory. So, from here on, I plan on just keeping my /home directory in the same partition as my / directory and using the majority of the disk as a large storage partition.

I think I'll just use my own example for this part.

Currently, on my laptop I have a fairly simple partition scheme. I have a 10GB Ubuntu partition, a 5GB Arch partition, a large chunk that is the Ubuntu /home directory, but which I'm working on changing to storage. (No Ubuntu link, cuz their site and documentation are shit!)

To change that into a storage partition, I simply put the entire Arch install on one partition. The home folder contains nothing but config files, a couple screenshots I happened to take, and a directory for temporarily keeping files for things I build to install using the tools and systems of Arch linux (dun worry about that).

Mountpoints! These are basically the second key component to my little scheme here. Mountpoints are just directories where storage devices are mounted in order to be accessible to your OS. I can't explain everything behind it but that's what it do. To learn how to actually do this, look up a tutorial. I'm just going to explain what you can do and why it's so freakin' cool!

So basically, I edit the right files in the right way to make the system mount the large storage partition on my internal drive to the mount point /home/username/internal. Now, whenever I turn my computer on and boot Arch linux, I can just go to /home/username/internal and see what's there. Usually the default is to start in your home folder, so all I have to do is click or type my way into internal and get what I want. It's super convenient.

The typical way of mounting things like external USB drives is to put the mount point in the /media directory, but it's an internal disk, it will always be there, and I'm the only user, so this is a thousand times more convenient. I also did this with my large external drive. Though it uses a USB connection, I hardly move any of my computer stuff here in the dorm. So for that and the same reasons as above, I just mount it to a mount point in my home directory at boot.

So, using this scheme, I have the entire operating system in one partition of my hard drive. Within it is my home folder, which is tiny, but which contains what are essentially "links" to larger partitions. They're not there, they just lead there, but as far as user experience goes, they might as well be there.

In addition to convenience, if you combine something like this with occasional or scheduled backups of your most important config files (or stuff like chat logs and your firefox profile) to one of the other drives (physically separate is safest), if the OS breaks, all your shit is safe.

Oh, and a note on / partition size. My Ubuntu is 10GB, and I've installed a bunch of crap, both of the largest desktop environments, and I think I barely take up half of it. The Arch is a little more cramped at 5BG containing the home directory as well. I wish I'd made it 10GB. But I plan to reinstall the Ubuntu sometime and free the large partition from it's dedication as a /home, so I may be shifting everything around...

No comments:

Post a Comment