• No results found

Sizing Out Partitions

In document Maximum Linux Security, 2nd Ed pdf (Page 96-99)

As noted, new users sometimes shy away from multiple partitions (beyond swap and root). That’s because creating multiple partitions forces you to make some hard choices. For exam- ple, just how large should each partition be? Unfortunately, there’s no definite answer to this question except when you’re dealing with swap and root partitions. Swap partitions are typi- cally twice the size of real memory available (recent decreases in RAM pricing make this unnecessary), and root should have 64MB minimum (although I allocate 100MB).

In respect to other file systems, you’ll make your choices depending on different factors. One factor is what you intend to do with your Linux box. On a multiuser system, you’ll want to give your users at least 20MB each (and probably more). Hence, for 10 users, you’ll need a /homepartition of at least 210MB.

Installation Issues CHAPTER3 73

3

I NST ALLA TION I SSUES 05 0672321343 CH03 5/25/01 3:30 PM Page 73

Some of these values are interdependent. For example, if you’re accommodating many users and providing mail and news services, your /varand/homepartitions will need to be substan- tial. Unless, of course, users use third-party mail and news solutions. In that case, their mes- sages will be stored in their /home/userdirectory; for example,/home/user/.netscape/. If you run a firewall, you’ll need a large log directory hierarchy (/var), and this should have its own partition. In fact, you might be forced to put this partition on a separate disk drive. That way you’ll avoid losing valuable audit information if the primary file system is corrupted. However, in most cases your largest partitions will house the /usrand/homedirectories. Linux Security Basics

PARTI

74

Some Linux distributions are moving towards storing more dynamic data in the /vardirec- tory than they did previously. Red Hat 7.x, for example, assumes the Apache root to be

/var/www. Take this into consideration when partitioning.

N

OTE

Let’s look at a conservative example. Here’s a dfreport from a 1.6GB IDE hard drive with a 128MB swap partition that isn’t visible from the dfquery:

Filesystem 1024-blocks Used Available Capacity Mounted on /dev/hda2 66365 17160 45778 27% /

/dev/hda5 373695 1549 352845 0% /home /dev/hda6 703417 344725 322356 52% /usr /dev/hda7 127816 21235 99981 18% /var /dev/hda8 123919 22 117498 0% /tmp

Here’s the fstabinformation immediately after installation:

/dev/hda2 / ext2 defaults 0 1 /proc /proc proc defaults 0 0 /dev/hda1 none swap defaults 0 0 /dev/hda5 /home ext2 defaults 0 2 /dev/hda6 /usr ext2 defaults 0 2 /dev/hda7 /var ext2 defaults 0 2 /dev/hda8 /tmp ext2 defaults 0 2 #

/dev/fd0 /mnt/floppy ext2 defaults,noauto 0 0 #

/dev/hdb /mnt/cdrom iso9660 ro,noauto 0 0

Note partitions 5, 6, 7, and 8. These are logical partitions. You’re allowed only four primary partitions in the Intel world, or three primary partitions, one extended partition, and multiple

logical partitions. To create additional partitions, first establish an extended partition and then slice this into logical partitions using either fdiskor, if you have Red Hat, Disk Druid.

Installation Issues CHAPTER3 75

3

I NST ALLA TION I SSUES

Some distributions offer user-friendly installation routines that automatically suggest disk lay- out (much like Sun’s Solaris does). These routines are convenient, but think carefully before accepting such a partitioning scheme. Automatic partitioning does not take into account the way that the system will be used. Instead, it creates a generalized partition table that doesn’t necessarily work well with Web or file servers. For beginners, however, automatic disk layout is a great way to create a solid file system foundation with very little effort.

C

AUTION

Although you’ve probably used fdiskalready, some folks who purchased this book might not have installed Linux yet. For their benefit, I’ll briefly address fdiskhere. If your Linux distrib- ution doesn’t use fdisk, keep reading. Cfdiskand Disk Druid are both discussed later in the chapter.

fdisk

fdiskis a partition manipulator for Linux. During your installation, Linux will move you from

a semi-graphical environment to a command-line interface so that you can partition your disks. At that point, you’ll almost certainly be dealing with fdisk.

fdisk’s initial prompt will look much like this:

Using /dev/hda as default device!

The number of cylinders for this disk is set to 1579. This is larger than 1024, and may cause problems with: 1) software that runs at boot time (e.g., LILO) 2) booting and partitioning software from other OSs

(e.g., DOS FDISK, OS/2 FDISK) Command (m for help):

Before continuing, if you’re using fdiskfor the first or even the fifth time, review the list of valid commands. That way, you can familiarize yourself with each one and reduce the chance of error. To view the complete command set, type mand press Enter. In response,fdiskwill print a help menu:

Command action

a toggle a bootable flag b edit bsd disklabel

c toggle the dos compatibility flag

d delete a partition

l list known partition types m print this menu

n add a new partition

o create a new empty DOS partition table p print the partition table

q quit without saving changes s create a new empty Sun disklabel t change a partition’s system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only)

Also, examine the current partition table before you make any changes. That way, you can ver- ify whether any partitions already exist. To do so, type pand press Enter. If you’re working with an unpartitioned disk,fdiskwill print a blank table:

Disk /dev/hda: 32 heads, 63 sectors, 1579 cylinders Units = cylinders of 2016 * 512 bytes

Device Boot Start End Blocks Id System Command (m for help):

Now you’re ready to begin creating your partitions.

From here on, I’ll stick with the values from the preceding partitioning example. You’ll need to adjust partition sizes according to your own needs. This is merely a walkthrough that demon- strates how to create an extended partition and logical partitions within it. Few Linux how-to books address this issue. (Most such books focus on Red Hat installations. Red Hat includes Disk Druid, a semi-graphical tool that simplifies the process for you. However, you might be installing another distribution, one with command-line fdisk. If so, this next section will illus- trate the steps required when you’re creating such partitions by hand.)

In document Maximum Linux Security, 2nd Ed pdf (Page 96-99)