05 – Partitions & Partitioning
December 5, 2009 – 10:16 pmPlease note… This information no longer exists at the referenced locations. This is only a copy of what was available in 2003.
Basic Linux Training™
Partitions & Partitioning
Anita Lewis
Table of Contents
Requirements
As we discussed in our last lesson, every hard disk contains a partition table which can contain space for up to four entries – primary or extended. Your PC probably came pre-installed with a Windows partition taking up the entire hard disk. And as previously stated, you’ll need to defrag Windows and resize this primary partition to allow room for other partitions to be created with another MS-DOS utility called fips.
By definition, many of the procedures involved with repartitioning are destructive. You run a very real risk of losing data, and you might render your system unable to boot from the hard disk. Backup anything important before you proceed!
The most common partitioning scheme is to have one partition for the operating system. Microsoft products require a primary partition; Linux is indifferent to whether it’s installed on a primary or extended logical partition. So, as previous mentioned, with a SCSI hard disk, you can have up to 15 partitions and thus up to 3 versions of Windows and 12 versions of Linux on that single drive; with IDE (which is what most of you have), up to 63 partitions and thus 3 versions of Windows and 60 versions of Linux.
Not many people actually have that many operating systems installed, of course, but it is possible. A much more realistic set up would be to resize and retain the one primary partition for your existing version of Windows, and create an extended partition with the remaining space with several logical partitions for one or several Linux distributions.
Initially, you should keep things simple until you have more knowledge and experience. The standard way to partition is to create a swap partition (roughly equal to the amount of physical RAM you have, or enough to total at least 128 MB of RAM + swap space combined), and a single partition for the root filesystem (single CDs may take anywhere from 600-800 MB for the recommended installation up to 1.1-1.4 GB to install ‘everything’). Unless you’re heavily into programming, graphics, or sound files, 2-3 GB will be more than enough to allocate to your Linux distribution of choice.
I would caution you, though, that it might be a good idea to go ahead and create a separate partition for your /home directory since this is where you will have most of your work and email (possibly on the order of 500-1200 MB out of that 2-3 GB allocation). This way, if you change your mind about using the distribution, and decide to install something else, you won’t necessarily need to erase everything – you can reformat and install another distribution on the / partition without affecting the /home partition.
The command line tools and utilities are relatively small. What eats up hard disk space is the GUI. To give you an idea:
- KDE – 170 MB
- GNOME – 100 MB
- Netscape – 35 MB
- StarOffice – 150 MB
- Applixware – 400 MB
- Oracle – 400 MB
- Sybase – 170 MB
Note: these are minimums for the application/suite – you’ll need additional free space for working and your data.
By comparison, the largest non-GUI ‘hog’ would be the kernel source; version 2.4 takes up just over 107 MB; a complete set of the LDP HOWTOs and mini-HOWTOs in HTML format takes up less than 23 MB.
By far the largest directory on a fresh install is /usr which can easily run 400 MB or more (that’s roughly 50-60% of the space used on some of the recommended ‘dial-up’ or ‘workstation’ configurations), and is commonly placed on a separate partition along with /var (which is about one-tenth the size). Increasingly, with the multi-gigabyte hard drives, a separate /boot partition (with ample room for several versions of the kernel image – say 10-50 MB) makes sense, not so much to compensate for the cylinder 1023 barrier, which has been defeated in the most recent versions of lilo, but due to the sheer size of the hard drive.
The problem with tossing specific or ballpark figures around is that they can too easyily mislead the new user. Your distribution of choice and your particular needs should always override blindly following any well-intentioned advice and general rules of thumb (many of which have been obsolete for years, but they are still glibly tossed around as if they were hard and fast rules). This, plus the obvious fact that 6 -12 months down the road, you will be much more knowledgeable, and comfortable with the prospects of repartitioning your hard drive.These are extremely valid reasons to keep your initial partitioning scheme very simple and straightforward.
Remember to allow plenty of free space on your Windows partition for future work within Windows – additional programs, data, temp files, etc.
Mechanics
Anything not specifically assigned to a separate partition will be part of the / filesystem. If you wish to include other partitions that are not a standard part of the filesystem, you can. For example, most of my work is text based, generally in plain text or HTML format, so I have separate partitions for them according to where they will be used – one partition for the pages related to this course, a separate one for the local Linux Users’ Group and several upcoming projects, etc. I create the partitions with fdisk, then format them with mkfs, and assign their names in /etc/fstab.
fdisk has a built-in help menu which can alleviate much of the uncertainty aboutrepartitioning. The main thing to remember is that there is no ‘undo’ command – check and double check what you are doing (‘p’ – print) as you go along; nothing will be written to disk until you give it the final OK (‘w’ – write).
With most Linux distributions, the installation programs handle most of the details for you, so you should not have nearly as much trouble as you might anticipate.
BTW, any of these separate non-standard partitions may be shared with other distributions; I would caution you, though, about sharing those that are normally part of the Linux filesystem – the various distributions do not necessarily assign the same ownership and permissions, and this can create minor problems that are more a nuisance to clear up than anything else.
One of my previous /etc/fstab looked like this:
# /etc/fstab: static file system information. # # <file system> <mount point> <type> <options> <dump> <pass> /dev/hda8 / ext2 defaults,errors=remount-ro 0 1 /dev/hda5 /boot ext2 defaults 0 1 /dev/hda6 none swap sw 0 0 proc /proc proc defaults 0 0 /dev/hda7 /mandrake ext2 noauto,user,defaults 0 2 /dev/hda9 /woody ext2 noauto,user,defaults 0 2 /dev/hda10 /home ext2 defaults 0 2 /dev/hda11 /var ext2 defaults 0 1 /dev/hda12 /work ext2 defaults 0 2 /dev/hda13 /basiclinux ext2 defaults 0 2 /dev/hda14 /web ext2 defaults 0 2 /dev/hda15 /suse ext2 noauto,user,defaults 0 2 /dev/fd0 /floppy msdos noauto,user,rw 0 0 /dev/hda1 /windows vfat defaults 0 0 /dev/hdc /cdrom-rw iso9660 noauto,user,defaults 0 2 /dev/hdd /cdrom iso9660 noauto,user,ro,defaults 0 2
The six fields in /etc/fstab are
- filesystem – the block special device or remote filesystem
- mount point – the name of the directory in the root filesystem
- filesystem type – valid entries here are
- mount options – basically whether this partition should be automagically mounted at boot or not, whether a mere ‘user’ will have permission to mount or un-mount the partition (with the commands mount/umount), and any restrictions applied to it (e.g., ‘read-only’)
- dump – how this will be treated by backup
- pass – whether or not this partition will be checked with fsck during boot
minix a local filesystem, supporting filenames of length
14 or 30 characters.
ext a local filesystem with longer filenames and larger
inodes. This filesystem has been replaced by the
ext2 file system, and should no longer be used.
ext2 a local filesystem with longer filenames, larger
inodes, and lots of other features.
ext3 is a journaling version of the ext2 filesystem. It is easy to
switch back and forth between ext2 and ext3.
xiafs a local filesystem with longer filenames, larger
inodes, and lots of other features.
msdos a local filesystem for MS-DOS partitions.
hpfs a local filesystem for HPFS partitions.
iso9660
a local filesystem used for CD-ROM drives.
nfs a filesystem for mounting partitions from remote
systems.
swap a disk partition to be used for swapping.
Those last two fields are usually a complete mystery to new users. man dump and man fsck will clear up most of the confusion. Usually the default settings are adequate, so don’t consider mine as an authoritative example.
A file related to /etc/fstab is /etc/mtab, and it tells you which partitions are currently mounted. To check the current disk space utilization of all partitions,type df at the command line.
Assignments
Terms and Concepts:
- boot partition
- extended partition
- filesystem
- logical partition
- mount point
- primary partition
- rescue disk
- root partition
- swap partition
- defrag (MS-DOS)
- df
- dump
- e2fsck
- fdisk
- fips (MS-DOS)
- free
- fsck
- mkfs
- mount/umount
- swapon/swapoff
- /etc/fstab
- /etc/mtab
On-line:
- http://www.tldp.org/HOWTO/mini/Partition/index.html (and the links in that mini-HOWTO)
- http://www.tldp.org/HOWTO/HOWTO-INDEX/index.html
- http://www.tldp.org/HOWTO/HOWTO-INDEX/mini.html
Copyright © 1997-2001 Henry White. Copyright © 2001-2003 Carmela Carter.
Copyright © 2003 Anita Lewis. All Rights Reserved.
Reproduction or redistribution without prior written consent is strictly prohibited. Address comments and inquiries to info@basiclinux.net
Sorry, comments for this entry are closed at this time.