Mount up Mount Up

Mount up Mount Up

Command Line: mount & fstab LINUXUSER www.sxc.hu Media access with mount and fstab This month we look at tools for mounting and unmounting stor- MOUNTMOUNT UPUP age media. BY HEIKE JURZIK he penguin does not use Win- structure of the storage medium: for ex- The utility for command line based dows-style drive letters – instead, ample, the first primary partition on an mounting is titled mount; besides a TLinux attaches media directly to IDE master hard disk attached to the first number of optional parameters, you the directory tree in a process known as controller is referred to as hda1, the sec- have to specify the device file and the mounting, which is performed either at ond partition is then hda2, etc. Logical mountpoint. If you call mount without boot time or using manual commands. partition numbers start at 5. The second supplying any parameters, the command There’s a place for everything in the logical partition on hdc thus maps to the tells you which media are currently Linux filesystem tree; device files for device file /dev/hdc6. mounted: devices of all kinds, such as network The system enumerates SCSI CD/ DVD devices, removable media, or hard disk drives in the same way (scd0, scd1, etc.), # mount partitions, can typically be found below along with floppy drives (fd0, fd1, etc.), /dev/hda10 on / type ext3 U the /dev (for “device”) directory. although it is quite common to not have (rw,errors=remount-ro) a floppy drive in a modern PC. /dev/hda5 on /boot U Name Game Many distributions use aliases such as type ext2 (rw) IDE device names (the names of hard /dev/cdrom or /dev/dvd that point to the /dev/hda13 on /home U disks, CD-ROM, or DVD drives) start actual device names for CD-ROM/ DVD type ext3 (rw) with hd (for “hard disk”); the letter that drives. /dev/hdd on /media/cdrom0 U then follows depends on the connector To support access to the various de- type iso9660 (ro,noexec,U and the order. Each controller provides vices and other filesystems, you need to nosuid,nodev,user=huhn) two connectors; the first connector is create a link between a device and a di- ... called the master and the second the rectory in the Linux filesystem tree: the slave. The device names are: hda (mas- device file is mounted to allow this to Besides the partition labels and the ter) and hdb (slave) for the devices at- happen. mountpoints, mount tells you about the tached to the first controller. Devices on filesystems for the devices, and it also the second controller are known as hdc Mounting lets you know the mount options that (master) and hdd (slave). Mounting either occurs at boot time, or are in place. The /dev/hda10 partition Linux handles SATA disks, USB mass manually at a later stage. Hard disk par- has been formatted with Ext3, for exam- storage devices, and Zip drives as if they titions are normally mounted at boot ple, and mounted as the root partition were SCSI devices; their device file time, whereas this is a manual process (at /); the IDE CD drive contains a me- names thus start with sd. SCSI CD and for CDs, DVDs, and other removable dium with the ISO9660 filesystem (the DVD drives are dubbed scd and floppy media. Mounting is often the domain of default filesystem for data CDs), and has disk drives are fd. the system administrator root – unless been mounted under /media/cdrom0. Besides the letters, many devices also the privilege is specifically given to users The listing also tells you that the hard have numbers that reflect the logical (see the Tabular – the “/ etc/ fstab” File). disk partitions are readable and writable WWW.LINUX - MAGAZINE.COM ISSUE 68 JULY 2006 87 LINUXUSER Command Line: mount & fstab for a medium mounted with read-write access, you need to supply two parame- ters when running the command, for example: mount -o remount,ro /media/usb This tells mount to remount the medium while at the same time disabling write access (ro). Figure 1: The fstab file provides information on hard disk partitions as well as removable The mount command has a practical media. parameter that allows you to mount ISO images. To mount a 1:1 copy of a disk (rw for “read-write”). The following Linux typically auto-detects the file- prior to burning on CD/ DVD for test pur- option system type for a medium. If you get an poses, enter the following: error message instead, you can give errors=remount-ro Linux a hand and explicitly specify the mount -o loop file.iso U filesystem by supplying a value for the -t /media/tmp ensures that the medium will be re- parameter, for example, mounted read-only in case of a system This tells Linux to use a loop device error; that is, the data will still be read- mount -t vfat /dev/sdd U to access the image just like a genuine able, but not have writable access. /media/usb device. Mounting Removable Media for an older Windows filesystem on a Tabular – the “/ etc/ fstab” Data CDs/ DVDs, floppy disks and USB FAT-formatted medium. Besides vfat (for File media are normally mounted manually, the DOS/ Windows filesystem), the sup- As mentioned previously, Linux mounts unless you have an automounter to han- ported values are ext2 (Extended Filesys- some filesystems directly at boot time. dle the task. Linux assigns directories tem, Version 2), ext3 (Extended Filesys- The /etc/fstab file has entries for the file- below /mnt or /media for removable tem, Version 3), reiserfs (Reiser Filesys- systems to mount. Besides the full set of media. In the command line, you need tem), iso9660 (ISO9660), ntfs (NT File- hard disk partitions, this file contains to type the device file name and the system), etc., to name just a few. definitions for various removable media mountpoint. If you are mounting a USB Most systems define the device names (Figure 1). mass storage device, it makes sense to and mountpoints for CDs/ DVDs and The first column has the device files, check the /var/log/messages logfile to floppies (see the Tabular – the “/ etc/ whereas the second provides the mount- see if the device has been correctly de- fstab” File box), and this means that a points. The other entries specify the file- tected, and to discover the device file- command such as system for the media (the kernel nor- name (see the box titled “Kernel Mes- mally auto-detects this – auto ), and var- sages for USB Sticks”). mount /media/cdrom ious mount options. To mount the device detected here, Besides the parameters referred to sdd, in an existing directory, /media/usb, may be all it takes to mount a CD. earlier on, ro and rw, you will often type the following: see entries such as user (the device can Critical Mount Options be mounted without root privileges), mount /dev/sdd /media/usb The mount program has a number of in- nouser (the opposite), auto (the filesys- teresting parameters. The -o ro option tem is mounted at boot time), noauto, You do not need to specify the partition, makes a device “read-only”; it’s counter- exec (programs on this medium are exe- as the USB stick in our example is not part is -o rw (for “read-write”), and also cutable), or noexec. As Figure 1 shows, partitioned – you would need to specify the default setting. Combinations are the CD-ROM, DVD, and floppy drives in /dev/sdd1 for a formatted stick. also supported: to remove write access our example are not mounted at boot time (noauto), and any user can mount Kernel Messages for USB Sticks these media manually (user). As the ap- propriate mountpoints (e.g., /media/ 01 Mar 31 19:05:14 transpluto kernel: Attached scsi removable disk U cdrom0, /media/floppy0), are defined, a sdd at scsi0, channel 0, id 0, lun 3 user can just type 02 Mar 31 19:05:14 transpluto usb.agent[4316]: usb-storage: U loaded successfully mount /media/cdrom0 03 Mar 31 19:05:14 transpluto kernel: usbcore: registered new U driver usb-storage to mount a CD. 04 Mar 31 19:05:14 transpluto kernel: USB Mass Storage support As Windows filesystems do not sup- registered. port file owners or groups, you can spec- 88 ISSUE 68 JULY 2006 WWW.LINUX - MAGAZINE.COM Command Line: mount & fstab LINUXUSER ify a default owner (uid=) and/ or group There is an additional safety mecha- The ps tool can give information on the (gid=) for directories on partitions of nism that comes in handy: umount will process number (PID in the listing). Your this type. Additionally, the umask entry not unmount a filesystem while a pro- best approach is to output a long list of in our example assigns default access cess is accessing the files: all processes in wide display mode, pipe privileges. To modify the /etc/fstab file, the output to the grep tool, and search become root, and open the file in your umount: /media/cdrom0: U the output for the process ID: favorite text editor. device is busy # ps auxwww | grep 4466 Out! A program might be using the data on huhn 4466 0.0 2.4 27972 U The command for unmounting filesys- the CD in the drive, or the data might be 12572 ? S 11:33 0:00 U tems is umount. Although Linux auto- part of the working directory used by the kdeinit: kio_audiocd audiocd U matically dismounts all mounted media Shelll or a file manager, /media/cdrom0 /tmp/ksocket-huhn/klauncherzU when you shutdown your computer, (or one of its subdirectories).

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    3 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us