LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Linux Answers > Hardware
User Name
Password

Notices


By moses at 2004-02-23 14:25
Introduction

At some point during your first Linux installation, you may be introduced to "partitioning". This document attempts to provide the new user with the knowledge and understanding necessary to make informed choices about the partitioning of their computer hard disk. First, a brief introduction to what it means to partition a hard disk, and why you would want to do this.

What are partitions? Well, as the name suggests, a partition is a small, virtual piece of your hard disk. A partition helps to separate data from other data on your hard disk. You can think of partitions as compartments in the old cafeteria trays--there are small containers built into the tray so you can keep your mashed potatoes separate from your Jell-o, which is kept separate from your meat loaf. If you had only one compartment, your food would run
together and you probably don't like lime-flavored gravy on your mashed potatoes. If the tray didn't have any compartments (say you turned the tray over), it wouldn't be useful for holding food at all. Similarly, without any partitions, your hard disk is one lump of empty space upon which no file systems may be placed (in the simplest view). With a single partition, you
will have all of your data collect together (while it's possible to separate the data using directories, there are good reasons to make more than one partition on a hard drive). With multiple partitions, you can easily collect similar data sets into one partition, which keeps everything logically and "physically" separate.

The simplest partition scheme is just to create one partition and install everything into it. However, there are multiple reasons you probably don't want to do this for the typical install. 1) Partitions keep data separated and safe from one another in case of certain hard drive failures. 2) You should almost always have a "swap" partition (this will be explained in more detail later). 3) If some rogue program starts spitting data to /tmp, if you've got that partition separated from /, your system will not become unusable. There are more reasons, but just let it suffice to say that partitioning is a Good Thing (R)

The second simplest partition scheme is to create one large / partition and a swap partition. I promised I would talk about swap space in more detail, so here goes: Swap is what the Linux people talk about when they mean "virtual memory". That is, swap space is used as a slow extension to RAM. The reason it's needed is that most computers don't have so much RAM that all of their programs (and associated files and data) will happily fit into RAM (you could conceivably need as much RAM as hard drive space, and that's prohibitively expensive).
So, what the kernel does is take data from some unused block of RAM and write that data out to the swap space. This then frees that RAM for something that needs it right away.
Now you know why you need swap, but how much do you need? Well, that depends on what you plan to do with your computer, and how much RAM you have.
The best way of determining your swap requirements is to estimate the total required memory of all programs that you will ever run at one time (kernel, X, games, music player, etc.). If you will have multiple people using the computer at one time, it's likely that many of your programs will be loaded two or more times (though that does not necessarily double or linearly increase the RAM requirements since many of the necessary libraries are only loaded into RAM once). After calculating what you think you'll need, multiply that number by 1.25 to 2 times. This is because you forgot some program, not all programs are dynamically linked to their libraries, you didn't take in to account everyone who will be using the computer, or whatever--you don't want to have too little available memory. Now, subtract the amount of RAM you have installed on your computer. If the number you finally calculate is more than about two times (or so) that of your RAM, you should add more RAM--your
computer is going to be slow and will be swapping to disk too often.

As an example, I have a Slackware image processing station at home. Here is a partial list of the results from a "top" command when I'm not running much:
Code:
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
    1 root      16   0   480  228  456 S  0.0  0.0   0:04.75 init
    2 root      34  19     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd/0
    3 root       5 -10     0    0    0 S  0.0  0.0   0:00.06 events/0
    4 root       5 -10     0    0    0 S  0.0  0.0   0:00.01 kblockd/0
    5 root      16   0     0    0    0 S  0.0  0.0   0:00.05 khubd
    6 root      25   0     0    0    0 S  0.0  0.0   0:00.00 pdflush
    7 root      15   0     0    0    0 S  0.0  0.0   0:00.39 pdflush
    8 root      25   0     0    0    0 S  0.0  0.0   0:00.00 kswapd0
    9 root      10 -10     0    0    0 S  0.0  0.0   0:00.00 aio/0
   10 root      16   0     0    0    0 S  0.0  0.0   0:00.00 kseriod
   11 root      16   0     0    0    0 S  0.0  0.0   0:00.00 usb-storage
   12 root      15   0     0    0    0 S  0.0  0.0   0:00.00 scsi_eh_0
   13 root       5 -10     0    0    0 S  0.0  0.0   0:00.00 reiserfs/0
   17 root      18   0  1488  688 1344 S  0.0  0.1   0:00.08 devfsd
   80 root      18   0  1388  536 1336 S  0.0  0.1   0:00.00 dhcpcd
  512 rpc       16   0  1512  580 1448 S  0.0  0.1   0:00.00 rpc.portmap
  518 root      16   0  1552  616 1364 S  0.0  0.1   0:00.03 syslogd
  521 root      16   0  1484  460 1320 S  0.0  0.1   0:00.00 klogd
  523 root      18   0  1400  528 1360 S  0.0  0.1   0:00.00 inetd
  526 root      20   0  3048 1396 2792 S  0.0  0.2   0:00.20 sshd
  535 root      15   0     0    0    0 S  0.0  0.0   0:00.00 nfsd
  536 root      21   0     0    0    0 S  0.0  0.0   0:00.00 nfsd
  538 root      18   0  1504  552 1424 S  0.0  0.1   0:00.00 rpc.mountd
  541 root      21   0     0    0    0 S  0.0  0.0   0:00.00 lockd
  542 root      19   0     0    0    0 S  0.0  0.0   0:00.00 rpciod
  543 root      21   0  1516  708 1452 S  0.0  0.1   0:00.00 rpc.statd
  557 root      16   0  4788 1880 3072 S  0.0  0.2   0:00.13 cupsd
  720 root      16   0  1480  588 1436 S  0.0  0.1   0:00.00 crond
  722 daemon    16   0  1612  652 1440 S  0.0  0.1   0:00.00 atd
  726 root      19   0  1360  556 1316 S  0.0  0.1   0:00.00 acpid
  729 root      16   0  3244 1612 2756 S  0.0  0.2   0:00.01 httpd
  731 root      16   0  1412  524 1364 S  0.0  0.1   0:00.00 gpm
  906 lp        15   0  3040 1164 2724 S  0.0  0.2   0:00.15 cups-polld
  913 nobody    16   0  3260 1604 2756 S  0.0  0.2   0:00.00 httpd
  914 nobody    16   0  3260 1604 2756 S  0.0  0.2   0:00.00 httpd
  915 nobody    16   0  3260 1604 2756 S  0.0  0.2   0:00.00 httpd
  916 nobody    16   0  3260 1604 2756 S  0.0  0.2   0:00.00 httpd
  917 nobody    16   0  3260 1604 2756 S  0.0  0.2   0:00.00 httpd
  981 moses     16   0  2288 1308 2060 S  0.0  0.2   0:00.01 bash
  982 root      16   0  1356  492 1312 S  0.0  0.1   0:00.00 agetty
  983 root      16   0  1356  492 1312 S  0.0  0.1   0:00.00 agetty
  984 root      16   0  1356  492 1312 S  0.0  0.1   0:00.00 agetty
  985 root      16   0  1356  492 1312 S  0.0  0.1   0:00.00 agetty
  986 root      16   0  1356  492 1312 S  0.0  0.1   0:00.00 agetty
  998 moses     17   0  2036  988 1936 S  0.0  0.1   0:00.01 startx
  999 moses     16   0  2772  984 2520 S  0.0  0.1   0:00.00 openwin
 1015 moses     17   0  2228  636 2192 S  0.0  0.1   0:00.00 xinit
 1016 root      15   0 46536  11m  35m S  0.0  1.5   3:33.90 X
 1026 moses     15   0  3176 1628 2748 S  0.0  0.2   0:00.49 olvwm
 1041 root      16   0  6468 2904 4468 S  0.0  0.4   0:00.50 xterm
 1043 root      16   0  6424 2592 4468 S  0.0  0.3   0:00.11 xterm
 1045 moses     16   0  2088 1048 1936 S  0.0  0.1   0:00.01 run-mozilla.sh
 1059 moses     15   0 45804  27m  24m S  0.0  3.7   0:52.84 MozillaFirebird
 1060 moses     18   0  3432 1448 3280 S  0.0  0.2   0:00.01 olwmslave
 1063 moses     16   0  2280 1276 2060 S  0.0  0.2   0:00.00 bash
 1064 moses     16   0  3112 1580 2784 S  0.0  0.2   0:00.14 ssh
 1072 moses     16   0  5004 2852 3952 S  0.0  0.4   0:00.04 gconfd-2
 1135 moses     15   0  1972  880 1732 S  0.0  0.1   0:00.10 telnet
 1137 moses     17   0  1704  452 1652 S  0.0  0.1   0:00.01 esd
 1138 moses     17   0     0    0    0 Z  0.0  0.0   0:00.00 netstat <defunct>
 1140 root      15   0  6456 4200 4468 S  0.0  0.5   0:00.40 xterm
 1141 moses     15   0  2280 1312 2060 S  0.0  0.2   0:00.09 bash
 1192 root      15   0  6432 2812 4468 S  0.0  0.4   0:00.22 xterm
 1193 moses     17   0  2280 1328 2060 S  0.0  0.2   0:00.03 bash
 1299 moses     16   0  1860  896 1740 R  0.0  0.1   0:00.00 top
The column labeled, "VIRT" shows the total amount of virtual memory (in KB) used by the task. This includes swapped and resident memory used. This is the interesting column since it tells me how much total memory (swap and RAM) I'm using. With the processes above, I'm using approximately 212MB of memory. This includes memory that's "reserved" but not actively being used. I have a total of 768 MB RAM to use. This means that, with very little going on, I'm already about 1/3 of the way to needing to actually use my swap disk. Now, if I were to start doing some image viewing, the total usage jumps to 360 MB with very little effort. If I were to do some actual image processing, the usage would go well over 500MB quickly. That's small beans image processing. I've got images of Io that are well over 800 MB in size, and there are times when I need to load the entire thing in to memory in order to do matrix math on it. A single file will easily max out my RAM, but generally when I do this kind of processing, I'll need several versions of the image in memory. I have a 2GB swap partition because I can not afford more RAM right now. When I do real work, the system slows to a crawl because everything is swapping out to disk.
Now, suppose I just want to run a game of Neverwinter Nights on this system? Well, pretty much everything shown in the top above is going to be in use, but I'll also have nwn running. This adds quite a bit because, though the game executable itself is not very large, its data files are huge. We could easily run into nwn needing >128 MB memory without a blink. This would bring us up to 340 MB of memory needed. Now, take in to account that I use my home machine for work, which is the reason I've got 768 MB RAM. If you've only got 128 MB RAM, you're likely going to have problems running your games (especially if you use wine) without swap space.
You may have heard that you should make your swap partition 2x the amount of RAM you have. This is OK advice, but it doesn't really address the issue of swap, and it can be horribly inaccurate (you may only need 1.1x or 1.2x RAM, or even 0.5x RAM--it all depends on your planned usage). You can also have more than one swap partition, so if you don't
have enough swap and will add another hard drive in the future, you can just create another swap partition on that new drive.


The first thing one needs to do before even turning on their shiny new computer is decide how to partition the hard drive. Several questions need to be asked and answered (these questions are not necessarily in order of importance) before that can be done:

Part 1. Is this to be a Linux only system?
If yes, continue on with part 1. If no, jump to part 2.

What kind of system is this?[list=a][*]A file server?[*]A desktop/gaming machine?[*]A work station?[*]A web server?[*]Something else? (Note that there are many similarities between most schemes)[/list=a]


Partitioning a Linux-only System:

Decisions, Decisions, Decisions:

Disk space requirements:
Slackware 9.1: About 2-3 GB for a full install. You should figure out how much your distro of choice needs.

What Kind of Partitions:
First, some philosophy and actual requirements from the Filesystem
Hierarchy Standard:
http://www.pathname.com/fhs/pub/fhs-...#THEFILESYSTEM
Quote:

The contents of the root filesystem must be adequate to boot,
restore, recover, and/or repair the system.

* To boot a system, enough must be present on the root partition
to mount other filesystems. This includes utilities,
configuration, boot loader information, and other essential
start-up data. /usr, /opt, and /var are designed such that
they may be located on other partitions or filesystems.
* To enable recovery and/or repair of a system, those utilities
needed by an experienced maintainer to diagnose and
reconstruct a damaged system must be present on the root
filesystem.
* To restore a system, those utilities needed to restore from
system backups (on floppy, tape, etc.) must be present on the
root filesystem.

The primary concern used to balance these considerations, which favor
placing many things on the root filesystem, is the goal of keeping
root as small as reasonably possible. For several reasons, it is
desirable to keep the root filesystem small:

* It is occasionally mounted from very small media.
* The root filesystem contains many system-specific configuration
files. Possible examples include a kernel that is specific to
the system, a specific hostname, etc. This means that the root
filesystem isn't always shareable between networked systems.
Keeping it small on servers in networked systems minimizes the
amount of lost space for areas of unshareable files. It also
allows workstations with smaller local hard drives.
* While you may have the root filesystem on a large partition, and
may be able to fill it to your heart's content, there will be
people with smaller partitions. If you have more files
installed, you may find incompatibilities with other systems
using root filesystems on smaller partitions. If you are a
developer then you may be turning your assumption into a problem
for a large number of users.
* Disk errors that corrupt data on the root filesystem are a greater
problem than errors on any other partition. A small root
filesystem is less prone to corruption as the result of a system
crash.

If the distribution follows the FHS, then the following directories
will be created in your root filesystem:

Code:
        bin     Essential command binaries
        boot    Static files of the boot loader
        dev     Device files
        etc     Host-specific system configuration
        lib     Essential shared libraries and kernel modules
        media   Mount point for removeable media
        mnt     Mount point for mounting a filesystem temporarily
        opt     Add-on application software packages
        sbin    Essential system binaries
        srv     Data for services provided by this system (export is more common)
        tmp     Temporary files
        usr     Secondary hierarchy
        var     Variable data
        home    User home directories (optional)
        root    Home directory for the root user (optional)
(note that not even Slackware follows this to the letter)

The FHS requires that /usr be used for shareable, read-only data. That means that /usr should be shareable between various FHS-compliant hosts and must not be written to. Any information that is host-specific or varies with time is stored elsewhere. Unfortunately, not all developers follow this rule, so you'll likely have to make /usr into a separate partition with enough room to add data and software later.

/opt is typically used for add-on software, so should also be made into its own partition.

It's a good idea to make a small parition for /boot so that it is safe from any errors in the root filesystem, and you can share it among various installations of Linux

If you are going to have a lot of users or a lot of space used by users, it is probably a good idea to make /home its own partition as well.

If you are serving a lot of data to other computers, you'll want a separate partition for /export (or /srv). You might even consider having multiple partitions that are mounted under /export, for example,
/export/Mars_images
/export/Jupiter_images
/export/Saturn_images, etc.

OK, now that we know what our filesystem is going to look like, it's time to answer some of those questions posed above.

i) What kind of system is this?[list=a][*]A file server?
You need to provide a lot of space for those files. You probably want to store the data in the /export partition. Give yourself plenty of room, and maybe even multiple partitions under /export. A good rule is to give yourself 2-5 times as much space as you think you'll ever need. If you have multiple data sets, you should provide separate partitions for each. The same goes for an FTP-type server, you'll just need different mount points and names. . .

[*]A desktop/gaming machine?
You'll want a lot of space in /home, and it should be on its own partition. You'll probably also want to have extra space in /opt and /usr since you're likely to be adding programs in the future. You'll need to have a lot of space available for your 500+ MB games, which means you should have separate partitions for /opt and /usr, since these are the places games typically install to. Also, leave enough space on / so that you can save stuff in your home directory if it's not on its own partition. You should also look at putting a few GB into a /tmp partition. Make sure you don't forget about the swap partition!

[*]A work station?
A work station typically mounts most necessary data and filesystems from a file server, so very little disk space is really necessary for this type of machine. You should probably have a lot of swap space and a large portion of what's left in /var and /tmp, but /usr and / should not be ignored either--this is probably the most "balanced" partition scheme since no one local filesystem is more important than any other.

[*]A web server?
Where ever you decide to install your web pages, they should not be directly on the root partition. It's become accepted policy to create a new mount point under / called /www (though not officially supported by the HFS). This should be a separate partition and large enough to grow. If you are going to log transactions, make sure you have enough space to deal with possible log explosions.[/list=a]

A good rule of thumb is to provide enough space to grow in /tmp, /usr, /opt, and the partitions specific to your needs. This means that you'll usually want to make these partitions 2-5 times as large as you think you'll need (really, disk space abhors a vacuum).


Creating an Actual Partition Map:

My first example is a Slackware file server. This file server is running Slack 9.1, has an 80 GB hard drive in it, almost a GB of RAM, and the only thing it does is export a large amount of data for NFS mounting by other systems. The swap space probably doesn't need to be as big as it is, and neither does the /boot partition. However, I tend to like round numbers. . .

Plan for the Partitions:
Code:
    Name    Size      mount point

     root    2 GB      /
     usr     3 GB      /usr
     opt     2 GB      /opt
     boot    1 GB     /boot
     Cassini 35 GB     /export/Cassini
     Galileo 35 GB     /export/Galileo
     swap    2 GB      swap

     Total:  80GB
Creating the Partitions:

On Slackware, once we've booted to the command prompt with, we do the following (assuming the drive is /dev/hda) (read the man page for fdisk!):
Code:
% fdisk /dev/hda

The number of cylinders for this disk is set to 10011.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/hda: 82.3 GB, 82348277760 bytes
255 heads, 63 sectors/track, 10011 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System
Create the / partition:
Code:
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1011, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-10011, default 10011): +2000M
Create the /usr partition
Code:
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (245-10011, default 245):
Using default value 245
Last cylinder or +size or +sizeM or +sizeK (245-10011, default 10011): +3000M
Create the /opt partition
Code:
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (611-10011, default 611):
Using default value 611
Last cylinder or +size or +sizeM or +sizeK (611-10011, default 10011): +2000M
Create an extended partition so we can have more than four partitions. This will extend to the end of the disk.
Code:
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e
Selected partition 4
First cylinder (855-10011, default 855):
Using default value 855
Last cylinder or +size or +sizeM or +sizeK (855-10011, default 10011):
Using default value 10011
Create the /boot partition
Code:
Command (m for help): n
First cylinder (855-10011, default 855):
Using default value 855
Last cylinder or +size or +sizeM or +sizeK (855-10011, default 10011): +1000M
Create the Cassini partition
Code:
Command (m for help): n
First cylinder (978-10011, default 978):
Using default value 978
Last cylinder or +size or +sizeM or +sizeK (978-10011, default 10011): +35000M
Create the Galileo partition
Code:
Command (m for help): n
First cylinder (5234-10011, default 5234):
Using default value 5234
Last cylinder or +size or +sizeM or +sizeK (5234-10011, default 10011): +35000M
Create the swap partition
Code:
Command (m for help):n
First cylinder (9490-10011, default 9490):
Using default value 9490
Last cylinder or +size or +sizeM or +sizeK (9490-10011, default 10011):
Using default value 10011
Activate the first partition as bootable and print the partition table, change the swap partition type to 82 (Linux Swap).
Code:
Command (m for help): a
Partition number (1-8): 1

Command (m for help): p

Disk /dev/hda: 82.3 GB, 82348277760 bytes
255 heads, 63 sectors/track, 10011 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/hda1   *         1       244   1959898+  83  Linux
/dev/hda2           245       610   2939895   83  Linux
/dev/hda3           611       854   1959930   83  Linux
/dev/hda4           855     10011  73553602+   5  Extended
/dev/hda5           855       977    987966   83  Linux
/dev/hda6           978      5233  34186288+  83  Linux
/dev/hda7          5234      9489  34186288+  83  Linux
/dev/hda8          9490     10011   4192933+  82  Linux

Command (m for help): t
Partition number (1-8): 8
Hex code (type L to list codes): 82
Changed system type of partition 8 to 82 (Linux swap)

Command (m for help): p

Disk /dev/hda: 82.3 GB, 82348277760 bytes
255 heads, 63 sectors/track, 10011 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/hda1   *         1       244   1959898+  83  Linux
/dev/hda2           245       610   2939895   83  Linux
/dev/hda3           611       854   1959930   83  Linux
/dev/hda4           855     10011  73553602+   5  Extended
/dev/hda5           855       977    987966   83  Linux
/dev/hda6           978      5233  34186288+  83  Linux
/dev/hda7          5234      9489  34186288+  83  Linux
/dev/hda8          9490     10011   4192933+  82  Linux swap

Command (m for help): w
So, if you're satisfied, you write the partition table. If not, you re-do it to your liking. You'll then need to create filesystems and swap space. That's not really part of this document.

You shold have noticed that there are two kinds of partition terms used in fdisk. The first is a "primary" partition, and the second is an "extended" partition (under which other partitions may reside). The reason for this distiction is mostly hereditary--it's a hold-over from the DOS days when we still partitioned disks using DOS, which could only handle four partitions at one time, and instead of fixing that, MS decided to extend the partition tables and created an "extended" partition. I don't really know why Linux still uses such a terrible method, but we're currently stuck with it unless you would like to rewrite a large chunk of the filesystem code in the kernel, as well as the partitioning programs. Anyway, know that the maximum number of regular (primary or extended) partitions is 4. So, if you want to have more than four partitions, you need to have one (and can have only one) extended partition under which you have some number of logical partitions. The partition table will number the extended partition even though you need to have logical partitions within the extended in order to put filesystems onto said partitions, so be wary of, for example, /dev/hda4 in the above example, it's not actually an available partition for the user (you), it's strictly for the computer.

The next step is to choose a filesystem for each of our new partitions. The root partition should be journaled (ext3, reiserfs, etc.). The boot partition doesn't need to be journaled, nor do /opt or /usr as long as they are relatively stable. If you are going to be making a lot of changes to the /export/Galileo or /export/Cassini data, you'll need to think about which is
more important, security (journaled) or access speed (probably limited by your network more than a journal). A journaled filesystem is not going to completely protect your data, so you should consider a backup solution.


The next example is a gaming/home computer running Slackware.

80 GB disk:

Plan for the Partitions:
Code:
     Name    Size      mount point

     root    10 GB      /
     usr     35 GB      /usr
     opt     33 GB      /opt
     swap    2 GB       swap
Why so much in root? Because I don't have a separate home partition and so I want room to put data such as papers, images, save files, etc. in my home directories. You may notice that I don't have a /tmp partition either. I tend to go through and clean out /tmp about once a week, so it's not become too much of a problem, though it could be some day. Especially since it's all residing on /. Maybe I should have saved a gig or so for /tmp, and if it ever becomes a problem, I'll probably make some adjustments (or change the swap partition to /tmp and install one of these "small" 6GB disks laying around).

Follow the example above for partitioning the disk. You don't need to make an extended partition this time because you only have four partitions. Don't forget to tag your swap partition as Linux Swap (code 82 in fdisk). There is no boot partition because 1) I only have one OS on this machine; 2) I'm living on the edge w.r.t. keeping my kernel, etc. safe from problems on the root filesystem.

I use reiserfs for almost all of my filesystem needs.


Part 2. Partitioning for Linux and another OS.
This section is going to try to stay generic with regard to which other OS you are going to let reside on your computer. There will, however, be specific references to certain filesystems most commonly used today. Again, before you jump in to partitioning your hard drive, you need to ask yourself some questions. Then you need to answer them.

A. Are you installing another OS onto a system on which Linux is already installed?[list=a][*]Have you made backups of the current OS and all data of importance?
Do so.
Do it again.
I'm not kidding or trying to be funny--one backup can be lost or destroyed, and once your data's gone, it's gone.[*]Will you be adding another hard drive or[*]Shrinking the filesystems/partitions to make space for the new OS?[*]Do you have safe backups of all your important data?[*]You might be thinking to yourself, do I need so many backups?[*]You've got to ask yourself a question: Do I feel lucky?[*]Well, do ya, punk?[/list=a]

B. Is the other OS already installed on the computer?[list=a][*]Have you made backups of the current OS and all data of importance?
Do so.
Do it again.
I'm not kidding. Don't you think the cost in time and money to back up your data is worth more than the cost in time and money to get back your lost data, if it's even possible?[*]Will you be adding another hard drive[*]Or be shrinking the other filesystem/partitions when you add Linux?[*]Do you have backups?[*]You might be thinking to yourself, do I need so many backups?[*]You've got to ask yourself a question: Do I feel lucky?[*]Well, do ya, punk?[/list=a]

C. There are currently no OSs on your system, but you would like to install two, a Linux OS and some other OS (may also be Linux).

i) Installing onto a system which already contains Linux.
If you are installing an OS onto a system which already contains Linux, you have basically two options:

[list=1][*] Add another hard drive and keep the OSs on their own hard drives.
This only works if you can afford another hard drive and have space in your computer for another drive (laptops are right out). This scenario is safe and easy. For partitioning, you essentially follow the same rules described in the first part of this document. If you are installing Windows or some other non-Linux OS, the partitioning tools and schemes for those OSs are beyond the scope of this document. Since the OS is going to reside apart from Linux, it can simply be treated as though it were not even on the same computer for purposes of partitioning (dual booting, etc. require other considerations).

[*] Add the other OS to the existing drive, which is currently completely occupied by Linux.[/list=1]
This is where the "fun" and danger come in. You absolutely MUST back up everything you consider important. If you don't want to reinstall the OS, back it all up.
[list=a][*]Backup up.[*]Begin by going to the GNU parted web page. Read the documentation on what you are doing. You must read this and understand that you are putting your data at risk by changing the size of your partitions. I won't recreate the documentation here, as it's lengthy. Rest assured that it's all important.
http://www.gnu.org/software/parted/m...no/parted.html[*]Follow the examples, making sure only to modify the end of a partition, not the beginnning. Section 2.5 contains the examples that will probably interest you.[/list=a]

ii) Installing Linux on a machine which already has an OS installed.

The most common filesystem other than ext2 is probably HPFS/NTFS, now that Windows XP has gotten itself away from that mess called FAT. To modify NTFS, you should get the ntfsresize package for Linux. I don't know anything about proprietary partitioning programs, so if you choose to use one of those, you're on your own. I am not responsible for any data loss that you may experience, regardless of whether you use ntfsresize or not, but there will be no mention of how to use any other resizeing tools (although parted may be getting to the point that it can mess with NTFS and FAT filesystems too).

Ok. So, you got your shiny new laptop with Windows XP installed on it and you're afraid to remove XP completely, but you really want Linux on it too. How to partition the hard drive? Really, it's a question of how to resize the NTFS filesystem so that you can incorporate a partition scheme as discussed above.

To change the size of the NTFS, there's a wonderful site that gives you a step-by-step cookbook on how to do it. Since this document is already too long, I'll just point you to the description.
http://mlf.linux.rulez.org/mlf/ezaz/ntfsresize.html
Read the page, understand the page, get a boot disk of some sort, and resize your NTFS partition. . .

The partition scheme on my laptops is very simple. I typically have a swap partition and a root partition. I don't dual boot, so there's no pressing need for a /boot partition. The hard drives are usually small (20 GB), so there's not much use in making many partitions since one of them is likely to be too small at some point, and I cannot add another hard drive. This is dangerous since I don't have /tmp separated, nor do I have /home separate. It requires that I be much more deligent about what is put on the hard drive. It requires that I worry about backups of important data more. However, it's the compromise I've made, and I live with it.

iii) Installing Linux and some other OS (or more) on a fresh computer

This is just a simple case of deciding what you want to do with your new computer. Read the first part of this document again, decide what kind of machine this is to be, and decide how you want to set it up. If you want to have Linux and Windows, it was true in the past that you needed to have the bootable windows partition be the first partition on the hard drive. It
is unclear to me if that's still the case, but Linux doesn't care, so you might as well make the first partition a windows partition. I use fdisk for ALL of my partitioning needs--I'm old fashioned and know how fdisk works (and doesn't work). cfdisk does weird things (IMHO), and any proprietary tool is never going to make it on my system, and is going to require the use of linux fdisk anyway. fdisk knows how to tag a partition with just about any partition type you need, so it'll work just fine if you want to install BeOS, Windows XP, Linux, and FreeBSD, you can partition the drive using fdisk and everything should be fine (cfdisk has the same abilities w.r.t. partition types).

You can see the list of partitions possible by typing "l" while at the fdisk prompt:
Code:
 0  Empty           1c  Hidden Win95 FA 70  DiskSecure Mult bb  Boot Wizard hid
 1  FAT12           1e  Hidden Win95 FA 75  PC/IX           be  Solaris boot
 2  XENIX root      24  NEC DOS         80  Old Minix       c1  DRDOS/sec (FAT-
 3  XENIX usr       39  Plan 9          81  Minix / old Lin c4  DRDOS/sec (FAT-
 4  FAT16 <32M      3c  PartitionMagic  82  Linux swap      c6  DRDOS/sec (FAT-
 5  Extended        40  Venix 80286     83  Linux           c7  Syrinx
 6  FAT16           41  PPC PReP Boot   84  OS/2 hidden C:  da  Non-FS data
 7  HPFS/NTFS       42  SFS             85  Linux extended  db  CP/M / CTOS / .
 8  AIX             4d  QNX4.x          86  NTFS volume set de  Dell Utility
 9  AIX bootable    4e  QNX4.x 2nd part 87  NTFS volume set df  BootIt
 a  OS/2 Boot Manag 4f  QNX4.x 3rd part 8e  Linux LVM       e1  DOS access
 b  Win95 FAT32     50  OnTrack DM      93  Amoeba          e3  DOS R/O
 c  Win95 FAT32 (LB 51  OnTrack DM6 Aux 94  Amoeba BBT      e4  SpeedStor
 e  Win95 FAT16 (LB 52  CP/M            9f  BSD/OS          eb  BeOS fs
 f  Win95 Ext'd (LB 53  OnTrack DM6 Aux a0  IBM Thinkpad hi ee  EFI GPT
10  OPUS            54  OnTrackDM6      a5  FreeBSD         ef  EFI (FAT-12/16/
11  Hidden FAT12    55  EZ-Drive        a6  OpenBSD         f0  Linux/PA-RISC b
12  Compaq diagnost 56  Golden Bow      a7  NeXTSTEP        f1  SpeedStor
14  Hidden FAT16 <3 5c  Priam Edisk     a8  Darwin UFS      f4  SpeedStor
16  Hidden FAT16    61  SpeedStor       a9  NetBSD          f2  DOS secondary
17  Hidden HPFS/NTF 63  GNU HURD or Sys ab  Darwin boot     fd  Linux raid auto
18  AST SmartSleep  64  Novell Netware  b7  BSDI fs         fe  LANstep
1b  Hidden Win95 FA 65  Novell Netware  b8  BSDI swap       ff  BBT
In order to have more than four partitions, you have to use extended partitions. fdisk defaults to using the "linux extended" partition type (type "85"). However, if you use type "85", you won't be able to put any non-Linux filesystems (that are accessable by their OSs) under that Linux extended partition, so you may need to use type "f".

Summary
So, the trick to partitioning your system is first to decide what you are going to use your system for, but there are some things that don't really change, regardless of the intended use.

* You should always have a swap partition.
* Partitions are for keeping data separate from other data.
* Make sure you have room to grow in the partitions that will need it.
* Before changing an existing system, always back up your data. Twice.
* If it's possible, it's best to keep your OSs on separate hard disks.

by johns123 on Mon, 2004-03-01 14:20
This is so typical of the Linux community. Why did you write this?
It contains no useful "How to" information at all, and yet you
call it a tutorial. Who do you think you are? Our Daddy? Why
don't you go back and simply put a "how to" under each heading,
and delete the rest of that arrogant poop. I just did a search on
"dual boot" of Linux and WinXP. Guess what? I got nothing
except this article with tells me nothing.

johns

by trickykid on Mon, 2004-03-01 20:05
Quote:
Originally posted by johns123
This is so typical of the Linux community. Why did you write this?
It contains no useful "How to" information at all, and yet you
call it a tutorial. Who do you think you are? Our Daddy? Why
don't you go back and simply put a "how to" under each heading,
and delete the rest of that arrogant poop. I just did a search on
"dual boot" of Linux and WinXP. Guess what? I got nothing
except this article with tells me nothing.

johns
Then you should simply move on as this article might help others.

Review our rules, if you have nothing constructive to say, then don't say it and just move on to the next thread.

http://www.linuxquestions.org/rules.php

If you want to post negative comments, do it constructively and explain yourself in why you think it was not helpful. There is no need to post utter crap like this which is not the least bit helpful itself.

If you want to discuss this privately, feel free to email me or the admin of the site. If not, then lets move on with the topic, IN A CONSTRUCTIVE MANNER PLEASE!

Regards.

by Hartmann on Fri, 2004-03-26 13:32
Hi Moses,

I can't thank you enough for this very instructive tutorial.
In my humble opinion, you are a talented, highly professional writer.
Keep writing!

Hartmann.

by Brain Drop on Sun, 2004-04-11 21:40
I have to agree, I thought it was great. I always say I'll make multiple partitions next time and now I think I really will.

by soupface on Wed, 2004-04-21 13:01
A decent article. I learned a lot about partitions—why they're important, how to create them—and about the organization of the filesystem.

My only criticism is that your partitioning suggestions aren't very useful. You list a few system types (Server, Workstation, Game-playing computer, etc.) and then have short paragraphs for each with suggestions on how to partition the drive(s). Below are your suggestions for Desktop/Gaming machines:
Quote:
You'll want a lot of space in /home, and it should be on its own partition. You'll probably also want to have extra space in /opt and /usr … You'll need to have a lot of space available for your 500+ MB games, which means you should have separate partitions for /opt and /usr, … Also, leave enough space on / … You should also look at putting a few GB into a /tmp partition. Make sure you don't forget about the swap partition!
So I should have lots of space for, uh, pretty much everything? I don't think this is particularly helpful. I can see that you want to avoid stating percentages explicitly (you mention that most people say "twice as much swap space as RAM" which isn't always best), but you need to say something.

Perhaps you could create a list of priorities and explain what users are most likely to want. For example:

A gaming system will require lots of space for game data, so a large /opt and /usr partition is most important. Second most important in a gaming system is large swap space so that load-times are reduced. Therefore you should make these partitions reasonably large compared to your /home and root partitions. For workstations, documents are the most important, so the /home directory should be pretty large. If you're working with multimedia (video, images, or sound) be sure to also have enough swap space so editing won't be slow (make your swap as large as the largest file you'll have to edit at a time, plus 100M). However, for other types of editing, the swap space isn't as important, so you can have a larger /opt, /usr partition…

(I don't know if the suggestions above are wrong or not, so please don't hold me to them)

People reading your article need to know why to make certain partitions certain sizes. Tell them what a larger /home partition means and why they do/don't need one. Don't worry about saying things like "your /tmp partition doesn't need to be more than 15% of your total disk space."

Other than that, it's a good article. Thanks for sharing it with us.

by moses on Mon, 2004-04-26 11:58
Thanks, guys!

Soupface,
You are correct, I didn't really want to state exact numbers because it depends on too many variables (disk size, number of applications, usage, etc.). However, you are also correct in stating that there should probably be more useful examples of how large specific partitions should be. . .
I'm unable to edit the original LA, so I'll have to post a errata here. That won't happen for some time, but I'll get to it, eventually. Thanks for your suggestions!

by GoinEasy9 on Tue, 2004-04-27 22:12
Thanks Moses

as a newbie...just 2 months into using Linux...i appreciate the time u spent writing this....

Thanks again
Tom

by Bebo on Thu, 2004-04-29 06:52
Hello,

moses, I totally agree with Hartmann - it's a very good article.

I have one comment for people reading it, though. I reacted on the gigantic /boot partition - 1 gig! Considering that it probably only will contain a few kernels, come kernel config files and possibly some initrd images, even 100 megs will definitely be enough.

Cheers!

by moses on Fri, 2004-04-30 12:32
Holy Cow! I didn't catch that in the editing. . . Yeah, that is huge! It should read something like 100 MB or maybe even 50 MB. . . I've got 9 different kernels in my /boot, some of which have boot splashes and other initrds associated with them and I only use 12 MB. . .

Thanks!

by Sage1 on Mon, 2004-05-17 07:27
Good info! Thanks!

I find it very difficult to give any credence to the first respondant/troll, who dissed you. He offered absolutely NO constructive guidance, so, is typical of the types of posting that I ignore. I noticed he didn't offer to write an article! If he thinks he is such an expert, he should offer to teach the rest of us!

I build up salvaged systems, and put Debian (from Knoppix) on them. My preference, and advice to newbies, is to KISS. For most installs, a 5 Gb home partition, plus the swap file, will do'er.

Do you have some advice about making and using, more partitions? I used to make a 60 to 100 Mb Boot partition, but, I quit that.


  



All times are GMT -5. The time now is 06:28 AM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration