侧边栏壁纸
博主头像
WinJay博主等级

博观而约取 厚积而薄发

  • 累计撰写 319 篇文章
  • 累计创建 169 个标签
  • 累计收到 1 条评论
隐藏侧边栏

使用parted命令对大容量盘进行分区及挂载

WinJay
2019-07-02 / 0 评论 / 0 点赞 / 128 阅读 / 5,076 字 / 正在检测是否收录...
温馨提示:
本文最后更新于 2022-06-08,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

使用parted命令对大容量盘进行分区及挂载

MBR分区表:(MBR含义:主引导记录)
所支持的最大卷:2T (T; terabytes,1TB=1024GB)
对分区的设限:最多4个主分区或3个主分区加一个扩展分区。

GPT分区表:(GPT含义:GUID分区表)
支持最大卷:18EB,(E:exabytes,1EB=1024TB)
每个磁盘最多支持128个分区

对新磁盘进行分区

[root@Node01 /]# parted /dev/sdh
GNU Parted 3.1
Using /dev/sdh
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p                                                                
Error: /dev/sdh: unrecognised disk label
Model: DGC VRAID (scsi)                                                   
Disk /dev/sdh: 2684GB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags: 
(parted)   mklabel gpt														#设置分区类型为gpt
Error: Input/output error during read on /dev/sdh
Retry/Ignore/Cancel? Ignore													#忽略错误


# 整个分区流程如下:
[root@Node01 /]# parted /dev/sdh
(parted) p										#可以输入p或print打印磁盘信息,查看分区的情况,找到起始和结束位置。
(parted) mklabel gpt							#设置分区类型为gpt
(parted) mkpart primary 0% 100%					#primary指分区类型为主分区,0是分区开始位置,100%是分区结束位置。相同的命令为:mkpart primary 0 XXXXXX结束的空间
(parted) quit									#完成后用quit命令退出。


------20211210-----
[root@localhost mnt]# parted /dev/vdb 
GNU Parted 3.1
使用 /dev/vdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p                                                                
错误: /dev/vdb: unrecognised disk label
Model: Virtio Block Device (virtblk)                                      
Disk /dev/vdb: 644GB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags: 
(parted)                                                                  
(parted)                                                                  
(parted)                                                                  
(parted)                                                                  
(parted)                                                                  
(parted)                                                                  
(parted) mklabel gpt                                                      
(parted) p                                                                
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 644GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start  End  Size  File system  Name  标志

(parted) mkpart primary 0% 100%
(parted) p                                                                
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 644GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End    Size   File system  Name     标志
 1      1049kB  644GB  644GB               primary

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




#--------------------------20220608-------------------------

WARNING! The remote SSH server rejected X11 forwarding request.
Last login: Wed Jun  8 03:35:25 2022
[root@Kuboard ~]# df -hl
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 3.9G     0  3.9G   0% /dev
tmpfs                    3.9G     0  3.9G   0% /dev/shm
tmpfs                    3.9G  8.9M  3.9G   1% /run
tmpfs                    3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/mapper/centos-root  200G  1.3G  199G   1% /
/dev/sda1                597M  148M  449M  25% /boot
tmpfs                    783M     0  783M   0% /run/user/0
[root@Kuboard ~]# lsblk
NAME            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda               8:0    0 200.6G  0 disk 
├─sda1            8:1    0   600M  0 part /boot
└─sda2            8:2    0   200G  0 part 
  └─centos-root 253:0    0   200G  0 lvm  /
sdb               8:16   0     2T  0 disk 
sr0              11:0    1   4.4G  0 rom


[root@Kuboard ~]# parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p                                                                
Error: /dev/sdb: unrecognised disk label
Model: VMware Virtual disk (scsi)                                         
Disk /dev/sdb: 2199GB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags: 
(parted) mklabel gpt                                                      
(parted) mkpart primary 0% 100%                                           
(parted) p                                                                
Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 2199GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  2199GB  2199GB               primary

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

image-20220608155255382

在退出之前可以先print一下,打印当前分区,查看分区设置是否正确。

格式化磁盘

操作完以上,即可对新分区进行格式化操作,mkfs.xfs /dev/sdb1

格式化完成后即可进行挂载。

通过使用blkid命令可以查看到当前的硬盘分区信息:

[root@Kuboard ~]# mkfs.xfs /dev/sdb1                                      
meta-data=/dev/sdb1              isize=512    agcount=4, agsize=134217600 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=536870400, imaxpct=5
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=262143, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

image-20220608155639556

查看磁盘信息:

[root@Kuboard ~]# blkid
/dev/sda1: UUID="bb3dad47-0964-4338-90a6-81ba5933de3c" TYPE="xfs" 
/dev/sda2: UUID="lOSTtP-tsgf-f5MH-iceg-e8Jw-5770-gD8955" TYPE="LVM2_member" 
/dev/sdb1: UUID="c4483afc-d160-4a2d-ac1a-34099e3c5b99" TYPE="xfs" PARTLABEL="primary" PARTUUID="7a5019fb-49b8-4e06-b150-e047607b549a" 
/dev/sr0: UUID="2020-11-04-11-36-43-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos" 
/dev/mapper/centos-root: UUID="459c7a26-6c0a-498e-8869-304109b251bd" TYPE="xfs" 

[root@Kuboard ~]# lsblk
NAME            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda               8:0    0 200.6G  0 disk 
├─sda1            8:1    0   600M  0 part /boot
└─sda2            8:2    0   200G  0 part 
  └─centos-root 253:0    0   200G  0 lvm  /
sdb               8:16   0     2T  0 disk 
└─sdb1            8:17   0     2T  0 part 
sr0              11:0    1   4.4G  0 rom  

image-20220608155830803

测试挂载磁盘

[root@Kuboard ~]# cd /mnt/

[root@Kuboard mnt]# mkdir Storage
[root@Kuboard mnt]# mount /dev/sdb1 /mnt/Storage/
[root@Kuboard mnt]# df -hl
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 3.9G     0  3.9G   0% /dev
tmpfs                    3.9G     0  3.9G   0% /dev/shm
tmpfs                    3.9G  8.9M  3.9G   1% /run
tmpfs                    3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/mapper/centos-root  200G  1.3G  199G   1% /
/dev/sda1                597M  148M  449M  25% /boot
tmpfs                    783M     0  783M   0% /run/user/0
/dev/sdb1                2.0T   33M  2.0T   1% /mnt/Storage

image-20220608160020638

配置开机自动挂载

[root@Kuboard mnt]# vi /etc/fstab 
#新增如下信息:

UUID=c4483afc-d160-4a2d-ac1a-34099e3c5b99	/mnt/Storage	xfs	defaults	0 0


[root@Kuboard mnt]# umount /mnt/Storage/
[root@Kuboard mnt]# df -hl
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 3.9G     0  3.9G   0% /dev
tmpfs                    3.9G     0  3.9G   0% /dev/shm
tmpfs                    3.9G  8.9M  3.9G   1% /run
tmpfs                    3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/mapper/centos-root  200G  1.3G  199G   1% /
/dev/sda1                597M  148M  449M  25% /boot
tmpfs                    783M     0  783M   0% /run/user/0


[root@Kuboard mnt]# mount -a
[root@Kuboard mnt]# df -hl
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 3.9G     0  3.9G   0% /dev
tmpfs                    3.9G     0  3.9G   0% /dev/shm
tmpfs                    3.9G  8.9M  3.9G   1% /run
tmpfs                    3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/mapper/centos-root  200G  1.3G  199G   1% /
/dev/sda1                597M  148M  449M  25% /boot
tmpfs                    783M     0  783M   0% /run/user/0
/dev/sdb1                2.0T   33M  2.0T   1% /mnt/Storage


image-20220608160245044

0

评论区