Расширение раздела в CentOS 6/7

Сначала добавляем необходимый объем в Hyper-V
 
 
Далее указываем объем который будет после добавления места на диске
 
И завершаем добавление.
 
Не забываем тоже самое проделать на резервной ноде для диска реплики, иначе процесс репликации встанет.
 
 
Особенность заключается в том, что операционная система «добавленное» место не сможет использовать самостоятельно, так как оно будет не размечено. 
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos_ansible-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
# 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_ansible-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_ansible-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_ansible
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_ansible /dev/sda3
Volume group "centos_ansible" successfully extended
Название логического тома, который нужно расширить:
 
# lvdisplay
--- Logical volume ---
LV Path /dev/centos_ansible/root
LV Name root
VG Name centos_ansible
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_ansible/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_ansible-root
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/mapper/centos_ansible-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_ansible-root to 1799936 (4k) blocks.
The filesystem on /dev/mapper/centos_ansible-root is now 1799936 blocks long.
Для CentOS 7
 
# xfs_growfs /dev/mapper/centos_ansible-root
meta-data=/dev/mapper/centos_ansible-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
Проверяем что получилось:
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos_ansible-root 58G 11G 47G 19% /
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
Размер корневой файловой системы увеличился. Прелесть в том, что это расширение производится в online режиме без каких либо live-систем и прочего. 

 

Была ли эта статья полезной?
Пользователи, считающие этот материал полезным: 3 из 3
Еще есть вопросы? Отправить запрос

0 Комментарии

Войдите в службу, чтобы оставить комментарий.
На базе технологии Zendesk