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

Vergrößern einer EXT Partition

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

Einleitung

Im Folgenden wird das Vergrößern der Partition und des Dateisystems nach einem Upgrade eines CX10 auf einen CX30 gezeigt.

Schritt 1 - Vorbereitung

Booten des vServers in das Rescue system.

Überprüfen der aktuellen Partitionstabelle mit:

# 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

Um auf Nummer sicher zu gehen bietet es sich an, den Stand und Endsektoren der Partition für den Fehlerfall zu notieren.

Schritt 2 - Formatierung

Nun kann die Partition gelöscht und neuerstellt werden:

root@rescue ~ # fdisk /dev/sda

Command (m for help): d
Selected partition 1
Partition 1 has been deleted.

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

Created a new partition 1 of type 'Linux' and of size 102 GB.
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.

Schritt 3 - Überprüfung

Nun wird das Dateisystem vor der Vergrößerung überprüft mit:

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

Schritt 4 - Vergrößern des Dateisystems

Nun ist alles bereit für die Vergrößerung des Dateisystems, die wir durchführen mit: # 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.

Zum Abschluss sollte der Server neugestartet und die Größe überprüft werden.

Fazit

Nun sollten sie ihre Partition nach ihren Vorstellungen vergrößert und mit einem neuen Dateisystem versehen haben.

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