Device files:
B: Block files, Unit-by-block, randomly accessed devices, such as disks
C: Character file, in alphabetical order, to access linear devices, such as keyboards
Ls-l View the device files, the original display size of the column is changed to display as
Main device number (major numbers)
Used to identify the device type
Secondary device number (minor numbers)
Used to identify different devices of the same type
Mknod creating a block or character device file
Mknod [OPTION] ... NAME TYPE [MAJOR MINOR]
-M MODE Specify permissions
Example: Mknod-m 640 Mydev C 66 0
Device file name for the hard disk device:
Ide,ata:hd
Sata:sd
Scsi:sd
Usb:sd
A,b,c,... To differentiate different devices under the same type
Ide:
First IDE port: Master, slave
/dev/hda,/dev/hdb
Second IDE port: Master, slave
/DEV/HDC,/DEV/HDD
SDA, SDB, SDC, ...
Hda
HDA1: First primary partition
HDA2:
Hda3:
HDA4:
HDA5: First Extended partition
Check that the current system recognizes several hard drives:
fdisk-l [/dev/to/some_device_file]
Managing Disk Partitions
Fdisk/dev/sda
P: Displays the partition of the current hardware, including unsaved changes
N: Create a new partition
E: Extended partition
P: Primary partition
D: Delete a partition
W: Save exit
Q: Do not save exit
T: Modify the partition type
L: Show all supported types
Re-read partition table
Partprobe
File System Management
Cat/proc/filenames: Used to display the file systems supported by the current kernel
Mkfs:make filesystem Creating a file system
MKFS [OPTIONS] device files
-T Fstype
Mkfs-t ext2 = mkfs.ext2
Nkfs-t ext3 = Mkfs.ext3
Specialized in managing the Ext series file system
Mke2fs
-j: ext3 type of file system
-B block_size: Specify block size, default is 4096
-L LABEL: Specifies the partition volume label, with the volume label, you can use the volume label to refer to the partition, for example, using the label to mount
-M # (no plus%): Specifies the percentage of blocks reserved for super users, and-M 2 for reserved 2%
-I #: Creates an inode for the space specified as multibyte, defaults to 8192, and the value should be 2^n times the block size
-N #: Specify the number of Inode
-F: Force the file system to be created; The default file system is already mounted and cannot be recreated
-E: User-specified additional file system attributes, such as stride=# (Chunk/block_size), play a role for RAID0 and RAID5 and speed up operation
Blkid device files: Used to view related properties of disk devices, including UUID, type, and label
E2label: Used to view or define volume labels
E2label Device files: viewing volume labels
E2label device File Volume label name: Set Volume label
TUNE2FS: Modify file System related properties without reformatting, non-destructive modification
TUNE2FS [OPTION] device files
-j: Do not compromise the original data, upgrade the ext2 to ext3, but ext3 cannot downgrade to ext2
-L LABEL: Set or modify volume label
-M: Adjust the reserved percentage, use the same as MKE2FS, but do not reformat
-R: Directly sets the number of reserved blocks and cannot be used with-m
-C #: Specify the number of mounts to # times after the self-test, 0 or 1 means to turn off this feature
-I #: Specifies how many days to use after a self test without mounting, 0 or 1 for turning off this feature
-L: Show information in super fast
DUMPE2FS: Displays information from the Super block and information for each block group
DUMPE2FS [OPTION] device files
-H: Show only information in the Super block
Fsck: Checking and repairing the Linux file system
-T Fstype: Specifying the file system type
-A: Do not ask for automatic repair
E2FSCK: Designed to check and repair the Ext class file system
-F: Forced check
-P: Auto fix, default option
Mount/unmount File system
Mount: Associate a new file system to the current root file system
Uninstall: Remove the association of a file system from the current file system
Mount: Mount
Mount [option] [-o-option] device mount point
Equipment:
Device files
Volume Label: label= ""
Uuid:uuid= ""
mount point: Directory
Requirements:
1. Not used by other processes
2. The catalogue must exist beforehand
3. Files in the directory will be temporarily hidden, uninstall before they can be displayed again
: does not follow the parameters, display the current system has been changed to the device and mount point
-A: Indicates that all file systems in the/etc/fstab file are mounted
-N: By default, mount commands save the mounted device information to the/etc/mtab file, with the-n option not saved, for each device mounted
-T Fstype: Specifies the type of file system on which the device is being mounted, and when this option is not used, Mount automatically calls the Blkid command to obtain the type of the corresponding file system
-R: Read-only mount, which is often used for mounting discs
-W: Read-write Mount
-O: Specify additional mount options, that is, specify the properties of the file system startup
Remount: Re-mount without specifying mount point
RO: Read-only Mount
RW: Read-write Mount
Loop: Mount the local loopback device, mount the ISO image
When the mount is complete, the files on the corresponding file system are accessed via the mount point
Umount: Uninstalling a file system
Umount Equipment
Umount mount point
-N:
Mounting considerations: Mounted devices or mount points are not being used by the process
Fuser: Verifying the file or socket file that the process is using
-V: View running processes on a file
-KM: Terminates all processes that are accessing this directory
Fuser-km/path/to/directory
Create swap partition
Free: Displays memory and swap partitions, including total, used, free, etc.
-M: Default unit is KB, choose-m after unit changed to MB
Steps:
①fdisk command, N creates a partition
In the ②fdisk command, T adjusts the partition type to 82
③ Create swap partition:
1.mkswap Device files
-L LABEL
2.swapon device file: Enable swap partition
-A: Enable all switching devices defined in the/etc/fdtab file
3.swapoff device file: Turn off swap partition
Loopback devices:
Loopback, using software to simulate the implementation of hardware
DD: Create a specific file by specifying the data source and data storage destination
if= Data sources
of= Data storage target
bs=#: Block size, such as bs=1m
count=#: Number of blocks
seek=#: The size of skipped space when creating a data file
DD IF=/DEV/SDA of=/mnt/usb/mbr.backup bs=512 count=1 backup SDA MBR to U-disk
DD if=/mnt/usb/mbr.backup OF=/DEV/SDA bs=512 count=1 restore MBR
DD If/dev/zero of=/var/swapfile bs=1m count=1024 Create an empty file of 1G size
Mount ISO images, specific files, etc. with Mount
Mount-o Loop file path Mount_point
Mount-o Loop/var/swapfile/mnt/loopback1
Configuration file for FS/etc/fstab
The OS automatically mounts each file system defined in this file when it is initially
The format of each line:
Devices to mount:/dev/sda5
Mount point:/mnt/test
File system type: ext3
Mount option: Defaults
Switching frequency (make a full backup every few days): 0
File system detection order (only root can be 1): 0
Practice:
1, create a 5G partition, the file system is ext3, the volume label is MyData, the block size is 1024, the reserved management space for the disk partition 3%, requires the boot can automatically mount to the/data directory, and automatically mount the device to use the volume label for reference;
2, create a local loopback file/var/swaptemp/swapfile for swap, the size of 512MB, the volume labeled Swap-file, and power on automatically enable this switching device;
# mkdir/var/swaptemp
# dd If=/dev/zero of=/var/swaptemp/swapfile bs=1m count=512
# Mkswap Lable=swap-file/var/swaptemp/swapfile
Append in the/etc/fstab file
/var/swaptemp/swapfile swapswapdefaults0 0
3, the above first question, how to let it automatically mount the same time to enable the ACL function;
/etc/fstab
Label= ' MYDATA '/dataext3defaults,acl0 0
Linux Learning Notes < 12 >--Disk Management