Category Archives: Linux

Mount command for Filers

For filers we can check at the following location:
/etc/fstab

1. Check the hosts
cat /etc/hosts

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
10.99.160.38 DCEPP-DBR-01
10.114.138.51 aptplaton.si.francetelecom.fr
172.20.20.16 FILER

2. Change the Filer in the fstab file
/dev/rootvg/root_lv / ext3 defaults 1 1
/dev/infravg/images_lv /images ext3 defaults 1 2
/dev/rootvg/usr_lv /usr ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/rootvg/swap_lv swap swap defaults 0 0
LABEL=/boot /boot ext3 defaults,nodev,nosuid 1 2
/dev/rootvg/home_lv /home ext3 defaults,nodev,nosuid 1 2
/dev/rootvg/opt_lv /opt ext3 defaults,nodev 1 2
/dev/rootvg/var_lv /var ext3 defaults,nodev,noexec 1 2
/dev/rootvg/tmp_lv /tmp ext3 defaults,nodev,nosuid 1 2
/dev/rootvg/system_lv /system ext3 defaults,nodev 1 2
/dev/cdrom /media/cdrom udf,iso9660 noauto,owner,nodev,nosuid,ro 0 0
/dev/fd0 /mnt/floppy auto noauto,owner,nodev,nosuid,ro 0 0
/dev/infravg/mysql_lv /opt/mysql ext3 defaults,nodev 1 2
/dev/infravg/mysql_na_5144_lv /opt/mysql/na/5.1.44 ext3 defaults,nodev 1 2
172.20.20.16:/vol/DCEPP/DBR1 /myqdata nfs nosuid,nodev,vers=3,tcp,bg,hard,nointr,wsize=32768,rsize=32768,rw,nolock,timeo=600 0 0

Use Filers instead of IP

3. Mount the filesystem
mount -a

4. Check all the mounted filesystem
mount

Transfer file to linux server in java

To transfer the file through SSH protocol we have to download two jar files : jsch-0.1.42.jar, xercesImpl.jar
JSch and ChannelSftp classes are used to transfer the file on linux server.

    /**
     * Transfer file to Linux server 
     * @return true or false
     */
    public static boolean transferFileToLinuxMachine(String filePath){
    	JSch jsch = new JSch();
    	Session session = null;
    	try {
		// Put username and ip of the server
                session = jsch.getSession("admycsr","10.170.201.11",22);
		session.setPassword("csrtdev1");
	    	session.setConfig("StrictHostKeyChecking", "no");
	    	session.connect();
	    	System.out.println("server connected successfully");
	    	ChannelSftp channel = null;
	    	channel = (ChannelSftp)session.openChannel("sftp");
	    	channel.connect();
	    	System.out.println("channel connected successfully");
	    	File localFile = new File("C://Users//hlcz0172//Desktop//Noname2.txt");
	    	//If you want you can change the directory using the following line.
	    	channel.cd("/home/admycsr");
	    	channel.put(new FileInputStream(localFile),localFile.getName());
	    	System.out.println("File trasfered successfully");
	    	channel.disconnect();
	    	session.disconnect();
		} catch (JSchException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SftpException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	
    	return true;
    }