Valid Arguments for Arranged

I read the parted page, but did not seem to find any documentation on valid parameters. I am trying to partition a USB CompactFlash with specific partition sizes (regardless of CF size). But I would like to make sure that my alignment is perfectly correct and optimal.

For example, when I use the following commands:

parted -s -a optimal $DEV mkpart primary ext3 1 1600 parted -s -a optimal $DEV mkpart primary ext3 1600 3200 parted -s -a optimal $DEV mkpart primary ext3 3200 3600 

It is unclear whether the first beginning of the section should be 1 or 0? The only hint I get should start from 1, not from scratch when I run:

 parted /dev/sdc align-check optimal 1 

Which tells me that it is aligned at startup from 1 and not aligned at startup from 0. But when I start from 1 and I do a β€œprint”, the start is 1049 KB ... is that normal? When I delete print sections created by other tools, I see that they start with 32 KB. If I use start 0, it prints start 512KB. What is right, I do not know!

In addition, I have seen many examples around the world of people using the initial value for the second and third sections as the final value of the section preceding it (that is: 1600 and 3200 values). Suppose we have an overlap or increment of 1? Human pages say nothing about this. And I saw some web pages where they say that a mistake for a start has the same value of the last end.

When I use "-optimal", it doesn't seem to even affect my section. Not using the alignment flag seems to give the same result. What is the purpose of this? Is something missing?

I really would like to leave much smarter and not demand a start, but could bring it out myself. In fact, many people need this exact function, so I'm not the only strange ball with this need. I hope some geek sees this need and actually adds it as a function.

Please note that I am using a script placed in automatic assembly, so I use the '-s' flag.

If anyone can enlighten me on this, I would really appreciate it ... thanks in advance!

+6
source share
1 answer

I think you asked a couple of interesting questions right here, which is a pity no one answered them before, so I will try to do it.


It is unclear whether the first start of the section should be 1 or 0?

The first start of the partition should be 1, because the first bytes of the disk contain the main boot record and the structure of some disk labels, such as MS-DOS. Therefore, if you use the value 0 as the beginning of the first partition, libparted will leave a few bytes at the beginning of the disk to allow this content by placing the beginning of the partition immediately after the first sector.


beginning at 1049kB ... is that normal?

This is normal. To explain this, you first need to know that for libparted, the kilobyte is not equal to 1024 bytes, instead it is equal to 1000 bytes.

KB = KiloByte = 1000Bytes
KiB = KibiByte = 1024Bytes

Additional Information:
http://en.wikipedia.org/wiki/Kilobyte
http://www.gnu.org/software/parted/manual/html_node/unit.html

The section offset is in KB (kilobytes), and its value is approximate if you change the unit to bytes:

 parted /dev/sdf unit b print 

you will see the real value: 1048576B is 1MiB (1048576B ~ = 1049KB), exactly what you wanted.


I see that they start with 32k

Yes, the partition starts with 32 KB, because the tool you are using is probably too old and you are using a disk with a sector size of 512 bytes. The actual initial offset of the partition is likely to be 32256, which corresponds to sector 63. Several years ago, the partitioning tools put the beginning of the first partition in the 63rd sector to align it with the old CHS geometry. This is too long to explain, but I recommend that you read these links for more details:

https://superuser.com/questions/352572/why-does-the-partition-start-on-sector-2048-instead-of-63 http://lwn.net/Articles/377895/


If I use start 0, it prints start 512kB

I think it prints a start on 512B, not KB, am I mistaken?
On your disk of 512-byte sectors, the first sector ends at offset 511, so, as I said above, the first section begins after the first sector.


Suppose we have an overlap or increment of 1?

I change the block to bytes, you will see the actual placement of the partitions and you can check that they do not overlap.


What is the purpose of this? Is something missing?

This is because by default parted works with MiB. When entering:

 parted -s -a optimal $DEV mkpart primary ext3 1 1600 

You ask for a split to create a partition between offsets corresponding to MiB # 1 and # 1600. Offsets matching MiB are always aligned for maximum performance, so -a optimal not necessary. If you change the block to bytes, you can create an unaligned section:

 parted $DEV unit b mkpart primary 1000000 160MB parted $DEV align-check optimal 1 

He showed the error: The resulting partition is not properly aligned for best performance.

So, try to do the same with the -a none option:

 parted -a none $DEV unit b mkpart primary 1000000 160MB 

Now there is no mistake, this is the purpose of this option.


I really would like the part to be much smarter and not demanding, but rather, he can do it himself.

I think that this function will be implemented by any tool using libparted, but I think that the library is not necessary ... but who knows? maybe some libparted developer is listening ... were you trying to send an error report? bug-parted@gnu.org

+17
source

Source: https://habr.com/ru/post/915301/


All Articles