Operating Systems and Systems Integration Partitioning the Hard Disk 1 Aim A hard disk needs to be divided into one or more sections called partitions. We will install a number of operating systems onto our hard disks. Each operating system needs at least one partition. We will use the Linux fdisk program to create these partitions today. Later, in your subject Systems and Network Administration, Albert will show you how to install Windows 2003 into some of these partitions. Our aim for today is to create the partitions necessary for installation of all these operating systems. 2 2.1 Background Types of partition On an ibm pc compatible, there are a few types of partition: type primary extended logical location outside of any other partition outside of any other partition inside an extended partition The total number of primary and extended partitions must be four or less. Also, the total number of partitions must be 15 or less. So if p = number of primary, e = number of extended and = number of logical, then p + e ≤ 4, and p + e + ≤ 15. 2.2 Limitations of the original IBM PC BIOS The computers we use are compatible with the original ibm pc. The bios (Basic Input Output System) also remains compatible with the original machine, and has the following limitations: parameter cylinders heads sectors number of bits 10 8 6 maximum value 1023 255 63 To boot an operating system on a PC, the bios must be able to load the first part of the operating system. The first part of the operating system must be on a location on the hard disk within these limitations. In particular, with older machines, without an extended bios, the boot files of the operating system must be entirely below cylinder 1024, or the computer may not be able to boot. However, newer machines, such as those in our lab, have an extended bios that gets around these limitations. Nick Urbanik nicku(at)vtc.edu.hk ver. 1.16 Partitioning the Hard Disk Operating Systems and Systems Integration 2 2.3 Disk and partition naming scheme in Linux The motherboards of the computers in the lab have two 40-pin ide connectors: one is called the primary ide bus, the other the secondary. A ribbon cable connects to each of these connectors. There are two female sockets on each cable. One connects to a disk configured as the master, the other to the slave. Jumpers on the hard disk determine whether the disk is the master or slave. The naming scheme for ide disks is: name hda hdb hdc hdd primary/secondary primary primary secondary secondary master/slave master slave master slave Partitions are named with the first three letters being that of the hard disk. Added to this is a number. A primary partition may be numbered 1 to 4 (i.e., on our hard disks, hda1, hda2, hda3 or hda4). Logical partitions start with the number 5, so on hda, the logical partitions are called hda5, hda6, hda7,. . . 2.4 Our partitioning scheme The partitioning scheme we use here will look like figure 1. Windows 98: FAT32 Windows NTFS extended hda2 Windows NTFS Windows NTFS Linux swap Linux root Linux 1GB primary hda1 3GB logical hda5 3GB logical hda6 3GB logical hda7 500MB logical hda8 10G logical hda9 remainder unpartitioned Figure 1: The partioning scheme we will use for our hard disk. We will create all these partitions today. We will use the Linux installation boot disk as a rescue disk. This will boot a basic Linux system independent of the local hard disks, suitable for doing emergency repairs to an installed operating system. We will use this to run fdisk and partition the removable hard disk. We begin by making two floppy disks: a boot disk and a network driver disk. Nick Urbanik nicku(at)vtc.edu.hk ver. 1.16 Partitioning the Hard Disk Operating Systems and Systems Integration 3 3 3.1 Procedure Making the Two Boot Floppies 1. Either make the two floppy disks yourself or take them from the technician or from the lecturer. How to make a the two floppy disks? Boot the lab machine into Linux, change to the network drive on /home/nfs/redhat-9/images, and put a good floppy disk into the drive. You should format each disk first to verify that it has no bad sectors: $ fdformat /dev/fd0 If you get any errors, throw that floppy disk away and get another one. Do the same with the second disk. Then use the dd command to create the boot disk from the disk image on our network drive: $ cd /home/nfs/redhat-9/images $ dd if=bootdisk.img of=/dev/fd0 bs=1440k When the floppy light is off, you have created your boot floppy. Then put in the second floppy and make the network driver disk: $ dd if=drvnet.img of=/dev/fd0 bs=1440k You can read more about the dd command if you type: $ man dd 3.2 Removable Hard Disks Hard disks are very delicate. Treat them as if they were very fragile and very expensive (they are!). Never plug or unplug a removable hard disk in while the power is on. Wait at least fifteen seconds before putting the hard disk in or removing it from the computer after turning off the power. 1. Turn off the computer, and wait at least 15 seconds. 2. Install the removable hard disk. Push it in firmly with both thumbs until you are sure it is pushed in all the way. This will be the master device on the primary IDE bus. Most people do not push the hard disk all the way in the first time! 3.3 Rescue Mode 1. Put the floppy disk into the drive and reboot the machine. 2. At the boot: prompt, enter linux rescue: boot: linux rescue 3. Accept defaults for language and keyboard. 4. When asked “What type of media contains the rescue image?” select “NFS image”. 5. At the message “No Driver found”, select “Use a driver disk” Nick Urbanik nicku(at)vtc.edu.hk ver. 1.16 Partitioning the Hard Disk Operating Systems and Systems Integration 4 6. For “Driver Disk Source”, select fd0 (the floppy disk), rather than hdb. What is i hdb? ............................................... 7. Insert the network driver disk when requested. 8. For “Network Device”, choose eth0. Note that the computers in this lab have two network cards. 9. If you are asked to choose the network driver, select the Intel EtherExpress Pro 100 (e100). Figure 2: The screen where you select using DHCP for TCP/IP parameters. 10. When asked for the IP address of the computer, accept the default of DHCP. See figure 2. If this does not immediately succeed, click on “Back” and choose eth1. If that does not work, check the connection of the network cable to the Ethernet socket on the motherboard. 11. For “nfs server name”, put ictlab.tyict.vtc.edu.hk 12. For “Red Hat directory”, put /var/ftp/pub/rh-9-updated 13. When asked if you want to mount the Linux system that is installed on the local hard disk, select “Skip”. In many other cases, for example, when using the rescue disk to fix some problem on a system that is already installed, it is often helpful to allow the rescue disk to mount that installation. 3.4 Running fdisk 1. Carefully start the fdisk program running on your removable hard disk: # fdisk /dev/hda Nick Urbanik nicku(at)vtc.edu.hk ver. 1.16 Partitioning the Hard Disk Operating Systems and Systems Integration 5 Make sure you type /dev/hda. This is very important; do not partition /dev/hdc, or Henry the system administrator will need to stay back and re-install the operating system for the other classes; he will be very upset!!! Be very careful. If you get an error message: Unable to open /dev/hda then there are a few possibilities: • Your hard disk is not pushed all the way in. Turn off the computer, wait 15 seconds, then push it in, and start again; or • Your hard disk jumpers are not set as master. Verify that this is the case. Do not use the cable select or slave jumper settings. 2. The lecturer will demonstrate the partitioning procedure. Make sure that you ask questions if you are unsure. If you make a mistake and partition the wrong hard disk, you will upset many people. The common fdisk commands that you will use are: command m p n d a q t w name menu print new partition delete active quit type write action show a list of all the commands display the partition table create a new partition delete a partition (useful if you make a mistake!) make a partition active exit without saving the table. Great if you really mess it up! set the type of partition Write changes to the disk. After that, it’s very hard to undo your changes, so think three times before pressing w. 3. Use the print command to display the partition table first. 4. Delete any partitions that are obviously the wrong size. Be very careful NOT to delete the partition that contains your installation of Windows. Think before you partition. Do not blindly follow this procedure if you do not understand what you are doing. Here is the sequence of commands I typed to destroy all the previously exising partitions. (Note that since I do not have Windows installed on my hard disk, I deleted all the partitions first): Command (m for help): d Partition number (1-9): 9 Command (m for help): d Partition number (1-8): 8 Command (m for help): d Partition number (1-7): 7 Nick Urbanik nicku(at)vtc.edu.hk ver. 1.16 Partitioning the Hard Disk Operating Systems and Systems Integration 6 Command (m for help): d Partition number (1-6): 6 Command (m for help): d Partition number (1-5): 5 Command (m for help): d Partition number (1-5): 2 Command (m for help): d Selected partition 1 5. Here are the fdisk commands I used to create the partition table: Command (m for help): p Disk /dev/hda: 41.1 GB, 41174138880 bytes 240 heads, 63 sectors/track, 5318 cylinders Units = cylinders of 15120 * 512 = 7741440 bytes Device Boot Start End Blocks Id System Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-5318, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-5318, default 5318): +1g Command (m for help): p Disk /dev/hda: 41.1 GB, 41174138880 bytes 240 heads, 63 sectors/track, 5318 cylinders Units = cylinders of 15120 * 512 = 7741440 bytes Device Boot /dev/hda1 Start 1 End 130 Blocks 982768+ Id 83 System Linux Command (m for help): t Selected partition 1 Hex code (type L to list codes): l 0 1 2 3 4 5 6 Empty FAT12 XENIX root XENIX usr FAT16 <32M Extended FAT16 1c 1e 24 39 3c 40 41 Hidden Win95 FA Hidden Win95 FA NEC DOS Plan 9 PartitionMagic Venix 80286 PPC PReP Boot 70 75 80 81 82 83 84 DiskSecure Mult PC/IX Old Minix Minix / old Lin Linux swap Linux OS/2 hidden C: bb be c1 c4 c6 c7 da Boot Wizard hid Solaris boot DRDOS/sec (FATDRDOS/sec (FATDRDOS/sec (FATSyrinx Non-FS data ver. 1.16 Nick Urbanik nicku(at)vtc.edu.hk Partitioning the Hard Disk Operating Systems and Systems Integration 7 7 HPFS/NTFS 8 AIX 9 AIX bootable a OS/2 Boot Manag b Win95 FAT32 c Win95 FAT32 (LB e Win95 FAT16 (LB f Win95 Ext’d (LB 10 OPUS 11 Hidden FAT12 12 Compaq diagnost 14 Hidden FAT16 <3 16 Hidden FAT16 17 Hidden HPFS/NTF 18 AST SmartSleep 1b Hidden Win95 FA Hex code (type L to Changed system type 42 SFS 4d QNX4.x 4e QNX4.x 2nd part 4f QNX4.x 3rd part 50 OnTrack DM 51 OnTrack DM6 Aux 52 CP/M 53 OnTrack DM6 Aux 54 OnTrackDM6 55 EZ-Drive 56 Golden Bow 5c Priam Edisk 61 SpeedStor 63 GNU HURD or Sys 64 Novell Netware 65 Novell Netware list codes): c of partition 1 to c 85 86 87 8e 93 94 9f a0 a5 a6 a7 a8 a9 ab b7 b8 Linux extended NTFS volume set NTFS volume set Linux LVM Amoeba Amoeba BBT BSD/OS IBM Thinkpad hi FreeBSD OpenBSD NeXTSTEP Darwin UFS NetBSD Darwin boot BSDI fs BSDI swap db de df e1 e3 e4 eb ee ef f0 f1 f4 f2 fd fe ff CP/M / CTOS / . Dell Utility BootIt DOS access DOS R/O SpeedStor BeOS fs EFI GPT EFI (FAT-12/16/ Linux/PA-RISC b SpeedStor SpeedStor DOS secondary Linux raid auto LANstep BBT (Win95 FAT32 (LBA)) Command (m for help): p Disk /dev/hda: 41.1 GB, 41174138880 bytes 240 heads, 63 sectors/track, 5318 cylinders Units = cylinders of 15120 * 512 = 7741440 bytes Device Boot /dev/hda1 Start 1 End 130 Blocks 982768+ Id c System Win95 FAT32 (LBA) Command (m for help): n Command action e extended p primary partition (1-4) e Partition number (1-4): 2 First cylinder (131-5318, default 131): Using default value 131 Last cylinder or +size or +sizeM or +sizeK (131-5318, default 5318): Using default value 5318 Command (m for help): p Disk /dev/hda: 41.1 GB, 41174138880 bytes 240 heads, 63 sectors/track, 5318 cylinders Units = cylinders of 15120 * 512 = 7741440 bytes Device Boot /dev/hda1 /dev/hda2 Start 1 131 End 130 5318 Blocks 982768+ 39221280 Id c 5 System Win95 FAT32 (LBA) Extended Command (m for help): t Partition number (1-5): 2 Hex code (type L to list codes): f Changed system type of partition 2 to f (Win95 Ext’d (LBA)) Nick Urbanik nicku(at)vtc.edu.hk ver. 1.16 Partitioning the Hard Disk Operating Systems and Systems Integration 8 Command (m for help): p Disk /dev/hda: 41.1 GB, 41174138880 bytes 240 heads, 63 sectors/track, 5318 cylinders Units = cylinders of 15120 * 512 = 7741440 bytes Device Boot /dev/hda1 /dev/hda2 Start 1 131 End 130 5318 Blocks 982768+ 39221280 Id c f System Win95 FAT32 (LBA) Win95 Ext’d (LBA) Command (m for help): n Command action l logical (5 or over) p primary partition (1-4) l First cylinder (131-5318, default 131): Using default value 131 Last cylinder or +size or +sizeM or +sizeK (131-5318, default 5318): +3g Command (m for help): p Disk /dev/hda: 41.1 GB, 41174138880 bytes 240 heads, 63 sectors/track, 5318 cylinders Units = cylinders of 15120 * 512 = 7741440 bytes Device Boot /dev/hda1 /dev/hda2 /dev/hda5 Start 1 131 131 End 130 5318 519 Blocks 982768+ 39221280 2940808+ Id c f 83 System Win95 FAT32 (LBA) Win95 Ext’d (LBA) Linux Command (m for help): t Partition number (1-6): 5 Hex code (type L to list codes): 7 Changed system type of partition 5 to 7 (HPFS/NTFS) Command (m for help): p Disk /dev/hda: 41.1 GB, 41174138880 bytes 240 heads, 63 sectors/track, 5318 cylinders Units = cylinders of 15120 * 512 = 7741440 bytes Device Boot /dev/hda1 /dev/hda2 /dev/hda5 Start 1 131 131 End 130 5318 519 Blocks 982768+ 39221280 2940808+ Id c f 7 System Win95 FAT32 (LBA) Win95 Ext’d (LBA) HPFS/NTFS Command (m for help): 6. The finished partition table should look something like this: Command (m for help): p Nick Urbanik nicku(at)vtc.edu.hk ver. 1.16 Partitioning the Hard Disk Operating Systems and Systems Integration 9 Disk /dev/hda: 41.1 GB, 41174138880 bytes 240 heads, 63 sectors/track, 5318 cylinders Units = cylinders of 15120 * 512 = 7741440 bytes Device Boot /dev/hda1 * /dev/hda2 /dev/hda5 /dev/hda6 /dev/hda7 /dev/hda8 /dev/hda9 Start 1 131 131 520 909 1298 1364 End 130 5318 519 908 1297 1363 2656 Blocks 982768+ 39221280 2940808+ 2940808+ 2940808+ 498928+ 9775048+ Id c f 7 7 7 82 83 System Win95 FAT32 (LBA) Win95 Ext’d (LBA) HPFS/NTFS HPFS/NTFS HPFS/NTFS Linux swap Linux ¨ Note that the type of the swap partition is “83 Linux swap”. w to 7. When the partitioning procedure is finished and you have pressed  © write your new partition table, then: (a) type the sync (short for synchronise) command a few times to ensure that the memory buffers are written to the hard disk before you shut down the computer. (b) type exit, and turn off the power on the computer when requested. (c) Wait 15 seconds before removing the hard disk and returning it to the cabinet at the end of the class. (d) Answer the questions in section 4 on the following page. Nick Urbanik nicku(at)vtc.edu.hk ver. 1.16 Partitioning the Hard Disk Operating Systems and Systems Integration 10 4 Review Questions A system administrator is given a disk partitioned as shown in figure 3. Windows 98: FAT32 Windows server NTFS unused extended hda4 2GB primary hda1 2GB primary hda2 2.5GB primary hda3 Windows XP NTFS logical hda5 remainder logical hda5 Figure 3: A partioning scheme. We want to add two more partitions. 1. Can you add two partitions, if the ntfs and fat32 partitions all contain data? i 2. What would you do if you were the system administrator? i 3. If you were creating the partitions originally, how would you have done it? i Nick Urbanik nicku(at)vtc.edu.hk ver. 1.16