大佬教程收集整理的这篇文章主要介绍了将Debian fstab转换为通过linux-base使用UUID?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
虽然通过手动编辑一堆文件可以切换到UUID,但以某种方式编写脚本会很有用. debconf和debconf-set-choices的各种咒语似乎都不起作用.
#!/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 1 fi cp /etc/fstab /etc/fstab.BACkup sed -n 's|^/dev/\([sh]d[a-z][0-9]\).*|\1|p' </etc/fstab >/tmp/devices # Stores all /dev entries from fstab into a file while read LINE; do # For each line in /tmp/devices UUID=`ls -l /dev/disk/by-uuid | grep "$LINE" | sed -n 's/^.* \([^ ]*\) -> .*$/\1/p'` # Sets the UUID name for that device sed -i "s|^/dev/${LINE}|UUID=${UUID}|" /etc/fstab # Changes the entry in fstab to UUID form done </tmp/devices cat /etc/fstab # Outputs the new fstab file printf "\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 ;; esac rm /tmp/devices echo "DONE!"
以上是大佬教程为你收集整理的将Debian fstab转换为通过linux-base使用UUID?全部内容,希望文章能够帮你解决将Debian fstab转换为通过linux-base使用UUID?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。