Disk Management:
command to display disk name including existing partitions : “ fdisk –l ”
The o/p displays the hard disk name as “ sda ” , “ sdb ” , “ hda ” , “ hdb ”
We can have 4 primary partitions, The 4th will be extended
Steps to create a partition:
1. Make a new Partition with required amount os size on mb
2. format the partition by making file system
3. create a directory
4. mount the partition onto the directory
5. make the partition permanent
1. Make a new Partition with required amount os size on mb
# fdisk /dev/sda
o/p: it asks for an option
enter “ n ” for a new partition
o/p: it asks for size in cylinders : press enter
then it asks for size in mb’s : +500M (means assigning 500mb)
give option “ w ” and press enter to save & quit, then restart
the system or run command: “ partprobe ”
2. format the partition by making file system
# mkfs -t <file-system:ext2/ext3> <partition-name:/dev/sda6>
3. create a directory
# mkdir /<directory-name(/test)>
4. mount the partition onto the directory
# mount <partition-name> <directory-name> ”
5. make the partition permanent
edit file “ /etc/fstab ” and enter the details(5 fields) of new partition
# vi /etc/fstab
<partition-name> <directory-name> <file-system> <permissions>
<dump-frequency> <fsck order>
/dev/sda6
0
/test
0
ext2
defaults
save & quit the file, and run the command: “ mount –a”
Note: 1. Primary partitions are the parttions created, extended is the memory
remained after partitions
2. Memory should be given given in mb’s not in cylinders, because
memory in cylinders is not read
3. After creating a new partition, system should be restarted, partprobe
command should only be used in case if
working online and not in a state to restart the system
4. In windows we run file systems like NTFS or FAT, here in LINUX the
file systems used are ext1, ext2, ext3, ext4
5. Run “ mount –a ” command just to confirm the details entered to file “ /
etc/fstab ” are correct, if any spelling
mistakes or mismatches it outputs error message
LVM(Logical Volume Manager):
Create LVM:1.Create 2 new partitions
after assigning sizes to each partition it asks for an option
enter “ t ” to change the partition id
enter “ L ” to list the codes & enter “ 8e ”(for LVM) for
both partitions saperately and then
save & quit by entering “ w ”
2. convert the both partitions to physical volumes
# pvcreate /dev/sda9 /dev/sda10
3. create the volume group
# vgcreate vg1 /dev/sda9 /dev/sda10
4. command to create RAID:
# lvcreate -L +800M -n lvm1 vg1
5. format the partition by making file system
# mkfs -t ext3 dev/vg1/lvm1
6. create a directory
# mkdir /lvms
7. mount the partition onto the directory
# mount dev/vg1/lvm1 /lvms
8. make the partition permanent
edit file “ /etc/fstab ” and enter the details(5 fields) of
new partition
# vi /etc/fstab
/dev/vg1/lvm1
/lvms
ext2
defaults
1 3
save & quit the file, and run the command: “ mount –a”
To display the existing LVM’s, VG’s, PV’s details
To display LVM details and its attributes
# lvdisplay
# lvs
To display Volume Group details and its attributes
# vgdisplay
# vgs
To display Physical Volume details and its attributes
# pvdisplay
# pvs
Extension of Volume Group by adding a new Physical Volume
# vgextend vg1 /dev/sda11
Extension of logical volume manager:
# lvextend –L+100M /dev/vg1/lvm1
# resize2fs /dev/vg1/lvm1 (to make it permanent)
To reduce the size of logical volume:
# mkdir /backup create a directory
# cd /lvms entering the directory
# cp -rpf * /backup taking backup
# umount /lvms to unmount the partition
# Lvreduce –L-100M /dev/vg1/lvm1
# mkfs -t ext3 /dev/vg1/lvm1 make file system again
# mount –a again mount
# cd /backup
# cp -rpf * /lvms get back the data to lvms
To remove physical Volume, Volume Groups, LVM:
First we need to remove LVM and then Volume Group and then Physical
Volume
# lvremove /dev/vg1/lvm1
# vgremove vg1
# pvremove /dev/sda9 /dev/sda10 /dev/sda11
Edit “ /etc/fstab ” file and delete the entries of LVM
Note:
While extending the lvm we are modifying the partition externally so it wont
corrupt data, while reducing the lvm, we are modifying the partition internally,
it may corrupt data, so take the backup of data and unmount the directory and
reduce lvm, later format the file system and mount it back, check the mount
points by running command “ mount ”
RAID(Redundant Array of Inexpensive Disk):
RAID helps to protect data against file/disk corruptions
Create RAID (Implementing raid1):
1.Create 2 new partitions with equal size(equal size mandatory)
after assigning sizes to each partition it asks for an option enter “ t ” to change
the partition id enter “ L ” to list the codes & enter “ fd ”(for RAID) for both
partitions saperately and then
save & quit by entering “ w ”
2. command to create RAID:
# mdadm --create <raid-name:/dev/md0> --level=1 --raid-
devices=2 <raid-partition:/dev/sda7> <raid-partition:/dev/sda8>
3. format the partition by making file system
# mkfs -t <file-system:ext2/ext3> <partition-name:/dev/md0>
4. create a directory
# mkdir /<directory-name(/raid)>
5. mount the partition onto the directory
# mount <partition-name:/dev/md0> <directory-name:/raid>
6. make the partition permanent
edit file “ /etc/fstab ” and enter the details(5 fields) of new partition
# vi /etc/fstab
/dev/md0
/raid
ext2
defaults
1 3
save & quit the file, and run the command: “ mount –a ”
Note:
In RAID we have six different raid levels raid0-raid6, for raid0 & raid1 we
need to have only two hard disks, whereas for raid2 to raid6 we can have more
than two hard disks
To display existing raid devices:
# mdadm --detail /dev/md0
Deleting raid device:
-Stop the array of raid device which is created which is in running mode
# mdadm -S /dev/md0
-Remove the Device and Array entry’s associated with the array from file
“ /etc/mdadm.conf ”
-Remove the array from file “ /etc/fstab ”
No comments:
Post a Comment