While I do not frequently have the need to create or extend logical volumes, I find that every time I do I need to lookup the commands. To make it easier for myself and others, I have decided to put together the commands I frequently run.
UPDATE: Added some more information and broke it down into a two step process.
1. Disk
a. DisksĀ less than 2 TB
# 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-621, default 1): <RETURN> Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-621, default 621): <RETURN> Command (m for help): t Hex code (type L to list codes): 8e Changed system type of partition 2 to 8e (Unknown) Command (m for help): w The partition table has been altered!
NOTE: You can join multiple disksĀ that are less than 2TB together instead of using a larger disk.
b. Disks greater than 2 TB
# parted /dev/sdb GNU Parted 2.3 Using /dev/sdb Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) mklabel gpt (parted) mkpart primary 0 -0 (parted) quit # parted /dev/sdc GNU Parted 2.3 Using /dev/sdc Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) mklabel gpt (parted) mkpart primary 0 -0 (parted) quit
2. Volumes
a. Create volumes
# pvcreate /dev/sdb1 # vgcreate lvm_vg /dev/sdb1 # vgextend lvm_vg /dev/sdc1 # note: only needed as adding another disk to the same LVM # lvcreate -L 4096G --name data lvm_lv # mke2fs -t ext3 -L /data /dev/lvm_vg/lvm_lv # mkdir /data # mount /dev/lvm_vg/lvm_lv /data
b. Extend volumes
# lvextend -L+ /dev/lvm_vg/lvm_lv # note: only needed if adding another disk AFTER a LV has been created, since vgextend is run previously this command is not needed # umount /dev/lvm_vg/lvm_lv # resize2fs /dev/lvm_vg/lvm_lv
NOTE: I find that using -L with a size often fails and -l with extents works better. You can use vgdisplay to find out how many extents you have available to use.
Windows
Looking for similar directions for Windows? See this post by Michael White.
© 2014, Steve Flanders. All rights reserved.