Vmware как расширить диск linux

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:

  1. Shutdown the guest
  2. Click on «edit virtual machine settings» of that guest
  3. Click on «Hard disk» and «Expand. «
  4. 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:

  1. In the same configuration window as before, instead of configure the «Hard Disk» go to «CD/DVD» section.
  2. Make sure the option «Connect at power on» is set.
  3. 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:

  1. Press the down arrow key to highlight «CD-ROM Drive» and press enter.
  2. Ubuntu will start as live session.
  3. Select appropriate language and «Try Ubuntu».
  4. Wait until the desktop is loaded.
Читайте также:  Система управления процессами linux

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:

  1. Right click on the yellow block and select «ummount» or «stop»
  2. Right click again and «resize».
  3. In the new window, drag the limit of the partition to wherever you want of the free space (gray).
  4. Click «Ok»
  5. 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).

Источник

Добавление дискового пространства виртуальной машине в VMware

Обновлено

Обновлено: 28.03.2023 Опубликовано: 21.06.2017

Любая работа с информацией подразумевает вероятность ее потери. Не поленитесь сделать резервную копию важных данных, прежде чем работать с дисковыми утилитами.

Увеличение диска виртуальной машины

Выбираем нужную машину — кликаем по ней правой кнопкой мыши и кликаем по Edit Settings:

Настройка виртуальной машины в VMware

В открывшемся окне устанавливаем курсор на виртуальном диске (Hard Disk) — в правой части окна добавляем пространство диску:

Добавление дискового пространства виртуальной машине в VMware

Нажимаем OK и ждем выполнения операции.

Настройка операционной системы

Предыдущие действия, всего лишь, увеличат сам диск, но система по прежнему будет видеть старый объем. Чтобы заставить систему увидеть весь диск, выполняем инструкцию ниже.

Windows

Открываем «Управление компьютером» (в панели администрирования или командой compmgmt.msc). Переходим в раздел Управление дисками:

Переход к управлению дисками в управлении компьютером

В правой части мы должны увидеть новое нераспределенное пространство, в противном случае, нажимаем F5:

Не распределенное пространство в управлении дисками Windows

Кликаем правой кнопкой мыши по существующему разделу, который хотим увеличить и выбираем Расширить том:

Расширение тома в Windows

В открывшемся мастере нажимаем ДалееДалееГотово.

Linux

Проверить состояние дисков и их размер можно командой:

После добавления пространства мы не увидим никаких изменений. Сканируем увеличение размера для дисковой подсистемы:

echo «1» > /sys/class/block/sda/device/rescan

* обратите внимание, что в данном примере мы просканировали изменения для диска sda. Если мы будем работать с другим диском, необходимо подставить в команду другое значение.

Если мы добавили диск, а не увеличили размер имеющегося, то для сканирования и поиска добавленных дисков вводим:

Читайте также:  Просмотр прав файла линукс

Мы должны увидеть, что размер диска стал больше.

Смотрим информацию о диске:

* в моем случае диск /dev/sda.

Disk /dev/sda: 161.1 GB, 161061273600 bytes, 314572800 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 label type: dos
Disk identifier: 0x0009fbee

Устр-во Загр Начало Конец Блоки Id Система
/dev/sda1 * 2048 1050623 524288 83 Linux
/dev/sda2 1050624 20971519 9960448 8e Linux LVM

* видно, что общий объем диска 161.1 Гб. Также диск разбит на два раздела sda1 и sda2.

Если система не увидит новый объем диска, придется ее перезагрузить.

Смотрим объем каждого из разделов:

Disk /dev/sda1: 536 MB, 536870912 bytes, 1048576 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 /dev/sda2: 10.2 GB, 10199498752 bytes, 19920896 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

* видно, что суммарно диск используется на 11 Гб.

Далее необходимо выполнить расширение раздела Linux. Для этого существуют различные способы и инструменты, которые я постарался собрать в статье Расширение диска или раздела Linux.

Источник

VMWare & Linux: Увеличиваем размер файловой системы

vosstanovlenie-dannih

Технологии виртуализации 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

Категория: Администрирование

Читайте также:  Восстановить разрешение экрана linux

Источник

Оцените статью
Adblock
detector