KNOW-HOW Ask Klaus! ASK KLAUS! during unmounting, and lost data results I edit an existing script that already on a frequent basis when I disconnect comes with Fedora 7 (as used by the the device. desktop), to resolve the problem? Or is The drive heads are not stopped ei- this behavior compiled in? Klaus Knopper is the creator of ther, and a strange whirring chirp sound I believe the “eject” feature used by Knoppix and co-founder of the occurs when unplugging the drive while Gnome is only meant for flash memory the platters are still spinning. drives such as USB keys, where there is LinuxTag expo. He currently I searched Google and found a shell no concept of flushing the data in RAM script to properly unmount the drive, to the magnetic storage medium and works as a teacher, program- and it uses a tool called sdparm to sync stopping the heads, and hence it is a mer, and consultant. If you have and stop the drive heads before physi- rather simple solution for unmounting cally disconnecting the USB hard drive. I that is not suitable for external portable a configuration problem, or if did not have sdparm installed by default hard drives. from my Fedora 7 distribution (obtained Thanks in advance for considering this you just want to learn more through a Linux Magazine DVD) and Linux hardware challenge. about how Linux works, send had to search and install the tool myself using the package manager. (Zenity mes- The quite long script you sent your questions to: sage boxes also had to be installed for can be reduced to (more or less) this script.) this skeleton: klaus@linux-magazine. com I have attached the script in its current working state. The script solves the #!/bin/bash problem and prevents lost data and exec >/dev/null 2>&1 U stops the drive, as long as I remember # No error messages to switch to root before calling it from pumount $1 || umount $1 External USB Hard Drive the shell. Otherwise, I am down in the sdparm --command=sync $1 I enjoy your column in Linux trenches trying to sync my drive before sdparm --command=stop $1 Magazine because I am a new unplugging. The script, however, is lim- Linux user and electrical engi- ited to only one drive at a time, as the pumount only works if it’s installed, and neer trying to understand how the sys- mount point is hard coded to a specific if the normal desktop user is a member tem works. location in /media/WDPASSPORT. of the group plugdev; otherwise, the My question is related to the Western I would like to know how to take a command will fail (and the script will Digital “Passport” 250GB external USB shell script like this one, which manually use umount instead). In that case, the hard drive and how the mounting and unmounts and sync’s my USB drives cor- desktop keeps the disk busy at the mo- synchronization of the data cache oper- rectly, and associate it with the icon that ment of the umount call. ates in Fedora 7 with the Gnome desk- is automatically created for the drive in Lazy umount (umount -l) could be top. Automatic mounting of the drive the Gnome desktop so that when I use called instead, which will umount the takes place when the device is plugged the mouse to in, and an icon is created on the desktop “eject” the that can be used to access the data. drive, it calls However, the “eject” feature using the this script. mouse does not properly synchronize Alterna- the data cache with the physical medium tively, can 60 ISSUE 90 MAY 2008 060-062_ask-klaus.indd 60 12.03.2008 14:31:10 Uhr Ask Klaus! KNOW-HOW drive whenever nobody accesses it any- I know it is more. Because a umount entry should be part of the usual KDE or Gnome ser- Chmod 777 vice menu for a hard disk, the entire umount... command line is not really but what do I write needed, but it probably does not hurt after that? if it’s there, either. I have a folder The SCSI disk control command sd- called church that is parm is available as a Debian package, under htdocs. At the but it is not necessarily preinstalled in prompt every distribution yet. In this example, it will send a “sync,” which will write dull:/srv/www/ U back all pending physically unwritten htdocs # data back to the medium; however, in theory, the umount command should I have typed also have told the (virtual) SCSI driver Figure 1: Type man chmod to call up the chmod manpage. to do this. chmod church/* The most important command in the The preceding command should do example is probably sdparm but when I checked later, I found some what you intended; however, with file --command=stop, which will power off files were not changed. permissions like this, everyone working the motor and park the heads of the re- What am I doing wrong? on the computer will be able to read, movable disk to avoid the noise effect change the content, and delete files. In you mentioned. Noise always means chmod works with options that case your web server uses potentially mechanical friction, which damages disk tell the command what to do. If unsecure scripting extensions, the web surface and heads in the long term. your intention is to make the di- server itself can even change the content Now, to get the script to work with the rectory church, which is a subdirectory of files now, because it has full write ac- right-click context menu, edit this file in of /srv/htdocs, and all files under it read- cess. Be aware of the security implica- KDE: able, writable, and executable for every- tions, and make sure you always have one on the system, the command is: a recent backup. /usr/share/apps/konqueror/U servicemenus/media_eject.desktop chmod -R ugo=rwX U Partitioning /srv/www/htdocs/church I just wrote you these few lines by changing the line that says because I have a couple of ques- Be careful with the spelling. Capitals and tions. I am very new to Linux. Exec=kio_mounthelper -e %u spaces have a meaning. I had installed a new hard drive to my Table 1 shows a description of the op- laptop because the old one was bad. to tions used in this command. Type man I used the recovery disk, and it put back chmod at the command line or consult a the original Windows XP operating sys- Exec=/path/to/your/script %v standard Linux reference for a complete tem on the hard drive. list of chmod options. I would like to partition my hard drive The script must be called with the device If you want to see what’s happening so I can install a Linux SUSE system as name as a parameter, which is what %v while it’s happening, use option -v right well. How can I partition my NTFS hard means. after -R in the preceding command. drive? For Gnome, I have not found a way to The abbreviation 777, which you men- Also, how can I differentiate between do this without changing the source of tioned, is a bitmask that means the same which operating system I want to use at the mount/ eject helper applets, but there thing as ugo=rwx (which would also the beginning of the booting process? may be a way to change the settings for force execute permissions for files that manually created icons. are not supposed to have them). Caution: There is no such thing as an “NTFS disk.” A hard disk Permissions Table 1: Options in chmod -R ugo=rwX is independent of the operating One of the frustra- system and can be partitioned into -R (capital R) means “recursive” (i.e., not only the tions I have in directory, but also everything inside). smaller parts that can be used by various Linux is folder ugo Change the settings for: user (file creator), group operating systems with their individual and file permissions. (every file/ dir has one), all others (who are neither filesystems. How do I give a com- user or group) Although Linux can read and write to mand so that a folder and = Set only these permissions; remove all others. NTFS without problems using ntfs-3g, all that is underneath rwX Set read and write permission and set the NTFS is still not a good filesystem for it (folders and files) are “executable” flag for directories, which is necessary hosting a Linux operating system be- in order to access their content. completely open? cause it simply does not support all of MAY 2008 ISSUE 90 61 060-062_ask-klaus.indd 61 12.03.2008 14:31:45 Uhr KNOW-HOW Ask Klaus! the features and file types that Linux 10.1.1.1 to configure, or the programs If your network card is eth0, you needs. The steps for creating a new can’t reach home to finish updates. would set an IP address for the card ei- partition for Linux – or better, two new Both computers use Firefox and Thun- ther via a graphical configuration front partitions, are: derbird, the same as Windows, using the end of your Linux distribution – use 1. Run an NTFS defragmentation on same asdl modem. As I said, all was DHCP with pump -i eth0 or dhclient eth0 Windows. This should put all files at working well and suddenly stopped.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages3 Page
-
File Size-