Увеличение диска Ubuntu

Статья может быть полезна пользователям услуг Виртуальный сервер VPS и Виртуальная инфраструктура IaaS

1. Запускаем утилиту parted:

root@ubuntu-vm:~# parted

2. Проверяем текущую разметку:

(parted) p
Model: VMware Virtual disk (scsi)
Disk /dev/sda: 53.7GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 512MB 511MB primary ext2 boot
2 513MB 10.7GB 10.2GB extended
5 513MB 10.7GB 10.2GB logical lvm
3. Изменим раздел и укажем новый общий размер раздела:
(parted) resizepart
Partition number? 2
End? [10.7GB]? 50G
Information: You may need to update /etc/fstab.

 

4. Расширим текущий логический раздел.

Требуется прописать следующие комбо-команды: n, l, p, enter, enter

root@ubuntu-vm:~# fdisk /dev/sda
Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n
Partition type
p primary (1 primary, 1 extended, 2 free)
l logical (numbered from 5)
Select (default p): l
Adding logical partition 6
First sector (20971520-97656250, default 20971520):
Last sector, +sectors or +size{K,M,G,T,P} (20971520-97656250, default 97656250):
Created a new partition 6 of type 'Linux' and of size 36.6 GiB.

 

5. Просмотрим новый созданный раздел:

Command (m for help): p
Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 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
Disklabel type: dos
Disk identifier: 0xeb48c344
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 999423 997376 487M 83 Linux
/dev/sda2 1001470 97656250 96654781 46.1G 5 Extended
/dev/sda5 1001472 20969471 19968000 9.5G 8e Linux LVM
/dev/sda6 20971520 97656250 76684731 36.6G 83 Linux

 

6. Меняем тип на Linux LVM:

Command (m for help): t
Partition number (1,2,5,6, default 6): 6
Partition type (type L to list all types): 8e
Changed type of partition 'Linux' to 'Linux LVM'.
Command (m for help): p
Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 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
Disklabel type: dos
Disk identifier: 0xeb48c344
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 999423 997376 487M 83 Linux
/dev/sda2 1001470 97656250 96654781 46.1G 5 Extended
/dev/sda5 1001472 20969471 19968000 9.5G 8e Linux LVM
/dev/sda6 20971520 97656250 76684731 36.6G 8e Linux LVM

 

7. Записываем изменения:

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: 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).

 

8. Перезагружаем и расширяем:

root@ubuntu-vm:~# pvcreate /dev/sda6
Physical volume "/dev/sda6" successfully created
root@ubuntu-vm:~# vgextend ubuntu-vg /dev/sda6
Volume group "ubuntu-vg" successfully extended
root@ubuntu-vm:~# lvextend -l +100%FREE /dev/ubuntu-vg/root
Size of logical volume ubuntu-vg/root changed from 7.50 GiB (1919 extents) to 44.09 GiB (11286 extents).
Logical volume root successfully resized.
root@ubuntu-vm:~# resize2fs /dev/ubuntu-vg/root
resize2fs 1.42.13 (17-May-2015)
Filesystem at /dev/ubuntu-vg/root is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 3
The filesystem on /dev/ubuntu-vg/root is now 11556864 (4k) blocks long.
Управление Виртуальными серверами VPS
Увеличение диска CentOS