#1
|
|
VMware Linux sanal server makina hdd boyutu büyütme
This post will cover how to increase the disk space for a VMware virtual machine running Linux that is using logical volume manager (LVM). Firstly we will be increasing the size of the actual disk on the VMware virtual machine, so at the hardware level – this is the VM’s .vmdk file. Once this is complete we will get into the virtual machine and make the necessary changes through the operating system in order to take advantage of the additional space that has been provided by the hard drive being extended. This will involve creating a new partition with the new space, expanding the volume group and logical group, then finally resizing the file system. As there are a number of different ways to increase disk space I have also posted some different methods here:
Prerequisites: As this method uses the additional space to create a primary partition, you must not already have 4 partitions as you will not be able to create more than 4. If you do not have space for another partition then you will need to consider a different method, there are some others in the above list. Throughout my examples I will be working with a VMware virtual machine running Debian 6, this was set up with a 20gb disk and we will be increasing it by 10gb for a total final size of 30gb. Identifying the partition type As this method focuses on working with LVM, we will first confirm that our partition type is actually Linux LVM by running the below command. Kod:
fdisk -l As you can see in the above image /dev/sda5 is listed as “Linux LVM” and it has the ID of 8e. The 8e hex code shows that it is a Linux LVM, while 83 shows a Linux native partition. Now that we have confirmed we are working with an LVM we can continue. For increasing the size of a Linux native partition (hex code 83) see this article. Below is the disk information showing that our initial setup only has the one 20gb disk currently, which is under the logical volume named /dev/mapper/Mega-root – this is what we will be expanding with the new disk. Note that /dev/mapper/Mega-root is the volume made up from /dev/sda5 currently – this is what we will be expanding. Increasing the virtual hard disk First off we increase the allocated disk space on the virtual machine itself. This is done by right clicking the virtual machine in vSphere, selecting edit settings, and then selecting the hard disk. In the below image I have changed the previously set hard disk of 20gb to 30gb while the virtual machine is up and running. Once complete click OK, this is all that needs to be done in VMware for this process. If you are not able to modify the size of the disk, the provisioned size setting is greyed out. This can happen if the virtual machine has a snapshot in place, these will need to be removed prior to making the changes to the disk. Alternatively you may need to shut down the virtual machine if it does not allow you to add or increase disks on the fly, if this is the case make the change then power it back on. Detect the new disk space Once the physical disk has been increased at the hardware level, we need to get into the operating system and create a new partition that makes use of this space to proceed. Before we can do this we need to check that the new unallocated disk space is detected by the server, you can use “fdisk -l” to list the primary disk. You will most likely see that the disk space is still showing as the same original size, at this point you can either reboot the server and it will detect the changes on boot or you can rescan your devices to avoid rebooting by running the below command. Note you may need to change host0 depending on your setup. Kod:
echo "- - -" > /sys/class/scsi_host/host0/scan Partition the new disk space As outlined in my previous images the disk in my example that I am working with is /dev/sda, so we use fdisk to create a new primary partition to make use of the new expanded disk space. Note that we do not have 4 primary partitions already in place, making this method possible. Kod:
fdisk /dev/sda ‘n’ was selected for adding a new partition. Kod:
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): n Kod:
Command action l logical (5 or over) p primary partition (1-4) p Kod:
Partition number (1-4): 3 Kod:
First cylinder (2611-3916, default 2611): "enter" Using default value 2611 Last cylinder, +cylinders or +size{K,M,G} (2611-3916, default 3916): "enter" Using default value 3916 Kod:
Command (m for help): t Partition number (1-5): 3 Kod:
Hex code (type L to list codes): 8e Changed system type of partition 3 to 8e (Linux LVM) Kod:
Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks. For CentOS/RHEL run a “partx -a /dev/sda3″ to avoid rebooting later on. That’s all for partitioning, we now have a new partition which is making use of the previously unallocated disk space from the increase in VMware. Increasing the logical volume We use the pvcreate command which creates a physical volume for later use by the logical volume manager (LVM). In this case the physical volume will be our new /dev/sda3 partition. Kod:
root@Mega:~# pvcreate /dev/sda3 Device /dev/sda3 not found (or ignored by filtering). Kod:
root@Mega:~# pvcreate /dev/sda3 Physical volume "/dev/sda3" successfully created Kod:
root@Mega:~# vgdisplay --- Volume group --- VG Name Mega ... VG Size 19.76 GiB Kod:
root@Mega:~# vgextend Mega /dev/sda3 Volume group "Mega" successfully extended Kod:
root@Mega:~# pvscan PV /dev/sda5 VG Mega lvm2 [19.76 GiB / 0 free] PV /dev/sda3 VG Mega lvm2 [10.00 GiB / 10.00 GiB free] Total: 2 [29.75 GiB] / in use: 2 [29.75 GiB] / in no VG: 0 [0 ] Firstly confirm the name of the logical volume using lvdisplay. This name will vary depending on your setup. Kod:
root@Mega:~# lvdisplay --- Logical volume --- LV Name /dev/Mega/root Kod:
root@Mega:~# lvextend /dev/Mega/root /dev/sda3 Extending logical volume root to 28.90 GiB Logical volume root successfully resized Kod:
root@Mega:~# resize2fs /dev/Mega/root resize2fs 1.41.12 (17-May-2010) Filesystem at /dev/Mega/root is mounted on /; on-line resizing required old desc_blocks = 2, new_desc_blocks = 2 Performing an on-line resize of /dev/Mega/root to 7576576 (4k) blocks. The filesystem on /dev/Mega/root is now 7576576 blocks long. Summary With this method we have increased the virtual disk drive through VMware, created a new partition out of this newly unallocated space within the guest OS, turned it into a physical volume, extended the volume group, and then finally extended the original logical volume over the newer physical volume resulting in overall disk space being increased successfully. Alıntı - Root Users |
Konuyu Toplam 3 Üye okuyor. (0 Kayıtlı üye ve 3 Misafir) | |
Seçenekler | |
Stil | |
|
Benzer Konular | ||||
Konu | Konuyu Başlatan | Forum | Cevap | Son Mesaj |
Forum.TuTSaKHoSTiNG.Com | Teknoloji Haberler - VMware, VMware Workstation 8?i kullanıma sundu! | PaLeRmO | Teknoloji | 0 | 12. October 2011 02:05 PM |
Forum.TuTSaKHoSTiNG.Com | Teknoloji Haberler - Deprem oluşturan makina geliştirildi! | PaLeRmO | Teknoloji | 0 | 30. March 2010 01:11 AM |
Forum.TuTSaKHoSTiNG.Com | Teknoloji Haberler - Hayatın her anını ölümsüzleştiren makina! | PaLeRmO | Teknoloji | 0 | 20. October 2009 09:29 PM |
Centos/Linux üzerine VMware Server 2.0 Kurulumu | PaLeRmO | Desler | 0 | 24. March 2009 06:45 PM |
imza boyutu | İSMAİL | Genel Sorunlar | 5 | 12. May 2008 12:00 AM |
En Fazla Arama Yapılan 100 Kelime Aranan Kelimeler |
... |