[ Anmerkung: Diese Anleitung zu fdisk ist ein Auszug eines News- ] [ Artikels von Matt Welsh, den wir um einige Kommentare ] [ ergänzt haben. ] --------------------------------------------------------------------- The Linux Installation HOWTO by Matt Welsh, mdw@sunsite.unc.edu v2.1, 23 March 1994 4.1. Repartitioning On most systems, the hard drive is already dedicated to partitions for MS-DOS, OS/2, and so on. You need to resize these partitions in order to make space for Linux. A partition is just a section of the hard drive set aside for a particular operating system to use. If you only have MS-DOS installed, your hard drive probably has just one partition, entirely for MS-DOS. To use Linux, however, you'll need to repartition the drive, so that you have one partition for MS-DOS, and one (or more) for Linux. The problem with resizing partitions is that there is no way to do it (easily) without deleting the data on those partitions. Therefore, you will need to make a full backup of your system before repartitioning. In order to resize a partition, we simply delete the partition(s), and re-create them with smaller sizes. NOTE: There is a non-destructive disk repartitioner available for MS- DOS, called FIPS. Look on sunsite.unc.edu in the directory /pub/Linux/system/Install. With FIPS, a disk optimizer (such as Norton Disk Doctor), and a little bit of luck, you should be able to resize MS-DOS partitions without destroying the data on them. [Anm: Wir halten FIPS für noch nicht ausgereift genug, um als ] [ Standardlösung in einer Disrtribution angeboten zu werden. ] If you're not using FIPS, however, the classic way to modify partitions is with the program FDISK. For example, let's say that you have an 80 meg hard drive, dedicated to MS-DOS. You'd like to split it in half---40 megs for MS-DOS and 40 megs for Linux. In order to do this, you need to run FDISK under MS-DOS, delete the 80 meg MS-DOS partition, and re-create a 40 meg MS-DOS partition in its place. You can then format the new partition and reinstall your MS-DOS software from backups. Use of MS-DOS FDISK should be self-explanatory. You'll need to make a full backup of your system, and have a bootable MS-DOS floppy with utilities such as FDISK.EXE and FORMAT.COM installed (the original MS- DOS installation disks are the best thing to use for this). Booting from the floppy, you run FDISK on your hard drive, and use the menu options to delete your current MS-DOS partition, and then re-create it with a smaller size. You can then re-install the MS-DOS software from backup. The mechanism used to repartition for OS/2 and other operating systems is similar. See the documentation for those operating systems for details. 4.2.1. Using fdisk To create partitions, you'll use the Linux fdisk program. After logging in as root, run the command fdisk [ Anm: fdisk wird automatisch vom Installationsskript aufgerufen, wenn Sie ] [ im Hauptmenü den Punkt "a" wählen. Sie müssen dann nur noch die ] [ entsprechende Festplatte angeben. ] where is the name of the drive that you wish to create Linux partitions on. Hard drive device names are: o /dev/hda First IDE drive o /dev/hdb Second IDE drive o /dev/sda First SCSI drive o /dev/sdb Second SCSI drive and so on. For example, to create Linux partitions on the first SCSI drive in your system, use the command fdisk /dev/sda If you use fdisk without an argument, it will assume /dev/hda. Use of fdisk is simple. The command ``p'' displays your current partition table. ``n'' creates a new partition, and ``d'' deletes a partition. To Linux, partitions are given a name based on the drive which they belong to. For example, the first partition on /dev/hda is /dev/hda1, the second is /dev/hda2, and so on. NOTE: You should not create or delete partitions for operating systems other than Linux with Linux fdisk. That is, don't create or delete MS- DOS partitions with this version of fdisk; use MS-DOS's version of FDISK instead. If you try to create MS-DOS partitions with Linux fdisk, chances are MS-DOS will not recognize the partition and not boot correctly. Here's an example of using fdisk. Here, we have a single MS-DOS partition using 61693 blocks on the drive, and the rest of the drive is free for Linux. (Under Linux, one block is 1024 bytes. Therefore, 61693 blocks is about 61 megabytes.) We will create two Linux partitions: one for swap, and one for the root filesystem. First, we use the ``p'' command to display the current partition table. As you can see, /dev/hda1 (the first partition on /dev/hda) is a DOS partition of 61693 blocks. ______________________________________________________________________ Command (m for help): p Disk /dev/hda: 16 heads, 38 sectors, 683 cylinders Units = cylinders of 608 * 512 bytes Device Boot Begin Start End Blocks Id System /dev/hda1 * 1 1 203 61693 6 DOS 16-bit >=32M Command (m for help): ______________________________________________________________________ Next, we use the ``n'' command to create a new partition. The Linux root partition will be 80 megs in size. ______________________________________________________________________ Command (m for help): n Command action e extended p primary partition (1-4) p ______________________________________________________________________ A primary partition is simply one of the 4 partitions on your drive. An extended partition allows you to create multiple logical partitions within it; this allows you to go over the four-partition limit on the drive. In most cases, you should only use primary partitions unless you need more than 4 partitions on a drive. ______________________________________________________________________ Partition number (1-4): 2 First cylinder (204-683): 204 Last cylinder or +size or +sizeM or +sizeK (204-683): +80M ______________________________________________________________________ The first cylinder should be the cylinder AFTER where the last partition left off. In this case, /dev/hda1 ended on cylinder 203, so we start the new partition at cylinder 204. As you can see, if we use the notation ``+80M'', it specifies a partition of 80 megs in size. Likewise, the notation ``+80K'' would specify an 80 kilobyte partition, and ``+80'' would specify just an 80 byte partition. ______________________________________________________________________ Warning: Linux cannot currently use 33090 sectors of this partition ______________________________________________________________________ If you see this warning, you can ignore it. It is left over from an old restriction that Linux filesystems could only be 64 megs in size. However, with newer filesystem types, that is no longer the case... partitions can now be up to 4 terabytes in size. Next, we create our 10 megabyte swap partition, /dev/hda3. ______________________________________________________________________ Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 3 First cylinder (474-683): 474 Last cylinder or +size or +sizeM or +sizeK (474-683): +10M ______________________________________________________________________ Again, we display the contents of the partition table. Be sure to write down the information here, especially the size of each partition in blocks. You need this information later. ______________________________________________________________________ Command (m for help): p Disk /dev/hda: 16 heads, 38 sectors, 683 cylinders Units = cylinders of 608 * 512 bytes Device Boot Begin Start End Blocks Id System /dev/hda1 * 1 1 203 61693 6 DOS 16-bit >=32M /dev/hda2 204 204 473 82080 83 Linux native /dev/hda3 474 474 507 10336 83 Linux native ______________________________________________________________________ Note that the Linux swap partition (here, /dev/hda3) has type ``Linux native''. We need to change the type of the swap partition to ``Linux swap'' so that the installation program will recognize it as a swap partition. In order to do this, use the fdisk ``t'' command: ______________________________________________________________________ Command (m for help): t Partition number (1-4): 3 Hex code (type L to list codes): 82 ______________________________________________________________________ If you use ``L'' to list the type codes, you'll find that 82 is the code corresponding to Linux swap. To quit fdisk and save the changes to the partition table, use the ``w'' command. To quit fdisk WITHOUT saving changes, use the ``q'' command. After quitting fdisk, the system may tell you to reboot to make sure that the changes took effect. In general there is no reason to reboot after using fdisk---the version of fdisk on the Slackware distribution is smart enough to update the partitions without rebooting. [ Anm: Unser fdisk auch... Aber wir empfehlen trotzdem den reboot... ]