Table of Contents

Disk, RAID, and LVM Howtos

The following related topics are roughly in the order that one would normally utilize them.

Device / Hard Drive Info

It is important to understand that unix calls hard drives ‘devices’. Many other things besides HDDs can be ‘devices’ also. They are ussually listed as special files located at:

Filesystem Info

fdisk /dev/sda  - plain text partition interface
fdisk -l        - list all partitions on all devices
cfdisk /dev/sdb - n-curses partition interface

mke2fs /dev/sdb1    - makes file system on partition sdb1
mkfs.ext3 /dev/sdb1 - ditto, does the same thing

mount
umount
resize2fs
ext2resize
e2fsadm

Normal order when adding a single disk:
pvcreate, vgcreate, lvcreate, mkfs.ext3, mount, df

See the following page if you have problems after executing some of the above commands and run into boot problems.

Examples

sudo mkfs -V -t ntfs /dev/sdd5     ; Makes/formats the NTFS filesystem on the existing partition sdd5

RAID5 Create New Howto

To create a software raid1 or raid5, for example, they are all very similar and involve the same pre and post process. Below shows how to create a raid5 with a non-boot empty-starting one-big-filesystem setup.

General Steps

  1. Determine installed devices (/dev/hd* or /dev/sd*)
  2. Format/Partition installed devices (cfdisk /dev/sda)
  3. Create RAID device with mdadm (mdadm –create ...)
  4. Create filesystem on RAID device (mkfs.ext3 ...)
  5. Mount filesystem (mount ...)
  6. Add to fstab file (nano /etc/fstab)

Commands

After its up

Existing RAID5 Mount Howto

I had already done the create of an array from above and was moving the array to a new Ubuntu Linux machine and just needed to get it going again. Most steps are similar to the create above. Mostly the first mdadm command is different.

LVM Info

http://tldp.org/HOWTO/LVM-HOWTO/index.html

+-- Volume Group --------------------------------+
|                                                |
|    +----------------------------------------+	 |
| PV | PE |  PE | PE | PE | PE | PE | PE | PE |	 |
|    +----------------------------------------+	 |
|      .       	  .    	     . 	      .	       	 |
|      .          .    	     .        .	         |
|    +----------------------------------------+	 |
| LV | LE |  LE | LE | LE | LE | LE | LE | LE |	 |
|    +----------------------------------------+	 |
|            .          .        .     	   .     |
|            . 	        .        .     	   .     |
|    +----------------------------------------+	 |
| PV | PE |  PE | PE | PE | PE | PE | PE | PE |	 |
|    +----------------------------------------+	 |
|                                                |
+------------------------------------------------+

get the current layout of your disks

pvscan                     ; physical volume scan, shows your hard drives
df -h                      ; disk file structure, shows usage of filesystems; h means human readable
du -hs <dir>               ; disk usage of a directory; h means human readable; s means summarize, dont show sub directories
dd                         ; device duplicate; copies or makes new files ; works with devices on block level;  can copy entire disks bitwise, can make test / fake files

common disk utilities

pvdisplay, vgdisplay, lvdisplay
pvcreate,  vgcreate,  lvcreate
pvchange,  vgchange,  lvchange
pvremove,  vgremove,  lvremove
pvmove,
           vgextend,  lvextend
           vgreduce,  lvreduce
           vgexport
           vgimport
           vgsplit