本文共 6823 字,大约阅读时间需要 22 分钟。
MBR最大分区不超过2T,1块硬盘最多4个主分区,也可以3(主)+1(扩展下N个逻辑分区);GPT支持128个分区,全是主分区; [root@localhost ~]#hexdump -C -n 512 /dev/sdb 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| [root@localhost ~]# parted /dev/sdb mklabel gpt #命令命令最后选择分区类型GPT或msdos Information: You may need to update /etc/fstab. [root@localhost ~]# fdisk -l /dev/sdb Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: B49D2C14-D087-486B-8ABF-72D3809D82E3 [root@localhost ~]# parted /dev/sdb print Model: VMware, VMware Virtual S (scsi) Sector size (logical/physical): 512B/512B Number Start End Size File system Name Flags 4、分区:选择主分区,100M,起始1M,终止101M,primary表示主分区。 [root@localhost ~]#parted /dev/sdb mkpart primary 1 101 [root@localhost ~]#parted /dev/sdb print Model: VMware, VMware Virtual S (scsi) Sector size (logical/physical): 512B/512B Number Start End Size File system Name Flags 1 1049kB 101MB 99.6MB primary NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT ├─sda1 8:1 0 1G 0 part /boot ├─sda2 8:2 0 100G 0 part / ├─sda3 8:3 0 50G 0 part /data └─sda5 8:5 0 4G 0 part [SWAP] [root@localhost ~]#parted /dev/sdb rm 1 NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT ├─sda1 8:1 0 1G 0 part /boot ├─sda2 8:2 0 100G 0 part / ├─sda3 8:3 0 50G 0 part /data └─sda5 8:5 0 4G 0 part [SWAP] 7、分区必须是连续的,无法跨越,如第一个分区是1-100M,第二个是101-202M, 如果删除1-100M,,再重新建立分区,如1-300M,实际是100M 8、删[root@localhost ~]#dd if=/dev/zero of=/dev/sdb bs=1 count=512 [root@localhost ~]#dd if=/dev/zero of=/dev/sdb bs=1 count=512 512 bytes copied, 0.00275154 s, 186 kB/s [root@localhost ~]#fdisk -l /dev/sdb Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes [root@localhost ~]#fdisk /dev/sdb Welcome to fdisk (util-linux 2.32.1). 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. Created a new DOS disklabel with disk identifier 0x1de77d65. p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions) Partition number (1-4, default 1): 1 First sector (2048-20971519, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (2048-20971519, default 20971519): +5G CreateCommand (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. d a new partition 1 of type 'Linux' and of size 5 GiB. centos7 w存盘退出后,分区同步:partprobe centos6 w存盘退出后,增加分区同步:partx -a /dev/sdb ;删除分区同步 partx -d --nr 6-8 /dev/sdb (6-8删除分区编号)(柱面单位,1个柱面:255*63*512=8M) [root@localhost ~]#fdisk /dev/sdb Welcome to fdisk (util-linux 2.32.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Partition number (1,2,5, default 5): 5 Partition 5 has been deleted. Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x1de77d65 Device Boot Start End Sectors Size Id Type /dev/sdb1 2048 10487807 10485760 5G 83 Linux /dev/sdb2 10487808 14682111 4194304 2G 5 Extended The partition table has been altered. Calling ioctl() to re-read partition table. PS:分区编号自动递增,如分区编号是:12345,删除3,则结果:1234. 分区挂载配置最好写分区UUID,唯一不变,写分区号,删除分区影响挂载配置文件。 [root@localhost ~]#hexdump -C -n 512 /dev/sdb 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 000001b0 00 00 00 00 00 00 00 00 65 7d e7 1d 00 00 00 20 |........e}..... | 000001c0 21 00 83 d5 89 8c 00 08 00 00 00 00 a0 00 00 d5 |!...............| 000001d0 8a 8c 05 ea d9 91 00 08 a0 00 00 00 40 00 00 00 |............@...| 000001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.| [root@localhost ~]#fdisk /dev/sdb Welcome to fdisk (util-linux 2.32.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Partition number (1,2, default 2): 2 Hex code (type L to list all codes): l 0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris 1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT- 2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT- 3 XENIX usr 3c PartitionMagic 84 OS/2 hidden or c6 DRDOS/sec (FAT- 4 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx 5 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data 6 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / . 7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility 8 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt 9 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi ea Rufus alignment e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD eb BeOS fs f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ee GPT 10 OPUS 55 EZ-Drive a7 NeXTSTEP ef EFI (FAT-12/16/ 11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f0 Linux/PA-RISC b 12 Compaq diagnost 5c Priam Edisk a9 NetBSD f1 SpeedStor 14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f4 SpeedStor 16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ f2 DOS secondary 17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fb VMware VMFS 18 AST SmartSleep 65 Novell Netware b8 BSDI swap fc VMware VMKCORE 1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fd Linux raid auto 1c Hidden W95 FAT3 75 PC/IX bc Acronis FAT32 L fe LANstep 1e Hidden W95 FAT1 80 Old Minix be Solaris boot ff BBT Hex code (type L to list all codes): 2.3 gdisk分区工具同等于fdisk分区工具。 转载地址:http://fyuki.baihongyu.com/