Resize space on your Tor(ified) RaspberryPi

It could happen that the sd memory card on your RaspberryPi will gets out of space. It's time, then, to enlarge your root partition.

Let's see how.


VERIFY YOUR FS

[jolek78@localhost ~]$ df -h Filesystem Size Used Avail Use% Mounted on /dev/root 29G 3.5G 25G 97% / <<<<<<<<<<<<<<<<< devtmpfs 460M 0 460M 0% /dev tmpfs 464M 0 464M 0% /dev/shm tmpfs 464M 13M 452M 3% /run tmpfs 464M 0 464M 0% /sys/fs/cgroup /dev/mmcblk0p1 286M 43M 244M 15% /boot tmpfs 93M 8.0K 93M 1% /run/user/42 tmpfs 93M 0 93M 0% /run/user/1000


VEFIFY STATUS PARTITION TABLES

[jolek78@localhost ~]$ sudo fdisk -l /dev/mmcblk0

Disk /dev/mmcblk0: 31.9 GB, 31914983424 bytes, 62333952 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: 0x00099aba

Device Boot Start End Blocks Id System /dev/mmcblk0p1 * 2048 587775 292864 c W95 FAT32 (LBA) /dev/mmcblk0p2 587776 1587199 499712 82 Linux swap / Solaris /dev/mmcblk0p3 1587200 9400319 3906560 83 Linux


MODIFY ROOT PARTITION TABLE

[jolek78@localhost ~]$ sudo su – Last login: Sun Jul 14 12:00:11 BST 2019 on pts/0

[root@localhost /]# fdisk /dev/mmcblk0 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): p

Disk /dev/mmcblk0: 31.9 GB, 31914983424 bytes, 62333952 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: 0x00099aba

Device Boot Start End Blocks Id System /dev/mmcblk0p1 * 2048 587775 292864 c W95 FAT32 (LBA) /dev/mmcblk0p2 587776 1587199 499712 82 Linux swap / Solaris /dev/mmcblk0p3 1587200 9400319 3906560 83 Linux

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

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): First sector (1587200-62333951, default 1587200): Using default value 1587200 Last sector, +sectors or +size{K,M,G} (1587200-62333951, default 62333951): Using default value 62333951 Partition 3 of type Linux and of size 29 GiB is set

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.

[root@localhost /]# reboot


FINALIZE THE OPERATION

[jolek78@localhost ~]$ sudo resize2fs /dev/mmcblk0p3 [sudo] password for jolek78: resize2fs 1.42.9 (28-Dec-2013) Filesystem at /dev/mmcblk0p3 is mounted on /; on-line resizing required olddescblocks = 1, newdescblocks = 4 The filesystem on /dev/mmcblk0p3 is now 7593344 blocks long.


VERIFY YOUR FS

[jolek78@localhost ~]$ df -h Filesystem Size Used Avail Use% Mounted on /dev/root 29G 3.5G 25G 13% / <<<<<<<<<<<<<<<<< devtmpfs 460M 0 460M 0% /dev tmpfs 464M 0 464M 0% /dev/shm tmpfs 464M 13M 452M 3% /run tmpfs 464M 0 464M 0% /sys/fs/cgroup /dev/mmcblk0p1 286M 43M 244M 15% /boot tmpfs 93M 8.0K 93M 1% /run/user/42 tmpfs 93M 0 93M 0% /run/user/1000


Artist: Singleton Snowstorms & Hurricanes || Album: Uncovered

— Jolek78