In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Partition and management of disk
This paper introduces the operation commands related to disk partition and management in linux system, and tests are added to each main command.
1. Disk partition: fdisk
Here we mainly use traditional disk partitions, not involving mdm, lvm and so on.
1. To view disk partition information, using fdisk-l, you can view information about traditional disk partitions and lvm volumes.
[root@liuqing ~] # fdisk-l
Disk / dev/sda:128.8 GB, 128849018880 bytes, 251658240 sectors
Units = sector of 1 * 512 = 512 bytes
Sector size (logical / physical): 512 bytes / 512 bytes
Igamo size (minimum / best): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000ce7f5
Device Boot Start End Blocks Id System
/ dev/sda1 * 2048 2099199 1048576 83 Linux
/ dev/sda2 2099200 209715199 103808000 8e Linux LVM
Disk / dev/mapper/centos-root:53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sector of 1 * 512 = 512 bytes
Sector size (logical / physical): 512 bytes / 512 bytes
Igamo size (minimum / best): 512 bytes / 512 bytes
Disk / dev/mapper/centos-swap:2147 MB, 2147483648 bytes, 4194304 sectors
Units = sector of 1 * 512 = 512 bytes
Sector size (logical / physical): 512 bytes / 512 bytes
Igamo size (minimum / best): 512 bytes / 512 bytes
Disk / dev/mapper/centos-home:50.5 GB, 50457477120 bytes, 98549760 sectors
Units = sector of 1 * 512 = 512 bytes
Sector size (logical / physical): 512 bytes / 512 bytes
Igamo size (minimum / best): 512 bytes / 512 bytes
2. Main parameters of fdisk
Note: fdisk operates in memory and does not operate on disk in real time. It is written to disk only when you save the disk using the w command.
D delete a partition # Delete a partition
L list known partition types # shows known partition types, common 82, 83, 8e,
M print this menu # displays the command menu
N add a new partition # create a new partition
P print the partition table # displays the partition table
Q quit without saving changes # do not save exit
T change a partition's system id # adjust partition type
W write table to disk and exit # Save and exit
3. Lab: create a 10G partition with partition type 83 and partition number / dev/sda3
[root@liuqing ~] # fdisk-l / dev/sda
Command (enter m for help): n
Partition type:
P primary (2 primary, 0 extended, 2 free)
E extended
Select (default p): P
Area number (3pd4, default 3): 3
Start sector (209715200-251658239, default is 209715200):
The default value of 209715200 will be used
Last sector, + sector or + size {K Magne M Magi G} (209715200-251658239, default is 251658239): + 10G
Partition 3 has been set to type Linux and the size is set to 10 GiB
Command (enter m for help): W
The partition table has been altered!
Calling ioctl () to re-read partition table.
# when creating a partition, enter the command n
# then choose whether the type of partition is primary partition or extended partition. For MBR disks, there are up to 4 primary partitions plus extended partitions
# Select partition number 1-4 as the primary partition or extended partition, and the logical partition under the extended partition starts from 5
# enter the starting sector number and partition size
# save and exit
4. Check the partition information, there is already one more.
[root@liuqing ~] # fdisk-l
Device Boot Start End Blocks Id System
/ dev/sda1 * 2048 2099199 1048576 83 Linux
/ dev/sda2 2099200 209715199 103808000 8e Linux LVM
/ dev/sda3 209715200 230686719 10485760 83 Linux
Second, let the kernel read the disk
After creating a partition using fdisk, the kernel does not recognize it in real time, and you need to use the command to reread the partition. There are two commands used: partx and kpartx.
1. Look at the partition information that has been recognized by the kernel and do not see the / dev/sda3 information.
[root@liuqing ~] # cat / proc/partitions
Major minor # blocks name
8 0 125829120 sda
8 1 1048576 sda1
8 2 103808000 sda2
. Omit other irrelevant information
two。 Use partx to reread the partition information, and if it doesn't work once, you can do it again.
[root@liuqing] # partx-a / dev/sda
Partx: / dev/sda: error adding partitions 1-2
[root@liuqing ~] # cat / proc/partitions
Major minor # blocks name
8 0 125829120 sda
8 1 1048576 sda1
8 2 103808000 sda2
8 3 10485760 sda3
3. How to use partx and kpartx
A. partx-a [device]
B. kpartx-af [device]
Third, create a file system
Master the commands and parameters for creating a file system
Here we mainly introduce the use of ext series file system creation tool mke2fs, which is more powerful. Other commands include mkfs.ext2, mkfs.ext3, mkfs.ext4; mkfs, etc.
Mke2fs [OPTIONS] device
-t {ext2 | ext3 | ext4}: indicates the type of file system to be created
Mkfs.ext4 = mkfs-t ext4 = mke2fs-t ext4
-b {1024 | 2048 | 4096}: indicates the block size of the file system
-L LABEL: indicates the volume label
-j: create a journaling file system ext3
Mke2fs-j = mke2fs-t ext3 = mkfs-t ext3 = mkfs.ext3
-I #: bytes-per-inode, indicating the ratio of inode to bytes; that is, creating an Indode for every number of bytes
-N #: directly indicates the number of inode to be created for this file system
-m #: specify reserved space, percentage
-O [^] FEATURE: creates the target file system with the specified properties
Lab: create a file system for / dev/sda3, the file system type is ext4, the block size used by the system is 2048, the volume label is Mydata, and the space reserved for the administrator is 4%
[root@liuqing] # mke2fs-t ext4-b 2048-L "Mydata"-M4 / dev/sda3
Mke2fs 1.42.9 (28-Dec-2013)
File system label = Mydata
OS type: Linux
Block size = 2048 (log=1)
Chunk size = 2048 (log=1)
Stride=0 blocks, Stripe width=0 blocks
655360 inodes, 5242880 blocks
209715 blocks (4.00%) reserved for the super user
First data block = 0
Maximum filesystem blocks=273678336
320 block groups
16384 blocks per group, 16384 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
16384, 49152, 81920, 114688, 147456, 409600, 442368, 802816, 1327104
2048000, 3981312
Allocating group tables: done
Writing inode table: complete
Creating journal (32768 blocks): complete
Writing superblocks and filesystem accounting information: done
Adjust partition properties and other commands
1. E2label: used to view and set volume labels
Viewing: e2label DEVICE
Settings: e2label DEVICE LABEL_NAME
2. Dumpe2fs: used to display attribute information of ext series file systems
Dumpe2fs [- h] device
3. E2fsck: disk check for ext series file systems
E2fsck [OPTIONS] device
-y: automatically answer yes to all questions
-f: force detection even if the file system is in the clean state
4. Fsck:check and repair a Linux file system
-t fstype: indicates the file system type
Fsck-t ext4 = fsck.ext4
-a: automatically fix all errors without interaction
-r: interactive repair
5. Tune2fs
Tune2fs command: view or modify some properties of the ext series file system
Adjust tunable filesystem parameters on ext2/ext3/ext4 filesystems
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
6. View information about partition super blocks
[root@liuqing ~] # tune2fs-l / dev/sda3
Tune2fs 1.42.9 (28-Dec-2013)
Filesystem volume name: Mydata
Last mounted on:
Filesystem UUID: 63a8e0d5-27b4-4dd6-9049-3f11acb620b7
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent 64bit flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize
Filesystem flags: signed_directory_hash
Default mount options: user_xattr acl
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 655360
Block count: 5242880
Reserved block count: 209715
Free blocks: 5121266
Free inodes: 655349
First block: 0
Block size: 2048
Fragment size: 2048
Group descriptor size: 64
Reserved GDT blocks: 512
Blocks per group: 16384
Fragments per group: 16384
Inodes per group: 2048
Inode blocks per group: 256
Flex block group size: 16
Filesystem created: Thu Nov 28 11:12:37 2019
Last mount time: n/a
Last write time: Thu Nov 28 11:12:38 2019
Mount count: 0
Maximum mount count:-1
Last checked: Thu Nov 28 11:12:37 2019
Check interval: 0 ()
Lifetime writes: 65 MB
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 256
Required extra isize: 28
Desired extra isize: 28
Journal inode: 8
Default directory hash: half_md4
Directory Hash Seed: e2e55f5f-e05f-431c-84b9-a734d29b078f
Journal backup: inode blocks
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.