Re: Free space after partitioning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2012-03-21 at 13:55 +0100, Jan Safranek wrote:
> Hello,
> 
> I am trying to use pyanaconda.storage to get overview of installed
> storage facilities and I have troubles counting free space on a disk.
> 
> Consider a (virtual) disk with 10 partitions, created by Anaconda (code
> is below). pyanaconda.storage.partitioning.getFreeRegions([disk]) returns:
> 
> parted.Geometry instance --
>   start: 63  end: 2047  length: 1985
> -> the first sector is MBR. Why there are additional 62 sectors skipped
> before the first free region? Is it because of alignment rules?
> -> why Anaconda leaves the first megabyte free? Boot loader/grub? I did
> not request any.

This is all based on the alignment data provided by the kernel. Anaconda
obtains the alignment data for each device from parted and uses it to
ensure that all partitions are aligned.

> 
> The rest of primary partitions are fine, without any gaps. Logical
> partitions are quite different:
> 
>   start: 63551  end: 64259  length: 709
> This free region is at the beginning of the extended partition. The
> extended partition starts at sector 63488 and the first logical
> partition starts at 67584.
> -> Why there is a free space at all? I did not request any.
> -> What are 3325 sectors between the free space end and the first
> logical partition start? I know, there is one sector for logical
> partition metadata, but 1.6MB, which is not part of any partition nor
> free space region, seems too much to me.
> -> Similarly, what are 63 sectors between the extended partition start
> and the free space start? 1 sector is for logical partition metadata,
> but the rest?
> 
>   start: 110592  end: 112454  length: 1863
> This is a free space between two logical partitions.
> -> Again, why is the free region here? And there are 186 'hidden'
> sectors between this free space end and start of the next logical partition.

We are somewhat more liberal with rounding start sector up for logical
partitions, basically because parted is more aggressive in aligning
start of logical partitions than it is with normal partitions. Also, we
need to account for at least one sector of metadata before each logical
partition. In some unfortunate cases this bump to the next MB boundary
can amount to 2047 520-byte sectors. Again, parted is so aggressive with
this that we had to do the same in order to ensure that parted
magic/fixups do not cause unwanted surprises when the partitions are
added to disk.

> 
> If the alignment to cylinder boundary is cause of these weird numbers,
> can I turn the alignment off in pyanaconda.storage? The numbers
> reported by disks are completely artificial anyway these days.

We turn off cylinder alignment already.

> 
> Thanks in advance for any partitioning insight.
> 
> Jan
> 
> 
> Gory details
> ------------
> Sample code to create 10 partitions:
> <initialization omitted>
> disk = storage.devicetree.getDeviceByName('sda')
> for i in range(10):
>     part = storage.newPartition(disks=[disk], size=10)
>     storage.createDevice(part)
> pyanaconda.storage.partitioning.doPartitioning(storage=storage)
> storage.devicetree.processActions(dryRun=False)
> 
> 
> complete print of pyanaconda.storage.partitioning.getFreeRegions([disk]):
> parted.Geometry instance --
>   start: 63  end: 2047  length: 1985
>   device: <parted.device.Device object at 0x1efa6d0>  PedGeometry:
> <_ped.Geometry object at 0x1efa690>
> parted.Geometry instance --
>   start: 63551  end: 64259  length: 709
>   device: <parted.device.Device object at 0x1efa710>  PedGeometry:
> <_ped.Geometry object at 0x1efa4d0>
> parted.Geometry instance --
>   start: 110592  end: 112454  length: 1863
>   device: <parted.device.Device object at 0x1efa190>  PedGeometry:
> <_ped.Geometry object at 0x1efa650>
> parted.Geometry instance --
>   start: 223232  end: 2097151  length: 1873920
>   device: <parted.device.Device object at 0x1efab10>  PedGeometry:
> <_ped.Geometry object at 0x1efa0d0>
> 
> 
> fdisk output:
> Disk /dev/sda: 1073 MB, 1073741824 bytes
> 34 heads, 61 sectors/track, 1011 cylinders, total 2097152 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: 0xc9797763
> 
>    Device Boot      Start         End      Blocks   Id  System
> /dev/sda1            2048       22527       10240   83  Linux
> /dev/sda2           22528       43007       10240   83  Linux
> /dev/sda3           43008       63487       10240   83  Linux
> /dev/sda4           63488     2097151     1016832    5  Extended
> /dev/sda5           67584       88063       10240   83  Linux
> /dev/sda6           90112      110591       10240   83  Linux
> /dev/sda7          112640      133119       10240   83  Linux
> /dev/sda8          135168      155647       10240   83  Linux
> /dev/sda9          157696      178175       10240   83  Linux
> /dev/sda10         180224      200703       10240   83  Linux
> /dev/sda11         202752      223231       10240   83  Linux
> 
> _______________________________________________
> Anaconda-devel-list mailing list
> Anaconda-devel-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/anaconda-devel-list


_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux