Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Saturday, July 23, 2011

How to use FTP filesystem on Ubuntu using CurlFtpFS


Some web hosting company do not offer shell access (SSH or Telnet) to your shared hosting account for security reasons, making it a bit harder for you to do regular file maintenance for your web account. Although the use of regular FTP client is adequate for most cases, some people still prefer to manipulate files directly using standard Unix tools (probably because of old habits).
Fortunately, there's CurlFtpFS which allow you to mount remote ftp account as a standard filesystem on your Linux operating system.
Using CurlFtpFS
First of all you need to install CurlFtpFS, which in case of Ubuntu or Debian based operating system is to run 'sudo apt-get install curlftpfs'.
Alternatively, you can use Synaptic to install CurlFtpFS.
Assuming you've successfully installed curlftpfs, all you need to do in order to mount ftp locally is to to run these commands.
mkdir hostr
sudo curlftpfs -o allow_other ftp://user:pass@ftp.example.com host
user:pass is the username and password to log into ftp account.
After that, you can change your working directory to the mount-point and use the regular unix utilities to work on the files that normally accessible on the FTP protocol. After you're done, you can unmount it by running the usual "sudo umount [mountpoint]" command
Using CurlFtpFS in fstab
You can add curlftpfs to fstab for automatic mounting by using this line :
curlftpfs#user:pass@ftp.example.com /mnt/host fuse rw,uid=500,user,noauto 0 0
Note: Please refer to CurlFtpFS website for further reference.
Thanks for reading this post, hopefully this will get you started to use curlftpfs FTP based filesystem in your Linux operating system.


How do I forcefully unmount a Linux disk partition


It happens many times you try to unmount a disk partition or mounted CD/DVD disk and if you try to unmount device, which is accessed by other users, then you will get error umount: /xxx: device is busy. However, Linux/FreeBSD comes with fuser command to kill forcefully mounted partition.

Understanding device error busy error

What happens basically, is that Linux / UNIX will not allow you to unmount a device that is busy. There are many reasons for this (such as program accessing partition or open file) , but the most important one is to prevent data loss.
Try the following command to find out what processes have activities on the device/partition. If your device name is /dev/sdb1, enter the following command as root user:
# lsof | grep '/dev/sda1'Output:
vi 4453       vivek    3u      BLK        8,1                 8167 /dev/sda1
Above output tells that user vivek has a vi process running that is using /dev/sda1. All you have to do is stop vi process and run umount again. As soon as that program terminates its task, the device will no longer be busy and you can unmount it with the following command:
# umount /dev/sda1
Following disussion allows you to unmout device and partition forcefully using Linux commands.

Linux fuser command to forcefully unmount a disk partition

Suppose you have /dev/sda1 mounted on /mnt directory then you can use fuser command as follows:
WARNING! These examples may result into data loss if not executed properly (see "Understanding device error busy error" for more information).
Type the command to unmount /mnt forcefully:
# fuser -km /mntWhere,
  • -k : Kill processes accessing the file.
  • -m : Name specifies a file on a mounted file system or a block device that is mounted. In above example you are using /mnt
Linux umount command to unmount a disk partition
You can also try umount command with –l option:
# umount -l /mntWhere,
  • -l : Also known as Lazy unmount. Detach the filesystem from the filesystem hierarchy now, and cleanup all references to the filesystem as soon as it is not busy anymore. This option works with kernel version 2.4.11+ and above only.
If you would like to unmount a NFS mount point then try following command:
# umount -f /mntWhere,
  • -f: Force unmount in case of an unreachable NFS system
Caution: Using these commands or option can cause data loss for open files; programs which access files after the file system has been unmounted will get an error.