Linux note0x01

  • 2017-12-24
  • 135
  • 0




  1. RAID0

RAID0 splits (“stripes”) data evenly across two or more disks, without parity information, redundancy, or fault tolerance.


  1. RAID1

RAID 1 consists of an exact copy (or mirror) of a set of data on two or more disks; a classic RAID 1 mirrored pair contains two disks.


  1. RAID5

RAID 5 consists of block-level striping with distributed parity. Unlike in RAID 4, parity information is distributed among the drives. It requires that all drives but one be present to operate. Upon failure of a single drive, subsequent reads can be calculated from the distributed parity such that no data is lost. RAID 5 requires at least three disks


  1. RAID1+0

RAID 01, also called RAID 0+1, is a RAID level using a mirror of stripes, achieving both replication and sharing of data between disks.


Mdadm command

Example: RAID1+0

  • mdadm -Cv /dev/md0 -a yes -n 4 -l 10 /dev/sdb /dev/sdc /dev/sdd /dev/sde
    • C create a RAID card

    • v verbose, display the process

    • a automanticly create dev file

    • n number of use disk

    • l plan 10 means RAID1+0

  • formatting: mkfs.ext4 /dev/md0

  • mkdir /RAID & mount /dev/md0 /RAID & df -h

  • mdadm -D /dev/md0 view the detail info

Damage to Disk Array & Repair

  1. Simulate dev damage: mdadm /dev/md0 -f /dev/sdb

  2. RAID 1+0: It will not be effected if only one RAID disk failed. Just use mdadm to replace it.

    • umount /RAID every operation about raid umount first

    • madam /dev/md0 -a /dev/sdb add new /dev/sdb

  3. Disk Array + backup-disk

Extrame:Both of disk from RAID 1 were damaged.

Solution: backup-disk

mdadm -Cv /dev/md0 -n 3 -l 5 -x 1 /dev/sdb /dev/sdc /dev/sdd /dev/sde
– x backup-disk /dev/sde

LVM: Logical Volume Manager

Note: extend or shrink volume




  1. support /sdb & /sdc with lvm pvcreate /dev/sdb /dev/sdc

  2. Add both of them into storage and check them vgcreate storage /dev/sdb /dev/sdc & vgdisplay

  3. split a logical volume dev about 150MB size lvcreate -n vo -l 37 storage & lvdisplay

  4. formatting and mount it to use. mkdfs.ext4 /dev/storage/vo & mount /dev/storage/vo /mountDir

  5. check info and make it effect permantly echo "/dev/storage/vo /mountDir ext4 defaults 0 0" >> /etc/fstab

Extend logical volume

  1. umount /mountDir before extend umount it

  2. lvextend -L 290M /dev/storgage/vo extend it to 290MB

  3. Check disk intergrity e2fsck -f /dev/storage/vo

  4. Resize disk resize2fs /dev/storage/vo

  5. Remount and df -h

Shrink logical volume

  1. umount /mountDir before shrink umount it

  2. e2fsck -f /dev/storage/vo check sys intergrity

  3. resize2fs /dev/storage/vo 120M shrink it to 120MB

  4. Remount mount -a & df -h


  1. View volume group vgdisplay

  2. lvcreate -L 120M -s -n SNAP /dev/storage/vo

    • s:create a snap group

    • L: size

  3. Do something…

  4. umount /mountDir & lvconvert --merge /dev/storage/SNAP Recover operation(will be deleted after that)

LVM Delete

  1. umount /mountDir & vim /etc/fstab

  2. lvremove /dev/storage/vo delete logical dev

  3. vgremove storage delete volume group

  4. pvremove /dev/sdb /dev/sdc delete physics group dev