Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have two SATA hard-disk drives attached to my server as shown in the following :

[root@cl-185 /]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             222G  166G   45G  79% /
tmpfs                 2.0G     0  2.0G   0% /dev/shm

[root@cl-185 /]# fdisk -l | grep Disk
Disk /dev/sda: 250.0 GB, 250000000000 bytes
Disk /dev/sdb: 2000.3 GB, 2000398934016 bytes

Now, being a linux noob I need help on two questions :

1). Why only 'sda1' is shown when using df -h to get disk space usage, and what else needs to be done to check stats for 'sdb' ?

2). My PHP script needs to save a lot of 'cache' files, how to make the script use the second disk for saving the files - I mean what path should I edit in my script (current is '/var/www/html/tmp') ?

Thanks

share|improve this question

migrated from serverfault.com May 10 '11 at 13:09

This question came from our site for professional system and network administrators.

add comment

2 Answers 2

up vote 4 down vote accepted

You need to mount sdb to a mountpoint first, then configure your script to use a path within that mountpoint.

I.e. if you mount /dev/sdb1 to "/var/storage", you could create the folder "/var/storage/cache" and use that path for your php script.

Briefly:
$ mkdir /var/storage
$ mount /dev/sdb1 /var/storage
$ mkdir /var/storage/cache

Unfortunately, this assumes the drive has a filesystem and is configured in fstab. For more detailed information about setting up a brand new disk, you should probably look up the relevant section in the installation documentation for your distro, but the gist of it is:

  • Create a partition on sdb with fdisk

  • Create a filesystem on the partition (for example with "mke2fs -j /dev/sdb1")

  • Edit /etc/fstab and add a line matching the partition and filesystem, something like: "/dev/sdb1 /var/storage ext3 noatime 0 1"

share|improve this answer
    
Thanks, can you pls. provide an example on how to do this. –  DeepeshAgarwal May 9 '11 at 7:51
    
Sure, do you know if sdb has a filesystem (has it ever been mounted?) –  Tzarium May 9 '11 at 8:27
    
Thanks, got things working with help of your answer and some googleing :) –  DeepeshAgarwal May 10 '11 at 17:33
add comment

Caching checklist:

If the cache files' total size is less than the amount of system RAM that can be spared, then use /dev/shm as a cache directory. (/dev/shm is a great secret and should exist automatically on your system.) It will avoid the extra latency of making trips to the disk. It can be made persistent by backing up on shutdown and restoring on boot up, (best to make an init script to run before and after httpd)

If the total size will be less than a few tens of GB then use an SSD.

If still not enough, then use two SSDs configured as a RAID0 stripeset.

If the file storage is massive, only then use traditional drives.

If the files are valuable, then use RAID1 or RAID10

If you have lots of small files and need a deep tree for image/thumbnails storage, then use the Reiser file system as it is the best for fast directory traversal and small files.

mkfs -t reiserfs /dev/sdb1

(and mount using noatime.)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.