Adding an IDE Disk to an IA-32 System Using fdisk

 < Day Day Up > 

As a comparison only to the Integrity procedure, look at the installation of a second IDE disk, this time on your IA-32 system. Keep in mind though that most IA-32 systems, like Proliants, have SCSI disks. It's really not that different from installing a second SCSI disk, but it's worth going over again. Linux automatically detects new SCSI and IDE disks if you already have one such disk in your system. In the example in this section, we'll add an IDE disk to the existing system that already has an IDE drive in it. In keeping with the "how to" format of this book, I'll walk through all the steps required to add the disk.

Just like when you installed Linux on the first IDE drive, you'll employ partitions when you set up our new disk. In the following example, you'll have only one partition that will contain the entire capacity of the disk.

The existing disk on the system is /dev/hda. Our new disk will be /dev/hdb, which are the names that Linux selects for IDE disks. Our existing disk is partitioned into /dev/hda1 for partition number one, /dev/hda2 for partition number two, and so on. If you want to see the partitions on your first disk, before you start adding the new disk, log on as root and issue the command fdisk -l /dev/hda. You will see all the partitions on your existing disk. Because this is the second IDE hard disk, our new disk will be /dev/hdb. Because there will be only one partition on it, the partition will be /dev/hdb1. If you read the earlier section, "Adding and Partitioning a SCSI Disk on an Integrity Server," you already know that the naming convention for SCSI disks is similar with /dev/sda being the first SCSI disk and /dev/sdb being the second disk.

In the example, you add an IDE drive that already has two partitions on it. Keep in mind that if you have a brand new drive, it may not have any partitions on it, and you can skip the sections where we delete the existing partitions.

After physically adding the disk drive and booting the system, log on as root to invoke fdisk in order to partition the disk. After fdisk starts, select m to view all the available fdisk options.

 # fdisk /dev/hdb Command (m for help): m 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) 

Now that you can see the fdisk options, we'll print the disk's partition table with p, delete the two existing partitions on the disk with d, and then confirm the partitions have been removed by printing the partition table again with p:

 Command (m for help): p Disk /dev/hdb: 255 heads, 63 sectors, 488 cylinders Units = cylinders of 16065 * 512 bytes    Device Boot    Start        End    Blocks   Id  System /dev/hdb1   *         1        128   1028128+  83  Linux Partition 1 has different physical/logical endings:      phys=(135, 239, 63) logical=(127, 254, 63) Partition 1 does not end on cylinder boundary:      phys=(135, 239, 63) should be (135, 254, 63) /dev/hdb2           129        137     68040   82  Linux swap Partition 2 has different physical/logical beginnings (non-Linux?):      phys=(136, 0, 1) logical=(128, 0, 1) Partition 2 has different physical/logical endings:      phys=(144, 239, 63) logical=(136, 119, 63) Partition 2 does not end on cylinder boundary:      phys=(144, 239, 63) should be (144, 254, 63) Command (m for help): d Partition number (1-4): 1 Command (m for help): d Partition number (1-4): 2 Command (m for help): p Disk /dev/hdb: 255 heads, 63 sectors, 488 cylinders Units = cylinders of 16065 * 512 bytes    Device Boot    Start        End    Blocks   Id  System 

As you can see, the second p command reports that you have successfully deleted both of the existing disk partitions and can now proceed to add our partition that will consist of the entire contents of the disk. As you can see in the next listing, we issue n to add a new partition, then make it primary with p. After that, set the partition number to 1 and accept the defaults for the first cylinder (1) and the last cylinder (488). This creates a partition that uses the entire disk. Lastly, use p to print the partition table:

 Command (m for help): n Command action    e   extended    p   primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-488, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-488, default 488): Using default value 488 Command (m for help): p Disk /dev/hdb: 255 heads, 63 sectors, 488 cylinders Units = cylinders of 16065 * 512 bytes    Device Boot    Start      End    Blocks   Id  System /dev/hdb1             1      488   3919828+  83  Linux 

When you viewed the partition, it was nearly four GB, which is the total capacity of the disk because we selected the defaults for the beginning and end of the partition. This partition looks just the way we want it with the entire disk in this single partition. Next, you'll change the type of partition with t, and then specify a type Linux with 83:

 Command (m for help): t Partition number (1-4): 1 Hex code (type L to list codes): l  0  Empty           1c  Hidden Win95 FA 65  Novell Netware  bb  Boot Wizard hid  1  FAT12           1e  Hidden Win95 FA 70  DiskSecure Mult c1  DRDOS/sec (FAT-  2  XENIX root      24  NEC DOS         75  PC/IX           c4  DRDOS/sec (FAT-  3  XENIX usr       39  Plan 9          80  Old Minix       c6  DRDOS/sec (FAT-  4  FAT16 <32M      3c  PartitionMagic  81  Minix /old Lin  c7  Syrinx  5  Extended        40  Venix 80286     82  Linux swap      da  Non-FS data  6  FAT16           41  PPC PReP Boot   83  Linux           db  CP/M /CTOS /.  7  HPFS/NTFS       42  SFS             84  OS/2 hidden C:  de  Dell Utility  8  AIX             4d  QNX4.x          85  Linux extended  df  BootIt  9  AIX bootable    4e  QNX4.x 2nd part 86  NTFS volume set e1  DOS access  a  OS/2 Boot Manag 4f  QNX4.x 3rd part 87  NTFS volume set e3  DOS R/O  b  Win95 FAT32     50  OnTrack DM      8e  Linux LVM       e4  SpeedStor  c  Win95 FAT32 (LB 51  OnTrack DM6 Aux 93  Amoeba          eb  BeOS fs  e  Win95 FAT16 (LB 52  CP/M            94  Amoeba BBT      ee  EFI GPT  f  Win95 Ext'd (LB 53  OnTrack DM6 Aux 9f  BSD/OS          ef  EFI (FAT-12/16/ 10  OPUS            54  OnTrackDM6      a0  IBM Thinkpad hi f0  Linux/PA-RISC b 11  Hidden FAT12    55  EZ-Drive        a5  FreeBSD         f1  SpeedStor 12  Compaq diagnost 56  Golden Bow      a6  OpenBSD         f4  SpeedStor 14  Hidden FAT16 <3 5c  Priam Edisk     a7  NeXTSTEP        f2  DOS secondary 16  Hidden FAT16    61  SpeedStor       a9  NetBSD          fd  Linux raid auto 17  Hidden HPFS/NTF 63  GNU HURD or Sys b7  BSDI fs         fe  LANstep 18  AST SmartSleep  64  Novell Netware  b8  BSDI swap       ff  BBT 1b  Hidden Win95 FA Hex code (type L to list codes): 83 Command (m for help): p Disk /dev/hdb: 255 heads, 63 sectors, 488 cylinders Units = cylinders of 16065 * 512 bytes    Device Boot    Start      End    Blocks  Id  System /dev/hdb1             1      488   3919828+ 83  Linux 

When you entered partition l, fdisk listed many types of partitions, including Linux, Linux swap, Linux extended, and Linux LVM. You selected Linux, but we could have selected any partition type. fdisk is a versatile program that can be used to create many types of partitions and the list is growing all the time.

Now that you're done partitioning the hard disk, it's time to write changes to the disk with w:

 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. # 

The partition is now ready for a file system. You'll use mke2fs to create one. Just like it did for our SCSI disk earlier, mke2fs puts a Linux second extended file system on the partition. When you specify the j option with mke2fs, an ext3 journal is placed on the partition. This is a little confusing because using the ext2 command of mke2fs, but specifying an option for the ext3 journaling. Note that if this partition were to be used for swap, you would create a swap file system on it with mkswap instead mke2fs:

 # mke2fs -j /dev/hdb1 mke2fs 1.27 (8-Mar-2002) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 490560 inodes, 979957 blocks 48997 blocks (5.00%) reserved for the super user First data block=0 30 block groups 32768 blocks per group, 32768 fragments per group 16352 inodes per group Superblock backups stored on blocks:               32768, 98304, 163840, 229376, 294912, 819200, 884736 Writing inode tables: 0/30 Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 28 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. 

Now, mount it with mount and view all of the partitions with df:

 # mount /dev/hdb1 /backup # df Filesystem        1k-blocks     Used Available  Use% Mounted on /dev/hda5            381139    75222     286239  21% / /dev/hda1             46636     8646      35582  20% /boot /dev/hda3           1423096    48216    1302588   4% /home none                  47160        0      47160   0% /dev/shm /dev/hda2           3889924  1661608    2030720  46% /usr /dev/hda6            256667    44297     199118  19% /var /dev/hdb1           3858204    32828    3629388   1% /backup # 

As you can see, /dev/hdb1 is mounted on /backup. Now that it's mounted, you can use it for whatever purpose you want. Just as you did with /dev/sdb1 earlier, if you want the filesystem mounted at boot time, you can add an entry to /etc/fstab. That's discussed that in the fstab section later in this chapter.

As you have seen, fdisk allows us to create many different types of file systems. Similarly, many other commands used in Linux support many different types of file systems. When you issue the mount command, for instance, you can use the -t option to specify the type of file system you want to mount. The man page for the mount command lists many types of file systems that can be used with the -t option. To see how to use mount to mount a DOS floppy disk or a CD-ROM drive, see page 87.

     < Day Day Up > 


    Linux on HP Integrity Servers. A System Administrator's Guide
    Linux on HP Integrity Servers: A System Administrators Guide
    ISBN: 0131400002
    EAN: 2147483647
    Year: 2004
    Pages: 100

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net