Tuesday, February 10, 2015

Non LVM add disk partition

For those who landed straight to LVM, this is how things used to be done

1. Check new disk
    to see the new added drive, in this case a 2gb drive. note you need to rescan your SCSI Bus to see new Storage.
a - Check the partitions and note them down, this will enable to u to see before and after the scan for changes. #cat /proc/partitions
b - run the scan partition, host by host while checking 'cat /proc/partitions' to see for any increase in the list

#echo "- - -" > /sys/class/scsi_host/host0/scan
#echo "- - -" > /sys/class/scsi_host/host1/scan (etc)

after you identify, continue with the process, run fdisk first to list the disks, in our case the new disk is a 2GB /dev/sdb

    [root@localhost ~]# fdisk -l

        Disk /dev/sda: 10.7 GB, 10737418240 bytes
        255 heads, 63 sectors/track, 1305 cylinders
        Units = cylinders of 16065 * 512 = 8225280 bytes
        Sector size (logical/physical): 512 bytes / 512 bytes
        I/O size (minimum/optimal): 512 bytes / 512 bytes
        Disk identifier: 0x0009385d

           Device Boot      Start         End      Blocks   Id  System
        /dev/sda1   *           1          64      512000   83  Linux
        Partition 1 does not end on cylinder boundary.
        /dev/sda2              64         957     7168000   83  Linux
        Partition 2 does not end on cylinder boundary.
        /dev/sda3             957        1087     1048576   82  Linux swap / Solaris
        /dev/sda4            1087        1306     1756160    5  Extended
        /dev/sda5            1087        1306     1755136   83  Linux

        Disk /dev/sdb: 2168 MB, 2168588288 bytes
        255 heads, 63 sectors/track, 263 cylinders
        Units = cylinders of 16065 * 512 = 8225280 bytes
        Sector size (logical/physical): 512 bytes / 512 bytes
        I/O size (minimum/optimal): 512 bytes / 512 bytes
        Disk identifier: 0x00000000

2.format the new drive
        [root@localhost ~]# fdisk /dev/sdb
        Command (m for help): n
        Command action
           e   extended
           p   primary partition (1-4)
        e
        Partition number (1-4):
        Value out of range.
        Partition number (1-4): 1
        First cylinder (1-263, default 1):
        Using default value 1
        Last cylinder, +cylinders or +size{K,M,G} (1-263, default 263):
        Using default value 263

        Command (m for help): p

        Disk /dev/sdb: 2168 MB, 2168588288 bytes
        255 heads, 63 sectors/track, 263 cylinders
        Units = cylinders of 16065 * 512 = 8225280 bytes
        Sector size (logical/physical): 512 bytes / 512 bytes
        I/O size (minimum/optimal): 512 bytes / 512 bytes
        Disk identifier: 0xcc1dca57

           Device Boot      Start         End      Blocks   Id  System
        /dev/sdb1               1         263     2112516    5  Extended

        Command (m for help): w
        The partition table has been altered!

now run fdisk -l

        [root@localhost ~]# fdisk -l

        Disk /dev/sda: 10.7 GB, 10737418240 bytes
        255 heads, 63 sectors/track, 1305 cylinders
        Units = cylinders of 16065 * 512 = 8225280 bytes
        Sector size (logical/physical): 512 bytes / 512 bytes
        I/O size (minimum/optimal): 512 bytes / 512 bytes
        Disk identifier: 0x0009385d

           Device Boot      Start         End      Blocks   Id  System
        /dev/sda1   *           1          64      512000   83  Linux
        Partition 1 does not end on cylinder boundary.
        /dev/sda2              64         957     7168000   83  Linux
        Partition 2 does not end on cylinder boundary.
        /dev/sda3             957        1087     1048576   82  Linux swap / Solaris
        /dev/sda4            1087        1306     1756160    5  Extended
        /dev/sda5            1087        1306     1755136   83  Linux

        Disk /dev/sdb: 2168 MB, 2168588288 bytes
        255 heads, 63 sectors/track, 263 cylinders
        Units = cylinders of 16065 * 512 = 8225280 bytes
        Sector size (logical/physical): 512 bytes / 512 bytes
        I/O size (minimum/optimal): 512 bytes / 512 bytes
        Disk identifier: 0x6fbd8ea9

           Device Boot      Start         End      Blocks   Id  System
        /dev/sdb1               1         263     2112516    5  Extended
create the new file system
        [root@localhost ~]# mkfs.ext4 -b 2168 /dev/sdb
        mke2fs 1.41.12 (17-May-2010)
        /dev/sdb is entire device, not just one partition!
        Proceed anyway? (y,n) y
        Filesystem label=
        OS type: Linux
        Block size=2048 (log=1)
        Fragment size=2048 (log=1)
        Stride=0 blocks, Stripe width=0 blocks
        132600 inodes, 1058880 blocks
        52944 blocks (5.00%) reserved for the super user
        First data block=0
        Maximum filesystem blocks=538968064
        65 block groups
        16384 blocks per group, 16384 fragments per group
        2040 inodes per group
        Superblock backups stored on blocks:
            16384, 49152, 81920, 114688, 147456, 409600, 442368, 802816

        Writing inode tables: done                          
        Creating journal (32768 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.

create the new mount point folder
        [root@localhost ~]# mkdir /yum
mount the new filesystem to yum folder
        [root@localhost ~]# mount /dev/sdb /yum

Note: this is pretty straight forward but there are many considerations that you may be working with and many other variables that would arise. this can guide on the basics. we can look at them in other blogs/ posts. Cheers, all the best

No comments:

Post a Comment