LVM is short for logical volume manager. It is a mechanism for managing disk partitions in Linux, LVM is a logical layer built on hard disks and partitions to improve the flexibility of disk partition management. As mentioned above, LVM is a logical layer added between the disk partition and the file system to shield the file system from the underlying disk partition layout and provide an abstract disk volume, create a file system on the disk.
2. LVM
1: see all hard disks on the local machine, including those not formatted.
Fdisk-l
In Linux, IDE devices are named after HD. The first ide device is hda, and the second is HDB. The SCSI push interface device is named after SD. the first device is SDA, and the second is SDB. The device name and number are used to name the push partition. For example, hda1 represents the first partition on the hda hard disk device.
2: For a hard disk, you must first partition it and then format the corresponding file system on the partition.
Partition command: fdisk Hard Disk
Format File System (ext3): mkfs. ext3 Partition
A hard disk partition can be divided into a primary partition (three primary partitions and one extended partition) and a logical partition, and the maximum number of primary partitions is four. Why?
Boot Sector is the first sector of the hard disk. It consists of MBR (Master Boot Record), DPT (Disk Partition Table), and Boot Record ID. MBR, also known as the Master Boot Record, occupies the first 446 bytes (0 to 0x1bd) of the boot sector and stores the system Master Boot Program (it is responsible for loading and running the system boot program from the active partition ). DPT indicates that the primary Partition Table occupies 64 bytes (0x1be to 0x1fd) and records the basic partition information of the disk. The primary Partition Table is divided into four partition items, each of which is 16
Bytes, which respectively records the information of each primary partition (so there can be up to four primary partitions ). the Boot Record ID indicates that the boot zone mark occupies two bytes (0x1fe and 0x1ff). For a valid boot zone, it is equal to 0xaa55, which indicates whether the boot zone is valid.
3: automatic mounting
In the centos environment:
/Etc/fstab records the list of file systems automatically mounted when Linux is started. For example:
<File system> <mount point> <type> <Options> <dump> <pass>
4: dd command
Dd is a very useful command in Linux/Unix. It is used to copy an object with a specified size block and perform the specified conversion at the same time.
For example, dd If =/dev/hda of = disk. mbr bs = 512 COUNT = 1
It means to copy count BS data from the/dev/had hard disk to disk. MBR.
5: Open Functions
The open function can directly open the hard disk, so that we can skip the file system and store data directly to the hard disk, but we need to define the data layout.
6: DF command to view related information in the file system.
In the case of confusion, I will call the inode structure in the memory as VFS inode, while the file system uses ext2 as the representative and ext2 inode as the inode on the disk. First, you must describe the inode in the memory and the inode on the disk separately: <inode structure in the memory:> VFS inode contains information such as file access permissions, owner, group, size, generation time, access time, and last modification time. It is the most basic unit for Linux to manage the file system and a bridge between the file system and any subdirectories and files. The static information in the inode structure is taken from the file system on the physical device and filled in by the function specified by the file system. It only exists in the memory and can be accessed through the inode cache. Although each file has an inode node, the system only establishes an inode data structure for it in the memory when necessary. The inode structure will form a linked list, we can traverse this linked list to get the file node we need. VFS also constructs cache and hash for the allocated inode.
Table to improve system performance. The struct inode_operations * IOP in the inode structure provides us with an inode operation list. Through the functions provided in this list, we can perform various operations on VFS inode nodes. Each inode structure has an I node number I _ino, which is unique in the same file system. <Inode on disk:> ext2 uses inode to define the structure of the file system and describe the management information of each file in the system. Each file has one inode and only one, even if there is no data in the file, its index Node also exists. Each file is described using a separate ext2 inode structure, and each inode has a unique identifier. Ext2
Inode provides basic information about the file for the inode structure in the memory. As the inode structure in the memory changes, the system will also update the corresponding content in the ext2 inode. Ext2 inode corresponds to the ext2_inode structure. From the above description, we can compare inode in memory with inode in Disk: Location: The VFS inode structure is in memory, while ext2_inode is in disk. Lifetime: VFS inode is created only when needed. If the system is powered off, the structure disappears. Ext2_inode ext2_inode ext2_inode exists regardless of whether the file contains data. Uniqueness: the two are unique in their own scopes. Link: VFS
Inode is the abstraction, ing, and expansion of ext2 inode, while the latter is the static information part of the former, and also the embodiment, instantiation, and persistence of the former. Operation: VFS inode operations are universal. inode operations on file systems are related to file systems and depend on specific implementations. Organization Management: The system organizes the table through the VFS inode linked list. In order to improve the access efficiency, inode is constructed to construct the cache and hash table. The ext2 inode information is located in the block group divided by the ext2 file system. Each block group contains the corresponding inode bitmap and inode table to specify the specific inode information. Each inode corresponds to the ext2_inode structure. In principle, the inode in the memory is compared with the inode in the disk. In fact, they are different in the code. In the following, I will write the structure code corresponding to the two in the kernel.
The Linux operating system supports many abstract technologies. NBD is a technology that abstracts files or block devices on the server for the client through TCP/IP networks. NBD (Network
Block device) allows you to use the disk space of a remote host as a block device, just like a hard disk.
Add the hard disk space of another server to the local server. NBD is different from NFS. NFS only provides a mount point for the client. The client cannot change the partition format of the mount point. the NBD provides a block device. The client can format the block device into various types of partitions.
NBD-Server & NBD-Client: create a file and treat the file as a device block. The client can set the format according to ext3/ext4.