Raspberry - SD Resize mit Archlinux

Nach der Installation eines frischen Arch Linux ARM Images auf meinem Raspberry, stellte ich erstaunt fest, das der maximal verfügbare Platz der SD-Karte nicht vollständig verfügbar ist. Dies ist ärgerlich, schliesslich will ich den komplett verfügbaren Platz für meine Installation verwenden.

Ein df -h liefert den Beweis

Filesystem      Size  Used Avail Use% Mounted on
/dev/root       1.7G  499M  1.1G  33% /

Eigentlich handelt es sich im eine 8Gb SD Karte. Also wo ist der Rest ?

fdisk -l liefert eine Übersicht aller Partionen auf der SD.

Disk /dev/mmcblk0: 7.3 GiB, 7861174272 bytes, 15353856 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
Disklabel type: dos
Disk identifier: 0x00057540

Device         Boot     Start       End  Blocks  Id System
/dev/mmcblk0p1           2048    186367   92160   c W95 FAT32 (LBA)
/dev/mmcblk0p2         186368   3667967 1740800   5 Extended
/dev/mmcblk0p5         188416   3667967 1739776  83 Linux

Es sind als 3 Partitionen verfügbar, wobei die erste als boot verwendet wird. Die zweite Partion überlappt die Nummer 5. Um das zu ändern löschen wir die Partition Nummer 2 mit Hilfe von fdisk /dev/mmcblk0

[root@raspberry ~]# fdisk /dev/mmcblk0
Command (m for help): d
Partition number (1,2,5, default 5): 2
Partition 2 has been deleted.

Da Partition Nummer 5 in der zweiten enthalten ist, ist diese nun ebenfalls verschwunden

Command (m for help): p
Disk /dev/mmcblk0: 7.3 GiB, 7861174272 bytes, 15353856 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
Disklabel type: dos
Disk identifier: 0x00057540
Device         Boot Start       End Blocks  Id System
/dev/mmcblk0p1       2048    186367  92160   c W95 FAT32 (LBA)

Nun erstellen wir eine neue 2te Extended Partition. Die Defaultwerte können dabei einfach mit Enter übernommen werden.

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): e
Partition number (2-4, default 2):
First sector (186368-15353855, default 186368):
Last sector, +sectors or +size{K,M,G,T,P} (186368-15353855, default 15353855):
Created a new partition 2 of type 'Extended' and of size 7.2 GiB.

Die neue Partition 2 hat nun die gewünschte Grösse von 8Gb (7.2Gb). Nun können wir die Root-Partition erstellen

<b>Command (m for help): n</b>
Partition type:
   p   primary (1 primary, 1 extended, 2 free)
   l   logical (numbered from 5)
<b>Select (default p): l</b>
Adding logical partition 5
First sector (188416-15353855, default 188416):
Last sector, +sectors or +size{K,M,G,T,P} (188416-15353855, default 15353855):
Created a new partition 5 of type 'Linux' and of size 7.2 GiB.

Mit w kann die Paritionstabelle neu geschrieben werden

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: 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).

Der Kernel übernimmt das neue Layout erst nach einem Reboot.

[root@raspberry ~]# reboot

Nachdem Reboot kann das eigentliche Resizing der Partition vorgenommen werden

[root@raspberry ~]# resize2fs /dev/mmcblk0p5

df -h –total zeigt nun den total verfügbaren Platz :-)

[root@raspberry ~]# df -h --total
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       7.1G  505M  6.3G   8% /
devtmpfs         83M     0   83M   0% /dev
tmpfs           231M     0  231M   0% /dev/shm
tmpfs           231M  260K  231M   1% /run
tmpfs           231M     0  231M   0% /sys/fs/cgroup
tmpfs           231M     0  231M   0% /tmp
/dev/mmcblk0p1   90M   24M   66M  27% /boot
total           8.2G  529M  7.4G   7% -