LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-05-2009, 07:10 AM   #1
thetiger2003
LQ Newbie
 
Registered: Apr 2009
Posts: 23

Rep: Reputation: 0
how to access the cdRom or any usb device by shell


how to access the cdRom or any usb device by shell without using the gui
 
Old 05-05-2009, 07:21 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Hi,

In short:

1) mount device
2) cd to mountpoint
3) do your thing
4) cd to other dir
5) umount device

Some distro's come with auto mounting, which means that the cdrom/usb device will be mounted the moment you insert them.

If that is not the case:

1) find out which device needs to be mounted (/dev/sr0 could be your cdrom player. /dev/sdb1 /dev/sdc2 could be your usb device),
2) mount device with proper options: mount -t vfat /dev/sdc1 /mnt/usb (mount point [/mnt/usb in this example] must already exist.
-t vfat is just an example (mount a usb device that holds a dos fs). See manpage for details.
Check your /etc/fstab to see if some of the devices (/dev/sdX, /dev/srX) are already present. If so, you can use a shortcut: mount /dev/sdcX (no extra options needed).

Unmounting is simpler: umount /dev/sdX (that is umount not unmount!)

Hope this helps.
 
Old 05-05-2009, 07:22 AM   #3
linus72
LQ Guru
 
Registered: Jan 2009
Location: Gordonsville-AKA Mayberry-Virginia
Distribution: PocketWriter/MinimalX
Posts: 5,087

Rep: Reputation: 337Reputation: 337Reputation: 337Reputation: 337
There are probably alot of ways....

You could use "mount", "df -h", "fdisk -l"(as sudo), and I'm sure more knowledgeable people here than me can tell you.

Welcome to LQ!

Please post your hardware specs and what you're trying to accomplish?
Include as much info as you can...
 
Old 05-05-2009, 07:24 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
First you have to mount the device, if the system doesn't mount it automatically. Insert the cd or the usb device, wait for some seconds, then use the command mount without arguments to check if the device is already mounted or not:
Code:
# mount
...
...
/dev/sda1 on /media/USB DISK type vfat (rw,noexec,nosuid,nodev,shortname=winnt,uid=502)
this example shows a usb device mounted in "/media/USB DISK". So you can check the mount point and access it as usual. The same for a CD/DVD. If you have to mount it manually you can check the output of fdisk -l, look for the device name and the filesystem type, then mount it using an existing directory a mount point (for example /mnt).
Code:
# fdisk -l
...
...
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         250     2007008+   6  FAT16
# mount /dev/sda1 /mnt
# cd /mnt
If you insert a CD in most cases it is mounted automatically. If not, you can use /dev/cdrom as device, since it exists on all system and usually is a link to a physical device (in this case you don't see the CD device using fdisk -l):
Code:
# mount /dev/cdrom /mnt
# cd /mnt
When you've finished, unmount the device using the umount command giving either the mount point or the device name as argument.
Hope this helps.

Last edited by colucix; 05-05-2009 at 07:27 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Best way to Access Raw sectors of a USB device Karbon Linux - Newbie 1 02-07-2009 05:39 PM
usb cdrom gives no block device Drake57 Linux - Hardware 1 11-21-2007 09:21 AM
"USB device stops working after a time" 'fix' stops cdrom device mount/readability adamben Slackware 6 04-18-2007 02:18 PM
usb mouse and cdrom access problem lestoil Slackware 7 06-16-2005 11:58 PM


All times are GMT -5. The time now is 06:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration