Skip to main content

How To Adding Additional Disk Drives to CentOS 5/6

Adding a new drive to CentOS or RedHat systems.

Making use of a second drive for extra space? Here's a quick run-down:

1) Make sure you know which disk is being formatted. First, second, and third drives will be /dev/sda, /dev/sdb, and /dev/sdc respectively. Check this with fdisk -l

[03:50:04] [root@virt ~]# fdisk -l    Disk /dev/sda: 34.3 GB, 34359738368 bytes  255 heads, 63 sectors/track, 4177 cylinders  Units = cylinders of 16065 * 512 = 8225280 bytes       Device Boot      Start         End      Blocks   Id  System  /dev/sda1   *           1          13      104391   83  Linux  /dev/sda2              14        4177    33447330   8e  Linux LVM    Disk /dev/sdb: 8589 MB, 8589934592 bytes  255 heads, 63 sectors/track, 1044 cylinders  Units = cylinders of 16065 * 512 = 8225280 bytes    Disk /dev/sdb doesn't contain a valid partition table

2) You can see that /dev/sdb (our second hard drive) does not have any partitions. We will need to create a partition(s) on the drive and then make a file system on it, then mount it. Let's write partitions to the drive using fdisk /dev/sdb:

[03:53:01] [root@virt ~]# fdisk /dev/sdb  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.    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):

3) As you can see from the help menu (by using the command "m") we want to add a new partition. Using the defaults will use the entire disk. After it's created, you will want to use the command "w" to "write table to disk and exit".

Command (m for help): n  Command action     e   extended     p   primary partition (1-4)  p  Partition number (1-4): 1  First cylinder (1-1044, default 1): 1  Last cylinder or +size or +sizeM or +sizeK (1-1044, default 1044):   Using default value 1044    Command (m for help): w  The partition table has been altered!    Calling ioctl() to re-read partition table.  Syncing disks.  [03:54:58] [root@virt ~]# 

4) Now you will notice that the output of fdisk -l /dev/sdb shows a partition as /dev/sdb1:

[03:57:08] [root@virt ~]# fdisk -l /dev/sdb    Disk /dev/sdb: 8589 MB, 8589934592 bytes  255 heads, 63 sectors/track, 1044 cylinders  Units = cylinders of 16065 * 512 = 8225280 bytes       Device Boot      Start         End      Blocks   Id  System  /dev/sdb1               1        1044     8385898+  83  Linux

5) Now we need to create a file system on it. I've always used ext3 for general use/purposes. You'll want to use the commandmkfs -t ext3 /dev/sdb1 as shown here:

[03:58:38] [root@virt ~]# mkfs -t ext3 /dev/sdb1  mke2fs 1.39 (29-May-2006)  Filesystem label=  OS type: Linux  Block size=4096 (log=2)  Fragment size=4096 (log=2)  1048576 inodes, 2096474 blocks  104823 blocks (5.00%) reserved for the super user  First data block=0  Maximum filesystem blocks=2147483648  64 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    Writing inode tables: done                              Creating journal (32768 blocks): done  Writing superblocks and filesystem accounting information: done    This filesystem will be automatically checked every 38 mounts or  180 days, whichever comes first.  Use tune2fs -c or -i to override.

6) Great, now we have a single partitioned secondary drive using ext3 file system. Now you want to create a directory to mount it in; lets just use "/drive2". You'll need to use the command mount -t [filesystem] [source] [mount directory] to mount it.

[03:59:50] [root@virt ~]# mount -t ext3 /dev/sdb1 /drive2/

7) Now you'll notice, via df, that the drive is mounted:

[03:59:57] [root@virt ~]# df -h  Filesystem            Size  Used Avail Use% Mounted on  /dev/mapper/VolGroup00-LogVol00                         28G  1.4G   25G   6% /  /dev/sda1              99M   19M   76M  20% /boot  tmpfs                1014M     0 1014M   0% /dev/shm  /dev/sdb1             7.9G  147M  7.4G   2% /drive2  

8) Last step - you want to make sure the drive automatically mounts itself when the server boots/reboots. You'll need to add the following line to your /etc/fstab file:

/dev/sdb1  /drive2  ext3  defaults 0 0

That's all

source : http://dbiers.me/

Popular posts from this blog

Privacy Policy

Another Pratama Privacy Statement What follows is the Privacy Statement for all Another Pratama websites (a.k.a. blogs) including all the websites run under the computer.pratama.us domain. Please read this statement regarding our blogs. If you have questions please ask us via our contact form. Email Addresses You may choose to add your email address to our contact list via the forms on our websites. We agree that we will never share you email with any third party and that we will remove your email at your request. We don’t currently send advertising via email, but in the future our email may contain advertisements and we may send dedicated email messages from our advertisers without revealing your email addresses to them. If you have any problem removing your email address please contact us via our contact form. Ownership of Information Another Pratama is the sole owner of any information collected on our websites. Comments/Message Boards Most Another Pratama websites contain com...

Extend a LVM partition after increasing its virtual disk on Virtualbox

No Linux machine at work? the easy way could be to simply install Virtualbox in one of the PC, create a VDI and install Ubuntu 14.04 in it. But the day will come when you need more space! Here is how to resize it: Resize Virtualbox VDI Open Virtualbox, make sure to shutdown your virtual machine. Then open a terminal (here windows): 1 2 3 4 cd “ C : \ Program Files \ Oracle \ VirtualBox ” VBoxManage list vms VBoxManage clonehd uuid 0000000000000000 backup . vdi VBoxManage modifyhd uuid 0000000000000000 -- resize 204800 This is the Virtualbox official manual  of available commands. And  this is a website  to convert Gb into Mb (–resize takes Mb as input, 200Gb = 204800Mb). Boot Gparted to resize the partition After a default install of Ubuntu Server on one physical disk, you will have a SWAP partition, and then an extended partition in which you’ll have your LVM partition (So 3 partitions).  Download Gparted  .iso,...

DirectX Standard Multimedia Development on Windows

In the past, game programmers create their own plot between device and the software. Because Computer Architecture is complicated, so it hard to obtain the desired speed for real animation, manufactures of sound cards and display adapter had to write drive for various display adaptor, it made the development of game is really hard. And if you know, most computer games were written for MS-DOS. Maybe you remember game Mario Bross, F1, Prince of Persia and others. Then Microsoft released MS Windows, so the game developer made game for its OS. And for the easier of programmer made their game, Microsoft give an idea that made programmer can make a standard plot to connect with hardware. This idea introduce in 1995 and at last it become a standard for develop multimedia on Windows platform named DirectX.