You are not logged in.
I am developing an installation program and a section of code which has worked for months suddenly began to fail. Upon closer inspection the issue lies with sgdisk:
sgdisk -Z "$disk1"
Problem opening 7qd for reading! Error is 2
The specified file does not exist!
Problem opening ' ' for writing! Program will now terminate.
Warning! MBR not overwritten! Error is 2!
If I bypass that code I get the following error later on:
sgdisk -n 1:2MiB:+1GiB -t 1:EF00 "$disk1"
Problem opening eR{.U for reading! Error is 2
The specified file does not exist!
This is running from a booted ISO that I had just made with archiso. An ISO that I made two days ago runs with no issues.
Something has changed with the last 48 hours but I am not certain what it is yet.
btrfs-progs versioned yesterday but I never reach that part of the code.
If it helps here is my code which is running ok on a previous ISO image.
#!/usr/bin/env bash
# error handling
set -Euo pipefail
# stubs
print() { tput setaf 2 ; echo -e "\n\t$1\n" ; tput sgr0 ; }
alert() { tput setaf 1 ; echo -e "\n\t$1\n" ; tput sgr0 ; }
# display error data and exit
trap '{ alert "${0##*/} line:$LINENO -> $BASH_COMMAND" ; exit ; }' err
# find usb boot
usb1=$(lsblk -o NAME,PATH,FSTYPE | awk '/^sd/ && /iso9660/ {print $2}')
# input validation
if [[ $# == 1 ]] ; then
hostname="${1}"
else
{ clear ; print "Usage: setup.sh hostname" ; exit ; }
fi
# args passed to chroot_config in sequence
chroot_args=( "$hostname" )
# install processor microcode
case "$(awk '/vendor_id/ {print $3}' /proc/cpuinfo | sort -u)" in
GenuineIntel) ucode=intel-ucode ;;
AuthenticAMD) ucode=amd-ucode ;;
esac
# base install packages
base_pkgs=( base linux-lts linux-lts-headers "$ucode" linux-firmware efibootmgr grub dosfstools e2fsprogs btrfs-progs )
# system utility packages
base_pkgs+=( irqbalance pacman-contrib usbmuxd usbutils hwinfo python-gpgme plocate )
# console utility packages
base_pkgs+=( man-db man-pages texinfo pkgfile fzf tmux gdu tree mtr parallel htop wget jq banner bat )
# system administration packages
base_pkgs+=( base-devel devtools shellcheck vim-ale neovim emacs glibc libpwquality neofetch )
# pipewire packages
base_pkgs+=( pipewire-alsa pipewire-pulse pipewire-jack wireplumber )
# networking & bluetooth packages
base_pkgs+=( networkmanager bluez bluez-utils bluez-cups reflector cifs-utils openssh )
# wifi packages
base_pkgs+=( wireless-regdb iwd )
## -- MAIN -- ##
# find disks
# ls /sys/block
if [[ "$(ls /dev/nvme*)" ]] ; then
mapfile -t drives < <(lsblk -o NAME,PATH | awk '/^nvme/ {print $2}')
disk1="${drives[1]}"
disk2="${drives[0]}"
else
mapfile -t drives < <(lsblk -o NAME,PATH | awk '/^sd/ {print $2}')
disk1="${drives[0]}"
disk2="${drives[1]}"
fi
# print info
clear
{ tput bold ; tput setaf 5 ; banner -lC 'Arch Btrfs' ; tput sgr0 ; }
print "Arch Linux on Btrfs Installer"
print "Disks Found:"
lsblk -T -o name,fstype,label,mountpoint
print "System Parameters"
cat << _end_
Root disk1 $disk1
Root disk2 $disk2
USB boot $usb1
Hostname $hostname
_end_
# confirmation
print "Continue?"
PS3=': '
select choice in Install Quit ; do
case "$choice" in
Install) { print "Installing Arch Linux on Btrfs" ; break ; } ;;
Quit) { print "Quitting" ; exit ; } ;;
esac
done
# set local real time clock
timedatectl set-local-rtc 0
# wipe disks
print "Wiping drives"
for drv in "$disk1" "$disk2" ; do
wipefs -a "$drv"
sgdisk -Z "$drv"
blkdiscard -f "$drv"
parted "$drv" mklabel gpt
done
# format nvme namespaces
case "$disk1":"$disk2" in
/dev/nvme?n?:/dev/nvme?n?)
print "Formatting NVMe namespaces"
for drv in "$disk1" "$disk2" ; do
nvme format -f "$drv" -n 1
done
;;
/dev/sd?:/dev/sd?) ;;
esac
# partition disks
print "Partitioning drives"
# disk1
sgdisk -n 1:2MiB:+1GiB -t 1:EF00 "$disk1"
sgdisk -n 2:0MiB:-0MiB -t 2:8300 "$disk1"
partprobe -s "$disk1"
# disk2
sgdisk -n 1:2MiB:+1GiB -t 1:8300 "$disk2"
sgdisk -n 2:0MiB:-0MiB -t 2:8300 "$disk2"
partprobe -s "$disk2"
# partition naming
case "$disk1:$disk2" in
/dev/nvme?n?:/dev/nvme?n?)
grub="$disk1"p1
#spare="$disk2"p1
root1="$disk1"p2
root2="$disk2"p2
;;
/dev/sd?:/dev/sd?)
grub="$disk1"1
#spare="$disk2"1
root1="$disk1"2
root2="$disk2"2
;;
esac
print "Creating filesystems"
# create & mount btrfs mirror Arch
mkfs.btrfs -L Arch -R free-space-tree -m raid1 -d raid1 "$root1" "$root2"
mount -t btrfs "$root1" /mnt
# create subvolumes
btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/home
btrfs subvolume create /mnt/archive
# remount Arch
umount -R /mnt
mount -t btrfs -o discard=async,autodefrag,noatime,subvol=/ "$root1" /mnt/
# create & mount ESP
mkfs.vfat -n GRUB "$grub"
mkdir /mnt/boot
mount "$grub" /mnt/boot
print "Installing the base system"
# installation
pacstrap /mnt "${base_pkgs[@]}"
# generate fstab
genfstab -U -p /mnt >> /mnt/etc/fstab
# chroot config
mkdir -p /mnt/archive/arch-btrfs
cp /usr/local/bin/* /mnt/archive/arch-btrfs
arch-chroot /mnt /archive/arch-btrfs/chroot_config.sh "${chroot_args[@]}"
print "Rebooting"
sync && sleep 3
reboot
Last edited by lenhuppe (2022-11-13 22:24:05)
"I'm suspicious of people who don't like dogs, but I trust a dog when it doesn't like a person." -- Bill Murray
Offline
Without having any more information, that just looks like there's nonsense values in $disk1 and/or $disk2.
What is the output of that "print info" part of your script?
More importantly, what is the behaviour if you just run sgdisk normally (i.e. without any variables that we don't know anything about)?
Offline
Might be this issue: https://github.com/rpm-software-managem … /issues/80
Other software seems to suffer, too: https://bbs.archlinux.org/viewtopic.php?id=281183
Inofficial first vice president of the Rust Evangelism Strike Force
Offline
Without having any more information, that just looks like there's nonsense values in $disk1 and/or $disk2.
What is the output of that "print info" part of your script?More importantly, what is the behaviour if you just run sgdisk normally (i.e. without any variables that we don't know anything about)?
The disk and system information when running the install are all correct:
Disks Found:
NAME FSTYPE LABEL MOUNTPOINT
sda iso9660 ARCH_10Nov22_1628 /run/archiso/airootfs
├─sda1 iso9660 ARCH_10Nov22_1628
└─sda2 vfat ARCHISO_EFI
nvme0n1
├─nvme0n1p1 vfat GRUB
└─nvme0n1p2 btrfs broot
nvme1n1
├─nvme1n1p1
└─nvme1n1p2 btrfs broot
System Parameters
Root disk1 /dev/nvme0n1
Root disk2 /dev/nvme1n1
USB boot /dev/sda
Hostname lurch
Running sgdisk manually gives the same error message as when running the script.
The disk other utilities used - wipefs, blkdiscard and partprobe all run with no errors.
If I install using the previous ISO, and then build a new ISO with no changes, the new ISO will fail in the same fashion as in my original post.
"I'm suspicious of people who don't like dogs, but I trust a dog when it doesn't like a person." -- Bill Murray
Offline
Might be this issue: https://github.com/rpm-software-managem … /issues/80
Other software seems to suffer, too: https://bbs.archlinux.org/viewtopic.php?id=281183
According to my logs I updated popt around the same time that I created a new ISO to test some changes to the script in question.
Nice troubleshooting
Last edited by lenhuppe (2022-11-11 00:10:08)
"I'm suspicious of people who don't like dogs, but I trust a dog when it doesn't like a person." -- Bill Murray
Offline
The gptfdisk package versioned (1.0.9-1 -> 1.0.9-2) today and that appears to have fixed the issue.
"I'm suspicious of people who don't like dogs, but I trust a dog when it doesn't like a person." -- Bill Murray
Offline