User Tools

Site Tools


linux:sysadmin:storage_management

Storage management

For disk usage commands see disk_usage.

Logical Volume Management (lvm2)

For Logical Volume Management see:

Extend a virtual machines disk on locical volume

  1. Extend the the virtual disk on your hypervisor
  2. create a new partition with fdisk using the free space available (new primary partition)
    fdisk /dev/sda
    1. Press p to print the partition table to identify the number of partitions. By default there are 2: sda1 and sda2.
    2. Press n to create a new primary partition.
    3. Press p for primary.
    4. Press 3 for the partition number, depending the output of the partition table print.
    5. Press Enter two times.
    6. Press w to write the changes to the partition table.
  3. Reboot the virtual machine ⇒ /dev/sda3 should be visible
  4. Convert sda3 to a physical volume:
    pvcreate /dev/sda3
  5. Extend the existing logical volume:
    vgextend VolGroup00 /dev/sda3
  6. Run this command to see the available free space:
    vgdisplay VolGroup00 | grep "Free"
  7. Extend the logical volume
    lvextend -L+#G /dev/VolGroup00/LogVol00
  8. Finally extend your file system:
    resize2fs /dev/VolGroup00/LogVol00
  9. You should see the additional space available:
    df -h

The mount / umount command

Example for mounting a 2nd scsi disk:

mount -t ext3 /dev/sdb5 /db

Unmount the drive:

umount /db

Configure a newly attached disk

Steps to follow after new scsi disk has been attached (/dev/sdb)

  • fdisk /dev/sdb
  • n (new partition)
  • e (extended)
  • accept defaults…
  • p (see partition table)
  • n (new partition)
  • l (logical)
  • accept defaults
  • p (see partition table and check entries)
  • w (write partition table)
  • q (quit)
  • mkfs -t ext3 /dev/hdb5
  • mkdir /db
  • mount -t ext3 /dev/hdb5 /db
  • /etc/fstab: enter ⇒ /dev/hdb5 /db ext3 defaults 1 2

Swap Space

Simple rule about how much swap space is needed on a server:

M = Amount of RAM in GB, and S = Amount of swap in GB, then
 
If M < 2
 S = M *2
Else
 S = M + 2

Example:

RAM = 4GB ⇒ Recommended Swap Space = 6GB (4 + 2)

Mount Shared Storage over NFS

Make sure the portmap service is started:

 service portmap start

Start portmap during every server startup:

chkconfig portmap on

Make a new entry in /etc/fstab:

# Managed Storage Mount
10.130.46.19:/vol/NoSnap/example.com     /mnt/nas nfs     defaults  0 0

Mount the NAS drive:

mount -t nfs 10.130.46.19:/vol/NoSnap/example.com /mnt/nas
If you use NFS storage on a server, make sure the nfslock deamon is running!
service nfslock status
rpc.statd (pid 3007) is running...

Mount a windows share (cifs / samba)

First you have to create a directory for mounting your drive. As example:

mkdir /mnt/samba/

Mount the windows drive with username and password credentials:

mount.cifs //server1.example.net/backup/server003 /mnt/samba/ -o username=TEL-NAS,password=secret

Alternatively, you can store your credentials in a text file. Create a text file with the following content:

username=TEL-NAS
password=secret

Now you can reverence the file holding the credentials during the mount command:

mount.cifs //server1.example.net/backup/server003 /mnt/samba/ -o credentials=/root/tel-nas.crd
/srv/wiki.niwos.com/data/pages/linux/sysadmin/storage_management.txt · Last modified: 2011/03/18 17:47 (external edit)