In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to format logical partitions on CentOS system". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian slowly and deeply to study and learn "how to format logical partitions on CentOS system" together!
Disk capacity versus primary, extended, logical partitions:
Capacity of hard disk = capacity of primary partition + capacity of extended partition
Capacity of extended partition = sum of capacities of logical partitions
A physical hard disk can have only one to four primary partitions (but only one of which can be active), or one to three primary partitions, and one extended partition. corresponding to hda1, hda2, hda3, hda4 respectively.
Linux stipulates that each hard disk device can have up to 4 primary partitions (including extended partitions), and any extended partition must occupy a primary partition number, that is, in a hard disk, the total number of primary partitions and extended partitions is up to 4.
The confusion I had was not knowing that extended partitions take up a partition number from the primary partition (up to 4).
My summary: a hard disk can be set only the main partition, then the main partition can be set 4 partition numbers. It can also be set to the main partition + logical partition, which is also a maximum of 4 partition numbers, but becomes 4 = 3 + 1. 4 is the main partition and extended partition add up to 4; 3 is the main partition, which can be less than or equal to 3; 1 is the extended partition number, occupying a main partition number. From 5 to 16 are logical partitions. If there is only one 5, then the extended partition is no longer partitioned, and the extended partition is a logical partition (the total number of disks in an extended partition equals the total number of disks in a logical partition). It is common for extended partitions to be divided into logical partitions identified by numbers 5, 6, 7, 8, etc.
If you encounter the following error while formatting a disk in Linux, you are formatting an extended partition.
The code is as follows:
[root@GETTestLNX06 ~]# mkfs.ext4 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
mkfs.ext4: inode_size (128) * inodes_count (0) too big for a
filesystem with 0 blocks, specify higher inode_ratio (-i)
or lower inode count (-N).
Direct formatting of extended partitions is not allowed, only primary and logical partitions can be formatted. So how do we format an extended partition? We either delete the extended partition and create a primary partition, or create a logical partition on top of the extended partition as follows
1: Create logical partitions
The code is as follows:
[root@GETTestLNX06 ~]# fdisk /dev/sdb
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): p
Disk /dev/sdb: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xd61351c9
Device Boot Start End Blocks Id System
/dev/sdb1 1 13054 104856223+ 5 Extended
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (1-13054, default 1): 1
Last cylinder, +cylinders or +size{K,M,G} (1-13054, default 13054):
Using default value 13054
Command (m for help): p
Disk /dev/sdb: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xd61351c9
Device Boot Start End Blocks Id System
/dev/sdb1 1 13054 104856223+ 5 Extended
/dev/sdb5 1 13054 104856192 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
2: Format logical partitions
The code is as follows:
[root@GETTestLNX06 ~]# mkfs.ext4 /dev/sdb5
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
6553600 inodes, 26214048 blocks
1310702 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
800 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
3: Write mount information to configuration file
edit
The code is as follows:
[root@GETTestLNX06 ~]# vi /etc/fstab
4: Mount the newly created partition
The code is as follows:
[root@GETTestLNX06 ~]# cd /
[root@GETTestLNX06 /]# mkdir u01
[root@GETTestLNX06 /]# mount -a
[root@GETTestLNX06 /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_gettestlnx06-lv_root
44G 2.3G 40G 6% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
/dev/sda1 477M 33M 419M 8% /boot
/dev/sdb5 99G 60M 94G 1% /u01
[root@GETTestLNX06 /]#
Thank you for reading, the above is "how to format logical partitions on CentOS system" content, after the study of this article, I believe we have a deeper understanding of how to format logical partitions on CentOS system, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!
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.