Skip to content

Instantly share code, notes, and snippets.

@binwiederhier
Created January 13, 2016 00:22
Show Gist options
  • Save binwiederhier/3a6137fc36d304ba061a to your computer and use it in GitHub Desktop.
Save binwiederhier/3a6137fc36d304ba061a to your computer and use it in GitHub Desktop.
Unattended single disk resize
  1. Create /usr/share/initramfs-tools/hooks/parttools as above
  2. Run update-initramfs -u
  3. Reboot
  4. Type e on the Grub2 boot menu entry
  5. Add break=mount to the kernel line
  6. In initramfs, run this (assuming /dev/sda1 is the to-be-resized disk):
e2fsck -f /dev/sda1
resize2fs /dev/sda1 20G
fdisk /dev/sda
# print
p
# delete part 1
d
1
# new primary part 1, start as suggested, end +20G
n
p
1
<return>
+20G
# make part 1 bootable
a
1
# new primary part 3, start as suggested, end as suggested
n
p
3
<enter>
<enter>
# write
w
#!/bin/sh
set -e
PREREQ=""
# Output pre-requisites
prereqs()
{
echo "$PREREQ"
}
case "$1" in
prereqs)
prereqs
exit 0
;;
esac
. /usr/share/initramfs-tools/hook-functions
copy_exec /sbin/parted /sbin
copy_exec /sbin/resize2fs /sbin
copy_exec /sbin/fdisk /sbin
copy_exec /sbin/blockdev /sbin
copy_exec /usr/bin/realpath
copy_exec /usr/bin/dirname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment