Parted分区大容量磁盘

创建了新的虚拟磁盘10T , 挂载后分区格式化
一.fdisk无法创建大容量的分区
Fileserver:~ # fdisk /dev/sdb

Welcome to fdisk (util-linux 2.29.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.
The size of this disk is 9.8 TiB (10737418240000 bytes). DOS partition table format can not be used on drives for volumes larger than 2199023255040 bytes for 512-byte sectors. Use GUID partition table format (GPT).
Created a new DOS disklabel with disk identifier 0x0506ad6d.
Command (m for help): m

Help:
  DOS (MBR)
   a   toggle a bootable flag
   b   edit nested BSD disklabel
   c   toggle the dos compatibility flag
  Generic
   d   delete a partition
   F   list free unpartitioned space
   l   list known partition types
   n   add a new partition
   p   print the partition table
   t   change a partition type
   v   verify the partition table
   i   print information about a partition
  Misc
   m   print this menu
   u   change display/entry units
   x   extra functionality (experts only)
  Script
   I   load disk layout from sfdisk script file
   O   dump disk layout to sfdisk script file
  Save & Exit
   w   write table to disk and exit
   q   quit without saving changes

  Create a new label
   g   create a new empty GPT partition table
   G   create a new empty SGI (IRIX) partition table
   o   create a new empty DOS partition table
   s   create a new empty Sun partition table

Command (m for help): p
Disk /dev/sdb: 9.8 TiB, 10737418240000 bytes, 20971520000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x0506ad6d

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 
First sector (2048-4294967295, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-4294967294, default 4294967294): 

Created a new partition 1 of type 'Linux' and of size 2 TiB.

Command (m for help): p
Disk /dev/sdb: 9.8 TiB, 10737418240000 bytes, 20971520000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x0506ad6d

Device     Boot Start        End    Sectors Size Id Type
/dev/sdb1        2048 4294967294 4294965247   2T 83 Linux

看起来只能创建2T的分区。
Command (m for help): q


二.使用Parted进行分区

Fileserver:~ # parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) help                                                             
  align-check TYPE N                        check partition N for TYPE(min|opt) alignment
  help [COMMAND]                           print general help, or help on COMMAND
  mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)
  mkpart PART-TYPE [FS-TYPE] START END     make a partition
  name NUMBER NAME                         name partition NUMBER as NAME
  print [devices|free|list,all|NUMBER]     display the partition table, available devices, free space, all found partitions, or a particular partition
  quit                                     exit program
  rescue START END                         rescue a lost partition near START and END
  resize NUMBER END                        change end sector of partition NUMBER
  rm NUMBER                                delete partition NUMBER
  select DEVICE                            choose the device to edit
  disk_set FLAG STATE                      change the FLAG on selected device
  disk_toggle [FLAG]                       toggle the state of FLAG on selected device
  set NUMBER FLAG STATE                    change the FLAG on partition NUMBER
  toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBER
  unit UNIT                                set the default unit to UNIT
  version                                  display the version number and copyright information of GNU Parted
(parted) mklabel GPT
(parted) p                                                                
Model: Msft Virtual Disk (scsi)
Disk /dev/sdb: 10.7TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start  End  Size  File system  Name  Flags

(parted) mkpart                                                           
Partition name?  []?                                                      
File system type?  [ext2]?                                                
Start? 0.000                                                              
End? 9000000     先划9000G练手                                                         
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? Ignore
(parted) p                                                                
Model: Msft Virtual Disk (scsi)
Disk /dev/sdb: 10.7TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

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

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

三.查看分区结果
Fileserver:~ # fdisk -l
Disk /dev/sdb: 9.8 TiB, 10737418240000 bytes, 20971520000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 7C734145-C793-4C60-BEB6-60BC58EA2BBA

Device     Start         End     Sectors  Size Type
/dev/sdb1     34 17578125000 17578124967  8.2T Microsoft basic data

四.格式化分区
Fileserver:~ # mkfs.ext4 /dev/sdb1
mke2fs 1.42.11 (09-Jul-2014)
/dev/sdb1 alignment is offset by 3072 bytes.
This may result in very poor performance, (re)-partitioning suggested.
Discarding device blocks: done                            
Creating filesystem with 2197265620 4k blocks and 274661376 inodes
Filesystem UUID: d9848b2b-09d7-4c4d-95cf-ca5afdf1467a
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

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

五.扩容分区
Fileserver:~ # lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sdb      8:16   0  9.8T  0 disk 
└─sdb1   8:17   0  8.2T  0 part 

Fileserver:~ # 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: Msft Virtual Disk (scsi)
Disk /dev/sdb: 10.7TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name  Flags
 1      17.4kB  9000GB  9000GB  ext4

(parted) rm 1          #删除                                                   
(parted) p                                                               
Model: Msft Virtual Disk (scsi)
Disk /dev/sdb: 10.7TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start  End  Size  File system  Name  Flags

(parted) mkpart opt 0.000 10000000              #创建                           
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? Ignore                                                     
(parted) p                                                                
Model: Msft Virtual Disk (scsi)
Disk /dev/sdb: 10.7TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size     File system  Name  Flags
 1      17.4kB  10.0TB  10000GB  ext4         opt

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

Fileserver:~ # e2fsck -f /dev/sdb1                  #检查
e2fsck 1.42.11 (09-Jul-2014)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sdb1: 11/274661376 files (0.0% non-contiguous), 17356797/2197265620 blocks
Fileserver:~ # resize2fs /dev/sdb1               #扩展分区大小
resize2fs 1.42.11 (09-Jul-2014)
Resizing the filesystem on /dev/sdb1 to 2441406245 (4k) blocks.
The filesystem on /dev/sdb1 is now 2441406245 blocks long.

Fileserver:~ # lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sdb      8:16   0  9.8T  0 disk 
└─sdb1   8:17   0  9.1T  0 part 

六.加入/etc/fstab自动挂载
Fileserver:~ # blkid              #查看UUID
/dev/sda1: UUID="b73fc08c-5be7-4e57-8f96-95910dc78724" TYPE="swap" PARTUUID="000b0496-01"
/dev/sda2: UUID="2d34979e-fcfb-4966-b11b-7a76506c4850" TYPE="xfs" PARTUUID="000b0496-02"
/dev/sdb1: UUID="d9848b2b-09d7-4c4d-95cf-ca5afdf1467a" TYPE="ext4" PARTLABEL="opt" PARTUUID="9905a1e8-428b-45f8-9677-612b78fbe416"
Fileserver:~  # echo "UUID=d9848b2b-09d7-4c4d-95cf-ca5afdf1467a /app/files ext4 defaults 0 0" >> /etc/fstab

  • 12
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值