Using pvscan, vgscan and lvscan
I'm extremely poor, so if this helped you in any way and you have some spare BitCoins, you may donate them to me - 16tb2Rgn4uDptrEuR94BkhQAZNgfoMj3ugUsing Linux LV makes a lot of sense, easy to maintain, easy to grow.
The machine in question has 8 x 600GB drives
What I would normally do it to setup hardware RAID 1+0 on a bunch of disks, in the case below, the 1st 2 disks are setup as RAID 1+0, /dev/sda, this disk is used for the OS install, the left over space on the /dev/sda was used to create /dev/sda3, IE created the 3rd partition to be used as a PV, VG and LV
The 2nd disk /dev/sdb is setup as RAID 1+0 as well, this disk consist of 2 x 600GB drives, partition 3, /dev/sdb3 was also created for use as a PV, VG and LV
The 3rd disk /dev/sdc is setup as RAID 1+0 as well, this disk consist of 4 x 600GB drives, partition 3, /dev/sdc3 was also created for use as a PV, VG and LV
I can hear you saying, why the hell is he using RAID 1+0, he is loosing halve the available space. The reason for this is that the server is a high availability Telcom grade server, so redundancy etc is vital
To check what you have, use hwinfo
Ninja141:~ # hwinfo --disk --short disk: /dev/sdb HP LOGICAL VOLUME /dev/sdc HP LOGICAL VOLUME /dev/sda HP LOGICAL VOLUME Ninja141:~ #
Let's do /dev/sda 1st, I have already set up partition 3 as can be seen below
Ninja141:~ # fdisk -l /dev/sda Disk /dev/sda: 600.1 GB, 600093712384 bytes 255 heads, 63 sectors/track, 72957 cylinders, total 1172058032 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 262144 bytes / 262144 bytes Disk identifier: 0x00012b9b Device Boot Start End Blocks Id System /dev/sda1 * 512 1060351 529920 83 Linux /dev/sda2 1060352 147862015 73400832 8e Linux LVM /dev/sda3 147862016 1172058031 512098008 8e Linux LVM Ninja141:~ #
Partition 1 /dev/sda1 and partition 2 /dev/sda2 are being used for the OS, partition 3 /dev/sda3 was created as follow
fdisk /dev/sda n - Create p3 p - Primary Extension t - Set to 8e w - Remember to write fdisk /dev/sdb n - Create p3 p - Primary Extension t - Set to 8e w - Remember to write fdisk /dev/sdc n - Create p3 p - Primary Extension t - Set to 8e w - Remember to write
Do partprobe afterwards to sync the changes
Ninja141:~ # partprobe
Create the PVs (Physical Volumes) and VGs (Volume Groups)
pvcreate -ff -y /dev/sda3 pvcreate -ff -y /dev/sdb3
pvcreate -ff -y /dev/sdc3 vgcreate disk0 /dev/sda3 vgcreate disk1 /dev/sdb3
vgcreate disk2 /dev/sdc3
After all of this, when doing vgscan and pvscan, you should see this below
Ninja141:~ # vgscan Reading all physical volumes. This may take a while... Found volume group "disk2" using metadata type lvm2 Found volume group "disk1" using metadata type lvm2 Found volume group "disk0" using metadata type lvm2 Found volume group "system" using metadata type lvm2 Ninja141:~ # pvscan PV /dev/sdb3 VG disk1 lvm2 [558.88 GiB / 558.88 GiB free] PV /dev/sdc3 VG disk2 lvm2 [1.09 TiB / 1.09 TiB free] PV /dev/sda3 VG disk0 lvm2 [488.37 GiB / 488,37 GiB free] PV /dev/sda2 VG system lvm2 [70.00 GiB / 10.00 GiB free] Total: 4 [2.18 TiB] / in use: 4 [2.18 TiB] / in no VG: 0 [0 ] Ninja141:~ #
Create the LV's (Logical Volumes)
lvcreate -L 200G -n part0 disk0 lvcreate -L 270G -n part1 disk0 lvcreate -L 500G -n part0 disk2 lvcreate -L 82G -n part2 disk1 lvcreate -L 860G -n part1 disk1 lvcreate -L 250G -n part0 disk1
When you do a lvscan, you should be seeing something similar as below
Ninja141:~ # lvscan ACTIVE '/dev/disk1/part0' [247.00 GiB] inherit ACTIVE '/dev/disk1/part1' [852.64 GiB] inherit ACTIVE '/dev/disk1/part2' [82.00 GiB] inherit ACTIVE '/dev/disk2/part0' [495.00 GiB] inherit ACTIVE '/dev/disk0/part0' [195.00 GiB] inherit ACTIVE '/dev/disk0/part1' [268.00 GiB] inherit ACTIVE '/dev/system/home' [1.00 GiB] inherit ACTIVE '/dev/system/opt' [10.00 GiB] inherit ACTIVE '/dev/system/root' [2.00 GiB] inherit ACTIVE '/dev/system/srv' [7.00 GiB] inherit ACTIVE '/dev/system/swap' [25.00 GiB] inherit ACTIVE '/dev/system/tmp' [5.00 GiB] inherit ACTIVE '/dev/system/usr' [6.00 GiB] inherit ACTIVE '/dev/system/var' [4.00 GiB] inherit Ninja141:~ #
Next step, create the filesystem, in this case I wanted ext3 filesystems
mkfs.ext3 /dev/disk0/part0 mkfs.ext3 /dev/disk0/part1 mkfs.ext3 /dev/disk1/part0 mkfs.ext3 /dev/disk1/part1 mkfs.ext3 /dev/disk1/part2 mkfs.ext3 /dev/disk2/part0
Create your directories
mkdir -p /opt/app mkdir -p /opt/mystuff mkdir -p /opt/mystuff/home mkdir -p /backup mkdir -p /postgrestablespace mkdir -p /mongodata
Change the /etc/fstab file to mount the directories
Ninja141:~ # cat /etc/fstab /dev/system/swap swap swap defaults 0 0 /dev/system/root / ext3 defaults 1 1 /dev/sda1 /boot ext3 acl,user_xattr 1 2 /dev/system/home /home ext3 defaults 1 2 /dev/system/opt /opt ext3 defaults 1 2 /dev/system/srv /srv ext3 defaults 1 2 /dev/system/tmp /tmp ext3 defaults 1 2 /dev/system/usr /usr ext3 defaults 1 2 /dev/system/var /var ext3 defaults 1 2 proc /proc proc defaults 0 0 sysfs /sys sysfs noauto 0 0 debugfs /sys/kernel/debug debugfs noauto 0 0 usbfs /proc/bus/usb usbfs noauto 0 0 devpts /dev/pts devpts mode=0620,gid=5 0 0 /dev/disk0/part0 /opt/app ext3 defaults 1 2 /dev/disk0/part1 /opt/mystuff ext3 defaults 1 2 /dev/disk1/part0 /opt/mystuff/home ext3 defaults 1 2 /dev/disk1/part1 /backup ext3 defaults 1 2 /dev/disk1/part2 /postgrestablespace ext3 defaults 1 2 /dev/disk2/part0 /mongodata ext3 defaults 1 2 Ninja141:~ #
Last but not least, mount the directories
mount /opt/app mount /opt/mystuff mount /opt/mystuff/home mount /backup mount /postgrestablespace mount /mongodata
If all is ok, df -h should display the following
Ninja141:~ # df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/system-root 2.0G 368M 1.6G 20% / udev 48G 208K 48G 1% /dev tmpfs 48G 0 48G 0% /dev/shm /dev/sda1 510M 132M 352M 28% /boot /dev/mapper/system-home 1008M 34M 924M 4% /home /dev/mapper/system-opt 9.9G 694M 8.7G 8% /opt /dev/mapper/system-srv 6.9G 3.7G 3.0G 56% /srv /dev/mapper/system-tmp 5.0G 139M 4.6G 3% /tmp /dev/mapper/system-usr 6.0G 3.9G 1.8G 69% /usr /dev/mapper/system-var 4.0G 300M 3.5G 8% /var /dev/mapper/disk0-part0 192G 4.4G 178G 3% /opt/app /dev/mapper/disk0-part1 264G 217G 34G 87% /opt/mystuff /dev/mapper/disk1-part0 250G 200G 33G 80% /opt/mystuff/home /dev/mapper/disk1-part1 860G 382M 231G 1% /backup /dev/mapper/disk1-part2 82G 382M 1G 1% /postgrestablespace /dev/mapper/disk2-part0 500G 323M 1.8G 1% /mongodata Ninja141:~ #
To grow and shrink the space, use yast
Go to System > Partitioner > Yes (we know what we are doing)
Select Volume Management, space bar will open the volumes, goto disk1, space bar, goto part4 and ENTER, make sure it says * Mount Point: /xxxxx
TAB to Resize
And enter the new value, in this case 400G
Click OK and TAB to Next
TAB to Finish and ENTER
It will take some time to complete
When done exit yast.
yast will automatically mount the /xxxxx volume again
See, told you is was easy.....
More reading :- http://en.wikipedia.org/wiki/Logical_Volume_Manager_%28Linux%29
No comments:
Post a Comment
Note: only a member of this blog may post a comment.