将Debian fstab转换为通过linux-base使用UUID?

将Debian fstab转换为通过linux-base使用UUID?,第1张

概述我们有一些Debian 5系统仍在fstab中使用/ dev / hda.我们想将它们转换为使用UUID.这应该是通过“ linux-base”软件包(postinst)自动完成的,但由于某些原因它并没有开始(可能有人已经运行它并且它保存了一些状态而不去做). 虽然通过手动编辑一堆文件可以切换到UUID,但以某种方式编写脚本会很有用. debconf和debconf-set-choices的各种咒 我们有一些Debian 5系统仍在fstab中使用/ dev / hda.我们想将它们转换为使用UUID.这应该是通过“ linux-base”软件包(postinst)自动完成的,但由于某些原因它并没有开始(可能有人已经运行它并且它保存了一些状态而不去做).

虽然通过手动编辑一堆文件可以切换到UUID,但以某种方式编写脚本会很有用. debconf和debconf-set-choices的各种咒语似乎都不起作用.

基本上,如何调用Debian提供的脚本来执行所有UUID转换?

解决方法 Per Gabor Vincze,来自 Ubuntu forums的脚本似乎做了一个不错的代码:
#!/bin/bash# This script will change all entrIEs of the form /dev/sd* in /etc/fstab to their appropriate UUID names# You must have root privelages to run this script (use sudo)if [ `ID -u` -ne 0 ]; then                                              # Checks to see if script is run as root        echo "This script must be run as root" >&2                      # If it isn't,exit with error        exit 1ficp /etc/fstab /etc/fstab.backupsed -n 's|^/dev/\([sh]d[a-z][0-9]\).*||p' </etc/fstab >/tmp/devices   # Stores all /dev entrIEs from fstab into a filewhile read liNE; do                                                     # For each line in /tmp/devices        UUID=`ls -l /dev/disk/by-uuID | grep "$liNE" | sed -n 's/^.* \([^ ]*\) -> .*$//p'` # Sets the UUID name for that device        sed -i "s|^/dev/${liNE}|UUID=${UUID}|" /etc/fstab               # Changes the entry in fstab to UUID formdone </tmp/devicescat /etc/fstab                                                          # Outputs the new fstab fileprintf "\n\nWrite changes to /etc/fstab? (y/n) "read RESPONSE;case "$RESPONSE" in        [yY]|[yY][eE][sS])                                              # If answer is yes,keep the changes to /etc/fstab                echo "Writing changes to /etc/fstab..."                ;;        [nN]|[nN][oO]|"")                                               # If answer is no,or if the user just pressed Enter                echo "Aborting: Not saving changes..."                  # don't save the new fstab file                cp /etc/fstab.backup /etc/fstab                rm /etc/fstab.backup                ;;        *)                                                              # If answer is anything else,exit and don't save changes                echo "InvalID Response"                                 # to fstab                echo "Exiting"                cp /etc/fstab.backup /etc/fstab                rm /etc/fstab.backup                exit 1                ;;esacrm /tmp/devicesecho "DONE!"
总结

以上是内存溢出为你收集整理的将Debian fstab转换为通过linux-base使用UUID?全部内容,希望文章能够帮你解决将Debian fstab转换为通过linux-base使用UUID?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/1034184.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存