TrooperZ
Posts: 8
Joined: Tue Jul 24, 2018 4:32 pm

Unallocated space on Raspbian

Sat Aug 11, 2018 5:39 pm

So I was fixing partitions on a micro SD card for my friend's Pi on my Pi (funny right? :lol: ), when I found out that my SD card has some random unallocated space (nothing more than 6MB) and wondered what that space can be used for?

At first, I thought that you could partition it into linux-swap space, but didn't want to in risk of corruption.

Here is a image of the gparted device tree:
Image

As you can see, there are a couple of those unallocated partitions
  • 4 MB
  • 1.69 MB
  • and 3 MB
Are these important, or can I format them?

User avatar
rpdom
Posts: 12948
Joined: Sun May 06, 2012 5:17 am
Location: Ankh-Morpork

Re: Unallocated space on Raspbian

Sat Aug 11, 2018 5:43 pm

Too small to be any use. I believe the reason for these gaps is to try and make sure the partitions are aligned to an SD card page boundary for performance reasons.

TrooperZ
Posts: 8
Joined: Tue Jul 24, 2018 4:32 pm

Re: Unallocated space on Raspbian

Sat Aug 11, 2018 5:45 pm

rpdom wrote:
Sat Aug 11, 2018 5:43 pm
Too small to be any use. I believe the reason for these gaps is to try and make sure the partitions are aligned to an SD card page boundary for performance reasons.
Well, can I reformat them? Will it do any harm?

Ernst
Posts: 715
Joined: Sat Feb 04, 2017 9:39 am
Location: Germany

Re: Unallocated space on Raspbian

Sat Aug 11, 2018 5:47 pm

TrooperZ wrote:
Sat Aug 11, 2018 5:45 pm
rpdom wrote:
Sat Aug 11, 2018 5:43 pm
Too small to be any use. I believe the reason for these gaps is to try and make sure the partitions are aligned to an SD card page boundary for performance reasons.
Well, can I reformat them? Will it do any harm?
Yes, it may do harm because before you can format you need to partition which can be a dangerous activity if you do not understand why this gaps exist.
The road to insanity is paved with static ip addresses

User avatar
rpdom
Posts: 12948
Joined: Sun May 06, 2012 5:17 am
Location: Ankh-Morpork

Re: Unallocated space on Raspbian

Sat Aug 11, 2018 5:48 pm

TrooperZ wrote:
Sat Aug 11, 2018 5:45 pm
Well, can I reformat them? Will it do any harm?
You can create partitions in that space and try and format them. Depending on the file system you may succeed.

TrooperZ
Posts: 8
Joined: Tue Jul 24, 2018 4:32 pm

Re: Unallocated space on Raspbian

Sat Aug 11, 2018 6:37 pm

Ernst wrote:
Sat Aug 11, 2018 5:47 pm
TrooperZ wrote:
Sat Aug 11, 2018 5:45 pm
rpdom wrote:
Sat Aug 11, 2018 5:43 pm
Too small to be any use. I believe the reason for these gaps is to try and make sure the partitions are aligned to an SD card page boundary for performance reasons.
Well, can I reformat them? Will it do any harm?
Yes, it may do harm because before you can format you need to partition which can be a dangerous activity if you do not understand why this gaps exist.
Could you please explain fully why they are there?

Ernst
Posts: 715
Joined: Sat Feb 04, 2017 9:39 am
Location: Germany

Re: Unallocated space on Raspbian

Sat Aug 11, 2018 6:59 pm

TrooperZ wrote:
Sat Aug 11, 2018 6:37 pm
Could you please explain fully why they are there?
No. You have to ask the developers of the partitioning and file system software.
It has to do with alignment, allocation size, the device type, or something similar.
If you really want to know you can make an image copy of the card that you can mount using an usb card reader so that you can try to manipulate the disk partitioning.
The total of 8MByte "wasted" on a 32GByte (29.72GiB) memory card is totally unimportant, this is the overhead of having a partitioned memory device.
The road to insanity is paved with static ip addresses

LTolledo
Posts: 736
Joined: Sat Mar 17, 2018 7:29 am

Re: Unallocated space on Raspbian

Sat Aug 11, 2018 9:03 pm

Looking at the image, it seems that the Raspbian was installed from NOOBs, as it always do 6 partitions

An image installed Raspbian (using Etcher/WIn32DiskImager/Pi-Baker) has only 2 partitions, eliminating the unallocated spaces.

If you have only a few app/packages/configuration changes on your current Raspbian, you might reconsider a fresh installation using the latest raspbian-stretch image (not use NOOBS/PINN)
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

User avatar
HawaiianPi
Posts: 3030
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: Unallocated space on Raspbian

Sun Aug 12, 2018 1:36 am

TrooperZ wrote:
Sat Aug 11, 2018 6:37 pm
Could you please explain fully why they are there?
Already explained.
rpdom wrote:
Sat Aug 11, 2018 5:43 pm
I believe the reason for these gaps is to try and make sure the partitions are aligned to an SD card page boundary for performance reasons.
You could expand the partitions to fill the unused space, but it would reduce the performance of the SD card, which would make your Pi run slower when the OS accesses the card. If you need more of an explanation than that, look up how flash memory devices read, write and erase data.
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

procount
Posts: 1304
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Re: Unallocated space on Raspbian

Sun Aug 12, 2018 9:30 am

The reason for the gaps is mainly historical and due to backwards compatibility.

Remember that disk formatting schemes were created a long time ago to store data on floppy disks (8", 5 1/4" etc) before being used for hard disk drives. So it helps to have an understanding of how magnetic disks are structured. See https://en.wikipedia.org/wiki/Cylinder-head-sector .

As hard disk drives became larger, the need to partition them into individual drives became necessary to manage them more easily. Partitions were typically aligned to start on a new cyclinder. I'm not sure what the constraints were, but many of the disk partitioning tools enforced these constraints to make sure they worked on a wide variety of different drives.

Despite the CHS addressing method being largely superceeded by Logical Block Addressing (LBA), most of the old constraints are still implemented to maintain backward compatibility. Even on SD cards, the concept of CHS addressing largely lives on, even though internally they are structured into quite a different structure. The blocks/nodes and clusters that your particular disk format uses to store its data in are mapped onto the SD card blocks, mapped onto LBA, mapped onto a virtual CHS structure etc. So the constraints of CHS still live on.

SD cards typically store data in larger blocks (1K, 4K etc) so they bring an additional level of constraint. Even if the disk writing drivers want to write a 512 sector of data, the low level SD card driver has to map this to a 4K block, read the whole block, change 512 bytes and write the whole block back again. If a partition straddles such a 4K block, you can see that writing to one partition could inadvertently change data in another partition should an error occur. So to keep partitions independent of each other, the block sizes of the SD card also need to be taken into account.

The fact that we can transfer disk images between very different types of media (SD cards, magnetic hard disk drives, USB sticks etc) is largely due to the fact that all of the constraints of all of these types of media are taken into account when a drive is formatted & partitioned. Sometimes you will lose some small areas of space, but if you violate the rules, things will start breaking.

But I think most of the constraints are due to the START location of a partition. So if you must fill gaps, I think it best to do this be extending the end of the previous partition to make it a bit larger.
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

Return to “Raspbian”