Difference between revisions of "Device"

From Linuxintro
imported>ThorstenStaerk
imported>ThorstenStaerk
 
Line 2: Line 2:
  
 
= Types =
 
= Types =
 +
== Block devices ==
 +
Main article: [[block devices]]
  
== Block devices ==
+
A block device is a device organized in blocks, typically a [[hard disk]] or [[CD]]. It differs from a character device by the possibility of seeking forward and backward. Hard disks typically have a device file like /dev/sda or /dev/sdb.
  
 
== Character devices ==
 
== Character devices ==
Line 9: Line 11:
  
 
== Network devices ==
 
== Network devices ==
 +
A network device like your network card does not have a representation in the /dev folder.
  
 
= What to do with a device =
 
= What to do with a device =
 
 
== format ==
 
== format ==
 +
Formatting means making a file system on a disk erasing all data. You can make different file systems under Linux, one of the most prominent ones being ext4. To make this, in this example on ''/dev/sdx1'', [[open a console]] and enter
 +
mkfs.ext4 ''/dev/sdx1''
  
 
== mount ==
 
== mount ==
 +
A hard disk with a file system on it can be mounted like this:
 +
mount ''/dev/sdx1'' /mnt
 +
This will use the partition /dev/sdx1 and mount it to /mnt

Latest revision as of 14:03, 8 January 2012

A device is a hardware component with a distinct purpose. For example your mouse, keyboard and monitor are devices. Under Linux, devices are assigned a special file and listed under /dev.

Types

Block devices

Main article: block devices

A block device is a device organized in blocks, typically a hard disk or CD. It differs from a character device by the possibility of seeking forward and backward. Hard disks typically have a device file like /dev/sda or /dev/sdb.

Character devices

A character device is a device that delivers characters, but you cannot seek on. Examples include the keyboard and /dev/random.

Network devices

A network device like your network card does not have a representation in the /dev folder.

What to do with a device

format

Formatting means making a file system on a disk erasing all data. You can make different file systems under Linux, one of the most prominent ones being ext4. To make this, in this example on /dev/sdx1, open a console and enter

mkfs.ext4 /dev/sdx1

mount

A hard disk with a file system on it can be mounted like this:

mount /dev/sdx1 /mnt

This will use the partition /dev/sdx1 and mount it to /mnt