add-drive.sh

来自「Shall高级编程」· Shell 代码 · 共 42 行

SH
42
字号
#!/bin/bash# Adding a second hard drive to system.# Software configuration. Assumes hardware already mounted.# From an article by the author of this document.# In issue #38 of "Linux Gazette", http://www.linuxgazette.com.ROOT_UID=0     # This script must be run as root.E_NOTROOT=67   # Non-root exit error.if [ "$UID" -ne "$ROOT_UID" ]then  echo "Must be root to run this script."  exit $E_NOTROOTfi  # Use with extreme caution!# If something goes wrong, you may wipe out your current filesystem.NEWDISK=/dev/hdb         # Assumes /dev/hdb vacant. Check!MOUNTPOINT=/mnt/newdisk  # Or choose another mount point.fdisk $NEWDISKmke2fs -cv $NEWDISK1   # Check for bad blocks & verbose output.#  Note:    /dev/hdb1, *not* /dev/hdb!mkdir $MOUNTPOINTchmod 777 $MOUNTPOINT  # Makes new drive accessible to all users.# Now, test...# mount -t ext2 /dev/hdb1 /mnt/newdisk# Try creating a directory.# If it works, umount it, and proceed.# Final step:# Add the following line to /etc/fstab.# /dev/hdb1  /mnt/newdisk  ext2  defaults  1 1exit 0

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?