Tuesday, October 14, 2014

formatting disks under linux (redhat flavor)


for host in `ls /sys/class/scsi_host`; do echo ""- - -" >/sys/class/scsi_host/$host/scan"; done

#!/bin/bash

for i in b c d e f; do
  if [ -b /dev/sd${i} ]; then
    echo "/dev/sd${i} is present.  Continuing....
  else
    exit 1
  fi
done
echo "Continuing with fdisk to create LVM Partitions"
echo "Press Ctrl+c to break out of the script"
sleep 5
for o in b c d e f; do
  fdisk /dev/sd$o << EOF
n
p
1

t
8e
w
EOF
done
fdisk -l /dev/sd$o
fdisk /dev/sdg << EOF
n
p
1

t
8e
w
EOF
fdisk -l /dev/sdg
partprobe /dev/sd$o


=================


#!/bin/bash
for i in b c d e f; do
  if [ -b /dev/sd${i} ]; then
    echo "/dev/sd${i} is present.  Continuing...."
    sleep 2
    (echo n; echo p; echo 1; echo 1;echo ;echo t; echo 8e;echo w) | fdisk /dev/sd${i}
  else
    exit 1
  fi
done

echo "Please enter a disk that you want to format"

#!/bin/ksh
#Create a single primary partiton with whole disk size and create LVM PV on it
disk=$1
partno=1
if [[ -z $disk ]]; then
   echo "Usage: $0 disk device name: e.g $0 /dev/sdb"
   exit
fi 
if [[ -e ${disk}${partno} ]]; then
   echo "==> ${disk}${partno} already exist"
   exit
fi

(echo n; echo p; echo 1; echo 1;echo ;echo t; echo 8e;echo w) | fdisk $disk

echo "==> create primary parition  $partno with $ncyl cylinders"
parted -a optimal $disk mkpart primary 0cyl ${ncyl}cyl
echo "==> set partition $partno to type: lvm "
parted $disk set $partno lvm on
partprobe > /dev/null 2>&1
echo "==> create PV ${disk}${partno} "
pvcreate ${disk}${partno}


#!/bin/sh
echo " Please enter the disk you like to partition"
read disk1 disk2 disk3 disk4 disk5 disk6 disk7
isslice=1
if [[ -z $disk


#!/bin/sh

echo "Please enter disk partition followed by space to create physical volume. eg: sdb1 sdb1 sdc1"
read a b c d d e f g h
pvcreate /dev/$a /dev/$b /dev/$c /dev/$d /dev/$e /dev/$f /dev/$g /dev/$h
echo "following confirms the pv is created"
pvs

echo "enter the size followed by the LV and VG name to create the  logical volume "
read a b c
lvcreate -L $a -n $b /dev/$c
echo "following confirms the logical volume is created"
lvs


echo "Please ensure the associated filesystem is unmounted before resize "
echo "enter the new size for lv followed by the vg and lv name and new size for filesystem for the resize operation "
echo "please be informed that during the resize operation filesystem consistency will be checked"
read a b c d
lvresize -L $a /dev/$b/$c ; e2fsck -f /dev/$b/$c ; resize2fs /dev/$b/$c $d
echo "following confirms the logical volume is resized"
lvs

#!/bin/ksh
# Create a single primary partiton with whole disk size and create LVM PV on it
disk=$1
partno=1
if [[ -z $disk ]]; then
echo "Usage: $0 disk device name: e.g $0 /dev/sdb"
exit
fi 
if [[ -e ${disk}${partno} ]]; then
echo "==> ${disk}${partno} already exist"
exit
fi

No comments:

Post a Comment