Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I ran out of space?? Resizing the SD/root partition
#1
The Raspberry is a good little unit, and one of the tasks it does for you automatically now is to resize the root partition so that you get the full size of your SD card. Sadly most other SBC's don't, and expect you to know how to do that.. But its actually not that obvious, especially if like me you are not a regular linix user.
When you create a new image on your SD it does not start off with all the SD memory free, so you have to resize, if you find your SBC is resizing (a few do) then you won't need this, but I never could get a simple answer to the issue!


Lucky I stumbled onto this blog post that helps to explain it all, you have to do this the 1st time you boot up a new SD image, if you write anything before you do that you will lose data.
Here's the original post
http://gleenders.blogspot.nl/2014/08/ban...-root.html 

As its quite old, and the blogger does not seem to post any more, it might vanish so here is the bones of it again

sudo fdisk /dev/mmcblk0
In fdisk:

Press ‘p’ to print the partition table:

Disk /dev/mmcblk0: 15.9 GB, 15931539456 bytes
4 heads, 16 sectors/track, 486192 cylinders, total 31116288 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: 0x00084078

   Device Boot           Start         End      Blocks   Id  System
/dev/mmcblk0p1            2048      124927       61440   83  Linux
/dev/mmcblk0p2          124928    31116287    15495680   83  Linux 

the 124928 number may well be quite different on your SD, but take note of it, its this number that matters as its the start of the partition
Press 'd' to delete a partition:
Enter '2' to choose the second partition.
Press 'n' to create a new partition:
Enter 'p' to select primary as partition type.
Partition number: enter to accept 2 as default partition number.
First sector: enter to accept default.
This should be that 124928 number of the number you took not of as the start
Last sector: enter to accept default.
Press 'w' to write the new partition table.
Reboot to force the kernel to recognise the new partition table.

sudo reboot
After the system has come back up you still have to resize the partition.

sudo resize2fs /dev/mmcblk0p2


when done you will now have the full size of your drive available to you to store data
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's 



Reply
#2
Its now quite rare for a system to not resize its filesystem, (seems obvious to me it should have been done in the 1st versions of any OS...)
So you are only likely to need this if you burn an old OS to an SD...if you suddenly run out of disk space...you should have resized..reburn the os and make sure this is the 1st thing you do before trying to update or install anything.
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's 



Reply
#3
Uh, I am not aware of a system that is no a Unix OS that will resize it's filesystem. Even then, it's hit and miss where or not it will resize the root partition using some third party tools.

However, the NVIDIA Jetson Nano is supposed to resize the root filesystem to use up all of the SD card automatically at boot, but does not work 100% of the time.

With the Raspberry Pi on the first boot of a fresh SD card, you would run 'raspi-config' and then select 'Advanced Options' and then 'Expand Filesystem' to resize the root partition and utilize the entire space of the SD card. Then reboot the Pi.

There are manual ways of doing this, like what is required on a BeagleBone system, but one must be careful to not mess up the image otherwise a reburn of the SD card is required.
Reply
#4
No thats the old way, Rpi and almost all current SBC distros, do an auto resize on the 1st boot, but tehre will be a few who don't
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's 



Reply
#5
I have yet to see a Raspberry Pi do an auto resize on the filesystem on first boot. The latest I tried was a RasPi 3 A+ and I still had to go the raspi-config route. I wonder if that is only available with the NOOB image and not Raspbian.
Reply
#6
?? resize hasn't been part of raspi-config for a year or 2 now...just double checked on an older 3B with jessie and it hasn't got it. I don't use noobs, so not sure if it has it, though it rather defeats the purpose of making things simple if it has.
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's 



Reply
#7
are you using the latest version of raspbian?
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's 



Reply
#8
I don't have the April release, but its fairly recent. I'll have to give it another go and see what is happening. The Jetson Nano had an issue as well so perhaps there is something going on with the Linux version of Etcher.


Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)