geom -t | grep DEV | awk '{print $1}' | xargs -n 1 -I {} echo "./myscript {}"
mkdir /mnt/$1
mount /dev/$1 /mnt/$1
clone -s /mnt/$1 /DESTDIR/$1
umount /mnt/$1
rmdir /mnt/$1
geom -t | grep PART | awk '{print $NF}'
for part in $(geom -t | grep PART | awk '{print $NF}'); do
echo "partition : /dev/$part"
# add your commands here
done
df -h | awk '{print $NF}'
gpart list --libxo=jsonSorry, that's in 16.0-CURRENTgpart: illegal option -- -
[…] a simple way of listing how many partitions there are on a disk. […]
# In the /dev directory find(1) all files that start with `ada0p` (or `ada0s`)
# but do not contain a period (such as `ada0p4.eli`).
# (s stands for slice, if MBR partitioning scheme is used;
# p is used for GPT partitioning scheme)
find /dev -name 'ada0[ps]*' '!' -name '*.*' | wc -l
Thanks for that. I wouldn't thought of doing it this way, but it's nice and straightforward.Just list the partition device files in /dev:Bash:# In the /dev directory find(1) all files that start with `ada0p` (or `ada0s`) # but do not contain a period (such as `ada0p4.eli`). # (s stands for slice, if MBR partitioning scheme is used; # p is used for GPT partitioning scheme) find /dev -name 'ada0[ps]*' '!' -name '*.*' | wc -l
I get gpart illegal option.gpart list --libxo=json
I failed hopelessly in trying to include that snippet in a for loop which is supposed to create a directory for every partition.I must practice writing for loops!!Just list the partition device files in /dev:Bash:# In the /dev directory find(1) all files that start with `ada0p` (or `ada0s`) # but do not contain a period (such as `ada0p4.eli`). # (s stands for slice, if MBR partitioning scheme is used; # p is used for GPT partitioning scheme) find /dev -name 'ada0[ps]*' '!' -name '*.*' | wc -l
I failed hopelessly in trying to include that snippet in a for loop which is supposed to create a directory for every partition. […]
‑exec action, but you probably want to translate the items first. A common pattern is a while read loop:# The -r option to read disables interpretation of backslash escaping, not that
# there should be any backslashes but I like to disable unneeded features.
find /dev -maxdepth 1 -name "${disk}[ps]*" -not -name '*.*' | while read -r partition
do
# ##*[ps] : remove longest prefix pattern,
# here everything up to and including last p or s
printf '%s\n' "${partition##*[ps]}"
done | xargs mkdir
I get gpart illegal option.
# geom part status -s
da0p1 OK da0
da0p2 OK da0
da0p3 OK da0
da1p1 OK da1
# geom part status -s | cut -w -f1
da0p1
da0p2
da0p3
da1p1
a=$(geom part status -s | cut -w -f1)
for i in a$
do
echo $i
doneJust a word of explanation... I have Ventoy disk with over 20 partitions which have various OSes installed.
It still feels strange that you’re working with partitions. Dealing with such low‐level details you’re possibly making your task more difficult than it has to be.
As unitrunker subsequently realized, this parameter is only available in 16 current. Besides this, then you need additional programs transforming the JSON or XML to something usable; there are none in the base system that I know of.
Show us your code, a minimal working example (or non‐working example). find(1) has an‑execaction, but you probably want to translate the items first. A common pattern is awhile readloop:
for every partition do
fstyp %PART -> $filesystem
mount -t $filesystem %PART /mnt
cp /mnt/etc/os-release /tmp/$PART-os
umount /mnt
done
Note , labels can be diffult.
zpool list -v SSD
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
SSD 432G 238G 194G - - 48% 55% 1.00x ONLINE -
nda0p3 190G 111G 78.0G - - 50% 58.7% - ONLINE
indirect-1 - - - - - - - - ONLINE
gpt/MYFREEBSD2 214G 124G 87.6G - - 47% 58.7% - ONLINE
indirect-3 - - - - - - - - ONLINE
indirect-4 - - - - - - - - ONLINE
special - - - - - - - - -
nda0p5 32G 2.79G 28.7G - - 48% 8.86% - ONLINE
logs - - - - - - - - -
nda0p6 32G 560K 31.5G - - 0% 0.00% - ONLINE
cache - - - - - - - - -
nda0p7 32G 30.0G 2.02G - - 0% 93.7% - ONLINE
nda0p8 32G 30.0G 1.99G - - 0% 93.8% - ONLIN