Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )

Advanced DNS Management
New ZoneEdit. New Managment.


Sign Up Now
Closed TopicStart new topic
> Creating A Linux Drive, How to partition a drive for linux
post Aug 11 2004, 04:53 PM
Post #1

Its GNU/

Group: Support Specialist
Posts: 1,280
Joined: 19-November 03
From: University of Minnesota- TC
Member No.: 1,828

This guide is intended to a intro course in linux files systems and partitioning schemes

The guide is broken up into four sections
1) Linux and Windows, two different beasts -- explains the difference in linux and windows filesystems
2) Designing a Drive for you -- gives ideas for how to set up a drive for you needs
3) Partitioning Cheat Sheet -- common commands for partitions drives
4) fstab Cheat Sheet -- formating for fstab file

Linux and Windows, two different beasts
First, you need to understand the difference between how linux handles drives and how Windows handles drives. In windows each drive or partition is assigned a letter, a for floppy drive, c for your hard drive d for your CD-ROM drive and so on. Each drive has a root, or highest point, and each is isolated from each other.

Linux handles drives in a very different manner, instead of having multiple trees and assigning each a letter, linux only has one, the top of which or root is simple / everything else exists at a point at or below /. Drives are mounted to folders in the tree. Lets look at an example…

A common linux drive usually has three partitions. All linux distros have what is called “swap space,” this is virtual ram for the system to use, if you are running low on ram, the system can use this space to store stuff, obviously its slower, but not as slow as being out of ram. In addition to that, all distros have to have a root partition. That is the partition that gets mounted to / and hold the bulk of the system data. Now, that is all you need to get going, nothing more, but there are many advantages to breaking some things off.

One common trick is putting /boot on its own partition. In this situation, the system, or a user, would create a separate partition on the physical drive, than mount that partition to /boot. This means when you change directory from / to /boot you are actually changing physical partitions just like changing from c:/ to d:/ The advantage of this is mainly that you can actually not mount the partition into your file system. You don’t need anything in the boot folder ounce the system is up and running, and it can boot without it being mounted, so your kernel images and important boot data is protected from accidental, or malicious changes. If you need to edit anything, simply mount it and edit away.

This can be done with any folder, each one having its own advantages. I like to keep my /home folder on a separate partition, that way if anything goes seriously wrong, or I want to do a clean up-grade, I can re-format the system partitions, but leave all my files alone. After I have re-installed I just re-mount my old /home partition and all my files, including most of my preference files, are back again.

Like I said, you can do this with any folder /var is another good one because you can keep all your server data safe and separate.

Designing a Drive for you:

1) Swap space
First, you have to decide how much swap space to give yourself. I recommend 512 MB on average. It all depends on what your system is doing and how much physical ram you have. The general rule of thumb is twice you physical RAM. If you have a small amount of physical RAM, say 64 MB, it isn’t a good idea to have 512 MB of swap space. If you do, your system will use the swap space to often and it will end up being really slow. On the other hand, if you have 512 MB or more, you will hardly even be maxing out your ram, so dedicating a gig to the swap space is useless.

2) How are you breaking apart your drive?
First you have to decide if you are going to use separate physical partitions for different folders like boot, home or var. If you decide that you are, next you will need to decide how much.

3) How much space where?
Obviously a lot of this has to do with the original size of your drive, but there are some guide lines. Unless your doing a test machine where you are going to have lots of active kernels you don’t need more than 64 MB for your boot partition.
If you are going to keep folders like /home on separate partitions you probably don’t need more than 6 gigs for your root folder. A full install takes about 3 gigs, so 6 leaves you plenty of room to grow and not get boxed in.
If you are going to be doing hosting putting /var on a separate partition isn’t a bad idea, but how much space is up to you. If your just hosting a simple web page you wont need much, but if your hosting media content… you can see where this is going.
I like to give everything I have left to my home folder because that is where the big files are and where I need the most space.

4) A shared windows/linux drive
If you are doing a dual boot with XP putting a small fat32 partition on your drive is a good idea. That way you can share and move files with your windows drive easily. Although linux can read NTFS, Linux doesn’t have a stable NTFS writer yet. And windows doesn’t even bother with linux file systems. So if you want to be able to move files back and forth easily, a fat32 partition is a good idea, how big, is up to you.

Partitioning Cheat Sheet

Here are just a few simple linux commands for partition and formatting drives

fdisk /dev/hda – opens a program to partition a drive
fdisk commands
p – prints out current partition table
d – delete a partition
n – new partition
a – activates a partition, makes it bootable
t – change type, swap is the only one that needs to be changed, its type 82

formatting commands
mke2fs /dev/hda1 – formats hda1 to etx2 file system
mke2fs –j /dev/hda1 –formats hda1 to etx3 file system
mkswap – formats swap partition

/mnt/fstab Cheat sheet

/mnt/fstab is the file that controls where partitions are mounted. If you configure the drive during installation, most distros set the file up for you, but here is a cheat sheet if you need it.

A standard entry looks like this

/dev/hda3   /home     ext2    defaults        0 2

Each field is separated by white space, either spaces or tabs.
Field one is the partition to mount
Two is the point to mount to
Three is the file system
Four is mount options (more on this below)
Five is dump switch, generally leave it as 0
Six is the checked switch, root should have a 1 and anything else should usually have a 2.

Common mount options
defaults – obviously default
noauto -- the system doesn’t automatically mount it at boot
noatime – stops system from recording access times, improves speed and is generally a good idea
users – allows users to mount the partition
umask=000 –will allow all users access to all files

I hope this guide has helped out a little, if you have any questions don’t hesitate to use the forums to ask questions. If you see a problem with this guide please PM me or e-mail me.

--Jim Lester

Distro: Gentoo
System: AMD Athlon 3000+ XP 2.166 GHz
NVIDIA nForce2 IGP Chipset
NVIDIA nForce2 Dual Head 64 MB Graphics

Server Distro: CentOS
Go to the top of the page
+Quote Post

Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:


RSS Lo-Fi Version Time is now: 17th October 2017 - 12:09 PM