In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Linux disk and file system management
CPU,Memory (RAM), iCompo
I/O:Disks,Ethtercard
Disk: persisting data
Interface type:
IDE (ata): parallel port, 133MB/s
SCSI: parallel port, Ultrascsl320320MB/s
SATA: serial port, 6gbps
SAS: serial port, 6gbps
USB: serial port, 480MB/s
Parallel port: multiple devices can be connected to the same cable
IDE: two, master, slave
SCSI:
Broadband: 16-1
Narrowband: 8-1
Iops:io per second
Serial port: one
Hard disk: mechanical hard disk, solid state hard disk:
Mechanical hard disk:
Track: track
Sector: sectors, 512bytes
Cylinder: cylinder: the same track of different disks
Partition based on cylinder
Average seek time:
5400rpm,7200rpm,10000rpm,15000rpm
Linux's philosophy: everything is a document:
Device type:
Block (block): random access, data exchange unit is "block"
Character (character): linear access, data exchange unit is "character"
Device files: FHS
/ dev
Device file: the driver associated with the device; the access type of the device
Device number:
Major: the main device number, which distinguishes the type of device; used to indicate the driver required by the device
Minor: secondary device number, which distinguishes different devices under the same type; it is the access entry for specific devices.
Mknod command:
Make block or character special files
Mknod [OPTION]... NAME TYPE [MAJOR MINOR]
-m MODE: access to the created device file
Device file name: ICANN
Disk:
IDE: / dev/hd [a Meiz]
For example: / dev/hda / dev/hdb
SCSI,SATA,USB,SAS:/dev/sa [a Murz]
Zoning:
/ dev/hda#
/ dev/hda1,...
Note: CentOS 6 and 7 systems identify the hard drive device as / dev/sd [a Murz] #
How the device is referenced:
Device file name
Volume label
UUID
Disk partitions: MBR,GPT
MBR:0 sector
Master Boot Record
It is divided into three parts:
446bytes:bootloader, program, boot program that starts the operating system
64bytes: partition table. Each 16bytes identifies one partition. There can only be 4 partitions in total.
Validity identification of 2bytes:MBR area; 55AA bit is valid; otherwise, it is invalid
Identification of primary and extended partitions: 1-4
Logical Partition: 5 +
When we want to add a hard drive to the system:
1: partition the disk to create a new available partition
2: format the partition to create a file system available to the system
3: verify the file system
4: on the Linux system, you need to create a mount point (directory) and mount it to
Logical partitioning: fdisk
1: view the partition information of the disk
Fdisk-l [- u] [device]; lists partition information on the specified disk device
2: manage Partition
Fdisk device
Fdisk provides an interactive interface to manage partitions with many subcommands for different management functions
All operations are done in memory and are not synchronized directly to disk until the w command is saved to common commands on disk:
N: create a new partition
D: delete existing partitions
T: modify the partition type
L: view all existing ID
W: save and exit
Q: do not save exit
M: view help information
P: show existing partition information
Note: for new partitions created on disk devices that are already partitioned and one of them has been mounted, the kernel may be created after the creation is complete
Cannot be directly identified.
View disk partitions: cat / proc/partitions
Notify the kernel to force rereading the disk partition table:
CentOS 5:partprobe [device]
CentOS 6,7:partx,kpartx
Increase partition synchronization
Partx-a [device]
Kpartx-af [device]
Delete partition synchronization
Partx-d-nr 7-8 [device]
Zone creation tools:
Parted,sfdisk
File system management tools:
Tools for creating file systems:
Mkfs
Mkfs.ext2,mkfs.ext3 mkfs.ext4 mkfs.ext4 mkfs.xfs mkfs.vfat
Tools for detecting and repairing file systems:
Fsck
Fsck.ext2 et al.
Tools for viewing its properties:
Dumpe2fs,tune2fs
Adjust file system properties:
Tune2fs
Components of the kernel level file system:
File system driver: provided by the kernel
File system management tools: provided by applications of user controls
Create a file system:
Formatting: low-level formatting (before partitioning, dividing tracks)
Advanced formatting (partition after partition, create file system)
Create a file system:
Linux file system type: ext2 ext3 ext4 xfs relserfs iso9660 swap
Metadata area
Metadata area:
Does not include file name
File metadata: inode (index node)
Size, permissions, belonging to master group, timestamp, block pointer, etc.
Symbolic link files: storing data
Management tools for ext series file systems:
Disk formatting:
Mkfs-t ext3=mkfs.ext3
In formatting to ext3, since we do not specify the specific options for the file system, the system uses default values for formatting.
Specify ext2/ext3 specific options (label,block size or number of inode)
Mke2fs [OPTIONS] device
-t: indicates the type of file system to be created
Mkfs-t ext3=mkfs.ext3
-b: {1024 | 2048 | 4096}: indicates the block size of the file system
-j: create a journaling file system ext3 (default is ext2)
Make2fs-j=make2fs-t ext3=mkfs-t ext3=mkfs.ext3
-I #: indicates the ratio of inode to bytes; that is, an inode is created for every number of bytes
-N #: directly indicates the number of inode to be created for this file system
-m #: specify reserved space, percentage
The volume is labeled: hello kitty
Block:2048
8192bytes assigns an inode
Build the ext3 file system of journal
E2label command: viewing and setting of volume label
Viewing: e2label device
Settings: e2label device LABEL
Tune2fs command: view or modify some properties of the ext series file system
Note: the block size cannot be modified after it is created
Tune2fs [OPTIONS] device
-l: view the contents of the super block
Modify the properties of the specified file system:
-j:ext2-> ext3
-L LABEL: modify the volume label
-m #: adjust the percentage of reserved space
-O [^] FEATHER: turn a feature on or off
-o [^] mount_options: turns some default mount option on or off
Acl
^ acl
Dumpe2fs command: displays attribute information for ext series file system
Dumpe2fs [- h] device
Fsck command: a tool for file system detection
File corruption may occur when the finalization operation is abnormally terminated due to unexpected termination of the process or system crash; at this time, the file system should be detected and repaired; it is recommended to proceed offline.
E2fsck [options] device
-y: automatically answer yes to all questions
-f: force detection even if the file system is in the clean state
Step 1: check inode, block, size
Step 2: check the directory structure
Step 3: check directory connectivity
Step 4: check the reference information
Step 5: check the cluster profile information
Fsck command:
-t fstype: indicates the file system type
Fsck-t ext4=fsck.ext4
-a: automatically fix all errors without interaction
-r: interactive repair
Blkid command: query the system type used on the device, UUID
Blkid device
Blkid-L LABEL: locate the device according to LABEL
Blkid-U UUID: locate the device according to UUID
Swap file system:
Swap partitions on Linux must use separate file systems
And the System ID of the file system must be 82
Create swap device: mkswap command
Mkswap [options] device
-L LABEL: indicates the volume label
-f: mandatory
Windows does not recognize Linux's file system; therefore, when a storage device needs to be cross-used between two systems, it should use a file system supported by both windows and Linux: fat32 (vfat)
# mkfs.vfat device
Use of the file system:
First mount: the mount command and the umount command
For a file system other than the root file system to be accessible, it must be "associated" to a directory on the file system for internship. This association operation is called "mount"; this directory is the "mount point".
Mount point: mount_point, which is used as an access entry to another file system
(1) exist beforehand
(2) directories that are not or will not be used by other processes should be used.
(3) the original files under the mount point will be hidden.
Mount command:
Mount [- nrw] [- t file system] [- L LABEL] [- o options] device dir
Command options:
-r:readonly, read-only mount
-w:read and write, read write mount
-n: by default, device mount or unmount operations are synchronously updated in / etc/mtab; used to disable this operation
-t vfstype: indicates the type of file system on the device to be mounted; in most cases it can be omitted
At this point, mount will determine the file type of the device to be mounted according to blkid.
-L LABEL: indicates the device as a volume label when mounting
-U UUID: indicates the device as UUID when mounting
-o options: mounting option
Sync/async: synchronous / asynchronous operations; (synchronous: write to memory and disk at the same time)
Atime/noatiome: whether to update the access timestamp when a file or directory is accessed
Diratime/nodiratime: whether to update the access timestamp when the directory is accessed
Remount: remount
Acl: supports the use of facl features
Example: no acl is added, and operation is not supported (setting access control function is not supported)
Only read and write permissions are found under mount
We use mount to remount and add the acl option
Enter / mnt again to see if it has access control function.
Acl acquiesce that we don't support it, it's too dangerous, you know, there's no need to dig a hole for yourself.
The second method:
Tune2fs-o acl / dev/sda6 enable acl
Tune2fs-l / dev/sda6 to see if acl is enabled
Ro: read-only
Rw: read and write
Dev/nodev: whether device files are allowed on this device
Exec/noexec: whether to allow running program files on this device
Auto/noauto: whether to allow ordinary users to mount this file system
Suid/nosuid: whether to allow suid and sgid special permissions on program files to take effect
Defaults: Use default options () default option):
Rw, suid, dev, exec, auto, nouser, async, and relatime
A technique to use:
You can bind a directory to another directory as a temporary access intersection
Mount-- bind source directory target directory
View all devices that have been attached to the current system
# mount
# cat / etc/mtab
# cat / proc/mounts
Mount the CD:
Mount-r / dev/cdrom mount_point (mount point)
Hang on the flash drive:
Identify the device file of the USB disk in advance
Mount the local loopback device:
Mount-o loop / PATH/TO/SOME_LOOP_FILE MOUNT_POINT
Umount command:
Umount device | dir
Note: the mount point being accessed by the process cannot be uninstalled
Check which process or processes are occupied by:
# lsof MOUNT_POINT or # fuser-v MOUNT_POINT
Terminate all processes that are accessing a mount point:
# fuser-km MOUNT_POINT forced T-drop
# unmount umount MOUNT_POINT again
Enable the swap partition:
Command to create a swap partition: mkswap
Enable: swapon
Swapon [OPTION] [DEVICE]
-a: all swap devices are defined in the / etc/fstab file
Disable: swapoff
Swapoff DEVICE
Set the file system other than the root file system to be automatically mounted when it is powered on: / etc/fstab file
Each line defines a file system to be mounted and related properties:
6 field
(1) the equipment to be hung:
Device file
LABEL
UUID
Pseudo file system: such as sysfs,proc,tmpfs, etc.
(2) Mount point
The mount point for devices of type swap is swap
(3) File system type
(4) Mount option
Defaults: use the default mount option
If you want to use multiple mount options at the same time, you can separate them by commas.
Example: defaults,acl,noatime,noexc
(5) dump frequency
0: never back up
1: backup every day
2: backup every other day
(6) self-check order
0: no self-test
1: self-test first, usually only the root file system is available 1
2: secondary self-test
...
Mount-a: all devices defined in this file that support auto-mount can be automatically mounted.
(1) automatically mount with LABEL
(2) automatically mount with device
Two commands: df and du
Df command:
Df [OPTION] [FILE]
-l: displays only relevant information about local files
-h:human-readable
-l: displays inode usage status instead of blocks
Du command:
Du [OPTION] [FILE]
-s:sumary
-h:human-readble
Lunix disk and file management system blogger summed up here, today is Sunday, bloggers began to sum up from the afternoon to writing a blog, intermittent in the middle, now there is a feeling of exhaustion! Then I'll see you in the next section. My wish is that there are no more witty bitches in the world.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.