Monday, May 7, 2012

Ubuntu - Add Another Disk To The Server


The following procedure assumes that the additional disk has been physically added to the server and needs to be added to the operating system.

This procedure has been tested against Ubuntu 10.04 LTS

First we confirm details of second disk by running the lshw command. If all goes well here we should see the original disk and the new disk appear here. Take note of the location of the disk, in this case it will be /dev/sdb

sudo lshw -C disk

Now open fdisk partitioning tool to create partitions on this disk.

sudo fdisk /dev/sdb

The fdisk tool will display a menu. Run through the following steps to creae a new partition that takes the entire disk:
  1. Type "n" and "enter" to create a new partition
  2. Type "p" to create a primary partition
  3. Type "1" to create 1 partition
  4. Press enter to accept the default start position of the partition
  5. Press enter to accept the default end position of the partition
  6. Type "w" to write the partition
Now that we have create a partition on the disk we now need to create the filesystem. To do this run the following command to create an ext4 filesystem:

sudo mkfs -t ext4 /dev/sdb1

Next we'll create a mount point. This is the point the new partition will be attached to on the host filesystem.

sudo mkdir /srv

Next we need to tell the operating system to mount the partition automatically on system startup. To do this we need to edit the /etc/fstab file which tells the operating system which filesystems to load on startup.

sudo nano /etc/fstab

Add the following line to /etc/fstab

/dev/sdb1 /srv ext4 defaults 0 2

Save the file and exit nano (using Ctrl-X). Now tell Ubuntu to mount the filesystems in /etc/fstab

sudo mount -a

The partition should exist on the mount point now. As a final check, reboot the server (if possible) and check that the second partition appears at the mount point.

No comments:

Post a Comment