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

Function get_can_expand returns 0 even if there is no space to expand #145

Open
majes-github opened this issue Dec 1, 2020 · 1 comment

Comments

@majes-github
Copy link

In order to automate installations of raspberry pis I'm writing an ansible playbook, which should also expand the rootfs if possible.

My idea was to use raspi-config nonint get_can_expand to check if the rootfs can be expanded (as the name indicates), but looking at the code it just checks if the rootfs partition is the second on drive and it is the last one. This would trigger the playbook to call raspi-config nonint do_expand_rootfs every time.

Actually it should also check if there is space left on the drive, e.g.

UNUSED_SECTORS=$(parted "$ROOT_DEV" -ms unit s p | awk -F: 'NR==2{ print $2, "-" } NR==4 { print $3 }' | tr -d 's' | xargs expr)
if [ $UNUSED_SECTORS -le 1 ]; then
  echo 2
  exit
fi
@majes-github
Copy link
Author

For the sake of completeness - this is the output from parted on my DUT:

$ sudo parted /dev/mmcblk0 -ms unit s p
BYT;
/dev/mmcblk0:61046784s:sd/mmc:512:512:msdos:SD SD32G:;
1:8192s:532479s:524288s:fat32::lba;
2:532480s:61046783s:60514304s:ext4::;

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

No branches or pull requests

1 participant