How to add an extra hard disk to a SME server
Author: Michiel Blotwijk <Michiel.Blotwijk@Altiplano.Be>
Release supported: All
License: GPL
Last updated: 9 June, 2006
Most Up-todate version can be found here: http://www.contribs.org/contribs/mblotwijk/HowToGuides/AddExtraHardDisk.htm

How to add an extra hard disk to an existing SME server

Step 1: Switch to single-user mode

First you need to switch to single-user mode. Logon as root and type:

[root@hogwarts /]# telinit 1


Step 2: Partition the disk 

Now you need to identify the device name of the new disk. The following command will show you all the drives on your server (including any USB drives you might have)

 

[root@hogwarts /]# fdisk -l | more


Let's assume you installed the disk as master on the second IDE controller. This means you have to partition /dev/hdc

 

IDE controller

Device name

Master

1

/dev/hda

Slave

1

/dev/hdb

Master

2

/dev/hdc

Slave

2

/dev/hdd

 

[root@hogwarts /]# fdisk /dev/hdc

 

and when prompted:

n (to add a new partition)

p (to make a primary partion)

1 (that's the number one, the number you want to assign to the partition)

(accept the suggested first & last cylinder values)

w (write and exit)

This will create the primary partition /dev/hdc1, using the entire disk space.


Step 3: Format the new partition 

Next you want to format the new partition:

[root@hogwarts /]# mkfs -t ext2 /dev/hdc1

 

If you are using SME 5.6 or newer, it is recommended to convert the partition to the ext3 format:

[root@hogwarts /]# tune2fs -j /dev/hdc1


Step 4: Create a mounting point for the new disk 

A mounting point is just an empty directory that will link to your new disk. This can be any valid directory on your server, but it is recommended not to use /home or one of its subdirectories. In step 6 you will see a much better method to link your /home directory to the second disk.

 

For now just create a directory underneath /mnt

[root@hogwarts /]# mkdir /mnt/bigdisk


Step 5: Automount at boot time

To automatically mount the partition at boot time, you need to add the following line to /etc/fstab:

[root@hogwarts /]# pico /etc/fstab
/dev/hdc1 /mnt/bigdisk ext3 usrquota,grpquota 1 2

Make sure you end this line with a newline. Hit <ctrl-x> to exit the editor

 

Check if everything works as expected:

[root@hogwarts /]# mount -a

[root@hogwarts /]# df -T

Filesystem

Type

1k-blocks

Used

Available

Use%

Mounted on

/dev/hda3

ext3

39151724

28441348

8721532

77%

/

/dev/hda1

ext3

101089

8953

86917

10%

/boot

/dev/hdc1

ext3

38474956

27948

38447008

0%

/mnt/bigdisk

 

If you don't see a line for /dev/hdc1, something went wrong. Go back to step 2 and check if you followed all instructions correctly.


Step 6 ( Optional): Use /home to mount the new disk

On standard Linux machines, the /home directory contains the user's directories and is therefore a popular place to mount a bigger disk. However, on a SME server this is not a good idea:

  1. SME stores all its configuration files in /home/e-smith/db. If for whatever reason your disk doesn't mount, the configuration files will no longer be accessible, causing all kinds of nasty problems.
  2. Mounting your second disk to /home or even /home/e-smith/files effectively means that your first disk will no longer be used to store user files. In some cases that might be a good idea, but in most cases you are just wasting the remaining space of your first disk.

A much better approach is to leave the second disk mounted at /mnt/bigdisk and to create symlinks for specific ibays or user folders. The following example shows you how to place the mp3 ibay on the second disk.

1/ Create the necessary subdirectories on your second disk

[root@hogwarts /]# mkdir -p /mnt/bigdisk/ibays/mp3


2/ Apply the ownerships and permissions from the original directory
[root@hogwarts /]# ls -l /home/e-smith/files/ibays
drwxrwxr-x 18 admin allstaff 4096 Sep 23 14:48 mp3

[root@hogwarts /]# chown admin:allstaff /mnt/bigdisk/ibays/mp3
[root@hogwarts /]# chmod 775 /mnt/bigdisk/ibays/mp3

3/ Copy the content to your new disk
[root@hogwarts /]# cp -rip /home/e-smith/files/ibays/mp3/* /mnt/bigdisk/ibays/mp3

4/ Check if all files have been copied correctly
[root@hogwarts /]# diff -r /mnt/bigdisk/ibays/mp3 /home/e-smith/files/ibays/mp3

5/ Remove the original files
[root@hogwarts /]# rm -rf /home/e-smith/files/ibays/mp3

6/ Create a symlink to the new location
[root@hogwarts /]# ln -s /mnt/bigdisk/ibays/mp3 /home/e-smith/files/mp3

7/ Test the new location

[root@hogwarts /]# ls /home/e-smith/files/ibays/mp3


8/ If you want the ibay to be accessible from the internet, you also need to enable "follow symlinks" in apache

[root@hogwarts /]# mkdir -p /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf

[root@hogwarts /]# echo Options FollowSymLinks >> /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/85DefaultAccess

[root@hogwarts /]# /sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf

[root@hogwarts /]# /etc/init.d/httpd graceful


Step 7( Optional): Activate the quota 

Next you might want to activate the quota on the disk. This will only work if you activated quota management for at least one user (Server Manager > Collaboration > Quota Management).

[root@hogwarts /]# quotacheck -vugc /dev/hdc1

 

If quotachecks comes back to the command prompt without errors, you're ready.


Step 8: Final check

Reboot your machine and check if the drive was mounted correctly. If that's the case, relax and tell the world about it:

[root@hogwarts /]# wall 'I did it! I did it!  ;-) '