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

Add scripts to enable rpool disk expansion #463

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

Conversation

prakashsurya
Copy link
Contributor

@prakashsurya prakashsurya commented Aug 29, 2023

Problem

Currently, if we need to swap the current rpool disk to a new disk (e.g. perhaps to expand the rpool size), the process for doing this is all manual. Further, the process required properly partitioning the new disk, and installing grub correctly on it, prior to adding it to the pool. Since none of this process is automated, it can be easy to forget how to do it correctly, and even easier to potentially do it incorrectly.

Solution

This PR attempts to alleviate the solution by adding a few scripts that can be used to accomplish these tasks.

Example

Format

$ sudo ./rpool-disk-format /dev/sda
+ sgdisk --zap-all /dev/sda
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
+ sgdisk /dev/sda --set-alignment=1 --new=2:1m:+1m --typecode=2:EF02
Creating new GPT entries in memory.
The operation has completed successfully.
+ sgdisk /dev/sda --new=1:: --typecode=1:8300
The operation has completed successfully.
+ sgdisk /dev/sda --print
Disk /dev/sda: 2147483648 sectors, 1024.0 GiB
Model: Virtual disk
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): CB2209E2-F883-440D-ABAE-DA8A5D40996C
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 2147483614
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            4096      2147483614   1024.0 GiB  8300
   2            2048            4095   1024.0 KiB  EF02

Attach

$ sudo ./rpool-disk-attach /dev/sde /dev/sda
+ zpool attach rpool /dev/sde1 /dev/sda1
+ mount -t zfs rpool/grub /tmp/unpack.nlu1JDk
+ grub-install --root-directory=/tmp/unpack.nlu1JDk /dev/sda
Installing for i386-pc platform.
Installation finished. No error reported.
+ grub-mkconfig -o /tmp/unpack.nlu1JDk/boot/grub/grub.cfg
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Sourcing file `/etc/default/grub.d/kdump-tools.cfg'
Sourcing file `/etc/default/grub.d/override.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.15.0-79-dx2023082816-dd7fad44b-generic
Found initrd image: /boot/initrd.img-5.15.0-79-dx2023082816-dd7fad44b-generic
done
+ cleanup
+ [[ -z /tmp/unpack.nlu1JDk ]]
+ [[ ! -d /tmp/unpack.nlu1JDk ]]
+ umount /tmp/unpack.nlu1JDk
+ rm -rf /tmp/unpack.nlu1JDk

Detach

$ sudo ./rpool-disk-detach /dev/sda
+ zpool detach rpool /dev/sda1

@prakashsurya prakashsurya force-pushed the dlpx/pr/prakashsurya/9b873b7c-8a7e-41a1-86d1-0eea93a1ed64 branch from 15eebc0 to dadbfd2 Compare August 29, 2023 17:29
@prakashsurya prakashsurya force-pushed the dlpx/pr/prakashsurya/9b873b7c-8a7e-41a1-86d1-0eea93a1ed64 branch 7 times, most recently from cd49c33 to a56f8f1 Compare August 29, 2023 17:51
@prakashsurya prakashsurya force-pushed the dlpx/pr/prakashsurya/9b873b7c-8a7e-41a1-86d1-0eea93a1ed64 branch from a56f8f1 to 3e0298c Compare August 29, 2023 17:54
@prakashsurya prakashsurya marked this pull request as ready for review September 7, 2023 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant