Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
rb:linuxlvm [10/10/2013 15:21]
127.0.0.1 external edit
rb:linuxlvm [19/09/2019 15:31] (current)
andrew [Logical Volume creation]
Line 150: Line 150:
  
  
 +==== Extend LV ====
 +
 +Extend Logical Volume to 100% of the size available in a Volume Group
 +
 +  # lvextend -l +100%FREE /​dev/​myvg/​testlv
 ==== Make Filesystems ====    ==== Make Filesystems ====   
  
Line 213: Line 218:
  
  
 +==== Resize LVM ====
 +
 +<​code>​
 +Idea, resize /home to give more to /data.
 +
 +
 +/​dev/​mapper/​rootvg-homelv 6.6G ​ 144M  6.2G   3% /home
 +/​dev/​mapper/​rootvg-varlv 2.9G ​ 176M  2.5G   7% /var
 +/​dev/​mapper/​datavg-datalv 30G ​  ​26G ​ 2.1G  93% /data
 +
 +reduce /home lv
 +
 +umount /home
 +[root@linuxbuild01 ~]# e2fsck -f /​dev/​rootvg/​homelv
 +e2fsck 1.39 (29-May-2006)
 +Pass 1: Checking inodes, blocks, and sizes
 +Pass 2: Checking directory structure
 +Pass 3: Checking directory connectivity
 +Pass 4: Checking reference counts
 +Pass 5: Checking group summary information
 +/​dev/​rootvg/​homelv:​ 11/1786400 files (9.1% non-contiguous),​ 92677/​1785856 blocks
 +
 +
 +[root@linuxbuild01 ~]# resize2fs -p /​dev/​rootvg/​homelv 2G
 +resize2fs 1.39 (29-May-2006)
 +Resizing the filesystem on /​dev/​rootvg/​homelv to 524288 (4k) blocks.
 +Begin pass 3 (max = 55)
 +Scanning inode table          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 +The filesystem on /​dev/​rootvg/​homelv is now 524288 blocks long.
 +
 +[root@linuxbuild01 ~]# 
 +</​code>​
  
 ===== Moving LVM filesystems ===== ===== Moving LVM filesystems =====
Line 378: Line 415:
 Edit /​etc/​multipath.conf and remove any lines relating to previously configured multipath disks. Restart multipathd with ''​service multipathd restart''​. This should cause SAN multipath disks to disappear. On RHEL4.x, a restart seems the safest option. Edit /​etc/​multipath.conf and remove any lines relating to previously configured multipath disks. Restart multipathd with ''​service multipathd restart''​. This should cause SAN multipath disks to disappear. On RHEL4.x, a restart seems the safest option.
  
- + 
 + 
 + 
 + 
 + 
 + 
 + 
 + 
 +=== Creating a new Logical Volume === 
 + 
 +In this example we will create a new logical volume called **wworks**, mounted at **/wworks** which will be part of the **vg00** Volume Group at **/​dev/​mapper/​vg00-lv_wworks** 
 + 
 +1. Check to see how much free space you have to allocate the new logical volume: 
 +  [root@gi-rgs-rng01 /]# vgdisplay | egrep '​Name|Free'​ 
 +    VG Name               ​vg00 
 +    Free  PE / Size       2515 / 78.59 GB 
 + 
 +2. Create the new logical volume and assign it to the vg00 volume group: 
 +  [root@gi-rgs-rng01 /]# lvcreate -L 30G -n lv_wworks vg00 
 +    Logical volume "​lv_wworks"​ created 
 + 
 +3. Format it with a journalled filesystem:​ 
 +  mkfs.ext3 -j /​dev/​mapper/​vg00-lv_wworks 
 +   
 +4. Add the new entry to fstab (use the others as a template):​ 
 +  [root@gi-rgs-rng01 /]# cat /etc/fstab | grep wworks 
 +  /​dev/​vg00/​lv_wworks ​    /​wwworks ​               ext3    defaults ​       1 2 
 + 
 +5. Mount the new logical volume and test it: 
 +  [root@gi-rgs-rng01 /]# mount -a && df -h | egrep '​File|wworks'​ && echo "​test">/​wworks/​neil.test && cat /​wworks/​neil.test 
 +  Filesystem ​           Size  Used Avail Use% Mounted on 
 +  /​dev/​mapper/​vg00-lv_wworks 
 +                       ​30G ​  ​76M ​  ​28G ​  1% /wworks 
 +  test 
 + 
 +6. You can also see it as a member of the vg00 Volume Group: 
 +  [root@gi-rgs-rng01 /]# lvs 
 +  LV        VG   ​Attr ​  ​LSize ​ Origin Snap%  Move Log Copy%  Convert 
 +  lv_home ​  vg00 -wi-ao 10.00G 
 +  lv_log ​   vg00 -wi-ao 10.00G 
 +  lv_root ​  vg00 -wi-ao 15.00G 
 +  lv_swap ​  vg00 -wi-ao ​ 5.88G 
 +  lv_tmp ​   vg00 -wi-ao ​ 2.00G 
 +  lv_var ​   vg00 -wi-ao 15.00G 
 +  lv_wworks vg00 -wi-ao 30.00G 
 + 
 + 
 +   
 +   
 +=== Reducing the size of an LVM === 
 + 
 +In this example we will reduce the size of **/​var/​log** which is an LV at **/​dev/​mapper/​vg00-lv_log** 
 + 
 +  [root@gi-rgs-rng01 /]# df -h | egrep '​Filesystem|log'​ 
 +  Filesystem ​           Size  Used Avail Use% Mounted on 
 +  /​dev/​mapper/​vg00-lv_log 
 +                       ​50G ​  ​85M ​  ​47G ​  1% /var/log 
 + 
 + 
 +1. Ensure the filesystem is unmounted 
 +  $ umount /var/log 
 + 
 +2. If the mount point is in use try identifying what's using it with lsof: 
 +  $ lsof | grep "/​var/​log"​ 
 + 
 +3. Ensure /var/log is no longer mounted. 
 +  $ df -h | grep "/​var/​log"​ 
 +// 
 +// 
 +**Ensure the amount of data contained within the LV does not exceed the size you will be reducing it to or this will result in data loss.** 
 +// 
 +// 
 + 
 +4. First the filesystem needs to be checked. 
 +  [root@gi-rgs-rng01 /]# e2fsck -f /​dev/​mapper/​vg00-lv_log 
 +  e2fsck 1.35 (28-Feb-2004) 
 +  Pass 1: Checking inodes, blocks, and sizes 
 +  Pass 2: Checking directory structure 
 +  Pass 3: Checking directory connectivity 
 +  Pass 4: Checking reference counts 
 +  Pass 5: Checking group summary information 
 +  /​dev/​mapper/​vg00-lv_log:​ 56/6553600 files (19.6% non-contiguous),​ 227290/​13107200 blocks 
 +   
 +5. Now reduce the filesystem to 10GB. 
 +  [root@gi-rgs-rng01 /]# resize2fs /​dev/​mapper/​vg00-lv_log 10G 
 +  resize2fs 1.35 (28-Feb-2004) 
 +  Resizing the filesystem on /​dev/​mapper/​vg00-lv_log to 2621440 (4k) blocks. 
 +  The filesystem on /​dev/​mapper/​vg00-lv_log is now 2621440 blocks long. 
 +   
 +6. Now reduce the size of the LV: 
 +  [root@gi-rgs-rng01 /]# lvreduce -L 10G /​dev/​mapper/​vg00-lv_log 
 +    WARNING: Reducing active logical volume to 10.00 GB 
 +    THIS MAY DESTROY YOUR DATA (filesystem etc.) 
 +  Do you really want to reduce lv_log? [y/n]: y 
 +    Reducing logical volume lv_log to 10.00 GB 
 +    Logical volume lv_log successfully resized 
 +   
 +7. Remount the partition and check the new size is correct: 
 +  [root@gi-rgs-rng01 /]# mount -a ; df -h | egrep '​Filesystem|log'​ 
 +  Filesystem ​           Size  Used Avail Use% Mounted on 
 +  /​dev/​mapper/​vg00-lv_log 
 +                      9.9G   ​69M ​ 9.3G   1% /var/log 
 +                       
 +                       
 + 
 +=== Extending the size of a Logical Volume === 
 + 
 +In this example we will extend the size of **/wworks** which is an LV at **/​dev/​mapper/​vg00-lv_wworks**,​ to 50GB. 
 + 
 +1. Ensure the filesystem is unmounted 
 +  $ umount /wworks 
 + 
 +2. If the mount point is in use try identifying what's using it with lsof: 
 +  $ lsof | grep "/​wworks"​ 
 + 
 +3. Ensure /var/log is no longer mounted. 
 +  $ df -h | grep "/​wworks"​ 
 + 
 +4. Extend the size of the logical volume: 
 +  $ lvextend -L 50GB /​dev/​mapper/​vg00-lv_wworks 
 + 
 +5. Now extend the filesystem to that new size 
 +  $ resizefs /​dev/​mapper/​vg00-lv_wworks 50G 
 +   
 +6. Remount the partition and check the new size is correct: 
 +  $ mount -a ; df -h | egrep '​Filesystem|wworks'​ 
 +   

rb/linuxlvm.1381414873.txt.gz · Last modified: 10/10/2013 15:21 by 127.0.0.1