Archive for September, 2007

163Chapter 4Learning Basic Administration6.To create a new partition, (Email web hosting)

Sunday, September 30th, 2007

163Chapter 4Learning Basic Administration6.To create a new partition, type the following: n7.Choose an extended (e) or primary partition (p). To choose a primary parti- tion, type the following: p8.Type in the partition number. If you are creating the first partition (or for onlyone partition), type the number one: 1Enter the first cylinder number (1 is the default). A range of cylinder numbersis displayed (for example, 1-4865 is the number of cylinders that appears formy 40GB hard drive). 9.To assign the new partition to begin at the first cylinder on the new hard disk, type the number 1.10.Enter the last cylinder number. If you are using the entire hard disk, use thelast cylinder number shown. Otherwise, choose the ending cylinder numberor indicate how many megabytes the partition should have. 11.To create more partitions on the hard disk, repeat steps 6 through 10 for eachpartition. 12.Type wto write changes to the hard disk and exit from the fdiskcommand. At this point, you should be back at the shell. 13.To create a file system on the new disk partition, use the mkfscommand. Bydefault, this command creates an ext2 file system, which is usable by Linux. However, in most cases you will want to use a journaling file system (such asext3 or reiserfs). To create an ext3 file system on the first partition of the sec- ond hard disk, type the following: # mkfs -t ext3 /dev/hdb1If you created multiple partitions, repeat this step for each partition (such as/dev/hdb2, /dev/hdb3, and so on). If you don t use -t ext3, an ext2 file system is created by default. Use other com- mands, or options to this command, to create other file system types. For example, use mkfs.vfatto create a VFAT file system, mkfs.msdosfor DOS, or mkfs. reiserfsfor Reiser file system type. The tune2fscommand, described later inthis section, can be used to change an ext2 file system to an ext3 file system. 14.After the file system is created, you can have the partition permanentlymounted by editing the /etc/fstaband adding the new partition. Here isanexample of a line you might add to that file: /dev/hdb1 /abc ext3 defaults 1 1Tip10_

Web site developers - 162Part IIRunning the ShowAdding a Hard DiskAdding a

Sunday, September 30th, 2007

162Part IIRunning the ShowAdding a Hard DiskAdding a new hard disk to your computer so that it can be used by Linux requires acombination of steps described in previous sections. Here s the general procedure: 1.Install the new hard disk hardware. 2.Identify the partitions on the new disk. 3.Create the file systems on the new disk. 4.Mount the file systems. The easiest way to add a hard disk to Linux is to have the entire disk devoted to asingle Linux partition. You can have multiple partitions, however, and assign themeach to different types of file systems and different mount points, if you like. Thefollowing process takes you through adding a hard disk containing a single Linuxpartition. Along the way, it also notes which steps you need to repeat to have multi- ple file systems with multiple mount points. This procedure assumes that Linux is already installed and working on the com- puter. If this is not the case, follow the instructions for adding a hard disk on yourcurrent operating system. Later, when you install Linux, you can identify this diskwhen you are asked to partition your hard disk(s). 1.Follow the manufacturer s instructions for physically installing and connect- ing the new hard disk in your computer. If, presumably, this is a second harddisk, you may need to change jumpers on the hard disk unit itself to have itoperate as a slave hard disk (if it s on the same cable as your first hard disk). You may also need to change the BIOS settings. 2.Boot your computer to Linux. 3.Determine the device name for the hard disk. As root user from a shell, type: # dmesg | less4.From the output, look for an indication that the new disk was found. For exam- ple, if it s a second IDE hard disk, you should see hdb:in the output. For a second SCSI drive, you d see sdb:instead. Be sure you identify the correctdisk, or you will erase all the data from disks you probably want to keep! 5.Use the fdiskcommand to create partitions on the new disk. For example, ifyou are formatting the second IDE disk (hdb), you could type the following: # fdisk /dev/hdb1Now you are in fdiskcommand mode, where you can use the fdisksingle- letter command set to work with your partitions. If the disk had existing partitions on it, you can change or delete those partitions now. Or, you cansimply reformat the whole disk to blow everything away. Use pto view all partitions and dto delete a partition. Note10_

161Chapter 4Learning Basic AdministrationAn alternative for (Windows 2003 server web) unmounting a

Saturday, September 29th, 2007

161Chapter 4Learning Basic AdministrationAn alternative for unmounting a busy device is the -loption. With umount -l(alazyunmount), the unmount happens as soon as the device is no longer busy. Tounmounta remote NFS file system that s no longer available (for example, the server wentdown), you can use the umount -foption to forcibly unmount the NFS file system. A really useful tool for discovering what s holding open a device you want tounmount is the lsofcommand. Type lsofwith the name of the partition you wantto unmount (such as lsof /mnt/floppy). The output shows you what com- mands are holding open files on that partition. Using the mkfs Command to Create a File SystemYou can create a file system for any supported file system type on a disk or partitionthat you choose. You do so with the mkfscommand. While this is most useful forcreating file systems on hard-disk partitions, you can create file systems on floppydisks or re-writable CDs as well. Here is an example of using mkfsto create a file system on a floppy disk: # mkfs -t ext3 /dev/fd0mke2fs 1.34, (25-Jul-2003) Filesystem label= OS type: LinuxBlock size=1024 (log=0) Fragment size=1024 (log=0) 184 inodes, 1440 blocks72 blocks (5.00%) reserved for the super userFirst data block=11 block group8192 blocks per group, 8192 fragments per group184 inodes per groupWriting inode tables: doneFilesystem too small for a journalWriting superblocks and filesystem accounting information: doneThe filesystem will be automatically checked every 32 mounts or180 days, whichever comes first. Use tune2fs -c or -i tooverride. You can see the statistics that are output with the formatting done by the mkfscommand. The number of inodes and blocks created are output, as are the numberof blocks per group and fragments per group. You could now mount this file system(mount /mnt/floppy), change to it as your current directory (cd /mnt/floppy), and create files on it as you please. Tip10_

160Part IIRunning the ShowMounting a Disk Image in (X web hosting)

Friday, September 28th, 2007

160Part IIRunning the ShowMounting a Disk Image in LoopbackAnother valuable way to use the mountcommand has to do with disk images. If youdownload a CD or floppy disk image from the Internet and you want to see what itcontains, you can do so without burning it to CD or floppy. With the image on yourhard disk, create a mount point and use the -o loopoption to mount it locally. Here s an example: # mkdir /mnt/mycdimage# mount -o loop whatever-i386-disc1.iso /mnt/mycdimageIn this example, the /mnt/mycdimage directory is created, and then the disk imagefile (whatever-i386-disc1.iso) residing in the current directory is mounted onit. I can now cdto that directory, view the contents of it, and copy or use any of itscontents. This is useful for downloaded CD images from which you want to installsoftware without having to burn the image to CD. When you are done, just typeumount /mnt/cdimageto unmount it. Other options to mountare available only for specific file system types. See themountmanual page for those and other useful options. Using the umount Command When you are done using a temporary file system, or you want to unmount a per- manent file system temporarily, use the umountcommand. This command detachesthe file system from its mount point in your Linux file system. To use umount, youcan give it either a directory name or a device name. For example: # umount /mnt/floppyThis unmounts the device (probably /dev/fd0) from the mount point/mnt/floppy. You can also unmount using the form# umount /dev/fd0In general, it s better to use the directory name (/mnt/floppy) because the umountcommand will fail if the device is mounted in more than one location. (Device namesall begin with /dev.) If you get the message device is busy, the umountrequest has failed. The reasonis that either a process has a file open on the device or that you have a shell openwith a directory on the device as a current directory. Stop the processes or changeto a directory outside the device you are trying to unmount for the umountrequestto succeed.

159Chapter 4Learning Basic AdministrationBy default, your CD-ROM is (Tomcat web server)

Friday, September 28th, 2007

159Chapter 4Learning Basic AdministrationBy default, your CD-ROM is mounted on the /mnt/cdromdirectory. (The filesystem type, device name, and other options are filled in automatically.) To seethe contents, type cd /mnt/cdrom,and then type ls. Files from the CD-ROM sroot directory will be displayed. .Floppy Disk If you want to mount a floppy in the Linux ext3 file system for- mat (ext3), or in some cases a format that can be autodetected, mount thatfloppy disk by inserting it in your floppy drive and typing the following: # mount /mnt/floppyThe file system type (ext3), device (/dev/fd0), and mount options are filled infrom the /etc/fstab file. You should be able to change to the floppy disk direc- tory (cd /mnt/floppy) and list the contents of the floppy s top directory (ls). In both of the these cases, you could give the device name (/dev/cdromor /dev/ fd0, respectively) instead of the mount point directory to get the same results. Of course, it is possible that you may get floppy disks you want to use that are in allformats. Someone may give you a floppy containing files from a Microsoft operatingsystem (in MS-DOS format). Or you may get a file from another UNIX system. Inthose cases, you can fill in your own options instead of relying on options from the/etc/fstabfile. In some cases, Linux autodetects that the floppy disk contains anMS-DOS (or Windows vfat) file system and mounts it properly without additionalarguments. If it doesn t, here s an example of how to mount a floppy containing MS-DOS files: # mount -t msdos /dev/fd0 /mnt/floppyThis shows the basic format of the mountcommand you would use to mount a floppydisk. You can change msdosto any other supported file system type (described earlier in this chapter) to mount a floppy of that type. Instead of using floppy driveA:(/dev/fd0), you could use drive B:(/dev/fd1) or any other accessible drive. Instead of mounting on /mnt/floppy, you could create any other directory andmount the floppy there. Here are some other useful options you could add to the mountcommand: .-t auto If you aren t sure exactly what type of file system is contained onthe floppy disk (or other medium you are mounting), use this option to indi- cate the file system type. The mountcommand will query the disk to try toascertain what type of file system it contains. .-r If you don t want to make changes to the mounted file system (or can tbecause it is a read-only medium), use this option to mount it read-only. .-w This mounts the file system with read/write permission. Note10_

Free web hosting with ftp - 158Part IIRunning the ShowIf you want to add

Thursday, September 27th, 2007

158Part IIRunning the ShowIf you want to add an additional local disk or partition, you can create an entry forit in the /etc/fstabfile. See Chapter 26 for information on mounting Samba, NFS, and other remount file systems from /etc/fstab. Using the mount Command to Mount File SystemsLinux systems automatically run mount -a(mount all file systems) each time youboot. For that reason, you generally use the mountcommand only for special situa- tions. In particular, the average user or administrator uses mountin two ways: .To display the disks, partitions, and remote file systems that are currentlymounted. .To temporarily mount a file system. Any user can type mount(with no options) to see what file systems are currentlymounted on the local Linux system. The following is an example of the mountcom- mand. It shows a single hard disk partition (/dev/hda1) containing the root (/) filesystem, and proc and devpts file system types mounted on /procand /dev, respec- tively. The last entry shows a floppy disk, formatted with a standard Linux file system(ext3) mounted on the /mnt/floppydirectory. $ mount/dev/hda3 on / type ext3 (rw) none on /proc type proc (rw) none on /sys type sysfs (rw) none on /dev/shm type tmpfs (rw) /dev/hda2 on /boot type ext3 (rw) none on /dev/pts type devpts (rw,gid=5,mode=0620) /dev/fd0 on /mnt/floppy type ext3 (rw) The most common devices to mount by hand are your floppy disk and your CD-ROM. However, depending on the type of desktop you are using, CD-ROMs and floppydisks may be mounted for you automatically when you insert them. (In some cases, the autorun program may also run automatically. For example, autorun may start aCD music player or software package installer to handle the data on the medium.) Mounting Removable MediaIf you want to mount a file system manually, the /etc/fstabfile helps make it simpleto mount a floppy disk or a CD-ROM. In some cases, you can use the mountcommandwith a single option to indicate what you want to mount, and information is taken fromthe /etc/fstabfile to fill in the other options. There are probably already entriesin your /etc/fstabfile to let you do these quick mounts in the following two cases: .CD-ROM If you are mounting a CD-ROM that is in the standard ISO 9960 for- mat (as most software CD-ROMs are), you can mount that CD-ROM by placingit in your CD-ROM drive and typing the following: # mount /mnt/cdrom10_

157Chapter 4Learning Basic AdministrationTo access my Windows partition, (Starting a web site)

Wednesday, September 26th, 2007

157Chapter 4Learning Basic AdministrationTo access my Windows partition, I must first create the mount point (by typingmkdir /mnt/win). Then I can mount it when I choose by typing (as root) mount/mnt/win. Different Linux distributions will set up their fstabfile differently. Some don t uselabels and many others don t use a separate /bootpartition by default. They willjust have a swap partition and have all user data under the root partition (/). Here is what s in each field of the fstabfile: .Field 1 The name of the device representing the file system. The word noneis often placed in this field for file systems (such as /procand /dev/pts) thatare not associated with special devices. This field can include the LABELoption, with which you can indicate a universally unique identifier (UUID) or volumelabel instead of a device name. The advantage to this approach is that becausethe partition is identified by volume name, you can move a volume to a differentdevice name and not have to change the fstabfile. .Field 2 The mount point in the file system. The file system contains all datafrom the mount point down the directory tree structure unless another filesystem is mounted at some point beneath it. .Field 3 The file system type. Valid file system types are described in the Supported File Systems section earlier in this chapter. .Field 4 Options to the mountcommand. In the preceding example, thenoautooption prevents the indicated file system from being mounted at boottime, and rosays to mount the file system read-only (which is reasonable fora CD-ROM drive). Commas must separate options. See the mountcommandmanual page (under the -ooption) for information on other supported options. Normally, only the root user is allowed to mount a file system using the mountcommand. However, to allow any user to mount a file system (such as a file systemon a floppy disk), you could add the useroption to Field 4 of /etc/fstab. InSUSE, read/write permissions are given to specific devices (such as disk or audiodevices) by specific groups (such as the disk or audio group) so that users assignedto those groups can mount or otherwise access those devices. Choose the Securityand Users selection in the YaST Control Center and look for Secondary Groups setfor New User Defaults to see how new users are assigned to groups. .Field 5 The number in this field indicates whether the indicated file systemneeds to be dumped (that is, have its data backed up). A 1means that the filesystem needs to be dumped, and a 2means that it doesn t. (I don t think thisfield is useful anymore because many Linux systems no longer include thedumpcommand. Most often, a 0is used.) .Field 6 The number in this field indicates whether the indicated file systemneeds to be checked with fsck: 1 means it needs to be checked, and 2 meansit doesn t. TipNote10_

156Part IIRunning the ShowTable 8-1(continued) TypeDescriptionnfsNetwork File System (Simple web server)

Wednesday, September 26th, 2007

156Part IIRunning the ShowTable 8-1(continued) TypeDescriptionnfsNetwork File System (NFS) type of file system. NFS is used to mount file systemson other Linux or UNIX computers. hpfsFile system is used to do read-only mounts of an OS/2 HPFS file system. ncpfsThis relates to Novell NetWare file systems. NetWare file systems can be mountedover a network. ntfsWindows NT file system. It is supported as a read-only file system (so that youcan mount and copy files from it). Read-write support is available but consideredunreliable (some say dangerous). affsFile system is used with Amiga computers. ufsFile system popular on Sun Microsystems operating systems (that is, Solaris andSunOS). Using the fstab File to Define Mountable File SystemsThe hard disks on your local computer and the remote file systems you use everyday are probably set up to automatically mount when you boot Linux. The definitionsfor which of these file systems are mounted are contained in the /etc/fstabfile. Here s an example of an /etc/fstabfile: LABEL=/ / ext3 defaults 1 1LABEL=/boot /boot ext3 defaults 1 2none /dev/pts devpts gid=5,mode=620 0 0none /dev/shm tmpfs defaults 0 0none /proc proc defaults 0 0/dev/hda5 swap swap defaults 0 0/dev/cdrom /mnt/cdrom udf,iso9660 noauto,owner,kudzu,ro 0 0/dev/hda1 /mnt/win vfat noauto 0 0/dev/fd0 /mnt/floppy auto noauto,owner 0 0All file systems listed in this file are mounted at boot time, except for those settonoautoin the fourth field. In this example, the root (/) and boot (/boot) harddisk partitions are mounted at boot time, along with the /dev/pts, /dev/shm, and/procfile systems (which are not associated with particular devices). The CD-ROM(/dev/cdrom) and floppy disk (/dev/fd0) drives are not mounted at boot time. Definitions are put in the fstabfile for floppy and CD-ROM drives so that they canbe mounted in the future (as described later). I also added one line for /dev/hda1, which enables me to mount the Windows (vfat) partition on my computer so I don t have to always boot Windows to get at the fileson my Windows partition.

155Chapter 4Learning Basic AdministrationTable 4-4Supported File System TypesTypeDescriptionadfsAcorn (Business web hosting)

Tuesday, September 25th, 2007

155Chapter 4Learning Basic AdministrationTable 4-4Supported File System TypesTypeDescriptionadfsAcorn disk file system, which is the standard file system used on RiscOS operatingsystems. befsFile system used by the BeOS operating system. cifsCommon Internet File System (CIFS), the virtual file system used to access serversthat comply with the SNIA CIFS specification. CIFS is an attempt to refine andstandardize the SMB protocol used by Samba and Windows file sharing. ext3Ext file systems are the most common in Red Hat and many other Linux systems. The ext3 file system, also called the Third Extended file system, includes journalingfeatures that, compared to ext2, improve a file system s capability to recover fromcrashes. ext2The default file system type for earlier Linux systems. Features are the same asext3, except that ext2 doesn t include journaling features. extThis is the first version of ext3. It is not used very often anymore. iso9660Evolved from the High Sierra file system (the original standard for CD-ROMs). Exten- sions to the High Sierra standard (called Rock Ridge extensions) allow iso9660 filesystems to support long filenames and UNIX-style information (such as file per- missions, ownership, and links). Data CD-ROMs typically use this file system type. kafsAFS client file system. Used in distributed computing environments to share fileswith Linux, Windows, and Macintosh clients. minixMinix file system type, used originally with the Minix version of UNIX. It supportsfilenames of up to only 30 characters. msdosAn MS-DOS file system. You can use this type to mount floppy disks that comefrom Microsoft operating systems. vfatMicrosoft extended FAT (VFAT) file system. umsdosAn MS-DOS file system with extensions to allow features that are similar to UNIX(including long filenames). procNot a real file system, but rather a file-system interface to the Linux kernel. Youprobably won t do anything special to set up a proc file system. However, the/procmount point should be a proc file system. Many utilities rely on /proctogain access to Linux kernel information. reiserfsReiserFS journaled file system. ReiserFS and ext3 are the most common filesystem types used with Linux today. swapUsed for swap partitions. Swap areas are used to hold data temporarily whenRAM is currently used up. Data is swapped to the swap area and then returned toRAM when it is needed again. Continued10_

152Part IIRunning the ShowFile systems are organized differently (Free web design)

Wednesday, September 19th, 2007

152Part IIRunning the ShowFile systems are organized differently in Linux than they are in Microsoft Windowsoperating systems. Instead of drive letters (for example, A:, B:, C:) for each localdisk, network file system, CD-ROM, or other type of storage medium, everything fitsneatly into the directory structure. It is up to an administrator to create a mountpoint in the file system and then connect the disk to that point in the file system. The organization of your file system begins when you install Linux. Part of the instal- lation process is to divide your hard disk (or disks) into partitions. Those partitionscan then be assigned to: .A part of the Linux file system .Swap space for Linux, or .Other file system types (perhaps containing other bootable operating systems) This chapter focuses on partitions that are used for the Linux file system. To seewhat partitions are currently set up on your hard disk, use the fdiskcommand: # fdisk lDisk /dev/hda: 40.0 GB, 40020664320 bytes255 heads, 63 sectors/track, 4825 cylindersUnits = cylinders of 16065 * 512 bytes = 8225280 bytesDevice Boot Start End Blocks Id System/dev/hda1 * 1 13 104 b Win95 FAT32/dev/hda2 84 89 48195 83 Linux/dev/hda3 90 522 3478072+ 83 Linux/dev/hda4 523 554 257040 5 Extended/dev/hda5 523 554 257008+ 82 Linux swapThis output shows the disk partitioning for a computer capable of running bothLinux and Microsoft Windows. You can see that the Linux partition on /dev/hda3has most of the space available for data. There is a Windows partition (/dev/hda1) and a Linux swap partition (/dev/hda5). There is also a small /bootpartition(46MB) on /dev/hda2. In this case, the root partition for Linux has 3.3GB of diskspace and resides on /dev/hda3. Next use the mountcommand (with no options) to see what partitions are actuallybeing used for your Linux system (which available disk partitions are actuallymounted and where they are mounted): # mount/dev/hda3 on / type ext3 (rw) /dev/hda2 on /boot type ext3 (rw) /dev/hda1 on /mnt/win type vfat (rw) none on /proc type proc (rw) none on /sys type sysfs (rw) none on /dev/pts type devpts (rw,gid=5,mode=620)