[ Pobierz całość w formacie PDF ]
.5.4.10.3 Examples of hard disk allocationI used to have a 109 MB hard disk.Now I am using a 330 MB hard disk.I'll explainhow and why I partitioned these disks.The 109 MB disk I partitioned in a lot of ways, when my needs and the operatingsystems I used changed; I'll explain two typical scenarios.First, I used to run MS-DOS together with Linux.For that, I needed about 20 MB of hard disk, or justenough to have MS-DOS, a C compiler, an editor, a few other utilities, the programI was working on, and enough free disk space to not feel claustrophobic.For Linux,I had a 10 MB swap partition, and the rest, or 79 MB, was a single partition withall the les I had under Linux.I experimented with having separate root, usr, andhome partitions, but there was never enough free disk space in one piece to do muchinteresting.When I didn't need MS-DOS anymore, I repartitioned the disk so that I had a12 MB swap partition, and again had the rest as a single lesystem.The 330 MB disk is partitioned into several partitions, like this:10Sic transit discus mundi.4.10.Allocating disk space 555 MB root lesystem10 MB swap partition180 MB usr lesystem120 MB home lesystem15 MB scratch partitionThe scratch partition is for playing around with things that require their own par-tition, e.g., trying di erent Linux distributions, or comparing speeds of lesystems.When not needed for anything else, it is used as swap space I like to have a lot ofopen windows.4.10.4 Adding more disk space for LinuxAdding more disk space for Linux is easy, at least after the hardware has been properlyinstalled the hardware installation is outside the scope of this book.You formatit if necessary, then create the partitions and lesystem as described above, and addthe proper lines to etc fstab so that it is mounted automatically.4.10.5 Tips for saving disk spaceThe best tip for saving disk space is to avoid installing unnecessary programs.MostLinux distributions have an option to install only part of the packages they contain,and by analyzing your needs you might notice that you don't need most of them.Thiswill help save a lot of disk space, since many programs are quite large.Even if youdo need a particular package or program, you might not need all of it.For example,some on-line documentation might be unnecessary, as might some of the Elisp lesfor GNU Emacs, some of the fonts for X11, or some of the libraries for programming.If you cannot uninstall packages, you might look into compression.Compressionprograms such as gzip or zip will compress and uncompress individual les orgroups of les.The gzexe system will compress and uncompress programs invisiblyto the user unused programs are compressed, then uncompressed as they are used.The experimental DouBle system will compress all les in a lesystem, invisibly tothe programs that use them.If you are familiar with products such as Stacker forMS-DOS, the principle is the same.Chapter 5Memory ManagementMinnet, jag har tappat mitt minne,r jag svensk eller nnekommer inte ih g.Bosse sterbergThis section describes the Linux memory management features, i.e., virtual memoryand the disk bu er cache.The purpose and workings and the things the systemadministrator needs to take into consideration are described.5.1 What is virtual memory?Linux supports virtual memory, that is, using a disk as an extension of RAM sothat the e ective size of usable memory grows correspondingly.The kernel will writethe contents of a currently unused block of memory to the hard disk so that thememory can be used for another purpose.When the original contents are neededagain, they are read back into memory.This is all made completely transparentto the user; programs running under Linux only see the larger amount of memoryavailable and don't notice that parts of them reside on the disk from time to time.Of course, reading and writing the hard disk is slower on the order of a thousandtimes slower than using real memory, so the programs don't run as fast.The part ofthe hard disk that is used as virtual memory is called the swap space.Linux can use either a normal le in the lesystem or a separate partition for swapspace.A swap partition is faster, but it is easier to change the size of a swap le565.2.Creating a swap space 57there's no need to repartition the whole hard disk, and possibly install everythingfrom scratch.When you know how much swap space you need, you should go for aswap partition, but if you are uncertain, you can use a swap le rst, use the systemfor a while so that you can get a feel for how much swap you need, and then make aswap partition when you're con dent about its size.You should also know that Linux allows one to use several swap partitions and orswap les at the same time.This means that if you only occasionally need an unusualamount of swap space, you can set up an extra swap le at such times, instead ofkeeping the whole amount allocated all the time.A note on operating system terminology: computer science usually distinguishesbetween swapping writing the whole process out to swap space and paging writingonly xed size parts, usually a few kilobytes, at a time.Paging is usually moree cient, and that's what Linux does, but traditional Linux terminology talks aboutswapping anyway.15.2 Creating a swap spaceA swap le is an ordinary le; it is in no way special to the kernel.The only thingthat matters to the kernel is that it has no holes, and that it is prepared for use withmkswap.It must reside on a local disk, however; it can't reside in a lesystem thathas been mounted over NFS due to implementation reasons.The bit about holes is important.The swap le reserves the disk space so thatthe kernel can quickly swap out a page without having to go through all the thingsthat are necessary when allocating a disk sector to a le.The kernel merely uses anysectors that have already been allocated to the le
[ Pobierz całość w formacie PDF ]