Give root more space

3

I just installed Minibian on my Raspberry Pi but I don't seem to be able to use all the space on my SD card (64 gigs). As far as I can figure out by myself, the root volume is too small. Here is the output from df -h:

root@minibian:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       705M  441M  213M  68% /
devtmpfs        483M     0  483M   0% /dev
tmpfs           487M     0  487M   0% /dev/shm
tmpfs           487M  6.5M  481M   2% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           487M     0  487M   0% /sys/fs/cgroup
tmpfs           487M     0  487M   0% /tmp
/dev/mmcblk0p1   61M   35M   27M  57% /boot
tmpfs            98M     0   98M   0% /run/user/0

Originally the the partitions looked like this:

root@minibian:~# fdisk -l
[...]
Disk /dev/mmcblk0: 59.5 GiB, 63864569856 bytes, 124735488 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: 0x00000000

Device         Boot  Start     End Sectors  Size Id Type
/dev/mmcblk0p1          16  125055  125040 61.1M  b W95 FAT32
/dev/mmcblk0p2      125056 1626111 1501056  733M 83 Linux

root@minibian:~# lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
mmcblk0     179:0    0 59.5G  0 disk 
├─mmcblk0p1 179:1    0 61.1M  0 part /boot
└─mmcblk0p2 179:2    0  733M  0 part /

But then I deleted the mmcblk0p2-partition and created a new one with more space:

Device         Boot  Start       End   Sectors  Size Id Type
/dev/mmcblk0p1          16    125055    125040 61.1M  b W95 FAT32
/dev/mmcblk0p2 *    125056 100788223 100663168   48G 83 Linux

root@minibian:~# lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
mmcblk0     179:0    0 59.5G  0 disk 
├─mmcblk0p1 179:1    0 61.1M  0 part /boot
└─mmcblk0p2 179:2    0   48G  0 part /

The output given by df -h remains exactly the same, though. How can I give /dev/root more space?

Sidenote: I don't care if I lose any data, I haven't begun using the Raspberry yet. Thanks a bunch!

partitioning
debian
raspberry-pi
root
asked on Super User Oct 1, 2016 by Simon Hyttfors

1 Answer

3

There is a difference between partition size and filesystem size. So far you have enlarged the partition and saved this information to the disk (or sd card), but you haven't changed the information saved in filesystem.

Method to enlarge the filesystem depends on it's type. Since it's minibian, you're most likely using ext3 or ext4 filesystem. Check to be certain.

Enlarging ext filesystem is fairly easy and if it's ext4 it should be possible to do it even when mounted. Just call resize2fs without size parameter to utilize entire partition:

resize2fs /dev/mmcblk0p2

answered on Super User Oct 1, 2016 by Marek Rost • edited Apr 13, 2017 by Community

User contributions licensed under CC BY-SA 3.0