Linux raw is a raw data format, which means "naked device" in Linux, also called naked partition and raw partition; linux raw is a data format that has not been formatted and cannot be read by Unix/Linux through the file system. The special character device obtained; the raw device can be bound to a partition or a disk.
#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.
What is the format of linux raw?
Original data format.
Linux raw device detailed explanation
Naked device overview
Bare device: also called raw partition (raw partition), it is a type that has not been formatted , a special character device that is not read by Unix/Linux through the file system. A raw device can be bound to a partition or a disk.
Character device: Reading and writing character devices do not need to go through the OS buffer. It cannot be mounted by the file system.
Block device: Reading and writing to the block device need to go through the OS buffer, which can be mounted to the file system.
This is related to the Linux version. In the old version, there can only be a maximum of 256 bare devices. Under Linux 4, you can bind 81Array2 bare devices. However, under Linux, there can only be a maximum of 255 partitions. Therefore, if you use a raw device to bind a partition, you can only bind a maximum of 255 raw devices. If you are using lvm, there is no such restriction.
A single disk can have up to 15 partitions under Linux. 3 primary partitions, 1 extended partition and 11 logical partitions.
The recommended partitioning method is: first divide into 3 primary partitions, the fourth partition is an extended partition, and then divide the extended partition into 11 logical partitions.
Note that raw devices should not be bound to extended partitions.
If you need to use bare devices under Linux, you need to bind them manually, but not under Unix.
Because every block device in Unix has a corresponding character device for unbuffered I/O, this is its corresponding raw device. Rawio in Linux implements a set of unbound (unbound) raw devices /dev/rawN or /dev/raw/rawN and a control device /dev/rawct to bind them to block devices. So when you need to use a raw device, you need to match it with a real block device. This step actually completes the automatic mapping of a non-cached character device in Unix.
major and minor device number
In unix/linux systems, everything is a file. All hard disks, floppy disks, keyboards and other devices are represented by files, corresponding to files under /dev. For applications, these device files can be opened, closed, read and written like ordinary files. However, such file names, such as /dev/sda and /dev/raw/raw1, are all user space names, and the OS Kernel does not know what this name refers to. In the kernel space, devices are distinguished by major and minor device numbers.
major device number can be regarded as a device driver. Devices managed by the same device driver have the same major device number. This number is actually the index of the device driver table in Kernel, which stores different devices. driver. The minor device number is used to represent the specific device being accessed. That is to say, Kernel finds the device driver based on the major device number, and then obtains the device location and other attributes from the minor device number. All these major device numbers are pre-allocated. Details can be viewed at http://www.lanana.org/docs/device-list/devices-2.6.txt.
For example, the raw device is 162 and the scsi block device is 8
/etc/udev/rules.d/60-raw.rules
The configuration of the raw device on the Redhat platform has changed after redhat 5. Before redhat 5, the /etc/sysconfig/rawdevices file was directly configured and the startup and shutdown of raw devices were managed through /etc/init.d/rawdevices. After Redhat 5, the original raw device interface has been cancelled, and redhat 5 is configured through udev rules. To configure, you need to edit the file /etc/udev/rules.d/60-raw.rules.
cat /etc/udev/rules.d/60-raw.rules # Enter raw device bindings here. # # An example would be: # ACTION=="add", KERNEL=="sda", RUN+="/bin/raw /dev/raw/raw1 %N" # to bind /dev/raw/raw1 to /dev/sda, or # ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="1", RUN+="/bin/raw /dev/raw/raw2 %M %m" # to bind /dev/raw/raw2 to the device with major 8, minor 1.
where
ACTION=="add", KERNEL="<device name>", RUN+="raw /dev/raw/rawX %N"
configure the device name, replace
Major/minor number:
ACTION=="add", ENV{MAJOR}="A", ENV{MINOR}="B", RUN+="raw /dev/raw/rawX %M %m"
"A" and "B" are the major/minor numbers of the device, and X is the raw device number used by the system.
My personal understanding of the process of managing raw in redhat is: in redhat 5, raw devices are managed through udev, and udev identifies raw devices through MAJOR and MINOR. Therefore, the device number and the raw device number need to be bound, and the major device number and minor device number can be specified by yourself or automatically assigned by the system. According to the example of raw.rule in red hat's official documentation, it is said that KERNEL==.. or ENV{MAJOR}... only needs to be configured arbitrarily. However, some netizens have tested and verified that both must be configured at the same time. .
Configure /etc/udev/rules.d/60-raw.rules file
Check the disk partition situation
# fdisk -l /dev/sdb Disk /dev/sdb: 4880 MB, 4880072704 bytes 255 heads, 63 sectors/track, 593 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 25 200781 83 Linux /dev/sdb2 26 50 200812+ 83 Linux
Configure /etc/udev/rules.d/60 -raw.rules file
# grep -v ^# /etc/udev/rules.d/60-raw.rules ACTION=="add", KERNEL=="sdb1", RUN+="/bin/raw /dev/raw/raw1 %N" ACTION=="add", KERNEL=="sdb2", RUN+="/bin/raw /dev/raw/raw2 %N" ACTION=="add", ENV{MAJOR}=="3", ENV{MINOR}=="2", RUN+="/bin/raw /dev/raw/raw1 %M %m" ACTION=="add", ENV{MAJOR}=="7", ENV{MINOR}=="2", RUN+="/bin/raw /dev/raw/raw2 %M %m"
Start the raw device
# start_udev Starting udev: [ OK ]
View the configuration
# raw -qa /dev/raw/raw1: bound to major 8, minor 17 /dev/raw/raw2: bound to major 8, minor 18
I don’t know why the main device number and the complex device number are not the same as mine/ etc/udev/rules.d/60-raw.rules is the same as specified in etc/udev/rules.d/60-raw.rules. Readers who want to know more about it will be informed that the system kernel information is as follows
# uname -a Linux rac1 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:54 EDT 2009 i686 i686 i386 GNU/Linux # cat /etc/redhat-release Red Hat Enterprise Linux Server release 5.4 (Tikanga)
You can specify the major device number and complex device number in the following way
# raw /dev/raw/raw1 1 1 /dev/raw/raw1: bound to major 1, minor 1 raw /dev/raw/raw[n] /dev/xxx
其中n的范围是0-8191。raw目录不存在的话会被自动创建。执行这个命令,就会在/dev/raw下生成一个对应的raw[n]文件用命令方式绑定裸设备在系统重启后会失效。
删除裸设备
# raw /dev/raw/raw2 0 0 /dev/raw/raw2: bound to major 0, minor 0 # raw -qa /dev/raw/raw1: bound to major 1, minor 1
以上设置必须同时修改/etc/udev/rules.d/60-raw.rules才能保证重启后生效,否则重启后系统会重新读取/etc/udev/rules.d/60-raw.rules
如需设置raw设备的用户和权限信息,可在/etc/udev/rules.d/60-raw.rules文件里添加如下信息:
ACTION=="add", KERNEL=="raw1", OWNER="dave", GROUP="tianlesoftware", MODE="660"
如果有多个raw设备,可以写成:
ACTION=="add", KERNEL=="raw[1-4]", OWNER="dave", GROUP="tianlesoftware", MODE="660" #chown oracle:oinstall /dev/raw/raw[1-4] #chmod 775 /dev/raw/raw[1-4]
注意:在内核2.6.9-89.5AXS2之前使用/etc/sysconfig/rawdevices和/etc/udev/permissions.d/50-udev.permissions进行raw设备的配置和权限管理。在内核 2.6.18-128.7AXS3以后则使用了本文介绍的/etc/udev/rules.d/60-raw.rules进行raw设备的管理
确定裸设备的大小
比较笨的办法是,找出看裸设备对应的是那个实际的块设备,然后用fdisk -l /dev/[h,s]dXN看那个块设备的大小就好了。比较简单的办法是用blockdev命令来计算,如:
#blockdev --getsize /dev/raw/raw1
11718750
11718750表示有多少OS BLIOCK。
一般一个OS BLOCK大小是512字节,所以11718750*512/1024/1024= 5722(m) 就是裸设备的大小。
使用裸设备作为oracle的数据文件的注意事项
1、一个裸设备只能放置一个数据文件
2、数据文件的大小不能超过裸设备的大小
如果是日志文件,则裸设备最大可用大小=裸设备对应分区大小 - 1 * 512 (保留一个redo lock)
如果是数据文件,则裸设备最大可用大小=裸设备对应分区大小 - 2 * db_block_size(保留两个block)
为了简单起见,对所有的文件设置称比裸设备小1M即可。
3、数据文件最好不要设置称自动扩展,如果设置称自动扩展,一定要把maxsize设置设置为比裸设备小
4、linux下oracle不能直接把逻辑卷作为裸设备,也要进行绑定。unix下就不需要。
相关推荐:《Linux视频教程》
The above is the detailed content of What is the format of linux raw?. For more information, please follow other related articles on the PHP Chinese website!

The five core components of the Linux operating system are: 1. Kernel, 2. System libraries, 3. System tools, 4. System services, 5. File system. These components work together to ensure the stable and efficient operation of the system, and together form a powerful and flexible operating system.

The five core elements of Linux are: 1. Kernel, 2. Command line interface, 3. File system, 4. Package management, 5. Community and open source. Together, these elements define the nature and functionality of Linux.

Linux user management and security can be achieved through the following steps: 1. Create users and groups, using commands such as sudouseradd-m-gdevelopers-s/bin/bashjohn. 2. Bulkly create users and set password policies, using the for loop and chpasswd commands. 3. Check and fix common errors, home directory and shell settings. 4. Implement best practices such as strong cryptographic policies, regular audits and the principle of minimum authority. 5. Optimize performance, use sudo and adjust PAM module configuration. Through these methods, users can be effectively managed and system security can be improved.

The core operations of Linux file system and process management include file system management and process control. 1) File system operations include creating, deleting, copying and moving files or directories, using commands such as mkdir, rmdir, cp and mv. 2) Process management involves starting, monitoring and killing processes, using commands such as ./my_script.sh&, top and kill.

Shell scripts are powerful tools for automated execution of commands in Linux systems. 1) The shell script executes commands line by line through the interpreter to process variable substitution and conditional judgment. 2) The basic usage includes backup operations, such as using the tar command to back up the directory. 3) Advanced usage involves the use of functions and case statements to manage services. 4) Debugging skills include using set-x to enable debugging mode and set-e to exit when the command fails. 5) Performance optimization is recommended to avoid subshells, use arrays and optimization loops.

Linux is a Unix-based multi-user, multi-tasking operating system that emphasizes simplicity, modularity and openness. Its core functions include: file system: organized in a tree structure, supports multiple file systems such as ext4, XFS, Btrfs, and use df-T to view file system types. Process management: View the process through the ps command, manage the process using PID, involving priority settings and signal processing. Network configuration: Flexible setting of IP addresses and managing network services, and use sudoipaddradd to configure IP. These features are applied in real-life operations through basic commands and advanced script automation, improving efficiency and reducing errors.

The methods to enter Linux maintenance mode include: 1. Edit the GRUB configuration file, add "single" or "1" parameters and update the GRUB configuration; 2. Edit the startup parameters in the GRUB menu, add "single" or "1". Exit maintenance mode only requires restarting the system. With these steps, you can quickly enter maintenance mode when needed and exit safely, ensuring system stability and security.

The core components of Linux include kernel, shell, file system, process management and memory management. 1) Kernel management system resources, 2) shell provides user interaction interface, 3) file system supports multiple formats, 4) Process management is implemented through system calls such as fork, and 5) memory management uses virtual memory technology.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Linux new version
SublimeText3 Linux latest version

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver Mac version
Visual web development tools
