Most of the time we used to get the task for creating the New Logical Volume in Redhat Linux. Here is the Step by step procedure for adding the disk into Linux Server. Let we can start with our high level plan.
High Level Plan:
1. Identify the New Disk.
2. Create a Physical volume.
3. Create a Volume group.
4. Create a Logical volume.
5. Create a Filesystem on the Logical Volume.
6. Create a Mountpoint and Mount the Logical Volume.
7. Add the entry in /etc/fstab for presist mount.
Checking the currently available disk with using fdisk command
[root@unixrock /]# fdisk -l Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000d0e67 Device Boot Start End Blocks Id System /dev/sda1 * 1 39 307200 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 39 549 4096000 82 Linux swap / Solaris Partition 2 does not end on cylinder boundary. /dev/sda3 549 2611 16567296 83 Linux Disk /dev/mapper/vg01-LVOL1: 25 MB, 25165824 bytes 255 heads, 63 sectors/track, 3 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 [root@unixrock /]#Before Scanning disks we can check the available host scsi connection
[root@unixrock ~]# cat /proc/scsi/scsi Attached devices: Host: scsi1 Channel: 00 Id: 00 Lun: 00 Vendor: NECVMWar Model: VMware IDE CDR10 Rev: 1.00 Type: CD-ROM ANSI SCSI revision: 05 Host: scsi2 Channel: 00 Id: 00 Lun: 00 Vendor: VMware, Model: VMware Virtual S Rev: 1.0 Type: Direct-Access ANSI SCSI revision: 02 [root@unixrock ~]#from the above output we can see 2 Host scsi connection (One is CDROM, another one is Disk) are present respectively. Now Scanning the new disk
[root@unixrock ~]# echo "- - -" >/sys/class/scsi_host/host2/scan [root@unixrock ~]#scanned "host2" according to the "cat /proc/scsi/scsi" output. Checking new disk availability.
[root@unixrock /]# fdisk -l Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000d0e67 Device Boot Start End Blocks Id System /dev/sda1 * 1 39 307200 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 39 549 4096000 82 Linux swap / Solaris Partition 2 does not end on cylinder boundary. /dev/sda3 549 2611 16567296 83 Linux Disk /dev/mapper/vg01-LVOL1: 25 MB, 25165824 bytes 255 heads, 63 sectors/track, 3 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/sdb: 234 MB, 234881024 bytes 8 heads, 56 sectors/track, 1024 cylinders Units = cylinders of 448 * 512 = 229376 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x8cb5a280 Device Boot Start End Blocks Id System /dev/sdb1 1 100 22372 83 Linux Disk /dev/sde: 234 MB, 234881024 bytes 8 heads, 56 sectors/track, 1024 cylinders Units = cylinders of 448 * 512 = 229376 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x2d576e29 Device Boot Start End Blocks Id System /dev/sde1 1 100 22372 83 Linux [root@unixrock /]#Now we can see 2 Newdisks (/dev/sdb;/dev/sde) has been added. let we can start working on LVM part
[root@unixrock ~]# pvcreate /dev/sdb1 Writing physical volume data to disk "/dev/sdb1" Physical volume "/dev/sdb1" successfully created [root@unixrock ~]# [root@unixrock ~]# pvs PV VG Fmt Attr PSize PFree /dev/sdb1 lvm2 a-- 21.85m 21.85m [root@unixrock ~]#Creating new Volume group
[root@unixrock ~]# vgcreate vg01 /dev/sdb1 Volume group "vg01" successfully created [root@unixrock ~]# [root@unixrock ~]# vgs VG #PV #LV #SN Attr VSize VFree vg01 1 0 0 wz--n- 20.00m 20.00m [root@unixrock ~]#Creating Logical Volume
[root@unixrock ~]# lvcreate -L 10M -n LVOL1 vg01 Rounding up size to full physical extent 12.00 MiB Logical volume "LVOL1" created [root@unixrock ~]#Creating New Filesystem
[root@unixrock ~]# mkfs.ext4 /dev/vg01/LVOL1 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 3072 inodes, 12288 blocks 614 blocks (5.00%) reserved for the super user First data block=1 Maximum filesystem blocks=12582912 2 block groups 8192 blocks per group, 8192 fragments per group 1536 inodes per group Superblock backups stored on blocks: 8193 Writing inode tables: done Creating journal (1024 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 28 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@unixrock ~]#Creating Mount point and mounting the logical Volume.
[root@unixrock ~]# mkdir /LVOL1_mnt [root@unixrock ~]# mount /dev/vg01/LVOL1 /LVOL1_mnt [root@unixrock ~]# [root@unixrock ~]# df -h /LVOL1_mnt Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg01-LVOL1 12M 1.2M 10M 11% /LVOL1_mnt [root@unixrock ~]#Cool...!!!! We have successfully get the newdisk into LVM control.
No comments:
Post a Comment