Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hyperv: expand root partition #3600

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gamora12
Copy link
Contributor

@gamora12 gamora12 commented Jan 15, 2025

The vm root partition (mounted at /) is not getting expanded to full disk size with dom0 3.0 vhd. With 2.0 vhd, this issue is not seen, resize vhd works as expected.

  • Implement a function to expand root partition to full disk size on hyperv platform.
  • After the vm starts, the root partition is expanded.

@gamora12 gamora12 marked this pull request as ready for review January 15, 2025 14:48
# be grown". In this case, it returns exit code 1 which we can ignore
if cmd_result.exit_code != 0 and "NOCHANGE" not in cmd_result.stdout:
raise LisaException(f"Failed to grow partition: {cmd_result.stdout}")
node.execute(f"resize2fs {device_name}", sudo=True)
Copy link
Collaborator

@smit-gardhariya smit-gardhariya Jan 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use expected_exit_code to ensure if command get executed successfully

Copy link
Contributor

@anirudhrb anirudhrb Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smit-gardhariya There is a case where we want to treat a non-zero error code as success. Please read the comment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, your comment is for the resize2fs command. Never mind.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

root_partition = node.tools[Mount].get_partition_info("/")[0]
device_name = root_partition.name
partition = root_partition.disk
root_part_num = device_name[-1]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Provide example of the name above.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks a regexp is more accurate, in case the number has two or more digits.

@smit-gardhariya smit-gardhariya changed the title hyperv: expand root partition for l1vh hyperv: expand root partition Jan 16, 2025
@@ -315,6 +315,8 @@ def _deploy_environment(self, environment: Environment, log: Logger) -> None:
address=ip_addr, username=username, password=password
)

self._expand_root_partition(node)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment here explaining why we need this even though we're doing _resize_vhd_if_needed() above.

cmd_result = node.execute(
f"growpart /dev/{partition} {root_part_num}", sudo=True
)
# In case, the partition is already expanded to full disk size, the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# In case, the partition is already expanded to full disk size, the
# In case the partition is already expanded to full disk size, the

@gamora12 gamora12 force-pushed the aastha/root_partition branch from 9df1ff8 to 52abe12 Compare January 17, 2025 10:30
# be grown". In this case, it returns exit code 1 which we can ignore
if cmd_result.exit_code != 0 and "NOCHANGE" not in cmd_result.stdout:
raise LisaException(f"Failed to grow partition: {cmd_result.stdout}")
node.execute(f"resize2fs {device_name}", sudo=True, expected_exit_code=0)
Copy link
Member

@squirrelsc squirrelsc Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Execute only if it can be grown. Reduce the number of running commands, even it do nothing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants