Adding and Partitioning a SCSI Disk on an Integrity Server

 < Day Day Up > 

A commonly run procedure on Linux systems is to add a new disk and partition it. In Chapter 2, you installed Linux on a SCSI disk on the Integrity server and now you want to expand our system to include an additional disk.

Linux automatically detects new SCSI and IDE disks if you already have one such disk in your system. In the example in this section, you add a SCSI disk to the existing system that already has an SCSI drive in it. I'll walk through all the steps required to add the disk. In this section, you perform disk-related procedures on an Integrity server with SCSI disks. Later in this chapter, you perform the same procedures on an IA-32 system with IDE disks.

As with the installation of Linux, you'll employ partitions when you set up your new disk. In the example, we'll have only one partition that will contain the entire capacity of the disk.

The Integrity system on which I'll install the new disk has four disks internal to it. Linux was loaded in on /dev/sdc (sdc for SCSI disk C). /dev/sda and /dev/sdb (for SCSI disk A and B respectively) have other operating systems on them. The unused disk of /dev/sdd will be used in this example to create one large partition and mount it.

Our existing disk is already partitioned into /dev/sdc1 for partition /boot/efi, /dev/sdc3 for partition /, and a none partition for /dev/shm. Our new disk will be /dev/sdd and we will create one partition on it that will be named /dev/sdd1.

After physically adding the disk drive and booting the system, invoke parted to partition the disk. parted has many options. The following listing shows what happens when you invoke parted for the new SCSI disk and then view the available command options with help:

 [root@linux1 root]# parted /dev/sdd GNU Parted 1.6.3 Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This program is free software, covered by the GNU General Public License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Using /dev/sdd (parted) help   check MINOR                   do a simple check on the filesystem   cp [FROM-DEVICE] FROM-MINOR TO-MINOR      copy filesystem to another partition   help [COMMAND]               prints general help, or help on COMMAND   mklabel LABEL-TYPE           create a new disklabel (partition table)   mkfs MINOR FS-TYPE          make a filesystem FS-TYPE on partititon MINOR   mkpart PART-TYPE [FS-TYPE] START END     make a partition  mkpartfs PART-TYPE FS-TYPE START END    make a partition with a filesystem   move MINOR START END          move partition MINOR   name MINOR NAME               name partition MINOR NAME   print [MINOR]                 display the partition table, or a partition   quit                          exit program   rescue START END              rescue a lost partition near START and END   resize MINOR START END        resize filesystem on partition MINOR   rm MINOR                      delete partition MINOR   select DEVICE                 choose the device to edit   set MINOR FLAG STATE          change a flag on partition MINOR (parted) 

Because your new disk might have been obtained from another system, it's important to delete any existing partitions. Consequently, the next step you perform is to delete the existing partition on the disk with rm, and then view the partition table to confirm the partitions have been removed with p:

 (parted) rm Partition number? 1 (parted) p Disk geometry for /dev/sdd: 0.000-34732.890 megabytes Disk label type: gpt Minor    Start       End     Filesystem  Name                  Flags (parted) 

You successfully deleted the partition and can now proceed to add your new partition which will consist of the entire contents of the disk. To do so, issue mkpart for adding a new partition, make it primary with default, select file system type ext3, and then specify as size of a start of 0 and an end of 34732 (the whole disk). Finally, use p to view the partition table:

 (parted) mkpart Partition type? [primary]? File system type? [ext2]? ext3 Start? 0 End? 34732 (parted) p Disk geometry for /dev/sdd: 0.000-34732.890 megabytes Disk label type: gpt Minor    Start       End     Filesystem  Name                  Flags 1          0.017  34732.874 (parted) 

Note that when you viewed the partition, it consumed the total capacity of the disk because you selected 0-34732 for the range. This partition looks just the way we want it with the entire disk in a single partition.

Now that you have the disk partitioned, you'll need to create and mount a file system on the partition we created. Use mke2fs to make it and mount to mount it to a directory called /backup. After you're done, you'll take a look at all the partitions with df:

 [root@linux1 root]# mke2fs -j /dev/sdd1 mke2fs 1.32 (09-Nov-2002) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 4447744 inodes, 8891611 blocks 444580 blocks (5.00%) reserved for the super user First data block=0 272 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, 1605632, 2654208,         4096000, 7962624 Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 37 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@linux1 root]# mkdir /backup [root@linux1 root]# mount /dev/sdd1 /backup [root@linux1 root]# df Filesystem           1K-blocks      Used Available Use% Mounted on /dev/sdc3             32891620   1915540  29305280   7% / /dev/sdc1               102182      4532     97650   5% /boot/efi none                   2072832         0   2072832   0% /dev/shm /dev/sdd1             35008108     32828  33196960   1% /backup [root@linux1 root]# 

df shows you that /dev/sdd1 is now mounted as /backup. You can now use it for whatever purpose we want. If you want the filesystem mounted at boot time, we can add an entry to /etc/fstab. You'll look at that in the fstab section later in this chapter.

parted gives you the option to create many different types of file systems. For example, if you wanted to use this partition for swap, you would have created a swap partition with parted and then used mkswap to create a swap file system on it.

Many other Linux commands 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.

For example, one common file system I often mount on Linux IA-32 systems is a DOS floppy disk. You probably won't be doing this on an Integrity server, but it's good to know anyway. To use a DOS floppy disk, use the following commands to mount a DOS floppy, copy a file to it, and unmount it on an IA-32 system. (Note that in most cases, you must be logged on as root to mount filesystems.)

 # mount -t msdos /dev/fd0 /mnt/floppy # cp * /mnt/floppy # ls /mnt/floppy file1              file2     file3    file4 # umount /dev/fd0 

This sequence of commands first mounts /dev/fd0, which is the floppy disk device file. At the mount point /mnt/floppy, /dev/fd0 is mounted as type msdos, as specified by the -t msdos. I next copy all files in the current directory to the floppy. All the files on the floppy are then listed with ls, producing the list of four files shown. I then unmount the floppy disk with the umount command so that I can take the floppy to a DOS system and read the files. Because the floppy was mounted as type msdos, the files were written to the floppy in DOS format.

Similarly, to mount a CD-ROM on a Linux system, you would issue the following mount command, unless it's mounted at boot. This CD-ROM is, of course, a read-only device, as the message from mount indicates:

 [root@localhost root]# mount /dev/cdrom /mnt/cdrom mount: block device /dev/cdrom is write-protected, mounting read-only [root@localhost root]# df Filesystem           1k-blocks      Used Available Use% Mounted on /dev/sda3             68450624   1419592  63553900   3% / /dev/sda1               104184      6120     98064   6% /boot/efi none                   1024560         0   1024560   0% /dev/shm /dev/sdb1             35001508     32828  33190688   1% /backup /dev/cdrom              658016    658016         0 100% /mnt/cdrom [root@localhost root]# 

     < 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