Renaming HD (in a Big Sur/Monterey world)

Valued Contributor

So I'm trying to remediate lots and lots of mis-named "HDs". Mostly when formatted, to reinstall OS, lots of stuff remaining as "APPLE SSD AP0512M Media (Boot Partition)"

I've got a script I grabbed from:

And while it works up to 10.15, it breaks at Big Sur and Monterey because of the new sealed system volume, booting from a snapshot, etc. 

I can rename via just disk1s8s1 but that doesn't rename the container. 

Does anyone have anything that works or is the actual partition just called "Data" 

Thanks! Maybe it doesn't matter.... 



Hey! I just tried this on my Monterey machine, it worked to change the HD volume name to my $hdName variable:



/usr/sbin/diskutil rename / $hdName