The The location is outside of the device error in parted triggers specifically when you try to create a partition that extends beyond the recognized end of your disk, usually after a clone or VM expansion. Fixing this requires either recalculating exact sector boundaries or moving the misplaced GPT backup header to the true end of the drive.
- Quickest Solution:
mkpart primary ext4 0% 100% - Backup Command:
sgdisk -b backup.gpt /dev/sda - Validation Command:
parted align-check optimal 1
What Causes the Location Outside of Device Error?
The error happens because the partition table disagrees with the physical disk boundaries. When you tell parted to use a specific end point, it checks its internal map. If your requested end sector overlaps with reserved space or ignores the actual disk geometry, the command fails immediately.
The GPT Backup Header Placement
GPT disks store partition data in two places for safety. The primary header sits at the very beginning of the disk, occupying the first 33 sectors. The backup header must sit at the absolute end, taking up the last 34 sectors. You cannot allocate space within these reserved zones.
Disk Cloning and VM Expansion Scenarios
This mismatch almost always happens right after expanding a virtual machine drive or cloning a smaller disk to a larger one. If you are running Linux inside Hyper-V on Windows 11, expanding the virtual hard disk from the Hyper-V Manager is a common trigger. The operating system sees the new raw capacity. The GPT backup header remains stuck at the end of the old capacity limit. Any attempt to partition the new free space results in the location error because the system thinks the disk ends early.
Pre-Fix Step: Backup Your Partition Table
Never modify disk structures without a safety net. Writing a wrong sector value can instantly wipe your file system. Create a rapid backup of your current partition layout before running any parted commands.
Run this command:
sgdisk -b /tmp/disk_backup.gpt /dev/sda
If things go terribly wrong, you can restore the exact previous state using sgdisk -l /tmp/disk_backup.gpt /dev/sda.
Method 1: The Quick Fix Using Percentages
You do not always need to calculate sector math manually. The parted utility has built-in logic to handle alignment and header reservations when you use percentage values instead of raw megabytes.
Type the following command inside the parted prompt:
mkpart primary ext4 0% 100%
This syntax forces parted to calculate the exact starting sector and the absolute last usable sector automatically. It leaves the mandatory 34 sectors untouched for the GPT backup.
Method 2: The Precise Fix Using Exact Sector Math
Sometimes percentage allocations fail or leave unallocated megabytes behind. To map the partition flawlessly, you need the exact sector numbers. Switch parted to sector display mode.
Run unit s followed by print free. Look at the free space block.
You need to calculate your end sector using a strict formula. Subtract 34 from the total number of sectors shown for the entire disk.
Physical vs. Logical Sector Sizes
Your math must align with your hardware. Modern drives use a 4096B physical sector size but report a 512B logical size for legacy compatibility. Check your hardware limits using blockdev --getpbsz /dev/sda. If you define a starting sector that is not a multiple of 2048, you will face severe write performance penalties.
Method 3: Fixing GPT Header After Disk Expansion (VMs)
If you just expanded a VMware or Proxmox disk, percentage fixes will not work until you fix the table structure. The GPT backup header is stranded in the middle of your newly expanded disk. You need to physically move that header to the new end of the block device.
Execute this utility:
sgdisk -e /dev/sda
This command relocates the backup data structures to the true end of the disk. Once relocated, you can open parted and allocate the free space without triggering any location boundary errors.
Validating Your New Partition Alignment
Creating the partition is only the first step. A misaligned partition silently degrades SSD lifespan and halves your IOPS speed. You must verify the boundaries immediately after creation.
Run this check inside parted:
align-check optimal 1
A result of 1 aligned confirms your sector math is perfect. If it reports unaligned, delete the partition and recalculate your starting sector using the 2048 multiple rule. To monitor live kernel messages while testing your new partition, the linux tail command lets you stream /var/log/kern.log in real time.




