Jerry_GD 发表于 2004-2-22 14:54:21

怎么样写一个shell挂载硬盘???

不想设置到开机自动挂载硬盘

如何写一个shell挂载硬盘呢

例如我要挂载
# mount -o iocharset=cp936 /dev/hdc1 /mnt/hdc1
# mount -o iocharset=cp936 /dev/hde1 /mnt/hde1
# mount -o iocharset=cp936 /dev/hde5 /mnt/hde5
# mount -o iocharset=cp936 /dev/hde6 /mnt/hde6
# mount -o iocharset=cp936 /dev/hde7 /mnt/hde7

Ivn 发表于 2004-2-23 00:08:30


#!/bin/sh

mount -o iocharset=cp936 /dev/hdc1 /mnt/hdc1
mount -o iocharset=cp936 /dev/hde1 /mnt/hde1
mount -o iocharset=cp936 /dev/hde5 /mnt/hde5
mount -o iocharset=cp936 /dev/hde6 /mnt/hde6
mount -o iocharset=cp936 /dev/hde7 /mnt/hde7


//
如果你要控制的精致点,就弄个 function , 向它传参数 .

Jerry_GD 发表于 2004-2-23 01:30:13

版主就是版主,强
有问必答


不过我不会用啊,能不能教教我
说详悉点,我是菜鸟

Ivn 发表于 2004-2-23 02:07:17

1. 将这个

#!/bin/sh

mount -o iocharset=cp936 /dev/hdc1 /mnt/hdc1
mount -o iocharset=cp936 /dev/hde1 /mnt/hde1
mount -o iocharset=cp936 /dev/hde5 /mnt/hde5
mount -o iocharset=cp936 /dev/hde6 /mnt/hde6
mount -o iocharset=cp936 /dev/hde7 /mnt/hde7

保存成 auto.sh (<--- 假定你用这个来自动挂载)
2. chmod +x auto.sh
3. 要挂载的时候,su 一下,然后运行 ./auto.sh 这样就不用输入上面那五个 mount 了。
4. 你还是学点 shell 脚本知识吧,公社和 www.linuxsir.com 都有这方面的文章 。
    掌握基本 shell 脚本编写后, 你可以把它改成个函数,通过传递参数来挂载指定的分区。

//================================

:mrgreen:

其实也不一定非要这么做,如果你经常这样 mount 分区,你的 bash history 设置的又比较大,
完全可以通过
history | grep 'mount'
你会看到输出的每条命令的前面都有编号,
只要输入
!编号
就可以执行你以前的输入过的 mount 了。

如果你想两步就完成,前提条件是你的 mount 指令要这样输入:
mount -o iocharset=cp936 /dev/hdc1 /mnt/hdc1 ;\
mount -o iocharset=cp936 /dev/hde1 /mnt/hde1; \
mount -o iocharset=cp936 /dev/hde5 /mnt/hde5; \
mount -o iocharset=cp936 /dev/hde6 /mnt/hde6; \
mount -o iocharset=cp936 /dev/hde7 /mnt/hde7

Jerry_GD 发表于 2004-2-23 04:11:15

谢谢版主,又学一招. :mrgreen:

那我继续问,如果要写一个umount的shell呢?是不是这样:

#!/bin/sh

umount /mnt/hdc1
umount /mnt/hde1
umount /mnt/hde5
umount /mnt/hde6
umount /mnt/hde7

Ivn 发表于 2004-2-23 14:10:35

呵呵,是的,但你要保证你 挂了上面你列的这些分区 ~~
//
另外,不是 sell 是 shell

Jerry_GD 发表于 2004-2-23 17:10:24

收到,原来那么简单.谢谢
页: [1]
查看完整版本: 怎么样写一个shell挂载硬盘???