<ask> Fsck otomatis ubuntu server

Diskusi tentang Ubuntu Server baik webserver, database server, samba server dan service lainnya serta jaringan menggunakan Sistem Operasi Ubuntu.
User avatar
zitux
Posts: 843
Joined: 15 Jan 2010, 23:17
Location: Malang Jatim Indonesia
Contact:

<ask> Fsck otomatis ubuntu server

Postby zitux » 13 Jun 2010, 18:28

ubuntu server
beberapa hari ini listrik sering mati
setiap kali server dipaksa mati tanpa melakukan shutdown atau reboot
startup boting berikutnya akan mengalami banyak error
muncul fsck manualy (scandisk manual)

how to menghindari scandisk manual td atau supaya bisa otomatis scandisk seperti ubuntu dekstop ??
.
tq
User avatar
Rh354
Posts: 718
Joined: 14 Mar 2010, 19:56
Location: between the truth and the lies
Contact:

Re: <ask> Fsck otomatis ubuntu server

Postby Rh354 » 13 Jun 2010, 18:49

fsck otomatis deh keknya tiap 30x booting...ga' tau jg klo server...pake ups :)
User avatar
zitux
Posts: 843
Joined: 15 Jan 2010, 23:17
Location: Malang Jatim Indonesia
Contact:

Re: <ask> Fsck otomatis ubuntu server

Postby zitux » 13 Jun 2010, 18:53

hu uh pake ups dan pake monitor :grin:
apakah tidak ada konfigurasi untuk scandisk otomatis nya ?

biasa orang indo mau nya ngirit :D :D
tanpa ups dan monitor :D
klo ups memang rencana dikasih
tp klo monitor kagak :(
jadi ribet klo pas fsck manual harus pasang monitor dulu baru scan manual :(
User avatar
Rh354
Posts: 718
Joined: 14 Mar 2010, 19:56
Location: between the truth and the lies
Contact:

Re: <ask> Fsck otomatis ubuntu server

Postby Rh354 » 13 Jun 2010, 19:02

zitux wrote:hu uh pake ups dan pake monitor :grin:
apakah tidak ada konfigurasi untuk scandisk otomatis nya ?

biasa orang indo mau nya ngirit :D :D
tanpa ups dan monitor :D
klo ups memang rencana dikasih
tp klo monitor kagak :(
jadi ribet klo pas fsck manual harus pasang monitor dulu baru scan manual :(
tetep klo kek gitu ceritanya mesti make ups :D konsekuensinya lebih besar :D HDD kena ,motherboard kena :D klo udah gitu dobel khan..klo udah diganti baru deh beli ups jadi duitnya tambah dobel :D

bandingkan klo bli ups lsg sebelum semuanya terlambat.. :D

klo monitor rasanya ga' perlu deh..selama masih bs di remote dari luar kompi laen..
User avatar
zitux
Posts: 843
Joined: 15 Jan 2010, 23:17
Location: Malang Jatim Indonesia
Contact:

Re: <ask> Fsck otomatis ubuntu server

Postby zitux » 13 Jun 2010, 20:11

klo ups memang rencana dikasih
bereskan :D masih setup ups pake aki mobil bisa tahan 5 jam :grin:

klo monitor rasanya ga' perlu deh..selama masih bs di remote dari luar kompi laen..
klo pas scandisk manual ?? kan gak bisa diremot :blush:
coz aplikasinya masih belum berjalan

back topik klo ada konfigurasi nya otomatis
bisa 99% tanpa monitor :blush:
User avatar
Rh354
Posts: 718
Joined: 14 Mar 2010, 19:56
Location: between the truth and the lies
Contact:

Re: <ask> Fsck otomatis ubuntu server

Postby Rh354 » 13 Jun 2010, 20:25

User avatar
zitux
Posts: 843
Joined: 15 Jan 2010, 23:17
Location: Malang Jatim Indonesia
Contact:

Re: <ask> Fsck otomatis ubuntu server

Postby zitux » 13 Jun 2010, 20:57

terima kasih mas resa
Tampilkan

Code: Select all

#!/bin/bash
#
#   Script adapted from "AutoFsck V3.2 by Jonathan Musther"
#   by Jonathan Musther, for Peter  -  1st May 2008
#
#   This script should be called when the machine is to be shutdown, it
#   will test to see if fsck is due, if it is, it will be run and the
#   machine will then be halted.  This script should be called thus:
#
#   /usr/bin/autofsck
#
#   where /usr/bin/autofsck is the path to this script.
#
#   Contact: jon@slymail.com
#
#------------------SCRIPT STARTS--------------------
#
#
#========================== Check on halt ==========================
function setupfsck {
   #Force checks.
   touch /forcefsck
   #Now create the script which will cause halt after the check:
   touch /tmp/postfsckhalt.sh
      #Actually create the script
      echo \#! /bin/sh >> /tmp/postfsckhalt.sh
      echo \# >> /tmp/postfsckhalt.sh
      echo \# This is a temporary script, it should not be >> /tmp/postfsckhalt.sh
      echo \# here while the system is in multi-user mode. >> /tmp/postfsckhalt.sh
      echo \# >> /tmp/postfsckhalt.sh
      echo rm /etc/init.d/postfsckhalt.sh >> /tmp/postfsckhalt.sh
      echo rm /etc/rc2.d/S*postfsckhalt.sh >> /tmp/postfsckhalt.sh
      echo rm /etc/rc3.d/S*postfsckhalt.sh >> /tmp/postfsckhalt.sh
      echo rm /etc/rc4.d/S*postfsckhalt.sh >> /tmp/postfsckhalt.sh
      echo rm /etc/rc5.d/S*postfsckhalt.sh >> /tmp/postfsckhalt.sh
      echo init 0 >> /tmp/postfsckhalt.sh
   #Put the script in init.d and update-rc
   mv /tmp/postfsckhalt.sh /etc/init.d/postfsckhalt.sh
   chmod a+x /etc/init.d/postfsckhalt.sh
   update-rc.d postfsckhalt.sh defaults
   #Tidy up so that the script isn't run during shutdown
   #but only during the subsequent boot.
   rm /etc/rc0.d/K*postfsckhalt.sh
   rm /etc/rc1.d/K*postfsckhalt.sh
   rm /etc/rc2.d/K*postfsckhalt.sh
   rm /etc/rc3.d/K*postfsckhalt.sh
   rm /etc/rc4.d/K*postfsckhalt.sh
   rm /etc/rc5.d/K*postfsckhalt.sh
   rm /etc/rc6.d/K*postfsckhalt.sh
}

#Consolidate info about the filesystems, given by mount.
function mountread {
   for i in $( mount | grep --regexp="/dev/hd" --regexp="/dev/sd" ); do
      echo $i
   done
}

function checkcount {
#Basically this section checks the mount command for mounted
#partitions, /dev/sdX and /dev/hdX.  Then it checks the mount count
#and maximum mount count of each one, any which is nearly ready for
#checking causes $CHECK to be flagged to "1" and therefore starts
#the main user interactive bit of the script.
CHECK="0"
#Loop to determine filesystems that need checking.
#MC = Mount count - MMC = Max Mount Count.
for i in $( mountread | grep --regexp="/dev/hd" --regexp="/dev/sd" ); do
   MC=$(tune2fs -l $i | grep --regexp="Mount count:" | tr -d "Mount count:")
   MMC=$(tune2fs -l $i | grep --regexp="Maximum mount count:" | tr -d "Maximum mount count:")
   MMC=$(echo $(($MMC-1)))
if [ "$MC" -ge "$MMC" ]; then
   CHECK="1"
fi
done
#Find out if check required.
if [ "$CHECK" = "0" ]; then #If no check required, halt.
   init 0
fi            #If a check is required, set up checks - using function setupfsck:
setupfsck
}

##################### FUNCTION CALLS #####################

checkcount
init 6
exit



script wrote:#Put the script in init.d and update-rc


ubuntuforums.org wrote:Thanks for the script.
But there seems to be a big bug!
It checks my filesystem after a reboot EVERYTIME i shut down the machine, insted of every 30th time. can someone see the bug in the script??
i couldnt find it. please help me, this would be so useful

Masukkan script di init.d dan update-rc
berarti setiap kali komputer restart/sutdown atau listrik padam :D
selalu meload script ini untuk pertama kali
tidak peduli/tidak mengenal restart /shutdown atau litrik padam
bener ndak :grin:

tp memang sangat berguna :grin:
mungkin masih ada yg mau nambahin
tqtqtq
User avatar
Rh354
Posts: 718
Joined: 14 Mar 2010, 19:56
Location: between the truth and the lies
Contact:

Re: <ask> Fsck otomatis ubuntu server

Postby Rh354 » 13 Jun 2010, 22:51

sepertinya cara ini yg bagus klo buat server..asumsinya server ga' pernah restart n K.O karena listrik n hanya di matikan pada saat maintenance...tp klo bolak balik restart itu yg kasian fsck mulu :D
User avatar
c0jack
Posts: 743
Joined: 12 Jan 2010, 10:33
Location: Jogjakarta, Indonesia
Contact:

Re: <ask> Fsck otomatis ubuntu server

Postby c0jack » 14 Jun 2010, 11:13

default ubuntu akan melakukan fsck setiap 30 kali bootup (CMIIW). untuk mengubahnya pake tune2fs. lebih lengkap googling aja yah, saya juga blom pernah pake soalnya :grin: :grin: :grin:


regards
c0jack
User avatar
Rh354
Posts: 718
Joined: 14 Mar 2010, 19:56
Location: between the truth and the lies
Contact:

Re: <ask> Fsck otomatis ubuntu server

Postby Rh354 » 14 Jun 2010, 11:26

c0jack wrote:default ubuntu akan melakukan fsck setiap 30 kali bootup (CMIIW). untuk mengubahnya pake tune2fs. lebih lengkap googling aja yah, saya juga blom pernah pake soalnya :grin: :grin: :grin:


regards
c0jack
iya bro tp ga' tau tu si bro zitux pengennya yg extrim...wekekekeke...

------------------------------------

Telling tune2fs when to do fsck
If errors are found on the file system, fsck will run no matter what. fsck will also run automatically after 30 mounts by default in Ubuntu. You can use tune2fs to increase the number of mounts and/or have it run after a certain amount of days.

fsck will run after 80 mounts:
tune2fs -c 80 /dev/HARDDRIVE

fsck will disregard the number of mounts:
tune2fs -c 0 /dev/HARDDRIVE

fsck will run after 3 days, 2 months and 1 week
tune2fs -i d3 m2 w1 /dev/HARDDRIVE

http://linux.die.net/man/8/tune2fs
User avatar
c0jack
Posts: 743
Joined: 12 Jan 2010, 10:33
Location: Jogjakarta, Indonesia
Contact:

Re: <ask> Fsck otomatis ubuntu server

Postby c0jack » 14 Jun 2010, 11:40

ada langkah antisipasi kalo listrik sering mati. pasang ups, install program nut(network ups tools). nut bisa mendeteksi jika power ups sudah masuk kategori low maka sistem akan di shutdown secara normal. perhatikan dalam pemilihan ups, karena tidak semua ups di support oleh nut. baca di sini untuk mengetahui apa saja merek dan tipe ups yang di support. semoga bermanfaat :)


regards,
c0jack
User avatar
zitux
Posts: 843
Joined: 15 Jan 2010, 23:17
Location: Malang Jatim Indonesia
Contact:

Re: <ask> Fsck otomatis ubuntu server

Postby zitux » 16 Jun 2010, 00:15

http://www.networkupstools.org/compat/stable.html

wuaaahh semua merk NIKISAE :d
gak ada yg NIKIMURAH :D :D
ups saya ndak masuk kategori :grin:
User avatar
zitux
Posts: 843
Joined: 15 Jan 2010, 23:17
Location: Malang Jatim Indonesia
Contact:

Re: <ask> Fsck otomatis ubuntu server

Postby zitux » 16 Jun 2010, 00:42

tune2fs
If errors are found on the file system, fsck will run no matter what.

jika ditemukan error akan mulai proses fsck (scandisk) <---lebih pinter dari srcipt diatas kaya'nya

Availability

tune2fs is part of the e2fsprogs package and is available from http://e2fsprogs.sourceforge.net.

:confused: :confused:
jika bagian dari e2fsprogs(yg sudah bawaan ubuntu) kenapa ubuntu server gak bisa otomatis ya ? <<--- maksutnya otomatis fsck jika menemukan error
:confused:

klo ubuntu desktop sudah sering nemuin otomatis nya ketika shutdown abnormal :confused:
User avatar
zitux
Posts: 843
Joined: 15 Jan 2010, 23:17
Location: Malang Jatim Indonesia
Contact:

Re: <ask> Fsck otomatis ubuntu server

Postby zitux » 16 Jun 2010, 01:28

jalan2 nemu ini
http://linux.die.net/man/8/e2fsck
yg membuat tertarik
-p
Automatically repair ("preen") the file system. This option will case e2fsck to automatically fix any filesystem problems that can be safely fixed without human intervention. If e2fsck discovers a problem which may require the system administrator to take additional corrective action, e2fsck will print a description of the problem and then exit with the value 4 logically or'ed into the exit code. (See the EXIT CODE section.) This option is normally used by the system's boot scripts. It may not be specified at the same time as the -n or -y options.


jadi pengin test dgn hasil
zitux@zitux:~$ e2fsck -p /dev/sda2
/dev/sda2 is mounted.

WARNING!!! The filesystem is mounted. If you continue you ***WILL***
cause ***SEVERE*** filesystem damage.

Do you really want to continue (y/n)? no

check aborted.
zitux@zitux:~$


wuaahh warning nya pake tanda seru 3X :D
gak berani sebelum tanya2 dulu :grin:

pertanyaan nya simple
1.jika filesystem nya tidak termount / partisi belum termount apakah aman ?(atau saya sendiri yg jadi tester nya :D :D )
2.jika saya ketik

Code: Select all

e2fsck -p /dev/sda2[/quote]
apakah akan berjalan seterusnya ? (setiap kali ada error disk/shutdown abnormal)

3.haruskah comand

Code: Select all

 e2fsck -p /dev/sda2 perlu ditambah dgn e2fsck -p -y /dev/sda2
yg berarti baca nya otomatis dan selalu jawan YA :grin:
binun ini :confused: :D
User avatar
Rh354
Posts: 718
Joined: 14 Mar 2010, 19:56
Location: between the truth and the lies
Contact:

Re: <ask> Fsck otomatis ubuntu server

Postby Rh354 » 16 Jun 2010, 01:49

http://pemula.linux.or.id/admin/crash.html


coba lakukan fsck pada saat boot live cd ato live fd bro...
User avatar
zitux
Posts: 843
Joined: 15 Jan 2010, 23:17
Location: Malang Jatim Indonesia
Contact:

Re: <ask> Fsck otomatis ubuntu server

Postby zitux » 16 Jun 2010, 02:41

test pada flashdisk

Code: Select all

root@zitux:/home/zitux# e2fsck -p /dev/sdb1
New_Volume: clean, 11/243840 files, 33627/975167 blocks
root@zitux:/home/zitux# e2fsck -a /dev/sdb1
New_Volume: clean, 11/243840 files, 33627/975167 blocks
root@zitux:/home/zitux# e2fsck -y /dev/sdb1
e2fsck 1.41.11 (14-Mar-2010)
New_Volume: clean, 11/243840 files, 33627/975167 blocks
root@zitux:/home/zitux#

aman :D

lanjut kepertanyaan ke 2 :( cara test nya gimana ya
klo comand diatas bisa jalan seterus nya ??

Return to “Ubuntu Server”

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest