Sie sind auf Seite 1von 5

How to extend a volume in Linux

After the volume has been provided to the VM, rescan the SCSI bus by doing : How-To: Rescan a SCSI bus without Rebooting
When you hotplug a hard drive in a virtual machine, the drive do not show in fdisk -l output until you reboot your VM. In order to get the drive to appear, the SCSI bus need to be rescanned. The rescan will be triggered through sysfs pseudo filesystem. First of all get root access and check what host is available:

# ls /sys/class/scsi_host host0 host1 host2 host3 Pick up the one (here host2 is taken) that match where the drive is and run: # echo "- - -" > /sys/class/scsi_host/host2/scan Now, you should be able to see the drive when running: # fdisk l

Format the new disk Format the newly detected drive using fdisk fdisk /dev/sdb n (for new partition) p (for primary partition) 1 (partition number) (keep the other values default) w (write changes) Change the type of the partition to LVM Linux: fdisk /dev/sdb t (change the partition type)

8e (for Linux LVM) w (write changes) LVM Initialize LVM Physical Volume pvcreate /dev/sdb1 Add Physical Volume to Volume Group List the Volume groups available at your machine. vgdisplay Replace VolGroupName with what you read from the output of the last command. vgextend VolGroupName /dev/sdb1 You should see the newly aquired free space in the output of vgdisplay Resize Logical Volumes After adding some free space to your Volume Group, you can distribute it to the Logical Volumes. The list of Logical Volumes can be obtained by running lvdisplay Run the following commands for each Logical Volume you want to resize (add space to). Again replace /dev/VolGroupName/Name with the Logical Volume name you can read from the output of the last command. The +10G means Add 10 GB lvextend -L +10G /dev/VolGroupName/Name also lvextend -l +100%FREE /dev/rsync/root

The last step is to resize the ext3 filesystem (use different tool is you use different filesystem): resize2fs /dev/VolGroupName/Name

MORE HELP

Redhat-linux

The Web T he Web

LVM (LOGICAL VOLUME MANAGER) 1. TO CREATE LVM 1.fdisk /dev/sda ->create 3 partitions + label to 8e 2.partprobe 3.fdisk -l 4.pvcreate /dev/sda8 /dev/sda9 5.pvdisplay /dev/sda8 6.pvdisplay /dev/sda9 7.vgcreate vg0 /dev/sda8 /dev/sda9 8.vgdisplay 9.lvcreate -L +200M -n /dev/vg0/home1 10.lvdisplay /dev/vg0/home1 11.lvcreate -L +300M -n /dev/vg0/var1 12.lvdisplay /dev/vg0/var1 13.mkfs.ext3 /dev/vg0/var1 14 mkfs.ext3 /dev/vg0/home1 15.mkdir /home1 16.mkdir /var1

17.mount /dev/vg0/home1 /home1 18.mount /dev/vg0/var1 /var1 19.cp /etc/a* /home1 20.cp /etc/b* /var1 21.vim /etc/fstab 22.mount -a TO EXTEND LVM 1.lvdisplay /dev/vg0/home1 2.lvextend -L +200M /dev/vg0/home1 3.ls /home1 4.resize2fs /dev/vg0/home1 5.ls /home1 TO REDUCE LVM 1. lvdisplay 2. umount /var1 3. e2fsck -f /dev/vg0/var1 4. resize2fs /dev/vg0/var1 100M 5. lvreduce -L -100M -n /dev/vg0/var1 6. mount /dev/vg0/var1 /var1 7. df -h LVM SNAPSHOT 1. lvcreate -L 200M -s -n lv2 /dev/llc/lv1 TO EXTEND PV 1.pvcreate /dev/sda10 2.pvdisplay TO EXTEND VG 1.vgextend vg0 /dev/sda10 2.vgdisplay vg0 TO REDUCE VG 1.vgreduce vg0 /dev/sda10 2.vgdisplay

TO REDUCE PV 1.pvremove /dev/sda10 2.pvdisplay REMOVE LVM 1.lvdisplay 2.umount /dev/vg0/home1 3.umount /dev/vg0/var1 4.vim /etc/fstab 5.lvremove /dev/vg0/home1 6.lvremove /dev/vg0/var1 7.lvdisplay REMOVE VG 1.vgdisplay 2.vgremove /dev/vg0 3.vgdisplay REMOVE PV 1.pvdisplay 2.pvremove /dev/sda9 3.pvremove /dev/sda8

Das könnte Ihnen auch gefallen