mirror of
https://github.com/skurudo/mikrotik-chr-installer.git
synced 2026-10-19 07:23:53 +00:00
disk patition search change
This commit is contained in:
parent
eabc3afbc1
commit
986ee77ade
6 changed files with 66 additions and 6 deletions
|
|
@ -301,7 +301,17 @@ echo ""
|
|||
lsblk -d -o NAME,SIZE,MODEL,TYPE | grep -E "(NAME|disk)"
|
||||
echo ""
|
||||
|
||||
DISK_DEVICE=$(lsblk -ndo NAME,TYPE | grep disk | head -n1 | awk '{print "/dev/"$1}')
|
||||
# Detect disk by root partition (excludes fd0, sr0, etc.)
|
||||
DISK_DEVICE=""
|
||||
ROOT_PART=$(findmnt -n -o SOURCE / 2>/dev/null)
|
||||
if [[ -n "$ROOT_PART" ]]; then
|
||||
DISK_DEVICE=$(lsblk -ndo PKNAME "$ROOT_PART" 2>/dev/null)
|
||||
[[ -n "$DISK_DEVICE" ]] && DISK_DEVICE="/dev/$DISK_DEVICE"
|
||||
fi
|
||||
# Fallback: first real disk (exclude floppy, cdrom, loop)
|
||||
if [[ -z "$DISK_DEVICE" ]]; then
|
||||
DISK_DEVICE=$(lsblk -ndo NAME,TYPE | awk '$2=="disk" && $1!~/^(fd|sr|loop)/ {print "/dev/"$1; exit}')
|
||||
fi
|
||||
|
||||
if [[ -z "$DISK_DEVICE" ]]; then
|
||||
log_error "Disk not found"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue