Discuz! BBS

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 483|回复: 0

grub-probe

[复制链接]

254

主题

363

帖子

2431

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
2431
发表于 2024-7-29 20:57:05 | 显示全部楼层 |阅读模式
  1. #!/bin/bash
  2. #
  3. # A faker script for grub-probe, if your's stops working properly
  4. #

  5. # Depends on /root/grub.hack file

  6. # . /root/grub.hach

  7. arg_is_device=0
  8. target=""

  9. # Call Order:
  10. # / --target=device
  11. # --target=fs_uuid /dev/sda1 --device
  12. # /boot --target=device
  13. # --target=fs_uuid /boot --device
  14. # "/" "--target=fs"
  15. # "--target=abstraction" "ext2" "--device"
  16. # "--target=fs" "ext2" "--device"
  17. # "--target=drive" "ext2" "--device"
  18. # "--target=fs_uuid" "ext2" "--device"
  19. # "--target=abstraction" "ext2" "--device"
  20. # "--target=fs" "ext2" "--device"
  21. # "--target=drive" "ext2" "--device"
  22. # "--target=fs_uuid" "ext2" "--device"
  23. # "/" "--target=device"
  24. # "--target=fs_uuid" "ext2" "--device"
  25. # "/boot" "--target=device"
  26. # "--target=fs_uuid" "ext2" "--device"
  27. # "/" "--target=fs"
  28. # "--target=abstraction" "ext2" "--device"
  29. # "--target=fs" "ext2" "--device"
  30. # "--target=drive" "ext2" "--device"
  31. # "--target=fs_uuid" "ext2" "--device"
  32. # "--target=abstraction" "ext2" "--device"
  33. # "--target=fs" "ext2" "--device"
  34. # "--target=drive" "ext2" "--device"
  35. # "--target=fs_uuid" "ext2" "--device"

  36. for opt in $@
  37. do
  38.     case "${opt}" in
  39.     --device)
  40.         # Means the thing in $arg is a device
  41.         arg_is_device=1
  42.         ;;
  43.     --target=*)
  44.         # = device, = fs, = fs_uuid
  45.         target=${opt#*=}
  46.         ;;
  47.     *)
  48.         arg=$opt
  49.         ;;
  50.     esac
  51. done

  52. set >> /tmp/probe.env

  53. case "$target" in
  54. abstraction)
  55.     echo
  56.     ;;
  57. device)
  58.     echo "/dev/sda1"
  59.     ;;
  60. drive)
  61.     echo "(hd0)"
  62.     ;;
  63. fs)
  64.     # Returns the filesystem type
  65.     echo "ext2"
  66.     ;;
  67. fs_uuid)
  68.     tune2fs -l $arg | awk '/Filesystem UUID/ { print $3 }'
  69.     ;;
  70. esac
复制代码

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|DiscuzX

GMT+8, 2025-4-16 09:11 , Processed in 0.016329 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表