If you try to unmount a partition and get a message like this:
# umount /media/usbdisk/ umount: /media/usbdisk: device is busy
use the lsof command to find out what programs are using what files:
# lsof /media/usbdisk/ COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME bash 6925 root cwd DIR 8,17 4096 1 /media/usbdisk/ xmms 6979 root cwd DIR 8,17 4096 1 /media/usbdisk/
This shows that the programs bash and xmms are using the device. For an even clearer picture, use the device name rather than the mountpoint:
# lsof /dev/sdb1 COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME bash 6925 root cwd DIR 8,17 4096 1 /media/usbdisk xmms 6979 root cwd DIR 8,17 4096 1 /media/usbdisk xmms 6979 root 8r REG 8,17 2713101 377 /media/usbdisk/a.mp3
You either can wait until those processes exit or terminate them manually.
To search a list of RPM files for a particular file, execute the following command:
$ ls RPMS-TO-SEARCH | \ xargs rpm --query --filesbypkg --package | \ grep FILE-TO-SEARCH-FOR
Replace RPMS-TO-SEARCH with the names of the RPM files to search, and replace FILE-TO-SEARCH-FOR with the name of the file to search for. The --filesbypkg option tells the rpm command to output the name of the package as well as the name of the file.
If you need to transfer an entire filesystem from one machine to another, for example, when you get a new computer, do the following steps.
1) Boot both PCs with any Linux live CD (for example, Knoppix), and make sure they can access each other via the network.
2) On the source machine, mount the partition containing the filesystem to be copied, and start the transfer using netcat and tar:
cd /mnt/sda1 tar -czpsf - . | pv -b | nc -l 3333
3) On the destination machine, mount the partition to receive the filesystem, and start the process:
cd /mnt/sda1 nc 192.168.10.101 3333 | pv -b | tar -xzpsf -
The nc (netcat) command is used for any kind of TCP connections between two hosts. The pv (progress viewer) command is used to display the progress of the transfer. tar is used to archive the files on the source machine and un-archive them on the destination.
- Brent Laster's Professional Git (Wrox)
- Own Your DNS Data
- Machine Learning Everywhere
- Smoothwall Express
- Bash Shell Script: Building a Better March Madness Bracket
- Simple Server Hardening
- From vs. to + for Microsoft and Linux
- Understanding OpenStack's Success
- The Weather Outside Is Frightful (Or Is It?)
- Ensono M.O.