Plan 9 from Bell Labs’s /usr/web/sources/contrib/someone/root/rc/bin/diskparts

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/bin/rc
# diskparts [/dev/sd?? ...] - set up any disk partitions
rfork e
if (! test -e /dev/sdctl)
	bind -b '#S' /dev
bind -a /bin/disk /bin >[2]/dev/null		# work with /boot too

# set up any /dev/sd partitions.
# note that really big disks (e.g., aoe devices) may have no mbr partition
# table because the mbr partition table can't cope with block numbers larger
# than 4G, so we may have to examine the data file with prep if
# there's no plan9 file.  beware that `disk/prep -p data' on a disk with
# no plan 9 partition table will delete all extant partitions.
if (~ $#* 0)
	# skip missing drives such as fs's /dev/sdF1
	* = `{grep -l '^inquiry..' '#S'/sd*/ctl | sed 's;/ctl$;;'}
for (disk) @ {
	cd $disk
	if (test -f data) {
		echo -n $disk...
		{ fdisk -p data | grep -v '^delpart ' >ctl } >[2]/dev/null
		if (test -f plan9)
			parts=(plan9*)
		if not
			parts=data
		for (part in $parts)
			if (test -f $part) {
				prep -p $part | grep -v '^delpart ' >ctl
			} >[2]/dev/null
	}
}

# set up any fs(3) partitions
echo -n /dev/fs...
if (! test -e /dev/fs/ctl && test -e '#k/fs')
	bind -b '#k' /dev
# initialize fs only if necessary
sysname=`{cat /dev/sysname}
if (~ $#sysname 1 && ! ~ $sysname '' &&
    test -r /cfg/$sysname/fsconfig && test -w /dev/fs/ctl &&
    ~ `{wc -l </dev/fs/ctl} 0)
	sed -n '/^exit/q; p' /cfg/$sysname/fsconfig | read -m >/dev/fs/ctl
echo

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.