Get Rewarded! We will reward you with up to €50 credit on your account for every tutorial that you write and we publish!

Изменение размера раздела EXT

profile picture
Author
Hetzner Online
Published
2019-03-08
Time to read
3 minutes reading time

Введение

Ниже приведён пример изменения размера дика после обновления CX10 до CX30.

Шаг 1 - Подготовка

Загрузите сервер в Rescue-систему.

Проверьте текущую таблицу разделов (она должна выглядеть следующим образом, в зависимости от модели): # fdisk -l /dev/sda

Disk /dev/sda: 102.4 GB, 102399737856 bytes
255 heads, 63 sectors/track, 12449 cylinders, total 199999488 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: 0x00051eb3

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048    52426752    26212352+  83  Linux

На всякий случай запомните начальный и конечный секторы, если что-либо пойдет не так.

Шаг 2 - Форматирование

Удалите раздел и создайте новый не его месте:

root@rescue ~ # fdisk /dev/sda

Command (m for help): d
Selected partition 1

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1):
Using default value 1
First sector (2048-199999487, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-199999487, default 199999487):
Using default value 199999487

Partition #1 contains a ext4 signature.
Do you want to remove the signature? [Y]es/[N]o: N

Command (m for help): p

Disk /dev/sda: 102.4 GB, 102399737856 bytes
255 heads, 63 sectors/track, 12449 cylinders, total 199999488 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: 0x00051eb3

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048   199999487    99998720   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Шаг 3 - Проверка файловой системы

Проверьте файловую систему с помощью:

root@rescue ~ # e2fsck -f -C0 /dev/sda1

e2fsck 1.42.5 (29-Jul-2012)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sda1: 26283/1638400 files (5.6% non-contiguous), 283813/6553088 blocks

Шаг 4 - Изменение размера файловой системы

Выполните изменение размера файловой системы:

# resize2fs /dev/sda1

resize2fs 1.42.5 (29-Jul-2012)
Resizing the filesystem on /dev/sda1 to 24999680 (4k) blocks.
The filesystem on /dev/sda1 is now 24999680 blocks long.

Сделайте перезагрузку и проверьте, стал ли диск больше.

Заключение

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

Want to contribute?

Get Rewarded: Get up to €50 in credit! Be a part of the community and contribute. Do it for the money. Do it for the bragging rights. And do it to teach others!

Report Issue
Try Hetzner Cloud

Get 20€ free credit!

Valid until: 31 December 2024 Valid for: 3 months and only for new customers
Get started
Want to contribute?

Get Rewarded: Get up to €50 credit on your account for every tutorial you write and we publish!

Find out more