Mounting and Unmounting Removable Disks
You need to know how to insert and remove removable disks, such as floppies, CDs, or USB storage devices.
Use the mount and umount commands.
This example mounts a CD drive:
# mount -r -t iso9660 /dev/scd0 /cdrom
-r means read-only; -t iso9660 is the filesystem type. /dev/scd0 is the name the kernel assigns to the device. /cdrom is the directory in which it is mounted. The /cdrom directory must already be present before you try to mount the disk.
To find the filesystem type, use the file command:
$ file - < /dev/scd0
/dev/stdin: ISO 9660 CD-ROM filesystem data 'Data1
You can omit the -r (read-only) flag when mounting a CD-ROM. It will complain, but it'll mount the disk anyway:
# mount -t iso9660 /dev/scd0 /cdrom
mount: block device /dev/scd0 is write-protected, mounting read-only
This mounts a floppy disk readable/writable:
# mount -w /dev/fd0 /floppy
The following command mounts a USB storage device. The noatime option should be used on rewritable media that have a limited number of rewrites, such as CD/DVD-RW and flash storage devices:
# mount -w -o noatime /dev/sda1 /memstick
To unmount the device, use:
# umount /memstick
You may get a response like:
# umount /memstick
umount: /memstick: device is busy
This means something (an application, a shell, or a file manager) is reading the filesystem. You can find out what with lsof (list open files):
$ lsof /memstick
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
gs 938 dawnm 128r DIR 2,0 1024 12 /memstick/may-04.pdf
bash 938 dawnm 129r DIR 2,0 1024 24 /memstick
Now you can either close out the applications, or kill the lot with a single command:
# kill -9 `lsof -t /memstick`
mount can only be run by root. To give non-root users permission to mount removeable disks, you'll need to edit /etc/fstab (see the next recipe).
You need to know how to insert and remove removable disks, such as floppies, CDs, or USB storage devices.
Use the mount and umount commands.
This example mounts a CD drive:
# mount -r -t iso9660 /dev/scd0 /cdrom
-r means read-only; -t iso9660 is the filesystem type. /dev/scd0 is the name the kernel assigns to the device. /cdrom is the directory in which it is mounted. The /cdrom directory must already be present before you try to mount the disk.
To find the filesystem type, use the file command:
$ file - < /dev/scd0
/dev/stdin: ISO 9660 CD-ROM filesystem data 'Data1
You can omit the -r (read-only) flag when mounting a CD-ROM. It will complain, but it'll mount the disk anyway:
# mount -t iso9660 /dev/scd0 /cdrom
mount: block device /dev/scd0 is write-protected, mounting read-only
This mounts a floppy disk readable/writable:
# mount -w /dev/fd0 /floppy
The following command mounts a USB storage device. The noatime option should be used on rewritable media that have a limited number of rewrites, such as CD/DVD-RW and flash storage devices:
# mount -w -o noatime /dev/sda1 /memstick
To unmount the device, use:
# umount /memstick
You may get a response like:
# umount /memstick
umount: /memstick: device is busy
This means something (an application, a shell, or a file manager) is reading the filesystem. You can find out what with lsof (list open files):
$ lsof /memstick
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
gs 938 dawnm 128r DIR 2,0 1024 12 /memstick/may-04.pdf
bash 938 dawnm 129r DIR 2,0 1024 24 /memstick
Now you can either close out the applications, or kill the lot with a single command:
# kill -9 `lsof -t /memstick`
mount can only be run by root. To give non-root users permission to mount removeable disks, you'll need to edit /etc/fstab (see the next recipe).
0 Comments