Hiển thị các bài đăng có nhãn LVM. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn LVM. Hiển thị tất cả bài đăng

Thứ Hai, 5 tháng 12, 2016

How to Shrink or reduce size of LVM partitons in RHEL/CentOS

1. Check disk partitions size
# df -hT
Filesystem    Type Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00 ext3 34G 6.6G 26G 21% /
/dev/mapper/VolGroup00-LogVol03 ext3 34G 29G 27G 52% /usr
/dev/mapper/VolGroup00-LogVol04 ext3 97G 89G 2.7G 98% /var
/dev/sda1 ext3 99M 27M 67M 29% /boot
tmpfs tmpfs 56G 0 56G 0% /dev/shm
/dev/mapper/VolGroup00-LogVol02 ext3 56G 9.1G   65G 13% /backup
2. Unmount the partitions that want to shrink or reduce
# umount /dev/mapper/VolGroup00-LogVol02

Difference between RAID and LVM

 S.No.

 RAID  LVM
 1.  RAID is used for redundancy.  LVM is a way in which you partition the hard disk logically and it contains its own advantages.
 2.  A RAID device is a physical grouping of disk devices in order to create a logical presentation of one device to an Operating System for redundancy or performance or a combination of the two.  LVM is a logical layer that that can be anipulated in order to create and, or expand a logical presentation of a disk device to an Operating System.
 3.  RAID is a way to create a redundant or striped block device with redundancy using other physical block devices.  LVM usually sits on top of RAID blocks or even standard block devices to accomplish the same result as a partitioning, however it is much more flexible than partitions. You can create multiple volumes crossing multiple physical devices, remove physical devices without loosing data, resize the volumes, create snapshots, etc
 4.  RAID is either a software or a hardware technique to create data storage redundancy across multiple block devices based on required RAID levels.  LVM is a software tool to manage large pool of storage devices making them appear as a single manageable pool of storage resource. LVM can be used to manage a large pool of what we call Just-a-bunch-of-Disk (JBOD) presenting them as a single logical volume and thereby create various partitions for software RAID.
 5.  RAID is NOT any kind of Data backup solution. Its a solution to prevent one of the SPOFs (Single Point of Failure) i.e. DISK failure. By configuring RAID you are just providing an emergency substitute for the Primary disk. It NEVER means that you have configured DATA backup.  LVM is a disk management approach that allows us to create, extend, reduce, delete or resize the volume groups or logical volumes.

Managing Disk Space with LVM -04

Adding A Hard Drive And Removing Another One

We haven't used /dev/sdf until now. We will now create the partition /dev/sdf1 (25GB) and add that to our fileserver volume group.
kilo:~#fdisk /dev/sdf
kilo:~# pvcreate /dev/sdf1
  Physical volume "/dev/sdf1" successfully created
Add /dev/sdf1 to our fileserver volume group:
kilo:~#:vgextend fileserver /dev/sdf1
kilo:~#:vgdisplay
That's it. /dev/sdf1 has been added to the fileserver volume group. Now let's remove /dev/sdb1. Before we do this, we must copy all data on it to /dev/sdf1
kilo:~# pvmove /dev/sdb1 /dev/sdf1
  /dev/sdb1: Moved: 1.9%
  . . .
  /dev/sdb1: Moved: 100.0%

Next we remove /dev/sdb1 from the fileserver volume group:
kilo:~# vgreduce fileserver /dev/sdb1
  Removed "/dev/sdb1" from volume group "fileserver"
kilo:~# vgdisplay
kilo:~#  pvremove /dev/sdb1 
kilo:~#  pvdisplay

You could now remove /dev/sdb from the system (if this was a real system and not a virtual machine).

Managing Disk Space with LVM -02

Basically LVM looks like this:



You have one or more physical volumes (/dev/sdb1 - /dev/sde1 in our example), and on these physical volumes you create one or more volume groups (e.g. fileserver), and in each volume group you can create one or more logical volumes. If you use multiple physical volumes, each logical volume can be bigger than one of the underlying physical volumes (but of course the sum of the logical volumes cannot exceed the total space offered by the physical volumes).
It is a good practice to not allocate the full space to logical volumes, but leave some space unused. That way you can enlarge one or more logical volumes later on if you feel the need for it.
In this example we will create a volume group called fileserver, and we will also create the logical volumes /dev/fileserver/share, /dev/fileserver/backup, and /dev/fileserver/media (which will use only half of the space offered by our physical volumes for now - that way we can switch to RAID1 later on (also described in this tutorial)).

Managing Disk Space with LVM -01

The Linux Logical Volume Manager (LVM) is a mechanism for virtualizing disks. It can create "virtual" disk partitions out of one or more physical hard drives, allowing you to grow, shrink, or move those partitions from drive to drive as your needs change. It also allows you to create larger partitions than you could achieve with a single drive.

Traditional uses of LVM have included databases and company file servers, but even home users may want large partitions for music or video collections, or for storing online backups. LVM and RAID 1 can also be convenient ways to gain redundancy without sacrificing flexibility.

This article looks first at a basic file server, then explains some variations on that theme, including adding redundancy with RAID 1 and some things to consider when using LVM for desktop machines.

Chủ Nhật, 4 tháng 12, 2016

Setting up a large (2TB+) hard disk drive on Linux

1. Physically install the hard drive.

After installing the drive, check that the BIOS detected your new drive with the correct size.
When I do this I get an error similar to: "WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted."

2. Identify the device

Also check the device has been detected by linux and identify the device name.
root@turtle:~# ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sda5  /dev/sdb
This shows a hard drive 'sda' with existing partitions sda1, sda2 and sda5. It also shows a hard drive 'sdb', but with no partitions detected. The new hard drive will have no partitions, so we can identify it as device 'sdb'


Bypassing Bad fstab Failure When Booting Linux

If /etc/fstab file is created with errors or the hardware configuration changes such as adding hard disks, Linux will boot into failure state. We can bypass the fstab failure by adding booting parameters to Linux. We can do this in two methods:

Method 1: Boot to single user mode 

When booting into single user mode, Linux will not mount anything. Then we can remount the / to some directory in read/write mode and then edit the /etc/fstab.
1. Boot Linux into single user mode
Press ESC in the grub menu and press ‘e’ to edit the grub entry. Add single to the kernel parameter like this:
kernel /vmlinuz-2.6.32.21-166.fc12.i686 ro root=/dev/mapper/VolGroup-LogVol00 vga=792 single