磁盘划区

reference

https://www.cnblogs.com/kevingrace/p/7612741.html
https://blog.csdn.net/ninghao2015/article/details/73382405
https://www.cnblogs.com/wq242424/p/9187285.html

常用命令

lsblk,df,fdisk

开机自动挂载

vi /etc/fstab
/dev/sdb1 /home/admin/test ext4 defaults 0 0

# 挂载所有
mount -a

磁盘格式化

mkfs.ext4 /dev/sdb2

fdisk划分

fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xeea96a98.

WARNING: The size of this disk is 7.0 TB (6997575467008 bytes).
DOS partition table format can not be used on drives for volumes
larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID 
partition table format (GPT).

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-4294967295, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-4294967294, default 4294967294): 4194030000
Partition 1 of type Linux and of size 2 TiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost admin]# 
[root@localhost admin]# 
[root@localhost admin]# lsblk 
NAME            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda               8:0    0   931G  0 disk 
├─sda1            8:1    0     1G  0 part /boot
└─sda2            8:2    0   930G  0 part 
  ├─centos-root 253:0    0    50G  0 lvm  /
  ├─centos-swap 253:1    0  15.8G  0 lvm  [SWAP]
  └─centos-home 253:2    0 864.2G  0 lvm  /home
sdb               8:16   0   6.4T  0 disk 
└─sdb1            8:17   0     2T  0 part 

parted 划分

[root@localhost admin]# parted /dev/sdb 
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p                                                                
Model: DELL PERC H700 (scsi)
Disk /dev/sdb: 6998GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start  End  Size  Type  File system  Flags

(parted) mklabel gpt                                                      
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you
want to continue?
Yes/No? y                                                                 
(parted) mkpart                                                           
Partition name?  []? sdb1                                                 
File system type?  [ext2]? ext4
Start? 0                                                                  
End? 3000GB
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? ignore                                                     
(parted) p                                                                
Model: DELL PERC H700 (scsi)
Disk /dev/sdb: 6998GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name  Flags
 1      17.4kB  3000GB  3000GB               sdb1

(parted) p                                                                
Model: DELL PERC H700 (scsi)
Disk /dev/sdb: 6998GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name  Flags
 1      17.4kB  3000GB  3000GB               sdb1

(parted) p                                                                
Model: DELL PERC H700 (scsi)
Disk /dev/sdb: 6998GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name  Flags
 1      17.4kB  3000GB  3000GB               sdb1

(parted) mkpart                                                           
Partition name?  []? sdb2                                                 
File system type?  [ext2]? ext4                                           
Start?                                                                    
Start? 3000GB
End? 6998GB                                                               
(parted) p                                                                
Model: DELL PERC H700 (scsi)
Disk /dev/sdb: 6998GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name  Flags
 1      17.4kB  3000GB  3000GB               sdb1
 2      3000GB  6998GB  3998GB               sdb2

(parted) quit                                                             
Information: You may need to update /etc/fstab.

[root@localhost admin]#                                                   
[root@localhost admin]# 
[root@localhost admin]# lsblk 
NAME            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda               8:0    0   931G  0 disk 
├─sda1            8:1    0     1G  0 part /boot
└─sda2            8:2    0   930G  0 part 
  ├─centos-root 253:0    0    50G  0 lvm  /
  ├─centos-swap 253:1    0  15.8G  0 lvm  [SWAP]
  └─centos-home 253:2    0 864.2G  0 lvm  /home
sdb               8:16   0   6.4T  0 disk 
├─sdb1            8:17   0   2.7T  0 part 
└─sdb2            8:18   0   3.7T  0 part 

注意Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel? ignore
这句话虽然不影响,但是可以合理划分解决
reference :https://www.cnblogs.com/wq242424/p/9187285.html

[root@localhost zhang]# cat /sys/block/sdb/queue/optimal_io_size
0
[root@localhost zhang]# cat /sys/block/sdb/queue/minimum_io_size
512
[root@localhost zhang]# cat /sys/block/sdb/alignment_offset
0
[root@localhost zhang]# cat /sys/block/sdb/queue/physical_block_size
512
(parted) mkpart primary 2048s 25%
(parted) mkpart primary 25% 50%                                     
(parted) mkpart primary 50% 75%                                       
(parted) mkpart primary 75% 100%
(parted)                                                                                                                         
(parted) align-check optimal 1
1 aligned
(parted)                                                                                                                               
(parted) quit 
Information: You may need to update /etc/fstab.
[root@localhost zhang]#                                            
[root@localhost zhang]# 
[root@localhost zhang]# lsblk 
NAME            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda               8:0    0 136.1G  0 disk 
├─sda1            8:1    0     1G  0 part /boot
└─sda2            8:2    0 135.1G  0 part 
  ├─centos-root 253:0    0    50G  0 lvm  /
  ├─centos-swap 253:1    0  13.6G  0 lvm  [SWAP]
  └─centos-home 253:2    0  71.5G  0 lvm  /home
sdb               8:16   0   9.1T  0 disk 
├─sdb1            8:17   0   2.3T  0 part 
├─sdb2            8:18   0   2.3T  0 part 
├─sdb3            8:19   0   2.3T  0 part 
└─sdb4            8:20   0   2.3T  0 part 

你可能感兴趣的:(磁盘划区)