Giter VIP home page Giter VIP logo

Comments (9)

Mic92 avatar Mic92 commented on September 21, 2024

This is contradicting the original message of this PR: #362

The following command:
sgdisk --new=4:0:-0 /dev/xda
will work but unless the overall disk size is aligned to 4k, the new partition will not be > aligned to 4k.
--set-alignment=2048 --align-end aligns new partitions to 1 MiB (2048 sectors). This enables for example --sector-size=4096 for cryptsetup luksFormat.

from disko.

Mic92 avatar Mic92 commented on September 21, 2024

Is there a way to specify bytes instead of sectors?

from disko.

intelfx avatar intelfx commented on September 21, 2024

This is contradicting the original message of this PR

I believe what matters for the goal described in #362 is --align-end, not --set-alignment 2048:

# truncate -s 123456789 test.img

# losetup -f --show test.img
/dev/loop1
losetup: test.img: Warning: file does not fit into a 512-byte sector; the end of the file will be ignored.

# sgdisk --align-end --new=4:0:-0  /dev/loop1
Creating new GPT entries in memory.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.

# gdisk -l /dev/loop1
GPT fdisk (gdisk) version 1.0.9.1

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/loop1: 241126 sectors, 117.7 MiB
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 254E2E19-9744-46F6-9DC9-3D6B761DA635
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 241092
Partitions will be aligned on 2048-sector boundaries
Total free space is 3491 sectors (1.7 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   4            2048          239615   116.0 MiB   8300

# bc <<< "(239615+1-2048)/2048"
116.00000000000000000000

Is there a way to specify bytes instead of sectors?

Not in sgdisk per se. This can be done with blockdev --getss and a bit of shell arithmetic (e. g. $(( 1048576 / $(blockdev --getss) ))), but per the above I don't think that's necessary.

from disko.

Mic92 avatar Mic92 commented on September 21, 2024

cc @rudolfvesely

from disko.

Mic92 avatar Mic92 commented on September 21, 2024

I guess than we should drop --set-alignment and only keep --align-end.

from disko.

rudolfvesely avatar rudolfvesely commented on September 21, 2024

for 4K-native disks this results in 8 MiB alignment which is excessive

I completely agree that 8 MiB is excessive. Btw. @intelfx , do you have an example of a cloud provider / hardware that shows up on Linux as 4k? All modern SSDs are 4k or more inside (physically) but outside (on Linux) they still show up as 512.

I guess than we should drop --set-alignment and only keep --align-end.

I found this: https://www.rodsbooks.com/gdisk/advice.html

When you specify a partition size in MiB or larger units, the partition-size end-alignment is automatic. It's only the last partition that might be affected by this policy, which is automatic in gdisk and cgdisk but must be activated by the new -I/--align-end option to sgdisk. You can override the feature by specifying an exact end sector in sgdisk, including by copying the end sector specified on the prompt line that shows the valid end sector values.

So dropping --set-alignment should work and @intelfx tested that on a loop device above (thank you for testing).

@intelfx :
Could you please confirm that the alignment with --align-end is in MiB regardless if you give sgdisk a specific size in MiB or no size at all?

from disko.

intelfx avatar intelfx commented on September 21, 2024

I guess than we should drop --set-alignment and only keep --align-end.

Yes, that's my impression as well. I'll make a PR.

from disko.

rudolfvesely avatar rudolfvesely commented on September 21, 2024

Yes, that's my impression as well. I'll make a PR.

@intelfx Did you see my questions?

from disko.

intelfx avatar intelfx commented on September 21, 2024

@rudolfvesely No, sorry, the GitHub app didn't load the comment for some reason and my mail is broken atm.

do you have an example of a cloud provider / hardware that shows up on Linux as 4k? All modern SSDs are 4k or more inside (physically) but outside (on Linux) they still show up as 512.

Lots of hardware is 4Kn-capable, just not configured that way by default. For example, all my hardware is like that (Seagate Exos X16 ST16000NM001G-2KK103 and WD_BLACK SN850 WDS200T1X0E-00AFY0).

You can also easily virtualize some yourself with qemu/KVM (on libvirt, saying <blockio logical_block_size='4096' physical_block_size='4096'/> is enough).

Could you please confirm that the alignment with --align-end is in MiB regardless if you give sgdisk a specific size in MiB or no size at all?

Yes --new=1:0:3M, --new-1:0:+3M and --new:1:0 all end up in 1 MiB alignment on both 4Kn and 512e hardware.

It does create a misaligned end, though, if you explicitly give it a misaligned size, a misaligned end OR a misaligned start and an aligned size:

  • --new=1:0:12345K
  • --new=1:0:+12345K
  • --new=1:12345K:+1M

But these behave the same way with or without --set-alignment=2048.

from disko.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.