Sample code for partition formatting of centos6 super 20TB disk

  • 2021-08-12 04:19:16
  • OfStack

1. Server environment configuration:

1. Check the disk partition:

In the recent project, a service was migrated from virtual machine to physical machine. The service disk user made raid himself, configured Raid1 for 3.8 TB 2 disks, and then configured Raid5 for 3.8 TB 6 disks. raid1 for installing sda 3.8 TB space used by operating system has been partitioned. 3.8TB*6 Disk sdb Total 20TB space needs to be partitioned and mounted to the system for storage. The steps are as follows:

1.1 Query to confirm sdb status:


# fdisk -l
WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted.
Disk /dev/sda: 4000.2 GB, 4000225165312 bytes
255 heads, 63 sectors/track, 486333 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

  Device Boot   Start     End   Blocks  Id System
/dev/sda1        1   267350 2147483647+ ee GPT
Partition 1 does not start on physical sector boundary.
WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted
Disk /dev/sdb: 20001.1 GB, 20001125826560 bytes
255 heads, 63 sectors/track, 2431665 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

  Device Boot   Start     End   Blocks  Id System
/dev/sdb1        1   267350 2147483647+ ee GPT
Partition 1 does not start on physical sector boundary.

Disk /dev/mapper/VolGroup-LogVol00: 2531.7 GB, 2531690283008 bytes
255 heads, 63 sectors/track, 307793 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/VolGroup-LogVol01: 1468.0 GB, 1468006400000 bytes
255 heads, 63 sectors/track, 178474 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

1.2, sdb Disk Partition:


# parted /dev/sdb
GNU Parted 2.1
 Use  /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.                       
(parted) print    # View the current partition                        
Model: LSI MRSASRoMB-8i (scsi)
Disk /dev/sdb: 20.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt

Number Start End Size File system Name  Sign 

(parted) mkpart primary 0% 100%    # Divide all disk space into 1 District                             
(parted) print      # Query the disk partition again                          
Model: LSI MRSASRoMB-8i (scsi)
Disk /dev/sdb: 20.0TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt

Number Start  End   Size  File system Name    Sign 
 1   1049kB 20.0TB 20.0TB        primary                                 
(parted) quit                               
 Information : You may need to update /etc/fstab.

1.3. Correct formatting method:

a, formatting with mkfs command (as follows) cannot be formatted. Check for mkfs. ext4 cannot format partitions above 16TB, because Centos6.10 e2fsprogs version is 1.41. 12 and needs to be upgraded to 1.42 version


mkfs.ext4 /dev/sdb1     # Cannot be formatted in this way 

b, upgrade e2fsprogs version:


tar zvxf e2fsprogs-1.42.10.tar.gz 
cd e2fsprogs-1.42.10
mkdir build
cd build/
../configure 
make
make install  ## If there is an "ignore" error, it is normal. 

c, query the sector size of the required partition


# df -h
Disk /dev/sdb: 20001.1 GB, 20001125826560 bytes
255 heads, 63 sectors/track, 2431665 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

  Device Boot   Start     End   Blocks  Id System
/dev/sdb1        1   267350 2147483647+ ee GPT
Partition 1 does not start on physical sector boundary.

d, the command to reformat the disk is as follows:


# mke2fs -O 64bit,has_journal,extents,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize -i 267350 /dev/sdb1
mke2fs 1.42.10 (18-May-2014)

Warning: the fs_type huge is not defined in mke2fs.conf

Creating filesystem with 4883086848 4k blocks and 76298240 inodes
Filesystem UUID: 74dabc93-177b-4531-aab9-e55a1e2efe9d
Superblock backups stored on blocks: 
  32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
  4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
  102400000, 214990848, 512000000, 550731776, 644972544, 1934917632, 
  2560000000, 3855122432

Allocating group tables:  Finish               
 Writing inode Table :  Finish               
Creating journal (32768 blocks):  Finish 
Writing superblocks and filesystem accounting information:  Finish     

This filesystem will be automatically checked every 34 mounts or      ## Prompt 180 Heavenly problem 
180 days, whichever comes first. Use tune2fs -c or -i to override.

e, solve the 180-day problem


# tune2fs -i 3650d /dev/sdb1
tune2fs 1.42.10 (18-May-2014)
Setting interval between checks to 315360000 seconds

# Make sure the time is correct 
# tune2fs -l /dev/sdb1
tune2fs 1.42.10 (18-May-2014)
Filesystem volume name:  <none>
Last mounted on:     <not available>
Filesystem UUID:     74dabc93-177b-4531-aab9-e55a1e2efe9d
Filesystem magic number: 0xEF53
Filesystem revision #:  1 (dynamic)
Filesystem features:   has_journal ext_attr 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:       76298240
Block count:       4883086848
Reserved block count:   244154342
Free blocks:       4877929145
Free inodes:       76298229
First block:       0
Block size:        4096
Fragment size:      4096
Group descriptor size:  64
Blocks per group:     32768
Fragments per group:   32768
Inodes per group:     512
Inode blocks per group:  32
Flex block group size:  16
Filesystem created:    Fri Jun 5 17:08:54 2020
Last mount time:     Fri Jun 5 17:14:34 2020
Last write time:     Fri Jun 5 17:15:58 2020
Mount count:       1
Maximum mount count:   34
Last checked:       Fri Jun 5 17:08:54 2020           ## Start time 
Check interval:      315360000 (121 months, 2 weeks, 6 days)
Next check after:     Mon Jun 3 17:08:54 2030           ## Final time 
Lifetime writes:     349 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:   0f4e7ee0-4aec-41cf-b81a-7d5a4ed045c4
Journal backup:      inode blocks

1.4. Mount disk:

a, mount disk


# cd /
# mkdir data
# mount /dev/sdb1 /data
# df -Th
Filesystem      Type  Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-LogVol00
           ext4  2.3T  12G 2.2T  1% /
tmpfs        tmpfs  32G 144K  32G  1% /dev/shm
/dev/sda1      ext4  477M  41M 412M  9% /boot
/dev/mapper/VolGroup-LogVol01
           ext4  1.4T  70M 1.3T  1% /home
/dev/sdb1      ext4  19T  20K  18T  1% /data

b, set up boot mount

Add 1 line at the end of the file as follows, paying attention to the actual file path.


vim /etc/fstab

/dev/sdb1        /data          ext4  defaults    0 0


Related articles: