🇩🇪 Deutsch

07 Oct 2019

Linux - Ein Dateisystem vergrößern

Folgende Situation: Man hat eine Partition mit einem Dateisystem von z. B. 80 GB. Das wird jetzt zu klein. Mann konnte aber hinter dieser Partition durch das Löschen einer anderen, unbenötigten Partition Platz schaffen. Es ist möglich, diese Partition und das Dateisystem ohne Datenverlust zu vergrlßern.

  • Die Ausgangssituation
fehmarn /home/chrissie # df -h
Filesystem      Size  Used Avail Use% Mounted on
udev             10M  4.0K   10M   1% /dev
/dev/sda3        79G   70G  4.4G  95% /
  • Als erstes mit fdisk die Partition in der Partitionstabelle löschen und größer anlegen

    Dies hat erstmal keine Auswirkungen auf das Dateisystem! Die Partitionstabelle wird vom Kernel separat behandelt. Dennoch sollte man hier sehr genau überlegen, was man tut. Besser auch mal die Partitionstabelle notieren oder backuppen. Im Beispieldialog ist auch ein Fehler enthalten, wenn man zum Beispiel eine zu große Partition erzeugen möchte.
fehmarn /home/chrissie # fdisk /dev/sda

Welcome to fdisk (util-linux 2.33).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): p
Disk /dev/sda: 298.1 GiB, 320072933376 bytes, 625142448 sectors
Disk model: WDC WD3200AAJS-5
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: 0x000862e8

Device     Boot     Start       End   Sectors  Size Id Type
/dev/sda1  *         2048   1050623   1048576  512M 83 Linux
/dev/sda2         1050624 197070847 196020224 93.5G 83 Linux
/dev/sda3       197070848 364843007 167772160   80G 83 Linux

Command (m for help): d
Partition number (1-3, default 3): 3

Partition 3 has been deleted.

Command (m for help): n
Partition type
   p   primary (2 primary, 0 extended, 2 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (3,4, default 3): 3
First sector (197070848-625142447, default 197070848):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (197070848-625142447, default 625142447): +240G
Value out of range.
Last sector, +/-sectors or +/-size{K,M,G,T,P} (197070848-625142447, default 625142447): +180G

Created a new partition 3 of type 'Linux' and of size 180 GiB.
Partition #3 contains a ext4 signature.

Do you want to remove the signature? [Y]es/[N]o: n

  • Jetzt die daten nochmals anzeigen, und dann ab, auf die Disk schreiben
Command (m for help): p

Disk /dev/sda: 298.1 GiB, 320072933376 bytes, 625142448 sectors
Disk model: WDC WD3200AAJS-5
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: 0x000862e8

Device     Boot     Start       End   Sectors  Size Id Type
/dev/sda1  *         2048   1050623   1048576  512M 83 Linux
/dev/sda2         1050624 197070847 196020224 93.5G 83 Linux
/dev/sda3       197070848 574558207 377487360  180G 83 Linux

Command (m for help): w
The partition table has been altered.
Syncing disks.
  • Nachdem man das getan hat, gilt es, das Dateisystem auf die vergrößerte Partition anzupassen. Das ist aber ‘ne Fingerübung.
fehmarn /home/chrissie # resize2fs /dev/sda3
resize2fs 1.44.5 (15-Dec-2018)
Filesystem at /dev/sda3 is mounted on /; on-line resizing required
old_desc_blocks = 10, new_desc_blocks = 23
The filesystem on /dev/sda3 is now 47185920 (4k) blocks long.

fehmarn /home/chrissie # df -h
Filesystem      Size  Used Avail Use% Mounted on
udev             10M  4.0K   10M   1% /dev
/dev/sda3       177G   70G   99G  42% /
tmpfs           1.2G  924K  1.2G   1% /run
cgroup_root      10M     0   10M   0% /sys/fs/cgroup
none            512M   71M  442M  14% /dev/shm
/dev/sda1       504M   62M  417M  13% /boot
/dev/md127      1.8T  1.6T  114G  94% /home
/dev/md126      2.7T  1.4T  1.3T  52% /media/fehmarn_data
none            5.8G   24K  5.8G   1% /run/user/1000