Board logo

標題: mkfs_mount在shell script [打印本頁]

作者: kenkilaw    時間: 2009-1-29 14:29     標題: mkfs_mount在shell script

只出到
mke2fs 1.35 (28-Feb-2004)
mount: you must specify the filesystem type
請問出了問題問題??請指點

---------------------shell script----------------------

if [ "$testing" == "" ]; then
    if [ $backupdir == "/home1" ];then

         //sbin/mkfs -t ext3 /dev/sdc1
         //bin/sleep 2
        //bin/mount /dev/sdc1 -t ext3 /home1
         //bin/sleep 10

    elif [ $backupdir == "/home4" ]; then

         //sbin/mkfs -t ext3 /dev/sdc1
         //bin/sleep 20
         //bin/mount /dev/sdc1 -t ext3 /home4
         //bin/sleep 1

      fi
fi
-----------------------------end-------------------------
作者: little_keung    時間: 2009-1-29 15:32

原帖由 kenkilaw 於 2009-1-29 14:29 發表
只出到
mke2fs 1.35 (28-Feb-2004)
mount: you must specify the filesystem type
請問出了問題問題??請指點

---------------------shell script----------------------
        //bin/mount /dev/sdc1 -t ext3 /home1
         //bin/mount /dev/sdc1 -t ext3 /home4


Wild guess. Try to put "-t ext3" before your device name.
作者: kenkilaw    時間: 2009-1-30 10:25

Thank you for reply

以跟指示.試了一下....結果還沒解決啊!!
作者: TuTu    時間: 2009-1-30 10:57

可以 cat /proc/filesystems 看一下嗎?
作者: archy    時間: 2009-1-31 02:48

先 umount 再 mkfs 然後再 mount
我估你 crontab 左黎做 , file system 已 mount 起不能 format
另外試下改改個 cmd 做 mkfs.ext3
作者: 我係一舊雲    時間: 2009-1-31 04:12

原帖由 kenkilaw 於 29-1-2009 14:29 發表
只出到
mke2fs 1.35 (28-Feb-2004)
mount: you must specify the filesystem type
請問出了問題問題??請指點

---------------------shell script----------------------

if [ "$testing" == "" ]; then
    if [ $ ...



請問你這個 script 的用途是什麼??
script 本來係將一些重覆又重覆既 command / job 寫埋一齊,方便每一次 run 唔需要再打咁多次而設的,那你每次 run 此 script 的話,都變成先 format 再 mount 成一個 mount point 的

mkfs > format (dos)

咁未即係每次一 run 就 format 左個 hdd ???
真係唔明你呢個 script 要黎做咩?

如果你係想 mount 起一個 hdd / partition 於每次 stratup 的話,就以為先要 mkfs 才可以,這明顯就錯了,只要做一次,之後係 /etc/fstab 再加上就可以
作者: kenkilaw    時間: 2009-2-1 01:10

其實係一個BACKUP既SCRIPT黎
只是~~用人手打./BACKUP.SH 冇問題
用CRON JOB行就出現問題~~
我POST出全SCRIPT 請教一下
作者: kenkilaw    時間: 2009-2-1 01:11

#!/bin/bash
# ==============================================================

# ==============================================================

log=/home/backup.log

location=/home2/location
BehindTheScene=/home2/BehindTheScene
casting=/home2/casting
LocalJob=/home3/LocalJob
OverseaJob=/home2/OverseaJob
proposal=/home3/proposal
Resume=/home3/resume
footage=/home3/footage
LocalQuotation=/home3/public223
production=/home3/production
Supplier=/home3/supplier
Art=/home3/art
visualreference=/home3/visualreference
RecyleBin=/home2/recyle_bin
PA=/home3/pa
Scan=/home3/scan
BusinessProspects=/home3/Prospects

if [ $1 == "-a" ];then

backupdir="/home1"

elif [ $1 == "-b" ]; then

backupdir="/home4"

else

echo "I don't know what is your choice" && exit 1
fi


testing=`df -h | grep $backupdir`
if [ "$testing" == "" ]; then
    if [ $backupdir == "/home1" ];then

         //sbin/mkfs -t ext3 /dev/sdc1
         //bin/sleep 2
        //bin/mount /dev/sdc1 -t ext3 /home1
         //bin/sleep 10

    elif [ $backupdir == "/home4" ]; then

         //sbin/mkfs -t ext3 /dev/sdc1
         //bin/sleep 20
         //bin/mount /dev/sdc1 -t ext3 /home4
         //bin/sleep 1

      fi
fi

echo "----------Backup-----------"`date`"----------Start-----------" >>$log
//bin/cp /home/backup.sh $backupdir/
//bin/cp /etc/passwd $backupdir/passwd
//bin/cp /etc/shadow $backupdir/shadow
//bin/cp /etc/samba/smb.conf $backupdir/smb.conf
//bin/cp /etc/samba/smbpasswd $backupdir/smbpasswd
//bin/cp /etc/samba/smbusers $backupdir/smbusers

//bin/tar -zcvf $backupdir/location-`date '+%d-%B-%Y'`.tar.gz $location
//bin/tar -zcvf $backupdir/BehindTheScene-`date '+%d-%B-%Y'`.tar.gz $BehindTheScene
//bin/tar -zcvf $backupdir/casting-`date '+%d-%B-%Y'`.tar.gz $casting
//bin/tar -zcvf $backupdir/LocalJob-`date '+%d-%B-%Y'`.tar.gz $LocalJob
//bin/tar -zcvf $backupdir/OverseaJob-`date '+%d-%B-%Y'`.tar.gz $OverseaJob
//bin/tar -zcvf $backupdir/proposal-`date '+%d-%B-%Y'`.tar.gz $proposal
//bin/tar -zcvf $backupdir/Resume-`date '+%d-%B-%Y'`.tar.gz $Resume
//bin/tar -zcvf $backupdir/footage-`date '+%d-%B-%Y'`.tar.gz $footage
//bin/tar -zcvf $backupdir/LocalQuotation-`date '+%d-%B-%Y'`.tar.gz $LocalQuotation
//bin/tar -zcvf $backupdir/production-`date '+%d-%B-%Y'`.tar.gz $production
//bin/tar -zcvf $backupdir/Supplier`date '+%d-%B-%Y'`.tar.gz $Supplier
//bin/tar -zcvf $backupdir/Art-`date '+%d-%B-%Y'`.tar.gz $Art
//bin/tar -zcvf $backupdir/visualreference-`date '+%d-%B-%Y'`.tar.gz $visualreference
//bin/tar -zcvf $backupdir/RecyleBin-`date '+%d-%B-%Y'`.tar.gz $RecyleBin
//bin/tar -zcvf $backupdir/PA-`date '+%d-%B-%Y'`.tar.gz $PA
//bin/tar -zcvf $backupdir/Scan-`date '+%d-%B-%Y'`.tar.gz $Scan
//bin/tar -zcvf $backupdir/BusinessProspects-`date '+%d-%B-%Y'`.tar.gz $BusinessProspects
//bin/sleep 200

//bin/umount $backupdir

//sbin/fuser -m -v $backupdir
echo "-----------Backup---------"`date`"-------------Stop-----------">>$log
exit 0

[ 本帖最後由 kenkilaw 於 2009-2-1 01:12 編輯 ]
作者: kenkilaw    時間: 2009-2-1 01:15

原帖由 archy 於 2009-1-31 02:48 發表
先 umount 再 mkfs 然後再 mount
我估你 crontab 左黎做 , file system 已 mount 起不能 format
另外試下改改個 cmd 做 mkfs.ext3



個SCRIPT每次也會自己UMOUNT  這個問題機會不大
作者: kenkilaw    時間: 2009-2-1 01:15

原帖由 TuTu 於 2009-1-30 10:57 發表
可以 cat /proc/filesystems 看一下嗎?


[root@production home]# cat /proc/filesystems
nodev   sysfs
nodev   rootfs
nodev   bdev
nodev   proc
nodev   sockfs
nodev   binfmt_misc
nodev   usbfs
nodev   usbdevfs
nodev   futexfs
nodev   tmpfs
nodev   pipefs
nodev   eventpollfs
nodev   devpts
        ext2
nodev   ramfs
nodev   hugetlbfs
        iso9660
nodev   relayfs
nodev   mqueue
        ext3
        vfat
作者: lazyfai    時間: 2009-2-1 11:46

人手行個 script 的時候有咩 output 同埋會唔會要答乜野問題先?
同埋有輸出的 cmd 最好用呢個方法 run:
mkfs -t ext3 /dev/sdc1 >& /tmp/backup.log
咁佢會放D output 入 /tmp/backup.log 你可以睇返。
或者你每次 run 都收 mail 都可以睇返。
作者: kenkilaw    時間: 2009-2-3 19:45

人手行冇問題~~~只是行CRON JOB時會唔得
作者: GraphiteCube    時間: 2009-2-3 20:39

Crontab內的Command要Full path。
作者: kenkilaw    時間: 2009-2-3 23:43

原帖由 GraphiteCube 於 2009-2-3 20:39 發表
Crontab內的Command要Full path。

我那一句還沒Full path??
作者: GraphiteCube    時間: 2009-2-4 00:09     標題: 回覆 14# 的帖子

我唔係指你個Script file入面的Programs要用Full path,我係指你響crontab -e入面的Command要Full path。

好似:
0 1 * * * poweroff
咁係唔Work,因為Cron唔知poweroff呢舊野放響邊。於是你要:
0 1 * * * /sbin/poweroff
咁先會Work(夜晚一點關機)。

我見你話就咁./script.sh就行到,咁我估你段Script無問題,以前我又試過自己加Cron jobs但係唔Work,就係因為無響crontab -e specifiy個Full path。

反而Script內的Program可以唔駛Full path。

(如果你一早就係Set左Full path,無視我吧...

[ 本帖最後由 GraphiteCube 於 2009-2-4 00:11 編輯 ]
作者: lazyfai    時間: 2009-2-4 14:03

mke2fs 1.35 (28-Feb-2004)
mount: you must specify the filesystem type

出到呢D 即係有行個 script 啦。
如果佢話 you must specify the filesystem type, 最有可能係 mkfs 出錯。
什至 mount 錯 filesystem(eg. 要 mount /dev/sda1 但入左 /dev/sda2, etc)。

問多一句,你個 crontab entry 係點寫的?
作者: kenkilaw    時間: 2009-2-4 16:45

1 21 1 * * /home/backup.sh -b 2>> /home/backup.log

如果 mkfs出錯即係 sh錯~~但我就咁行就冇事架喎
作者: lazyfai    時間: 2009-2-4 17:13

1 21 1 * * /home/backup.sh -b >& /home/backup.log
睇下 backup.log 有咩野野睇。
作者: kenkilaw    時間: 2009-2-5 10:10

如果//bin/mount -t ext3 /dev/sdc1  /home4

mke2fs 1.35 (28-Feb-2004)
mount: wrong fs type, bad option, bad superblock on /dev/sdc1,
       or too many mounted file systems
----------Backup-----------Thu Feb 5 09:14:36 HKT 2009----------Start-----------
//bin/tar: Removing leading `/' from member names
//bin/tar: Removing leading `/' from member names
//bin/tar: Removing leading `/' from member names
//bin/tar: Removing leading `/' from member names
//bin/tar: Removing leading `/' from member names
//bin/tar: Removing leading `/' from member names
//bin/tar: Removing leading `/' from member names
//bin/tar: Removing leading `/' from member names
//bin/tar: Removing leading `/' from member names
//bin/tar: Removing leading `/' from member names
//bin/tar: Removing leading `/' from member names
//bin/tar: Removing leading `/' from member names
//bin/tar: Removing leading `/' from member names
//bin/tar: Removing leading `/' from member names
//bin/tar: Removing leading `/' from member names
//bin/tar: Removing leading `/' from member names
//bin/tar: Removing leading `/' from member names
umount: /home4: not mounted
-----------Backup---------Thu Feb 5 09:17:57 HKT 2009-------------Stop-----------


如果 //bin/mount  /dev/sdc1  /home4

mke2fs 1.35 (28-Feb-2004)
mount: you must specify the filesystem type
----------Backup-----------Thu Feb 5 09:24:36 HKT 2009----------Start-----------
//bin/tar: Removing leading `/' from member names
//bin/tar: Removing leading `/' from member names
//bin/tar: Removing leading `/' from member names
//bin/tar: Removing leading `/' from member names
作者: bluesheet    時間: 2009-2-5 10:23

原帖由 kenkilaw 於 2009-1-29 14:29 發表
---------------------shell script----------------------

if [ "$testing" == "" ]; then
    if [ $backupdir == "/home1" ];then

         //sbin/mkfs -t ext3 /dev/sdc1
         //bin/sleep 2
        //bin/mount /dev/sdc1 -t ext3 /home1
         //bin/sleep 10

    elif [ $backupdir == "/home4" ]; then

         //sbin/mkfs -t ext3 /dev/sdc1
         //bin/sleep 20
         //bin/mount /dev/sdc1 -t ext3 /home4
         //bin/sleep 1

      fi
fi
-----------------------------end-------------------------


做乜會 double "//" 呢?? 一個就可以了. 無需二個.
仲有 file type option 最好在 command 後就加
/path/mount -t ext3 /mount/device /mount/path

[ 本帖最後由 bluesheet 於 2009-2-5 10:24 編輯 ]
作者: lazyfai    時間: 2009-2-5 23:27

就咁睇 log, 個 mke2fs 好似冇做野。
作者: kenkilaw    時間: 2009-2-6 12:08

原帖由 lazyfai 於 2009-2-5 23:27 發表
就咁睇 log, 個 mke2fs 好似冇做野。


係~~~因為入面d野仲係到€





歡迎光臨 電腦領域 HKEPC Hardware (https://h2.hkepc.com/forum/) Powered by Discuz! 7.2