解决XFS文件系统NFS输出Stale NFS file handle错误

公司有一台SAN存储,其中划出了26TB的容量通过open-iscsi输出到某台Ubuntu Server上,然后再在这台Ubuntu Server配置好NFS,将26TB共享至其它Clients上。一直使用的好好的,在某一天,客户端在挂载时,突然就出现了Stale NFS file handle的错误。经过无数次谷歌以后,找到了解决方案。这里记录一下。

一开始,以为是分区出现逻辑错误,准备尝试fsck一下(XFS文件系统不能使用fsck命令),于是有了以下过程

$ sudo xfs_check /dev/vg-15k/users
ERROR: The filesystem has valuable metadata changes in a log which needs to
be replayed.  Mount the filesystem to replay the log, and unmount it before
re-running xfs_check.  If you are unable to mount the filesystem, then use
the xfs_repair -L option to destroy the log and attempt a repair.
Note that destroying the log may cause corruption -- please attempt a mount
of the filesystem before doing this.



$ sudo xfs_repair /dev/vg-15k/users
Phase 1 - find and verify superblock...
Phase 2 - using internal log
        - zero log...
ERROR: The filesystem has valuable metadata changes in a log which needs to
be replayed.  Mount the filesystem to replay the log, and unmount it before
re-running xfs_repair.  If you are unable to mount the filesystem, then use
the -L option to destroy the log and attempt a repair.
Note that destroying the log may cause corruption -- please attempt a mount
of the filesystem before doing this.



$ sudo xfs_repair -L /dev/vg-15k/users
Phase 1 - find and verify superblock...
Phase 2 - using internal log
        - zero log...
ALERT: The filesystem has valuable metadata changes in a log which is being
destroyed because the -L option was used.
        - scan filesystem freespace and inode maps...
sb_icount 64, counted 4884352
sb_ifree 61, counted 15726
sb_fdblocks 2683832778, counted 1409694604
        - found root inode chunk
Phase 3 - for each AG...
        - scan and clear agi unlinked lists...
        - process known inodes and perform inode discovery...
        - agno = 0
        - agno = 1
        - agno = 2
        - agno = 3
        - agno = 4
        - agno = 5
        - agno = 6
        - agno = 7
        - agno = 8
        - agno = 9
        - process newly discovered inodes...
Phase 4 - check for duplicate blocks...
        - setting up duplicate extent list...
        - check for inodes claiming duplicate blocks...
        - agno = 0
        - agno = 1
        - agno = 3
        - agno = 2
        - agno = 4
        - agno = 5
        - agno = 6
        - agno = 7
        - agno = 9
        - agno = 8
Phase 5 - rebuild AG headers and trees...
        - reset superblock...
Phase 6 - check inode connectivity...
        - resetting contents of realtime bitmap and summary inodes
        - traversing filesystem ...
        - traversal finished ...
        - moving disconnected inodes to lost+found ...
Phase 7 - verify and correct link counts...
done

(more…)

Read More

Ubuntu14.04配置LDAP Client

Ubuntu 14.04系统上配置LDAP客户端的过程,记录一下。

sudo apt-get install ldap-utils ldap-auth-client libnss-ldap libpam-ldap

安装过程中提示填写ldap相关信息:ldap server地址,base dc等,信息保存在/etc/ldap.conf中,可通过dpkg-reconfigure ldap-auth-config重新配置,其中:

lda地址格式 ldap://192.168.x.x:389
Distinguished name of the search base: 就是你目录树的根,比如我的是dc=163,dc=com
LDAP version to use: 3
Make local root Database admin: Yes
Does the LDAP database require login? No
LDAP account for root:  安装LDAP服务器时的创建的admin账号,我的是cn=admin,dc=163,dc=com
LDAP root account password: 

修改/etc/nsswitch.conf文件,添加ldap登陆方式,同时系统查找顺序,以便在查询 LDAP服务器之前先检查您的本地passwd文件

sudo cp -p /etc/nsswitch.conf /etc/nsswitch.conf.bak
sudo auth-client-config -t nss -p lac_ldap

(more…)

Read More

在Ubuntu上使用XFS文件系统

虽说ext4格式的文件系统支持超过16TB的容量,但一旦给16TB以上的分区扩容时,问题就来了,因为resize2fs工具不支持给16TB以上的文件系统扩容,怎么办呢?改用XFS文件系统。本文是在Ubuntu 12.04 64bit系统上配置LVM+XFS的过程,记录一下。

遇到的问题
当给lv容量超出16TB以上时,lvextend为逻辑卷扩容可以成功,但resize2fs时就会失败。因Ubuntu系统自带的e2fsprogs版本不支持扩容16TB以上的分区,谷歌了一阵,貌似最新版本的e2fsprogs可以支持超过16TB的系统分区,但升级完成以后,再次尝试resize2fs的时候,又报出如下错误:

$ sudo lvscan
  ACTIVE            '/dev/vg_02/lv-release' [5.00 TiB] inherit
  ACTIVE            '/dev/vg_02/lv-product-b' [23.80 TiB] inherit
$ sudo resize2fs /dev/vg_02/lv-product-b
resize2fs 1.42.13 (17-May-2015)
Filesystem at /dev/vg_02/lv-product-b is mounted on /data/product-b; on-line resizing required
old_desc_blocks = 2791, new_desc_blocks = 3047
resize2fs: Filesystem does not support online resizing 

很搞笑,这三条提示前后互相矛盾,前面说on-line resizing required,后面说does not support online resizing。

尝试解决办法:修改blocksize
要修改blocksize的话,重新mkfs是肯定的了。这里重新格式化以后,发现根本无法mount。

$ sudo mkfs.ext4 -b 8192 /dev/dm-3
Warning: blocksize 8192 not usable on most systems.
Proceed anyway? (y,n) y
mkfs.ext4: 8192-byte blocks too big for system (max 4096)
Proceed anyway? (y,n) y
Warning: 8192-byte blocks too big for system (max 4096), forced to continue
……
Writing superblocks and filesystem accounting information: done

$ sudo mount -t ext4 -o blocksize=8192 /dev/dm-3 /data/output-b
mount: wrong fs type, bad option, bad superblock on /dev/dm-3,
   missing codepage or helper program, or other error
   In some cases useful info is found in syslog - try
   dmesg | tail  or so

后来查了一下原因,貌似是blocksize不能超出系统的pagesize。这简直是在断我的后路呀。 (more…)

Read More

Fedora/Ubuntu系统安装小度WIFI/360随身WIFI驱动

小度WIFI最近在某东的价格跌到了10元以内,于是没忍住,连续撸了好几个。本文介绍一下在Fedora21系统中安装小度WIFI驱动的方法(Ubuntu的用户可以直接跳到本文最末尾,本文最底部介绍了在Ubuntu系统下安装驱动的方法)。

由于小度WIFI和360随身WIFI都使用了MT7601U的方案,因此本文同时适用于小度WIFI和360随身WIFI。

准备工作

$ sudo yum install gcc gcc-c++ make git

$ sudo yum install kernel-headers kernel-devel

#查看系统安装的kernel/kernel-devel/kernel-headers版本
$ sudo rpm -qa | grep kernel
#如果kernel/kernel-devel/kernel-headers版本不一致,需要执行
$ sudo yum update kernel*

#查看当前启动的kernel版本
$ sudo uname -r
#如果当前启动的kernel版本跟上面的不一样,则需要重启

安装驱动
需要说明的是,MTK官方提供的驱动版本,说明了只支持2.4/2.6版本的内核。但fedora已经更新到了3.19内核,于是,只能使用GitHub某大神修改过的驱动了。 (more…)

Read More

ubuntu自定义登录xsession和桌面环境

查看系统内置的xsession

$ ls /usr/share/xsessions/
gnome-classic.desktop  gnome-fallback.desktop  ubuntu-2d.desktop  xsession.desktop
gnome.desktop          gnome-shell.desktop     ubuntu.desktop     xterm.desktop

修改默认登陆的Xsession

$ sudo vim /etc/lightdm/lightdm.conf
[SeatDefaults]
greeter-session=unity-greeter
user-session=ubuntu    #修改为如上的xsession即可
……

注意,Ubuntu 14.04的配置文件位于/usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf

切换X管理程序
以下命令需要远程操作,因为停止X管理程序会导致黑屏

$ sudo apt-get install gdm
$ sudo dpkg-reconfigure gdm  #切换显示管理器(将lightdm换为gdm)
$ sudo /etc/init.d/lightdm stop  #注意此时会黑屏
$ ps -ef | grep Xorg         #找到Xorg的进程,并kill之
$ sudo /etc/init.d/gdm start #然后就会发现桌面恢复了

(more…)

Read More

解决Ubuntu提示500 OOPS: vsftpd: refusing to run with writable root inside chroot()

Ubuntu 12.04 64bit系统下安装的vsftpd,在登陆时提示500 OOPS: vsftpd: refusing to run with writable root inside chroot()。根本原因在于,从vsftpd_2.3.5版开始,取消了根目录的可写权限。因此,网上的普遍解决方案是以下两种:

方案一
$ chmod a-w /vaf/ftp

方案二
$ vim /etc/vsftpd.conf add the following
  allow_writeable_chroot=YES

看起来,貌似第二种方式是更完美,但当我把allow_writeable_chroot=YES配置项加入的时候,重启vsftpd服务的时候发现不能正常工作了(21端口无程序在监听),于是上网查找解决方案,发现说法五花八门的,有人说配置项是allow_writable_chroot(少了个e),还有说配置项是allow_writable_root(少了ch)等的,经过我测试,发现全都不行。后来总算找到一个可行的方法。

Ubuntu 12.04 64bit的完整解决方案

$ apt-get install python-software-properties
$ sudo add-apt-repository ppa:thefrontiergroup/vsftpd
$ sudo apt-get update
$ sudo apt-get install vsftpd
$ vim /etc/vsftpd.conf and add the following
  chroot_local_user=YES
  allow_writeable_chroot=YES
$ sudo service vsftpd restart
Read More