背景:
某台rsync服务端突然出现问题,客户端无法rsync文件过去,登录服务器查看,发现/var变为只读了,所有文件都无法对其写入操作,从而导致无法写入日志,而重启服务亦说是磁盘是只读的;在对/var进行了多方面的操作后(fsck/remount),都无法把该分区变为rw,死活都是只读,而查看dmesg下有很多错误信息:SCSI error : <0 0 0 0> return code = 0x8000002 Info fld=0x16e5296, Deferred sda: sense key Hardware Error,一般处理方法都是在/etc/fstab把该段注释掉,然后reboot再remount,但由于该台服务器的特殊性,害怕重启后无法启动而影响业务,故采取以下方法解决:
[[email protected] /]#mkdir /home1/bak/varbackup [[email protected] /]#mount --move /var /home1/bak/varbackup [[email protected] /]#rm -rf /var [[email protected] /]#cd / [[email protected] /]#mkdir -p /home1/bak/var [[email protected] /]#ln -s /home1/bak/var /var [[email protected] /]#cp -R /home1/bak/varbackup/* /var/ 修改/etc/fstab: [[email protected] /]# cat /etc/fstab LABEL=/ / ext3 defaults 1 1 LABEL=/boot /boot ext3 defaults 1 2 none /dev/pts devpts gid=5,mode=620 0 0 none /dev/shm tmpfs defaults 0 0 LABEL=/home /home ext3 defaults 1 2 LABEL=/home1 /home1 ext3 defaults 1 2 LABEL=/home2 /home2 ext3 defaults 1 2 LABEL=/home3 /home3 ext3 defaults 1 2 LABEL=/data2 /data2 ext3 defaults 0 0 none /proc proc defaults 0 0 none /sys sysfs defaults 0 0 LABEL=/tmp /tmp ext3 defaults 1 2 LABEL=/usr /usr ext3 defaults 1 2 #LABEL=/var /var ext3 defaults 1 2 LABEL=/var /home1/bak/var ext3 defaults 1 2 LABEL=SWAP-sda3 swap swap defaults 0 0 /dev/hda /media/cdrom auto pamconsole,exec,noauto,managed 0 0 /dev/fd0 /media/floppy auto pamconsole,exec,noauto,managed 0 0
修改fstab,使服务器能正常重启,并能挂载/var,此时把原有的相关服务重启,重启成功,/var变为可读写。
此时使用mount查看:
[[email protected] bak]# mount /dev/sda2 on / type ext3 (rw) none on /proc type proc (rw) none on /sys type sysfs (rw) none on /dev/pts type devpts (rw,gid=5,mode=620) usbfs on /proc/bus/usb type usbfs (rw) /dev/sda1 on /boot type ext3 (rw) none on /dev/shm type tmpfs (rw) /dev/sda8 on /home type ext3 (rw) /dev/sdb1 on /home1 type ext3 (rw) /dev/sdc1 on /home2 type ext3 (rw) /dev/sdd1 on /home3 type ext3 (rw) /dev/sda5 on /tmp type ext3 (rw) /dev/sda6 on /usr type ext3 (rw) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw) /dev/sde1 on /data2 type ext3 (rw) /home1/bak/var on /home1/bak/varbackup type none (rw)
有问题的分区已经屏蔽,/var已经使用了新的分区。
mount move参数:Move a subtree to some other place.
从 Linux 2.5.1 开始,可以完整地将一个子树移动到另一个位置。调用的方法是
mount --move olddir newdir
这样不影响系统的挂载服务。
时间: 2024-10-27 13:56:02