Klaus Knopper is the creator of Knoppix and co-founder of the LinuxTag expo. He currently works as a teacher, programmer, and consultant. If you have a configuration problem, or if you just want to learn more about how Linux works, send your questions to: firstname.lastname@example.org
External USB Hard Drive
I enjoy your column in Linux Magazine because I am a new Linux user and electrical engineer trying to understand how the system works.
My question is related to the Western Digital "Passport" 250GB external USB hard drive and how the mounting and synchronization of the data cache operates in Fedora 7 with the Gnome desktop. Automatic mounting of the drive takes place when the device is plugged in, and an icon is created on the desktop that can be used to access the data. However, the "eject" feature using the mouse does not properly synchronize the data cache with the physical medium during unmounting, and lost data results on a frequent basis when I disconnect the device.
The drive heads are not stopped either, and a strange whirring chirp sound occurs when unplugging the drive while the platters are still spinning.
I searched Google and found a shell script to properly unmount the drive, and it uses a tool called sdparm to sync and stop the drive heads before physically disconnecting the USB hard drive. I did not have sdparm installed by default from my Fedora 7 distribution (obtained through a Linux Magazine DVD) and had to search and install the tool myself using the package manager. (Zenity message boxes also had to be installed for this script.)
I have attached the script in its current working state. The script solves the problem and prevents lost data and stops the drive, as long as I remember to switch to root before calling it from the shell. Otherwise, I am down in the trenches trying to sync my drive before unplugging. The script, however, is limited to only one drive at a time, as the mount point is hard coded to a specific location in /media/WDPASSPORT.
I would like to know how to take a shell script like this one, which manually unmounts and sync's my USB drives correctly, and associate it with the icon that is automatically created for the drive in the Gnome desktop so that when I use the mouse to "eject" the drive, it calls this script.
Alternatively, can I edit an existing script that already comes with Fedora 7 (as used by the desktop), to resolve the problem? Or is this behavior compiled in?
I believe the "eject" feature used by Gnome is only meant for flash memory drives such as USB keys, where there is no concept of flushing the data in RAM to the magnetic storage medium and stopping the heads, and hence it is a rather simple solution for unmounting that is not suitable for external portable hard drives.
Thanks in advance for considering this Linux hardware challenge.
The quite long script you sent can be reduced to (more or less) this skeleton:
#!/bin/bash exec >/dev/null 2>&1 # No error messages pumount $1 || umount $1 sdparm --command=sync $1 sdparm --command=stop $1
pumount only works if it's installed, and if the normal desktop user is a member of the group plugdev; otherwise, the command will fail (and the script will use umount instead). In that case, the desktop keeps the disk busy at the moment of the umount call.
Lazy umount (umount -l) could be called instead, which will umount the drive whenever nobody accesses it anymore. Because a umount entry should be part of the usual KDE or Gnome service menu for a hard disk, the entire umount… command line is not really needed, but it probably does not hurt if it's there, either.
The SCSI disk control command sdparm is available as a Debian package, but it is not necessarily preinstalled in every distribution yet. In this example, it will send a "sync," which will write back all pending physically unwritten data back to the medium; however, in theory, the umount command should also have told the (virtual) SCSI driver to do this.
The most important command in the example is probably sdparm --command=stop, which will power off the motor and park the heads of the removable disk to avoid the noise effect you mentioned. Noise always means mechanical friction, which damages disk surface and heads in the long term.
Now, to get the script to work with the right-click context menu, edit this file in KDE:
by changing the line that says
Exec=kio_mounthelper -e %u
The script must be called with the device name as a parameter, which is what %v means.
For Gnome, I have not found a way to do this without changing the source of the mount/eject helper applets, but there may be a way to change the settings for manually created icons.
One of the frustrations I have in Linux is folder and file permissions.
How do I give a command so that a folder and all that is underneath it (folders and files) are completely open?
I know it is
but what do I write after that?
I have a folder called church that is under htdocs. At the prompt
dull:/srv/www/ htdocs #
I have typed
but when I checked later, I found some files were not changed.
What am I doing wrong?
chmod works with options that tell the command what to do. If your intention is to make the directory church, which is a subdirectory of /srv/htdocs, and all files under it readable, writable, and executable for everyone on the system, the command is:
chmod -R ugo=rwX /srv/www/htdocs/church
Be careful with the spelling. Capitals and spaces have a meaning.
Table 1 shows a description of the options used in this command. Type man chmod at the command line or consult a standard Linux reference for a complete list of chmod options.
If you want to see what's happening while it's happening, use option -v right after -R in the preceding command.
The abbreviation 777, which you mentioned, is a bitmask that means the same thing as ugo=rwx (which would also force execute permissions for files that are not supposed to have them).
The preceding command should do what you intended; however, with file permissions like this, everyone working on the computer will be able to read, change the content, and delete files. In case your web server uses potentially unsecure scripting extensions, the web server itself can even change the content of files now, because it has full write access. Be aware of the security implications, and make sure you always have a recent backup.
I just wrote you these few lines because I have a couple of questions. I am very new to Linux. I had installed a new hard drive to my laptop because the old one was bad. I used the recovery disk, and it put back the original Windows XP operating system on the hard drive.
I would like to partition my hard drive so I can install a Linux SUSE system as well. How can I partition my NTFS hard drive?
Also, how can I differentiate between which operating system I want to use at the beginning of the booting process?
Caution: There is no such thing as an "NTFS disk." A hard disk is independent of the operating system and can be partitioned into smaller parts that can be used by various operating systems with their individual filesystems.
Although Linux can read and write to NTFS without problems using ntfs-3g, NTFS is still not a good filesystem for hosting a Linux operating system because it simply does not support all of the features and file types that Linux needs. The steps for creating a new partition for Linux – or better, two new partitions, are:
- Run an NTFS defragmentation on Windows. This should put all files at the beginning of the NTFS partition, so there is enough free space at the end to resize and create new partitions.
- After defragmenting the filesystem, resize the partition holding the NTFS/Windows filesystem – reduce the partition to a size that you think is necessary. Be aware that Windows is not capable of writing to Linux filesystem partitions without additional drivers, but Linux can write to NTFS. You can do the NTFS resizing on Windows (there should be an utility in "properties") or use a hard disk partitioning program under Linux that can handle NTFS (qtparted, gparted, or ntfsresize).
- Create at least two new partitions on the remaining free space. One should be a swap partition that is used by Linux to extend the available RAM with available hard disk space. (The size of the swap partition depends on what you plan to do; for large graphics/video editing programs, use 2GB or more for swap), and use the second (third, in total) partition for the Linux installation. You can create the Linux partitions from the installer of most Linux distributions, so you could also just go straight to step 4.
- Run the Linux installation disk, and be careful to install to the new Linux partition, not the Windows partition.
Usually, the GNU/Linux installations will create a master boot record that lets you choose the operating system from a boot menu.
Buy this article as PDF
Customers can take a free test drive of SLES for HPC on the Azure Cloud
San Francisco-based chip company announces their first fully open source chip platform.
The whole distro gets rebuilt on glibc 2.3
Ubuntu Vendor tries to solve app packaging and distribution problem across distributions.
Founder of ownCloud launches the Nextcloud project.
Will The Machine change the way future programmers think about memory?
The new Torus distributed storage system is available under an open source license on GitHub
Juries decides Google’s use of Java APIs Was Fair Use
But if you are not using the latest Linux kernel, your system is insecure.
Home routers will give room for custom firmware but still comply with FCC rules