Create and manage logical volumes in Linux

Source: Internet
Author: User
Tags hex code

In Linux, add a hard disk to the Virtual Machine for logical volume creation and management, and view the hard disk status. Run the fdisk-l command: [root @ jerrybj ~] # Fdisk-l Disk/dev/sda: 21.4 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065*512 = 8225280 bytes Device Boot Start End Blocks Id System/dev/sda1 * 1 13 104391 83 Linux/dev/sda2 14 2610 20860402 + 8e Linux LVM disk/dev/sdb: 34.3 GB, 34359738368 bytes 255 heads, 63 sectors/track, 4177 cylinders Units = cylinders of 16065*512 = 8225280 bytes Disk/d Ev/sdb doesn' t contain a valid partition table where/dev/sdb is newly added and will be used as a logical volume later. Next, add partition: [root @ jerrybj ~] # Fdisk/dev/sdb Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4 ): 1 First cylinder (1-4177, default 1): Using default value 1 Last cylinder or + size or + sizeM or + sizeK (1-4177, default4177 ): using default value 4177 Command (m for help): p Disk/dev/sdb: 34.3 GB, 34359738368 bytes 255 heads, 63 sectors/track, 4177 cylinders Units = cylinders 16065*512 = 8225280 bytes Device Boot Start End Blocks Id System/dev/sdb1 1 4177 33551721 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl () to re-read partition table. Syncing disks. Now I divide the linux type into the LinuxLVM type. [Root @ jerrybj ~] # Fdisk/dev/sdb Command (m for help): t Hex code (type L to list codes): L... Hex code (type L to list codes): 8e Changed system type of partition 1 to 8e (Linux LVM) Command (m for help ): create pv, vg, and lv under w [root @ jerrybj ~] # Pv pvchange pvcreate pvmove pvresize pvscan pvck pvdisplay pvremove pvs pv. sh [root @ jerrybj ~] # Pvcreate/dev/sdb1 Physical volume "/dev/sdb1" successfully created and create vg [root @ jerrybj ~] # Vg kernel vgconvert vgextend kernel vgs kernel vgcreate vgimport vgreduce vgscan vgchange vgdisplay vgimportclone vgremove vgsplit vgck vgexport vgmerge vgrename [root @ jerrybj ~] # Vgcreate datavg/dev/sdb1 Volume group "datavg" successfully created create lv [root @ jerrybj ~] # Lv lvchange lvdisplay lvmchange lvmsadc lvreduce lvresize lvconvert lvextend lvmdiskscan lvmsar lvremove lvs lvcreate lvm lvmdump lvm. static lvrename lvscan [root @ jerrybj ~] # Lvcreate-n lv_data1-L 15g datavg Logical volume "lv_data1" created [root @ jerrybj ~] # Lvcreate-n lv_dsk1-L 4g datavg Logical volume "lv_dsk1" created [root @ jerrybj ~] # Lvcreate-n lv_dsk2-L 4g datavg Logical volume "lv_dsk2" created [root @ jerrybj ~] # Lvcreate-n lv_dsk3-L 4g datavg Logical volume "lv_dsk3" created [root @ jerrybj ~] # Lvcreate-n lv_dsk4-L 4g datavg Logical volume "lv_dsk4" created next format: [root @ jerrybj ~] # Mkfs. ext3/dev/datavg/lv_data1 [root @ jerrybj ~] # Mkfs. ext3/dev/datavg/lv_dsk1 [root @ jerrybj ~] # Mkfs. ext3/dev/datavg/lv_dsk2 [root @ jerrybj ~] # Mkfs. ext3/dev/datavg/lv_dsk3 [root @ jerrybj ~] # Create a directory under mkfs. ext3/dev/datavg/lv_dsk4: [root @ jerrybj ~] # Mount mkdir/u01/dsk1/dsk2/dsk3/dsk4 at startup: [root @ jerrybj ~] # Add the following content to the end of vi/etc/fstab: /dev/datavg/lv_data1/u01 ext3 defaults 0 0/dev/datavg/lv_dsk1/dsk1 ext3 defaults 0 0 0/dev/datavg/lv_dsk2/dsk2 ext3 defaults 0 0/dev/datavg /lv_dsk3/dsk3 ext3 defaults 0 0/dev/datavg/lv_dsk4/dsk4 ext3 defaults 0 0 [root @ jerrybj ~] # Mount/u01 [root @ jerrybj ~] # Mount/dsk1 [root @ jerrybj ~] # Mount/dsk2 [root @ jerrybj ~] # Mount/dsk3 [root @ jerrybj ~] # Mount/dsk4 success!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.