One of the objectives of switching to linux is to have a more usable, more secure, and more robust (read "dependable") system. Protecting your data and the usability of your system is paramount to this objective.
This article is a beginner's lesson about partitioning and formating your hard drive to facilitate the protection of your data and system. Please note these same issues exist with Windows installs, just these no simple way to do this with Windows.
Possible failures or issues include:
- hardware failure of a drive
- software upgrade or install "breaking" your system
- user error causing system to be unusable or un-bootable
- a runaway or failed process filling up your hard drive
- multiple installs of operating system
- multiple hard drives
- space available for data backups and/or redundancy
What linux needs and what you need:
Linux installs can use free drive space to "swap" memory to disk if you exceed your physical memory and/or as storage for hibernation or sleep mode. The generally accepted amount is no more than double the physical memory installed in your computer. I think in some higher end desktop systems, those with 4gb or more RAM, you can safely use less or even no swap at all. Swap usually exists on it's own partition and tends to be a bit faster if it's the first partition the drive.
Rather than the Windows scheme of drive letters; Linux uses a simple subdirectory system to organize it files. Files are group by purpose into these subdirectories. One benefit to this approach is the ease in which some of these subdirectories can be relocated to a new partition, drive, or even off-system to expand your usable space without requiring a total reinstall. This system also allows you to backup your personal data or your entire install with relative ease.
Linux also allows itself to be installed and run from any partition. This feature makes backups and re-installs much easier. You may also install linux along side other linux or even a Windows install without issue - however, the details of this type of setup are not discussed here. There are dozens of web pages on how to do that.
Subdirectories addressed in this section:
/ contains the operating system install
/home contains all your personal data and settings
/tmp contains temporary files
swap as discussed above
The optimal install has two drives for redundancy, backup and speed purposes but lets address a single drive setup first since that's what most of you have. In this example I assume you have one 80gb hard drive and 1gb of RAM (an older or inexpensive computer to be sure).
Hard drives and their partitions are "named" in linux parlance by their interface type, drive letter and then finally partition number and referred to as devices. Modern and common drive interfaces are SATA, SCSI and IDE. Most modern linux distributions simplify the naming scheme somewhat by lettering all these interfaces as "s" for SCSI. Older distributions may refer to the IDE interface as "h" for "hard drive."
You may have up to four primary partitions (just like Windows), one of these may be an extended partition which holds logical partitions, and up to 63 logical partitions in your extended partition.
So, your first sata drive is "a" (usually first drive on the interface but occasionally the drive you booted to if not the first) and your primary partitions are numbered 1 through 4. Logical partitions begin at 5 and go up in number from there. Note that logical drive numbering will begin at 5, reserving 1-4 for primary partitions, regardless of how many primary partitions you have.
Since hard drives are "devices" to linux, these will be referred to as "/dev/sda1" and so on.
Most linux install programs will default to a single partition install for simplicity for the beginner. Some will ask if you want a swap partition or maybe even offer other options. Almost all offer an "Advanced" option allowing you to create your own partition setup. This is what we want to do.
On to the setup:
One 80gb drive, device names, partition numbers, their use, and their size.
Primary partitions:
/dev/sda1 partition 1 swap 2gb
/dev/sda2 partition 2 extended 78gb
Logical partitions
/dev/sda5 partition 5 /tmp 10gb
/dev/sda6 partition 6 / 8gb
/dev/sda7 partition 7 /home 26gb
/dev/sda8 partition 8 backup of /dev/sda6 8gb
/dev/sda9 partition 9 backup of /dev/sda7 26gb
By partitioning your drive this way, you can have two installed operation systems - partitions 6 and 8, all full backup of your data and settings - partitions 7 and 9, and if you fill up the /tmp directory somehow you will still be able to boot your system without issues. Note: a single drive setup cannot protect you from a hard drive crash. If you were to later add a second drive to the above setup, you could "move" the backup partitions to the new drive and have full redundancy.
Two 80gb drives, device names, partition numbers, their use, and their size.
Primary partitions drive 1:
/dev/sda1 partition 1 swap 1gb
/dev/sda2 partition 2 extended 79gb
Logical partitions
/dev/sda5 partition 5 /tmp 20gb
/dev/sda6 partition 6 / 12gb
/dev/sda7 partition 7 backup of /dev/sdb2 47gb
Primary partitions drive 2:
/dev/sdb1 partition 1 swap 1gb
/dev/sdb2 partition 2 extended 79gb
Logical partitions
/dev/sdb5 partition 5 unused 20gb
/dev/sdb5 partition 6 backup of /dev/sda6 12gb
/dev/sdb5 partition 7 /home 47gb
Notice here we moved the /home and / directories to different drives. This may result in a slight improvement in system speed during file access. Also notice we left partiton 5 on drive 2 unused. With this much space, it's unlikely you'd need this space anyway so it's saved for future expansion. You can use it to store music or downloaded files or leave it to install a new linux distro to that you want to try out before you let it take over your system. Obviously we have more space for everything here. Having multiple swap partitions will allow your system to use both drives when needed and it's a bit faster than a single swap.
Should your installed software grow beyond the 12gb allowed, shrink or repartition your /home or /tmp and allow your system to use the space for /usr/share/local or /opt to free up space on /. This is easier than it sounds and most distros have tools (partition managers) that can assist you in doing so.
No comments:
Post a Comment