{"id":13587509,"url":"https://github.com/EugenMayer/parted-auto-resize","last_synced_at":"2025-04-07T22:31:19.989Z","repository":{"id":137561735,"uuid":"101502251","full_name":"EugenMayer/parted-auto-resize","owner":"EugenMayer","description":"Automatically or non-interactive resize a partition to its maximum, e.g. for LVM pv resizing when using a partition as PV","archived":false,"fork":false,"pushed_at":"2020-05-23T09:43:03.000Z","size":16,"stargazers_count":66,"open_issues_count":2,"forks_count":15,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-06T04:41:38.955Z","etag":null,"topics":["hypervisor","linux","lvm","parted"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EugenMayer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":"eugenmayer","patreon":"eugenmayer"}},"created_at":"2017-08-26T17:37:50.000Z","updated_at":"2024-08-08T09:52:04.000Z","dependencies_parsed_at":"2023-04-20T10:15:43.701Z","dependency_job_id":null,"html_url":"https://github.com/EugenMayer/parted-auto-resize","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EugenMayer%2Fparted-auto-resize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EugenMayer%2Fparted-auto-resize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EugenMayer%2Fparted-auto-resize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EugenMayer%2Fparted-auto-resize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EugenMayer","download_url":"https://codeload.github.com/EugenMayer/parted-auto-resize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247740738,"owners_count":20988260,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hypervisor","linux","lvm","parted"],"created_at":"2024-08-01T15:06:14.677Z","updated_at":"2025-04-07T22:31:19.708Z","avatar_url":"https://github.com/EugenMayer.png","language":"Shell","funding_links":["https://github.com/sponsors/eugenmayer","https://patreon.com/eugenmayer"],"categories":["Shell"],"sub_categories":[],"readme":"## WAT\n\nin short `resize a partition non-interactive to its maximum size`\n\n#### The long story..\n\nSince using fdisk in this case is pretty complicated due to the case that non-interactive ways are probably not possible or very complicated using printf, i want to use `parted resizepart` for resizing a partition to its maximum size.\n\nThis can be used in scenarios like disk-resizes ( hypervisor / virtualization ). Now you need to adjust your logical volume / pv to the new size (LVM case) or you want to adjust the partition size of a normal partition.\n\nSo lets assume i want to resize partition /dev/sda1 on disk /dev/sda to its maximum possible size - how would i do this without getting asked any questions at all.\n\nEventhough `parted /dev/sda resizepart 1` exists, it needs **me to calculate** and enter the maximum disk size - so how to automate this would be the next question - and the answer was the reason `parted auto resize` has been written.\n\n## Installation\n\n```bash\n  curl -o /usr/local/bin/resize.sh https://raw.githubusercontent.com/EugenMayer/parted-auto-resize/master/resize.sh\n ```\n \n### Dependencies\n\n- parted 3.0 or higher (otherwise probably rename `parted resizepart` to `parted resize`)\n\n## Usage \nSave the script above as `resize.sh` and make it executable\n    \n    # resize the fourth partition to the maximum size, so /dev/sda4\n    # this is the sandbox mode, so no changes are actually done - just previewed\n    ./resize.sh /dev/sda 4\n\n    # apply those changes\n    ./resize.sh /dev/sda 4 apply\n\n## Scenarios / motivation\n\nSince debian does not allow you to preseed a LVM configuration, which uses a disk as a pv / vg, but always force you to use a partition, you need a convinient way to resize the pv partition, so you can resize any logical volumes. It can be done using fdisk, but this needs ot be done by hand, interactive with a lot more steps ( usual delete / create / set type to Linux LVM / write / reload partition table \n\nAssuming your pv / vg is created on /dev/sdb1 named vgdata and the LV to resize is named data and you resized your disk using your hypervisor.\n\nNow using this script, all you do is\n\n    ./resize.sh /dev/sdb 1 apply\n    pvresize /dev/sdb1\n    lvextend -r /dev/mapper/vgdata-data -l '+100%FREE'\n\nthats it! Note, if you happen to notice -r in lvextend, yes thats pretty cool, it calls `resize2fs /dev/mapper/vgdata-data` for us automatically after the partition resize ( to adjust the filesystem size )\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEugenMayer%2Fparted-auto-resize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FEugenMayer%2Fparted-auto-resize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEugenMayer%2Fparted-auto-resize/lists"}