How to extend partition in Ubuntu Guest on Vmware
On my Windows 7 host, I am using VMware Player to use Ubuntu. I had initially allocated 20GB and now getting Disk space full errors. So I wanted to extend partition. By searching on forums I saw how to add more disk and used this command to make it 30G —
sudo lvextend -L30G /dev/sda1
But still df command shows that max is 20GB. After more searching it seems that I need to extend partition using gparted. I tried using that but Resize button is disabled. I searched for that and they say that if the partition shows a key image then that partition is active and I cannot change it if it is live. Screenshot After some more search looks like this can also be fixed by using booting the OS from CD or using gparted boot from cd, boot using iso etc etc without giving any clear instructions. Can someone please guide or post any link which has clear instructions including screenshots for a linux layman as to how I can extend the partition.
3 Answers 3
Just did it in a Ubuntu 18.04 Server guest over a Windows 10 host.
The easiest way is, like you already suggested, to boot a live Ubuntu (the regular one, not server) and use GParted.
But first you need to «configure» the VMWare to increase the «virtual disk» size. Follow these steps:
- Shutdown the guest
- Click on «edit virtual machine settings» of that guest
- Click on «Hard disk» and «Expand. «
- A VMware window will let you modify the size, in GBs, of the device. Set the size you want and click on «Expand». After a while it will end.
At this point, the hard drive is bigger than before, but the partition is not. You must resize the partition also. To do so, download the ISO file of the regular Ubuntu distribution. Any other bootable device will also work, but this is the simplest way. Having the ISO downloaded do this:
- In the same configuration window as before, instead of configure the «Hard Disk» go to «CD/DVD» section.
- Make sure the option «Connect at power on» is set.
- Select «Use ISO image file:» and browse to the ISO file you downloaded.
After this, the guest is ready to be launched. Click in «Play virtual machine» and pay attention because you need to press the Esc key very quick to enter the boot menu, just before the VMWARE logo appears. As it were the BIOS of your physical computer.
Tip: After click on «Play. » click again over the VMWare window (black screen at this point) to make sure that the control of keyboard and mouse are in the guest, and not in the host. If you miss this step, you can simply reboot and try again.
Once you see the boot options:
- Press the down arrow key to highlight «CD-ROM Drive» and press enter.
- Ubuntu will start as live session.
- Select appropriate language and «Try Ubuntu».
- Wait until the desktop is loaded.
Look for the GParted tool and launch it. You will see two main blocks, one with some color (yellow probably) and the other in gray. The colored block is your actual partition (probably called /sda/sda1). To resize it do:
- Right click on the yellow block and select «ummount» or «stop»
- Right click again and «resize».
- In the new window, drag the limit of the partition to wherever you want of the free space (gray).
- Click «Ok»
- Don’t forget to click in «Apply changes» in Gparted’s main window before closing, otherwise the operation is not performed.
Once it is finished, you have already a bigger partition, just reboot and you will be good to go. (Don’t forget to uncheck the CD/DVD Connect at power on if it is not needed).
how to increase HD size of Linux running on VMware
I have already increased the size by going into VMWARE Workstation settings ->Hardisk to 34GB. But I cant able to relocate it inside the Ubunto running inside the VMware. I want to increase the size of /dev/sda1
4 Answers 4
I faced the same problem and fixed it using gparted .
After increasing the size by going into VMWARE Workstation settings -> Hardisk,
sudo apt-get install gparted
- After installation, open gparted
- You will see the space unallocated(1), this is the space that you indicated in your vmware workstation settings (5GB in my case)
- Select your existing partition(1), then click the Resize/Move icon(2).
- Simply, move the resize handle up to your desired new size(1), click Resize (2).
- Do not forget to click the Check icon to Apply all operation made.
- and that’s it! You have expanded your VM HD Size.
Try it out, the app’s ui made it easier to use. I used this method in my VMWare Workstation for Ubuntu 18.04. (might work as well with Ubuntu 20.x)
For me this is not working. Despite the space showing up as unallocated as expected, after selecting the existing partition and clicking Resize/Move , the space cannot be allocated. Minimum size and maximum size show the same value.
Sometimes the GUI approach beats the CLI approach. The check icon looked slightly different in v1.2.0. Thank you!
How to expand hard disk size using VMware:
To increase the virtual disk from the command line:
- Open a command prompt. For more information, see how to open command prompt.
- Navigate to the product’s installation directory. See how to do that
- Type vmware-vdiskmanager -x 100Gb vm.vmdk and press Enter(Replace 100Gb with the actual size of virtual disk that you want. You can also specify Kb and Mb.)
- Follow this
And, I guess you’ve tried this(from GUI):
- Select the virtual machine from the Inventory.
- Click Edit Virtual Machine Settings.
- Click Hard Disk.
- Click Utilities > Expand, enter the new size, then click Expand.
- Again, follow this one
How to expand hard disk size inside Ubuntu(using gparted tool):
What about expanding inside Ubuntu, I guess you should try gparted or similar tool. How to do that, go here
To open gparted do the following:
- Install it by typing sudo apt-get install gparted
- Run it by pressing Alt+F2 , and type there gparted
Note: To edit the hard disk size we must remove existing snapshots, so be careful
First, remove any existing snapshots and edit the Hard disk size and launch the VM
COMMANDS
Run below commands as ROOT user
=> Select the File System ‘linux-swap’ and click on ‘Swapoff’
=> Select the File System ‘extended’ then do right click and select ‘resize/move’ and drag the right arrow to full-right, then click ‘resize/move’
=> Select the File System ‘linux-swap’ then do right click and select ‘resize/move’ and drag the left-and-right symbol to full-right, then click ‘resize/move’ and click ‘OK’
=> Select the File System ‘extended’ then do right click and select ‘resize/move’ and drag the left arrow to full-right and select Align to ‘Cylinder’ from drop-down menu, then click ‘resize/move’
=> Select the File System ‘ext4’ then do right click and select ‘resize/move’ and drag the right arrow to full-right, then click ‘Resize’
=> Then either click on ‘check symbol’ or go to edit and select ‘Apply All Operations’ then click ‘Apply ‘ and ‘Close’ (Ignore warnings)
VMWare & Linux: Увеличиваем размер файловой системы
Технологии виртуализации VMWare позволяет налету изменять размер дисков гостевых ОС — это факт.
Если для Windows процедура увеличения корневого раздела происходит в пару кликов, без перезагрузки, то изменение корневого (в частности) или смонтированного раздела Linux во время выполнения происходит не так просто. Модифицированная таблица разделов для «корня» не перечитывается ядром, даже после выполнения «partprobe», т.е. в любом случае придется делать перезагрузку.
В случае наличии у вас LVM все гораздо проще, но в моем случае все достаточно стандартно — система состоит из 3 разделов:
[root@ ~]# parted -l Model: VMware Virtual disk (scsi) Disk /dev/sda: 10.7GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 1049kB 211MB 210MB primary ext3 boot 2 211MB 9664MB 9453MB primary ext4 3 9664MB 10.7GB 1074MB primary linux-swap(v1)
Рассмотрим один из возможных вариантов расширение корневой файловой системы Linux «по старинке», используя parted, fdisk и reboot.
- Заходим в VMWare Client и увеличиваем размер жесткого диска.
- Запускаем повторное сканирование шины SCSI.
for scsi_device in /sys/class/scsi_device/*; do echo 1 > $scsi_device/device/rescan; done
Как видно из синтаксиса ниже общий объем диска увеличился с 10.7GB до 15.0GiB. При этом размеры разделов остались без изменений.
[root@ ~]# parted -ms /dev/sda 'u GiB p' BYT; /dev/sda:15.0GiB:scsi:512:512:msdos:VMware Virtual disk; 1:0.00GiB:0.20GiB:0.20GiB:ext3::boot; 2:0.20GiB:9.00GiB:8.80GiB:ext4::; 3:9.00GiB:10.0GiB:1.00GiB:linux-swap(v1)::;
Мне необходимо увеличить раздел с порядковым номером «2».
GNU Parted 2.2 Using /dev/sda Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) rm 3 (parted) rm 2 Error: Partition /dev/sda2 is being used. You must unmount it before you modify it with Parted.
Parted не дает возможность вносить изменения в смонтированный раздел, потому переходим в FDISK. Порядок команд следующий:
u переключается на секторах р печатаем таблица разделов и запоминаем стартовый сектор 2 раздела d удаляем раздел №2 n создать новый раздел: p создать основной раздел 2 создания разделов №2 2048 начало в секторе 411648 (выставляем согласно исходному значению) +12G раздел должен включать 12GiB t изменение типа раздела 2 выберите раздел №2 80 Linux раздел Аналогично, на свободном месте в конце раздела делаем swap, с типом раздела "82" р снова печатаем таблицу разделов Если все верно w записи таблицы разделов на диск и выход
[root@ ~]# fdisk /dev/sda 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): u Changing display/entry units to sectors Command (m for help): d Selected partition 2 Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First sector (63-54525951, default 63): 411648 Last sector, +sectors or +size (2048-54525951, default 54525951): +12G Command (m for help): t Partition number (1-4): 2 Hex code (type L to list codes): 80 Changed system type of partition 2 to 80 (Linux swap / Solaris) К сожалению исходного листинга данной машины не осталось, но вывод должен быть примерно такой, swap на данном этапе отсуствует: Command (m for help): p Disk /dev/sda: 16.1 GB, 16106127360 bytes 255 heads, 63 sectors/track, 1958 cylinders, total 31457280 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000bceec Device Boot Start End Blocks Id System /dev/sda1 * 2048 411647 204800 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 411648 31005449 15296901 83 Linux 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. root@ubuntu:~# partprobe Warning: WARNING: partition(s) 1 on /dev/sda could not be modified, probably because it/they is/are in use. As a result, the old partition(s) will remain in use until after reboot. You should reboot now before making further changes.
- fdisk записал таблицу разделов, но ядро по-прежнему использует старую таблицу разделов, так что мы должны перезагрузиться.
- После перезагрузки делаем:
[root@ ~]# df -H Filesystem Size Used Avail Use% Mounted on /dev/sda2 14G 1.2G 12G 10% / tmpfs 985M 0 985M 0% /dev/shm /dev/sda1 204M 100M 94M 52% /boot
Как видно размер корневого раздела был увеличен, что нам и требовалось.
# swapon -a # swapon -s Filename Type Size Used Priority /dev/sda3 partition 2096116 0 -1
Категория: Администрирование