User Tools

Site Tools


tech:documentation:procedures:vm:vm_disk_expansion_lvm_xfs

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
tech:documentation:procedures:vm:vm_disk_expansion_lvm_xfs [2011/08/11 16:13] kohofertech:documentation:procedures:vm:vm_disk_expansion_lvm_xfs [2013/04/12 10:54] – [Create LVM] KoHofer@unibz.it
Line 1: Line 1:
-====== VM disk Expansion LVM+XFS =======+====== VM disk Expansion LVM with XFS/EXT4 =======
  
-Expand the original disk or add a second vdisk from Infrastructure client.\\ If you want to perform a grow w/o reboot you have to add a second disk +<note important>CREATE SNAPSHOT</note>
-**THEN TAKE A SNAPSHOT!!!**+
  
-then from on the vm either create an additional partition on the free spaceThe partition type is 8e+Expand the original disk or add a second vdisk from **Infrastructure Client**.\\ 
 +If you want to perform a grow w/o reboot you have to add a second disk.
  
-  cfdisk /dev/sda +If you are on a kernel newer or equal to 2.6.32 then you can issue the command
-# for example if the new partition is /dev/sda3+
  
-# create logical disk /dev/sda3+<code>echo "1"/sys/block/sdX/device/rescan</code>
  
-# make disk visible to linux+to get the new size w/o reboot.
  
-  partprobe 
-  pvcreate /dev/sda3 
  
 +In case you cant see the "disk" do this:
  
-if you are running a newer kernel you can issue this command to male linux re-read the disk geometry:+  echo "- -" > /sys/class/scsi_host/host0/scan 
 +   
 +Do this for all host0,1,2 etc.
  
-  echo "1" > /sys/class/scsi_device/<device>/device/rescan 
  
 +or
  
-or assign the whole new disk to lvm assuming it'/dev/sdb+  echo "1"/sys/class/scsi_device/2\:0\:0\:0/device/rescan
  
-  apt-get install scsitools +whereby after scsi_device you need to find the correct scsi device
-  rescan-scsi-bus.sh +
-  cfdisk /dev/sdb+
  
-### for example if the new partition is /dev/sda3 
  
-   pvcreate /dev/sdb 
  
-now you have to extend the volgroup. use ''lvdisplay'' to see which is the name of the group, in this example it's base+**EXPAND ORIGINAL DISK** 
 + 
 +Create an additional partition on the free space, say you increased the existing disc 
 +from 8GB to 15GB. The partition type is 8e. 
 + 
 +  cfdisk /dev/sda 
 + 
 +# for example if the new partition is /dev/sda3 
 + 
 +# create logical disk /dev/sda3 of type 8e (Linux LVM) 
 + 
 +# make disk visible to linux 
 + 
 +  partprobe 
 +  pvcreate /dev/sda3 
 + 
 +now you have to extend the volgroup. use ''lvdisplay'' to see which is the name of the group,\\ 
 +in this example it'**base**
  
   lvdisplay    lvdisplay 
Line 103: Line 116:
 11.5 G is the NEW total size of the disk we want to extend! 11.5 G is the NEW total size of the disk we want to extend!
  
- +Extend the LV to use all free space 
-  lvextend -L 11.5G  /dev/base/data+  lvextend -l +100%FREE /dev/base/data
  
 Extend with 20G Extend with 20G
- 
- 
   lvextend -L +20G  /dev/base/data    lvextend -L +20G  /dev/base/data 
  
Line 114: Line 125:
  
    xfs_growfs /data    xfs_growfs /data
 +
 +
 +===== FOR EXT3/4 =====
 +
 +Extend filesystem  to use all free space
 +
 +  vgextend base /dev/sda3
 +
 +  lvextend -l +100%FREE /dev/base/root
 +
 +Check that the filesystem is ok, **but only if the FS is unmounted**
 +
 +  fsck.ext4 -f /dev/base
 +
 +Now resize the filesystem
 +
 +  resize2fs -p /dev/base/root
  
  
 ===== For swap ===== ===== For swap =====
  
-swapoff /dev/base/swap  +  swapoff /dev/base/swap 
-lvextend -L 3.9G /dev/base/swap  +  lvextend -L 3.9G /dev/base/swap 
-mkswap /dev/base/swap  +  mkswap /dev/base/swap 
-swapon /dev/base/swap  +  swapon /dev/base/swap 
-free+  free
  
 Check if filesystems are ok, and only then release the snapshot Check if filesystems are ok, and only then release the snapshot
  
-For ext2/ext3 
- 
-  resize2fs /dev/base/data 
  
 ======= Create LVM ======= ======= Create LVM =======
Line 152: Line 177:
 Hier legen wir jetzt alle unsere logischen Volumes an. Als Namen verwenden wir, etwas fantasielos, lvol1, lvol2 und lvol3. Dabei bedienen wir uns mit dem Plattenplatz auf Volume Group vg01, der einzigen Volume Group in diesem Beispiel. Es ist offensichtlich, dass wir hier nicht mehr Plattenplatz "verteilen" können, als wir bei vgcreate in die Volume Group "hineingesteckt" haben, und zwar in Form der beiden Partitionen hda3 und hdb2. (lvcreate -L<Grösse> -n <LogicalVolumeName> <Volume Group>). Hier legen wir jetzt alle unsere logischen Volumes an. Als Namen verwenden wir, etwas fantasielos, lvol1, lvol2 und lvol3. Dabei bedienen wir uns mit dem Plattenplatz auf Volume Group vg01, der einzigen Volume Group in diesem Beispiel. Es ist offensichtlich, dass wir hier nicht mehr Plattenplatz "verteilen" können, als wir bei vgcreate in die Volume Group "hineingesteckt" haben, und zwar in Form der beiden Partitionen hda3 und hdb2. (lvcreate -L<Grösse> -n <LogicalVolumeName> <Volume Group>).
  
-   lvcreate -L 1500M -n lvol1 vg01 +   lvcreate -l +100%FREE -n lvol1 vg01
  
 +or you can specify the size (1500M)
 +   
 +   lvcreate -L 1500M -n lvol1 vg01
 +   
 Filesysteme anlegen Filesysteme anlegen
  
Line 168: Line 197:
 http://www.linuxhaven.de/dlhp/HOWTO-test/DE-LVM-HOWTO-2.html http://www.linuxhaven.de/dlhp/HOWTO-test/DE-LVM-HOWTO-2.html
  
 +http://www.howtogeek.com/howto/40702/how-to-manage-and-use-lvm-logical-volume-management-in-ubuntu/
/data/www/wiki.inf.unibz.it/data/pages/tech/documentation/procedures/vm/vm_disk_expansion_lvm_xfs.txt · Last modified: 2020/10/13 16:46 by kohofer