tech:documentation:procedures:vm:vm_disk_expansion_lvm_xfs
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tech:documentation:procedures:vm:vm_disk_expansion_lvm_xfs [2010/03/17 15:30] – kohofer | tech:documentation:procedures:vm:vm_disk_expansion_lvm_xfs [2020/10/13 16:46] (current) – [VM disk Expansion LVM with XFS/EXT4] kohofer | ||
---|---|---|---|
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 | + | Expand the original disk or add a second vdisk from **Infrastructure |
- | **THEN TAKE A SNAPSHOT!!!** | + | |
+ | If you are on a kernel newer or equal to 2.6.32 then you can issue the command | ||
+ | |||
+ | < | ||
+ | |||
+ | to get the new size w/o reboot. | ||
+ | |||
+ | |||
+ | In case you cant see the " | ||
+ | |||
+ | echo "- - -" > / | ||
+ | |||
+ | Do this for all host0,1,2 etc. | ||
+ | |||
+ | |||
+ | or | ||
+ | |||
+ | echo " | ||
+ | |||
+ | whereby after scsi_device you need to find the correct scsi device | ||
+ | |||
+ | or | ||
+ | |||
+ | apt-get install scsitools | ||
+ | rescan-scsi-bus | ||
+ | |||
+ | At the end it should list that a new device was found, note down the name/ | ||
+ | |||
+ | echo ' | ||
+ | |||
+ | IMPORTANT: Be sure to replace the 32\:0\:1\:0 with the appropriate | ||
+ | |||
+ | |||
+ | **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 or cfdisk /dev/sdb | ||
+ | |||
+ | |||
+ | **RESIZE ORIGINAL DISK** | ||
+ | |||
+ | Resize the already existing partition, e.g. /dev/sda4 to the newly created free partition. | ||
+ | |||
+ | cfdisk /dev/sda or cfdisk /dev/sdb | ||
+ | |||
+ | Now resize the Physical Volume to the new size | ||
+ | |||
+ | pvresize /dev/sda4 | ||
+ | |||
+ | extend the logical volume | ||
+ | |||
+ | lvextend -l +100%FREE | ||
+ | |||
+ | next resize the file system | ||
+ | |||
+ | resize2fs -p / | ||
+ | |||
+ | |||
+ | If you get a error: | ||
+ | |||
+ | <color # | ||
+ | |||
+ | run this command: | ||
+ | |||
+ | parted -l | ||
+ | |||
+ | and when asked to Fix/Cancel? type **F** | ||
+ | |||
+ | # for example if the new partition is /dev/sda3 | ||
+ | |||
+ | # create logical disk /dev/sda3 of type 8e (Linux LVM) | ||
- | then from on the vm either create an additional partition on the free space. The partition type is 8e | ||
- | < | ||
- | cfdisk /dev/sda | ||
- | ## for example if the new partition is /dev/sda3 | ||
- | ## create logical disk /dev/sda3 | ||
# make disk visible to linux | # make disk visible to linux | ||
- | partprobe | ||
- | pvcreate /dev/sda3 | ||
- | </ | ||
- | if you are running a newer kernel you can issue this command to male linux re-read the disk geometry: | + | partprobe |
- | < | + | |
- | echo " | + | |
- | </code> | + | |
- | or assign | + | now you have to extend |
- | < | + | in this example |
- | apt-get install scsitools | + | |
- | 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 | ||
--- Logical volume --- | --- Logical volume --- | ||
LV Name / | LV Name / | ||
Line 86: | Line 143: | ||
Read ahead sectors | Read ahead sectors | ||
Block device | Block device | ||
+ | </ | ||
+ | and we assume the new partition is /dev/sda3 | ||
- | </ | + | |
- | + | ||
- | < | + | |
- | vgextend base /dev/sda3 | + | |
- | </ | + | |
check with '' | check with '' | ||
- | < | + | |
- | pvscan | + | |
- | </ | + | |
Now we extend the " | Now we extend the " | ||
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 | + | lvextend -l +100%FREE |
- | </ | + | |
Extend with 20G | Extend with 20G | ||
- | + | | |
- | < | + | |
- | lvextend -L +20G / | + | |
- | </ | + | |
now we have to grow the filesystem /data | now we have to grow the filesystem /data | ||
- | < | + | |
- | xfs_growfs /data | + | |
- | </code> | + | |
+ | |||
+ | ===== FOR EXT3/4 ===== | ||
+ | |||
+ | Extend filesystem | ||
+ | |||
+ | vgextend base /dev/sda3 | ||
+ | |||
+ | lvextend -l +100%FREE / | ||
+ | |||
+ | Check that the filesystem is ok, **but only if the FS is unmounted** | ||
+ | |||
+ | fsck.ext4 -f /dev/base | ||
+ | |||
+ | Now resize the filesystem | ||
+ | |||
+ | Debian System: | ||
+ | |||
+ | resize2fs -p / | ||
+ | |||
+ | Centos/ | ||
+ | |||
+ | resize4fs -p / | ||
+ | |||
+ | ===== For swap ===== | ||
+ | |||
+ | swapoff / | ||
+ | lvextend -L 3.9G / | ||
+ | mkswap / | ||
+ | swapon / | ||
+ | free | ||
Check if filesystems are ok, and only then release the snapshot | Check if filesystems are ok, and only then release the snapshot | ||
+ | |||
+ | Fix issue with swap | ||
+ | |||
+ | * swapoff: /dev/dm-1: swapoff failed: Cannot allocate memory | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | < | ||
+ | |||
+ | |||
+ | ======= Create LVM ======= | ||
+ | |||
+ | Find all LVM VG | ||
+ | |||
+ | vgscan | ||
+ | |||
+ | Create Physical Volumes | ||
+ | |||
+ | Der Befehl pvcreate legt den VGDA Block auf dem PV an. Er muss für jedes PV ausgeführt werden, bevor es von LVM verwendet werden kann: | ||
+ | |||
+ | | ||
+ | |||
+ | Volume Groups anlegen | ||
+ | |||
+ | Jetzt legen wir mit ' | ||
+ | |||
+ | | ||
+ | |||
+ | Logische Volumes anlegen. | ||
+ | |||
+ | Hier legen wir jetzt alle unsere logischen Volumes an. Als Namen verwenden wir, etwas fantasielos, | ||
+ | |||
+ | | ||
+ | |||
+ | oder wir könne die Größen angeben! (1500M) | ||
+ | |||
+ | | ||
+ | |||
+ | Filesysteme anlegen | ||
+ | |||
+ | Ab jetzt können die logischen Partitionen, | ||
+ | |||
+ | mkfs.ext4 / | ||
+ | |||
+ | fstab anpassen | ||
+ | |||
+ | Damit die neuen Filesysteme nun bei jedem Systemstart automatisch gemountet werden, müssen wir sie in die Datei /etc/fstab eintragen (siehe 'man fstab' | ||
+ | |||
+ | / | ||
+ | |||
+ | ===== Links ===== | ||
+ | |||
+ | |||
+ | [[http:// | ||
+ | [[https:// | ||
+ | [[http:// | ||
+ | [[http:// | ||
+ | [[http:// | ||
+ | [[http:// | ||
+ | [[http:// | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | http:// | ||
+ | http:// |
/data/www/wiki.inf.unibz.it/data/attic/tech/documentation/procedures/vm/vm_disk_expansion_lvm_xfs.1268836222.txt.gz · Last modified: 2019/01/16 10:03 (external edit)