---
title: "Centos и расширение разделов"
description: "Это действие сродни физической замены диска на вдвое больший. Особенность заключается в том, что опе..."
author: "anonops"
published: "2017-06-15T22:20:26+00:00"
modified: "2017-06-15T22:20:26+00:00"
locale: "ru"
canonical_url: "https://yvision.kz/post/centos-i-rasshirenie-razdelov-770199"
markdown_url: "https://yvision.kz/post/centos-i-rasshirenie-razdelov-770199/markdown"
site_name: "Yvision.kz"
---

# Centos и расширение разделов

> Это действие сродни физической замены диска на вдвое больший. Особенность заключается в том, что опе...

Это действие сродни физической замены диска на вдвое больший. Особенность заключается в том, что операционная система «добавленное» место не сможет использовать самостоятельно, так как оно будет не размечено. Собственно разметкой и последующим использованием мы и займёмся. Сперва стартовые данные:

```

# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos_monitor-root 28G 11G 17G 40% / devtmpfs 911M 0 911M 0% /dev tmpfs 921M 0 921M 0% /dev/shm tmpfs 921M 8.5M 912M 1% /run tmpfs 921M 0 921M 0% /sys/fs/cgroup /dev/sda1 497M 277M 221M 56% /boot tmpfs 185M 0 185M 0% /run/user/0
```

```

# fdisk -l Disk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 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: 0x000bf751 Device Boot Start End Blocks Id System /dev/sda1 * 2048 1026047 512000 83 Linux /dev/sda2 1026048 62914559 30944256 8e Linux LVM Disk /dev/mapper/centos_monitor-swap: 2147 MB, 2147483648 bytes, 4194304 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/mapper/centos_monitor-root: 29.5 GB, 29490151424 bytes, 57597952 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
```

Теперь создаём на диске новый раздел

```

# fdisk /dev/sda Welcome to fdisk (util-linux 2.23.2). 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 (2 primary, 0 extended, 2 free) e extended Select (default p): p Partition number (3,4, default 3): 3

# Следующий незанятый номер First sector (62914560-125829119, default 62914560): 62914560

# Следующий сектор Last sector, +sectors or +size{K,M,G} (62914560-125829119, default 125829119): 125829119

# Последний сектор, оставляем по умолчанию Partition 3 of type Linux and of size 30 GiB is set Command (m for help): t

# Меняем тип ФС Partition number (1-3, default 3): 3 Hex code (type L to list all codes): 8e

# Соответствует Linux LVM Changed type of partition 'Linux' to 'Linux LVM' Command (m for help): p Disk /dev/sda: 64.4 GB, 64424509440 bytes, 125829120 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: 0x000bf751 Device Boot Start End Blocks Id System /dev/sda1 * 2048 1026047 512000 83 Linux /dev/sda2 1026048 62914559 30944256 8e Linux LVM /dev/sda3 62914560 125829119 31457280 8e Linux LVM 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.
```

После этого необходимо перегрузить машинку

```

# reboot
```

После перезагрузки создаём физический раздел:

```

# pvcreate /dev/sda3 Physical volume "/dev/sda3" successfully created
```

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

```

# vgdisplay --- Volume group --- VG Name centos_monitor System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 1 Act PV 1 VG Size 29.51 GiB PE Size 4.00 MiB Total PE 7554 Alloc PE / Size 7543 / 29.46 GiB Free PE / Size 11 / 44.00 MiB VG UUID B7FEqI-aDzN-G0xX-xUgH-oTpd-TRWc-O9sKMi
```

Добавляем раздел:

```

# vgextend centos_monitor /dev/sda3 Volume group "centos_monitor" successfully extended
```

название логического тома, который нужно расширить:

```

# lvdisplay --- Logical volume --- LV Path /dev/centos_monitor/root LV Name root VG Name centos_monitor LV UUID cmFknm-2nVO-kREo-tQUr-Y7X5-VBPc-AfWkYR LV Write Access read/write LV Creation host, time localhost, 2015-05-26 02:03:59 +0300 LV Status available

# open 1 LV Size 27.46 GiB Current LE 7031 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:1
```

Расширяем раздел

```

# lvextend -l +100%FREE /dev/centos_monitor/root Size of logical volume centos_monitor/root changed from 27.46 GiB (7031 extents) to 57.50 GiB (14721 extents). Logical volume root successfully resized.
```

И последний шаг, который немного отличается в зависимости от версии Для CentOS 6

```

# resize2fs -p /dev/mapper/centos_monitor-root resize2fs 1.42.9 (28-Dec-2013) Filesystem at /dev/mapper/centos_monitor-root is mounted on /; on-line resizing required old desc_blocks = 1, new_desc_blocks = 2 Performing an on-line resize of /dev/mapper/centos_monitor-root to 1799936 (4k) blocks. The filesystem on /dev/mapper/centos_monitor-root is now 1799936 blocks long.
```

Для CentOS 7

```

# xfs_growfs /dev/mapper/centos_monitor-root meta-data=/dev/mapper/centos_monitor-root isize=256 agcount=4, agsize=1799936 blks = sectsz=512 attr=2, projid32bit=1 = crc=0 finobt=0 data = bsize=4096 blocks=7199744, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=0 log =internal bsize=4096 blocks=3515, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 7199744 to 15074304
```

---

Source: [https://yvision.kz/post/centos-i-rasshirenie-razdelov-770199](https://yvision.kz/post/centos-i-rasshirenie-razdelov-770199)