Published Book on Amazon
|All of IOT Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 1|
|All of IOT Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 2|
출판된 한글판 도서
|최신 라즈베리파이(Raspberry Pi)로 시작하는 사물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (상)|
|최신 라즈베리파이(Raspberry Pi)로 시작하는 사물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (하)|
Original Book Contents
The block device inputs and outputs data in unit of block when processing data in the device, and increases the processing performance by placing a intermediate buffer.
The "/dev" file is created with "mknod" command. Once created, it is maintained regardless of the existence of the actual device. Therefore, even if the device does not actually exist, the "/dev" file may be created. Linux can open, read, and write these block devices using standard system functions as if it were a single file in other programs.
A typical device of a block device is a hard disk. At present, there are IDE (Integrated Disk Electronics) type and SCSI (Small Computer System Interface) type for disks that are widely used in Linux.
USB flash memory is also a disk of block device type, usually a disk of SCSI type.
188.8.131.52 Naming Rules for Disk Device
In Linux, when the disk device is installed, it has a name with a certain rule as follows.
■ Disk -- Disk type + disk number
■ Partition -- Disk type + disk number + partition number
All disks installed on the system are connected to the "/dev" directory as one file.
● Disk type
The following code is given according to the disk type:
■ IDE type disk -- hd
■ SCSI type disk -- sd
■ Virtual type disk -- vd
■ SD card -- mmcblk
● Disk number
The disk numbers are assigned according to the installation order by the same disk type. A disk with the disk number only and without the partition number refers to the specific entire disk unit. This name should be used to refer to the entire disk device:
■ Hard disk -- Name is given in the order of a, b, c ..
■ SD card -- Name is given in the order of 0, 1, 2 ...
The following is an example of a device:
sda -- SCSI type - disk a - whole
sda -- SCSI type - disk a - whole
mmcblk0 -- SD card type - disk 0 - whole
● Partition number
When a partition is divided from a specific disk number, a name is given to each device in order. You must use this name when specifying a particular partition:
■ Hard disk -- Name is given in the order of 1, 2, 3 ..
■ SD card -- Name is given in the order of p1, p2, p3 ...
The following is an example of partitioning by device:
/dev/hda1 -- IDE type - disk a - partitioning 1
/dev/sdb2 -- SCSI type - disk b - partitioning 2
/dev/ mmcblk0p1 -- SD card type - disk 0 - partitioning 1
● /dev registeration file
In "/dev" directory, the disk itself is also registered as a file, and the partition is also registered as a single file. The disk without a partition number means the disk itself.
The following is an example of a device file name registered to "/dev" directory for disk:
/dev/hdb -- IDE type - disk b - whole
/dev/hdb1 -- IDE type - disk b - partition 1
/dev/hdb2 -- IDE type - disk b - partition 2
/dev/sda -- SCSI type - disk a - whole
/dev/sda1 -- SCSI type - disk a - partition 1
/dev/sda2 -- SCSI type - disk a - partition 2
/dev/mmcblk0 -- SD card type - disk 0 - whole
/dev/mmcblk0p1 -- SD card type - disk 0 – partition 1
/dev/mmcblk0p2 -- SD card type - disk 0 – partition 2
/dev/mmcblk0p3 -- SD card type - disk 0 – partition 3
The command to use to check information about the block device in the system is the "blkid".
blkid [ options ] device
■ This shows various informations about the block devices in the system.
■ User privilege -- Super user.
■ This command can search block devices in the system or check the attributes of block devices. This command displays the filesystem information, such as type, LABEL, and UUID for the block device
■ This command shows only the block devices actually installed. Therefore, even if it is defined in "/dev" directory, it is not displayed if it does not actually exist.
Display a usage message and exit.
Look up only one device that matches the search parameter specified with -t.
Search for block devices with tokens named NAME that have the value, and display any devices which are found. Common values for NAME include TYPE, LABEL, and UUID. If there are no devices specified on the Shell, all block devices will be searched; otherwise only the specified devices are searched.
Look up the device that uses this label (equal to: -l -o device -t LABEL= <label>). This lookup method is able to reliably use /dev/disk/by-label udev symlinks (dependent on a setting in /etc/blkid.conf). Avoid using the symlinks directly; it isnot reliable to use the symlinks without verification. The -L option works on systems with and without udev.
The following is an example of executing the command with SD card and USB flash memory installed.
pi@raspberrypi ~ $ sudo blkid
/dev/mmcblk0p1: LABEL="RECOVERY" UUID="5019-0CBC" TYPE="vfat"
/dev/mmcblk0p3: LABEL="SETTINGS" UUID="fbc9f2d1-837b-4b3b-8efc-62e04052534a" TYPE="ext4"
/dev/mmcblk0p5: LABEL="boot0" UUID="0501-A21E" TYPE="vfat"
/dev/mmcblk0p6: LABEL="root" UUID="6f5f8ed3-8603-4468-969b-964be078e131" TYPE="ext4"
/dev/mmcblk0p7: LABEL="boot" UUID="5E6B-94DB" TYPE="vfat"
/dev/mmcblk0p8: LABEL="root0" UUID="6af8520e-9e0b-4197-a848-b5fec5d09136" TYPE="ext4"
/dev/sda1: LABEL="REAL USB" UUID="FEF225C2F2257FCF" TYPE="ntfs"