In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "Linux disk partitioning and file system management". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "Linux disk partitioning and file system management".
1. Linux disk
Iops: io per second disk interface type: IDE: parallel port, easy to make mistakes at high frequency, 133MB/s SATA: serial port, but high frequency, 6gbps (1gbps=128MB/s) SCIS: parallel port, ultrascsi320, 320MB/s SAS: serial port, 6gbps USB: serial port, 480MB/s hard disk type: mechanical hard disk track: track sector: sector cylinder: cylinder, partition based on cylinder Average seek time: 5400 rpm 7200 rpm 7200 rpm 10000 rpm 15000 rpm (the rotational speed of the uranium separation equipment reaches 30000rpm, the mechanical hard disk speed is already very strong) High speed produces a lot of heat energy, any tiny dust particles at such high speed will affect the hard disk) linux device type: block: random access Character (character): linear access; device file: FHS / dev device file: driver associated to the device, access to the device; device number: major: main device number, distinguishing device type, used to indicate the driver required by the device Minior: secondary device number, which distinguishes different devices under the same type, and is the access entry for specific devices. Device file name disk: IDE:/dev/hd [a murz] SCSI,SATA,SAS,USB: / dev/sd [a murz] Note: Centos6 and 7 all identify the disk device file / dev/sd [[a murz] # such as / dev/sda / dev/sda1,/dev/sda2;... How to reference a device: device file name, volume label, UUID
Disk Partition:
MBR and its use: MBR: Master Boot Record characteristics: occupy disk 0 sector,512bytes, divided into three parts: 446bytes:bootloader program, boot boot operating system; 64bytes: partition table, every 16 bytes identifies one partition, a total of only 4 partitions; 4 primary partitions or 3 primary + 1 extended partitions (multiple logical partitions) 2bytes: the validity identification of the MBR area. 55AA is valid.
GPT and its use.
GPT:Globally Unique IdentifierPartition Table Format globally unique identifier partition table. Features: each partition on the drive has a globally unique identifier; supports an almost unlimited number of partitions unless limited by the operating system; the first sector occupied by MBR is now LBA0,GPT uses 34 LBA blocks to record partition information (the first sector is still compatible with MBR) GPT in addition to the first 34 LBA, the last 33 LBA of the entire disk is also used as another backup. The LBA0 (MBR compatible block) is similar to the MBR mode, with the first 446B being boot loader and the last 64B being replaced with a special tag, which is used to surface this disk in GPT format. LBA1 (GPT header record) records the location and size of the partition table itself, the location of the backup GPT partition, and the check code LBA2-33 (actual record partition information) starting from the LBA2 block, each LBA can record 4 partition records, so by default, there can be a total of 4 ^ 32 = 128partition records in traditional BIOS---- > MBR format. UEFI-> MBR format + GPT format (Unified Extensible Firmware Interface: unified extensible firmware interface)
GPT partition under linux:
The parted command is used here, and fdisk also has gpt partitioning operations. (1) [root@localhost tmp] # parted; (2) help; (3) select device; (4) mklabel gpt; (5) mkpart;-enter the partition name;-File system;-start point, do not start with 0;-end point -starting point, you can use # G; at this time the partition has been successful (6) print view (7) quit [root@localhost tmp] # partedGNU Parted 3.1Using / dev/sdaWelcome to GNU Parted! Type 'help' to view a list of commands. (parted) select / dev/sddUsing / dev/sdd (parted) mklabel gptWarning: The existing disk label on / dev/sdd will be destroyed and all data onthis disk will be lost. Do you want to continue?Yes/No? Yes (parted) mkpart Partition name? []? Mygpd_data File system type? [ext2]? Ext4 Start? 1 End? 2G (parted) printModel: VMware VMware Virtual S (scsi) Disk / dev/sdd: 2147MBSector size (logical/physical): 512B/512BPartition Table: gptDisk Flags: Number Start End Size File system Name Flags 1 1049kB 2146MB 2145MB mygpd_data
II. Fdisk command
1. Check out fdisk-k device 2. Management fdisk device fdisk provides an interactive interface to manage partitions with multiple subcommands; all operations are done in memory; not synchronized directly to disk until saved to disk using the w command; Note: create a new partition on a disk device that is already partitioned and one of the partitions is mounted, and the kernel may not recognize it after it has been created. View: cat / proc/partitions notifies the kernel to force read disk partitions: centos5: partprobe device; centos6.7: partx-a device kpartx-a device Partition creation tool: parted; sfdisk
III. File system creation
Formatting: low-level formatting, dividing tracks before partitioning; advanced formatting, creating file systems for partitions after partitions, superblock,i node inode table, data block data block, directory block directory block, indirect block indirection blockblock, bitmap index inode bitmap,block bitmap Metadata area + actual data area: inode table file metadata: file size, permissions, host groups, timestamps, block pointers, etc., without recording the file name; the metadata area records the information of each file in a uniform format. Give a template and fill it in according to the actual situation of the file. The recording content of the block pointer is limited, which determines the upper limit of the file size. Get the actual data of the file according to the data block pointer to the data area. Match the linked file: the real access path to the file is stored in the space where the data pointer is stored. Device file: the device number is stored in the space where the data pointer is stored. Neither of these files occupies the data area.
VFS: Virtual File System solves the problem of mutual recognition between different file systems.
Linux file system: ext2,ext3,ext4,xfs,btrfs CD: ISO9660 network file system: nfs,clfs cluster file system: gfs2,ocfs2 kernel-level distributed file system: ceph windows file system: vfat,ntfs windows does not recognize the file system of linux, so when the storage device needs to cross-use between the two systems You should use a file system that supports both: vfat # mkfs.vfat device Note: if the U disk format is ntfs, you can use a plug-in for NTFS-3G. After installation, linux can support NTFS files. Linux recognizes it as ntfs-3g file system ntfs-3g-ntfsprogs-2011.3.32.tgz decompresses and executes. / config make makeinstall compilation and installation if the U disk is identified as a sda3 device, execute the following instruction # mount-t ntfs-3g / dev/sda / mnt/win pseudo file system: proc,sysfs,tmpfs Hugepagefs user space distributed file system: mogilefs,moonsefs,glusterfs interactive file system: swap The interactive partition on linux must use a separate file system, and the system ID must be 82, set by t on fdisk; create a swap file system: mkswap device enable: swapon devcie-a: enable all swap devices in the / etc/fstab file. Disable: swapoff devcie creates a 1G swap partition and enables it. [root@localhost ~] # fdisk / dev/sdeCommand (m for help): nPartition type: P primary (0 primary, 0 extended, 4 free) e extendedSelect (default p): pPartition number (1-4, default 1): 1First sector (2048-4194303, default 2048): Using default value 2048Last sector, + sectors or + size {Kjogeng G} (2048-4194303) Default 4194303): + 1G Partition 1 of type Linux and of size 1 GiB is setCommand (m for help): tSelected partition 1Hex code (type L to list all codes): 82Changed type of partition 'Linux' to' Linux swap / Solaris'Command (m for help): wThe partition table has been altered! [root@localhost ~] # mkswap / dev/sde1Setting up swapspace version 1, size = 1048572 KiBno label UUID=adcb05b1-3368-4e97-80c8-7ed13e959c63 [root@localhost etc] # free-m total used free shared buff/cache availableMem: 3778 380 166 6 3231 3140Swap: 2047 6 2041 [root@localhost etc] # swapon / dev/sde1 [root@localhost etc] # free-m total Used free shared buff/cache availableMem: 3778 381 165 6 3231 3139Swap: 3071 6 3065
IV. File system usage
1. Create File system tool: mkfs mkfs.ext2; mkfs.ext3; mkfs.ext4; mkfs.xfs; View File system Type: blkid device Mke2fs command mke2fs [OPTIONS] device-t {ext2 | ext3 | ext4}-b {1024 | 2048 | 4096}-L LABEL Volume label-j create Log function File system ext3-I # Total number of bytes an inode-N # create inode-m # reserve space, percentile table-O [^] creates the target file system with the specified characteristics Exercise: create a 1G partition and format it as an ext4 file system. Requirements: (1) block size is 2048, reserved space is 20%, and volume label is MYDATA. [root@localhost tmp] # fdisk / dev/sde Command (m for help): nPartition type: P primary (0 primary, 0 extended, 4 free) e extendedSelect (default p): pPartition number (1-4, default 1): 1First sector (2048-4194303, default 2048): Using default value 2048Last sector, + sectors or + size {Kjordenmund G} (2048-4194303) Default 4194303): + 1GPartition 1 of type Linux and of size 1 GiB is setCommand (m for help): wThe partition table has been altered calling ioctl () to re-read partition table.Syncing disks.root@localhost tmp] # mke2fs-t ext4-b 2048-L MYDATA-m 20 / dev/sde1mke2fs 1.42.9 (28-Dec-2013) Filesystem label=MYDATAOS type: LinuxBlock size=2048 (log=1) Fragment size=2048 (log=1) Stride=0 blocks, Stripe width=0 blocks65536 inodes, 524288 blocks104857 blocks (20.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=26895974432 block groups16384 blocks per group 16384 fragments per group2048 inodes per groupSuperblock backups stored on blocks: 16384, 49152, 81920, 114688, 147456, 409600, 442368Allocating group tables: doneWriting inode tables: done Creating journal (16384blocks): doneWriting superblocks and filesystem accounting information: done
two。 File system mount and unmount
Mount and unmount: for a file system other than the mount umount root file system to be accessible, it must be 'associated' to a directory on the root file system. This' association 'operation is' mount', and this directory is the mount point. Mount point: mount point is used to access another file system (1): exists beforehand; (2): the application uses directories that are not or will not be used by other directory processes; (3): the original file creation under the mount point will be hidden Consider a question: connect a disk with a linux system (root file system A) to a device on another linux system (B), and then mount it in a directory on system B. what is the read and write permission of a user on B (root or an ordinary user) to A file? Mount [- fnrsvw] [- t vfstype] [- o options] device dir-r: read-only-w: read and write (default option)-n: synchronization is disabled (by default Device mount and unmount are synchronized to / etc/mtab)-t-- vfstype: specify the file type-L-- LABEL: specify the device by label-U-- UUID: specify the device by uuid-o: automatically mount all devices that support automatic mount sync/async: Synchronous / asynchronous atime/noatime: whether to update its access timestamp diratime/nodiratime: only for directory timestamps remount: rehang acl: support using acl function # mount-o acl device dir # mount-o alc device ro : read-only rw: whether reading and writing exec/noexec allows you to run files on this device Tip: mount-- bind source directory target directory You can bind a directory to another directory as its temporary access entry. View all mounted devices on the current system: # mount # cat / etc/mtab # cat / proc/mounts umount [- dflnrv] {dir | device}. The mount point being accessed by the process cannot be uninstalled to see which process is in use: # lsof mount_point # fuser-v mount_point [root@localhost /] # fuser-v / dev/sde1USER PID ACCESS COMMAND/dev/sde1: root kernel swap / dev/sde1
3. Other files are automatically mounted on boot except for the root file.
/ etc/fstab
UUID=795d1641-c4f8-4f72-911b-6eedfe2ac733 / xfs defaults 0 0UUID=ecde1354-5470-4692-bc2b-9cc94bd3b11c / boot xfs defaults 0 0UUID=ad488060-c1c6-4871-a8e2-228de0b90457 swap swap defaults 0 (1) Devices to be mounted: device files, LABEL,UUID Pseudo file system (2) mount point, swap type mount point is swap (3) file system type (4) mount option (5) dump frequency, 0 never, 1 every day, 2 every other day (6) self-test sequence is connected to the above exercise: (2) mount to / mydata directory, require that the program is not allowed to run automatically during mount And the access timestamp of the file is not updated. (3) it can be booted and mounted automatically. [root@localhost mydata] # mount-o noatime noexec-L MYDATA / mydata-error, o the following parameters are Separate [root@localhost mydata] # mount-o noatime,noexec-L MYDATA / mydata [root@localhost /] # vim / etc/fstab UUID=795d1641-c4f8-4f72-911b-6eedfe2ac733 / xfs defaults 0 0UUID=ecde1354-5470-4692-bc2b-9cc94bd3b11c / boot xfs defaults 0 0UUID=ad488060-c1c6-4871-a8e2-228de0b90457 swap swap defaults 0 0LABEL=MYDATA / mydata ext4 defaults 00 Thank you for reading The above is the content of "Linux disk partition and file system management". After the study of this article, I believe you have a deeper understanding of Linux disk partition and file system management, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.