Pages

Monday 17 February 2014

Adding Additional Hard Disk(s) in Centos

Doing the Work

Once your drive is plugged, detected by the system bios and you are booted into your system open a terminal and type: su –login
  1. Finding the hard disk devices your computer sees attached.
  2. [root@quetzalcoatl ~]# fdisk -l
    
    Disk /dev/sda: 20.8 GB, 20847697920 bytes
    16 heads, 63 sectors/track, 40395 cylinders
    Units = cylinders of 1008 * 512 = 516096 bytes
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *           1        1016      512032+  83  Linux
    /dev/sda2            1017        5079     2047752   82  Linux swap / Solaris
    /dev/sda3            5080       40395    17799264   83  Linux
    
    Disk /dev/sdb: 120.0 GB, 120034123776 bytes
    16 heads, 63 sectors/track, 232581 cylinders
    Units = cylinders of 1008 * 512 = 516096 bytes
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1               1      232581   117220792+  83  Linux
    Disk /dev/sdi: 250.0 GB, 250059350016 bytes
    255 heads, 63 sectors/track, 30401 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdi1               1       30401   244196001   83  Linux
    Disk /dev/sdj: 80.0 GB, 80026361856 bytes
    255 heads, 63 sectors/track, 9729 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    
    
    
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdj1               1        9729    78148161   83  Linux
    
    Disk /dev/sdk: 120.0 GB, 120034123776 bytes
    16 heads, 63 sectors/track, 232581 cylinders
    Units = cylinders of 1008 * 512 = 516096 bytes
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdk1   *           1      232576   117218241   83  Linux
    
    Disk /dev/sdl: 251.0 GB, 251000193024 bytes
    255 heads, 63 sectors/track, 30515 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    
    Disk /dev/sdl doesn't contain a valid partition table
    
    
  3. At the bottom we see: “Disk /dev/sdl doesn’t contain a valid partition table“, this is what we are looking for, now we can create the partitions. For this example, we’re taking a 250GB Maxtor hard disk and using the entire space as one large partition. If you want more than one partition on your new disk you can alter this when you choose the size of your new partitions using +sizeM (megabytes) or +sizeK (Kilobytes).
  4. [root@quetzalcoatl ~]# fdisk /dev/sdl
    Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
    Building a new DOS disklabel. Changes will remain in memory only,
    until you decide to write them. After that, of course, the previous
    content won't be recoverable.
    
    
    The number of cylinders for this disk is set to 30515.
    There is nothing wrong with that, but this is larger than 1024,
    and could in certain setups cause problems with:
    1) software that runs at boot time (e.g., old versions of LILO)
    2) booting and partitioning software from other OSs
       (e.g., DOS FDISK, OS/2 FDISK)
    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)
    
    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)
    p
    Partition number (1-4): 1
    First cylinder (1-30515, default 1): <enter>
    Using default value 1
    Last cylinder or +size or +sizeM or +sizeK (1-30515, default 30515): <enter>
    Using default value 30515
    
    Command (m for help):
    
  5. Now that we’ve created the partition scheme we’d like, we need to write the changes to the disk partition table.
  6. Command (m for help): w
    The partition table has been altered!
    
    Calling ioctl() to re-read partition table.
    Syncing disks.
    [root@quetzalcoatl ~]#
    
  7. Now we need to create a filesystem on the new partition. For this howto we will use the native linux filesystem (ext3 or type 83). Make note of the superblock backups for this new disk in case an fsck is required and the main journal is corrupted or missing. You can point fsck to a backup superblock provided you thought ahead and recorded them.
  8. [root@quetzalcoatl ~]# mkfs.ext3 /dev/sdl1
    mke2fs 1.39 (29-May-2006)
    Filesystem label=
    OS type: Linux
    Block size=4096 (log=2)
    Fragment size=4096 (log=2)
    30654464 inodes, 61277926 blocks
    3063896 blocks (5.00%) reserved for the super user
    First data block=0
    Maximum filesystem blocks=0
    1871 block groups
    32768 blocks per group, 32768 fragments per group
    16384 inodes per group
    Superblock backups stored on blocks: 
            32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
            4096000, 7962624, 11239424, 20480000, 23887872
    Writing inode tables: done                            
    Creating journal (32768 blocks): done
    Writing superblocks and filesystem accounting information: done
    This filesystem will be automatically checked every 24 mounts or
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
    [root@quetzalcoatl ~]# 
    
  9. Mounting the new disk on /mnt/250GB so we can put data on it and use it normally. First, we create the directory with the mkdir command. Second we mount the disk device into our newly created directory /mnt/250GB as read/write. Note: if you have trouble with directory permissions or not being allowed to write to the directory see: man chmod | man chown.
  10. [root@quetzalcoatl ~]# mkdir /mnt/250GB && mount -t ext3 /dev/sdl1 /mnt/250GB rw
    [root@quetzalcoatl ~]# 
    
  11. Setting your drive up to automount on boot. For this we’ll edit the /etc/fstab file and add in the appropriate line save/exit. We’ll then tell the system to execute the fstab file with: mount -a  and finally we’ll use: df -h to verify that the disk is indeed mounted and the system sees it where we expect.
  12. [root@quetzalcoatl ~]# nano /etc/fstab
    # This file is edited by fstab-sync - see 'man fstab-sync' for details
    LABEL=/1                /                       ext3    defaults        1 1
    LABEL=/boot1            /boot                   ext3    defaults        1 2
    none                    /dev/pts                devpts  gid=5,mode=620  0 0
    none                    /dev/shm                tmpfs   defaults        0 0
    none                    /proc                   proc    defaults        0 0
    none                    /sys                    sysfs   defaults        0 0
    LABEL=SWAP-hda2         swap                    swap    defaults        0 0
    /dev/sdb1                /mnt/sdb120             ext3 rw
    /dev/sdi1                /mnt/sdi250             ext3 rw
    /dev/sdj1                /mnt/sdj80              ext3 rw
    /dev/sdk1                /mnt/sdk120             ext3 rw
    /dev/sdl1                /mnt/sdl250             ext3 rw 
    /dev/fd0                /media/floppy1          auto    pamconsole,exec,noauto,utf8,managed 0 0
    /dev/sdd                /media/cdrom            auto    pamconsole,exec,noauto,managed 0 0
    /dev/sdc                /media/cdrecorder       auto    pamconsole,exec,noauto,managed 0 0
    [root@quetzalcoatl ~]# mount -a
    [root@quetzalcoatl ~]# df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/sda3              17G   15G  1.8G  90% /
    /dev/sda1             485M   52M  408M  12% /boot
    >
    none                  506M     0  506M   0% /dev/shm
    /dev/sdb1             111G   97G  8.3G  93% /mnt/sdb120
    /dev/sdi1             230G  216G  2.6G  99% /mnt/sdi250
    /dev/sdj1              74G   67G  2.8G  97% /mnt/sdj80
    /dev/sdk1             111G  100G  4.9G  96% /mnt/sdk120
    /dev/sdl1             231G  188M  219G   1% /mnt/sdl250
    [root@quetzalcoatl ~]# 
    

Source : Centoshelp.org

No comments:

Post a Comment