8. Mount RPMs With FTPFS

By this time, your kernel is compiled and running ok. You will have the need to access countless number of RPMs which you may need to install in near future. One way is to physically mount the Linux CDROMS, but there are more than 3 Linux cdroms and it is cumbersome to remove and change the Linux cdroms. Hence, here comes the FTPFS.

FTP File System is a Linux kernel module, enhancing the VFS with FTP volume mounting capabilities. That is, you can "mount" FTP shared directories in your very personal file system and take advantage of local files ops. It is at "http://lufs.sourceforge.net/lufs" and at "http://ftpfs.sourceforge.net" .

8.1. Using the ftpfs

Download the ftpfs and install it on your system. The ftpfs is installed as a module in /lib/modules/2.4.18-19.8.0/kernel/fs/ftpfs/ftpfs.o. And also the command ftpmount is in /usr/bin/ftpmount. And you can do the following:

Login as root (su - root) and run this script:


	#!/bin/sh -x
	# Use this script to mount ftp redhat cdroms rpms directory disk1,2,3
	# Built rpm by name ftpfs.
	# http://lufs.sourceforge.net/main/projects.html
	# ftpmount --help
	# Try this: ftpmount [user[:pass]@]host_name[:port][/root_dir] mount_point [-o]
	# [-uid=id] [gid=id] [fmask=mask] [dmask=mask]
	#ftpmount anonymous:[email protected] /mnt/ftpfs
	#mkdir -p /mnt/ftpfs /mnt/ftpfs/updates /mnt/ftpfs/rpms /mnt/ftpfs/contrib
	# Redhat ftp mirror sites - http://www.redhat.com/download/mirror.html
	FTPSITE="csociety-ftp.ecn.purdue.edu"
	USER="anonymous:pass"
	ftpmount $USER@$FTPSITE/pub/redhat/redhat  /mnt/ftpfs/site
	ftpmount $USER@$FTPSITE/pub/redhat/redhat/linux/updates/8.0/en/os  /mnt/ftpfs/updates
	ftpmount $USER@$FTPSITE/pub/redhat/redhat/linux/8.0/en/os/i386/RedHat /mnt/ftpfs/rpms
	ftpmount $USER@$FTPSITE/pub/redhat-contrib /mnt/ftpfs/contrib
        

8.2. The ftpfs Commands

Before you even start thinking about mounting FTP volumes, make sure you have a decent bandwidth or it's gonna suck.

8.2.1. The autofs way - A must try!

If you were wise enough to install the autofs/automount bridge (check out the installation notes) there is a cool way to use ftpfs: just try to access any file/dir on the desired server under /mnt/ftpfs.


	cd /mnt/ftpfs/[user:pass@]ftp_server[:port]
          

Something like cd /mnt/ftpfs/ftp.kernel.org. And guess what? You're there!

Normally you will only use this for anonymous ftp since you don't want your user/pass info to show up in the /mnt/ftpfs/ tree.

8.2.2. The ftpmount way

ftpmount [lsqb ]user[lsqb ]:password]@]hostname[lsqb ]:port ][lsqb ]/root_dir] mount_point [lsqb ]-own] [lsqb ]-uid=id] [lsqb ]-gid=id] [lsqb ]-fmask=mask] [lsqb ]-dmask=mask] [lsqb ]-active]


	The parameters: [defaults]
	    * user: The user to be used for logging on the FTP server. [anonymous]
	    * password: The password for that user. [[email protected]]
	    * hostname: The FTP server.
	    * port: The port the server is listening on. [21]
	    * root_dir: The directory on the FTP server you want to be mounted. This should be specified without the trailing slash (that is "/home/duru", not "/home/duru/"). [/]
	    * mount_point: The local directory you want to mount the FTP server onto.
	    * own: Flag to force ownership on all remote files. Useful for FTP servers that list user IDs instead of user names.
	    * uid: The local user ID you want to be the owner of the mounted tree.
	    * gid: The local group ID you want to own the mounted tree.
	    * fmask: The numeric mode to be ORed on all mounted files.
	    * dmask: The numeric mode to be ORed on all mounted dirs.
	    * active: Flag to enable active mode for FTP transfers. Useful if you're behind some firewall and cannot connect to random ports.
          

Eg: ftpmount [email protected] /mnt/ftpfs -uid=500 -gid=500 -dmask=555

It is generally a good idea not to provide your password as a parameter, since ftpmount will ask for it.

8.2.3. The mount way

If for some reason you choose not to use ftpmount (you probably installed the kernel patch and are too lazy to install ftpmount too), here's the way to use good-ol mount:

mount -n -t ftpfs none mount_point -o ip=server_ip [lsqb ],user=user_name] [lsqb ],pass=password] [lsqb ],port=server_port] [lsqb ],root= root_dir] [lsqb ],own] [lsqb ],uid=id] [lsqb ],gid=id] [lsqb ],fmode=mask] [lsqb ],dmode=mask] [lsqb ],active]

Please note that you have to provide the server's IP and that the only way to enter a password is in clear. For example, while testing, I used the following command:

mount -n -t ftpfs none /mnt/ftpfs -o ip=127.0.0.1,user=mali,pass=my_pass

8.2.4. Some notes

To unmount the volume, you go like


	umount mount_point
          

The own option (-o for ftpmount) forces ownership by the mounting user on all files. This is useful for accommodating servers with strange user/permissions management (SERVU & stuff).

A few words of wisdom:

  • Use -n mount option! I bet you don't want your user/password information listed in mtab.

  • Don't push it! (pushing it = a dozen processes reading on the mount point)

  • It works best for one process! While concurrent access (under normal circumstances) shouldn't cause any problem, the output is optimized for one process reading (the TCP connection is kept alive). So, if you're gonna watch a movie, you don't want other processes to access the mount point and kill the throughoutput (trust me!).

  • The address in IP format sucks! - Go get ftpmount.