[root@oldboyedu ~]# 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.
Command (m for help): 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 C: 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 eb BeOS fs
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD ee GPT
f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ef EFI (FAT-12/16/
10 OPUS 55 EZ-Drive a7 NeXTSTEP f0 Linux/PA-RISC b
11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f1 SpeedStor
12 Compaq diagnost 5c Priam Edisk a9 NetBSD f4 SpeedStor
14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f2 DOS secondary
16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ fb VMware VMFS
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fc VMware VMKCORE
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fd Linux raid auto
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 75 PC/IX be Solaris boot ff BBT
1e Hidden W95 FAT1 80 Old Minix
Command (m for help): p
Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 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 label type: dos
Disk identifier: 0xbc9b0906
Device Boot Start End Blocks Id System
/dev/sdb1 2048 309247 153600 83 Linux
/dev/sdb2 309248 616447 153600 83 Linux
/dev/sdb3 616448 923647 153600 83 Linux
/dev/sdb4 923648 2097151 586752 5 Extended
/dev/sdb5 925696 1232895 153600 83 Linux
/dev/sdb6 1234944 1542143 153600 83 Linux
/dev/sdb7 1544192 1851391 153600 83 Linux
Command (m for help): t
Partition number (1-7, default 7): 7
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 C: 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 eb BeOS fs
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD ee GPT
f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ef EFI (FAT-12/16/
10 OPUS 55 EZ-Drive a7 NeXTSTEP f0 Linux/PA-RISC b
11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f1 SpeedStor
12 Compaq diagnost 5c Priam Edisk a9 NetBSD f4 SpeedStor
14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f2 DOS secondary
16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ fb VMware VMFS
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fc VMware VMKCORE
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fd Linux raid auto
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 75 PC/IX be Solaris boot ff BBT
1e Hidden W95 FAT1 80 Old Minix
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): p
Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 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 label type: dos
Disk identifier: 0xbc9b0906
Device Boot Start End Blocks Id System
/dev/sdb1 2048 309247 153600 83 Linux
/dev/sdb2 309248 616447 153600 83 Linux
/dev/sdb3 616448 923647 153600 83 Linux
/dev/sdb4 923648 2097151 586752 5 Extended
/dev/sdb5 925696 1232895 153600 83 Linux
/dev/sdb6 1234944 1542143 153600 83 Linux
/dev/sdb7 1544192 1851391 153600 8e Linux LVM
Command (m for help):
dd if=/dev/sda of=/dev/sdc bs=512 count=10240
来源 生成文件系统 block大小 块个数
[root@oldboyedu ~]# dd if=/dev/sda of=/dev/sdc bs=512 count=10240
10240+0 records in
10240+0 records out
5242880 bytes (5.2 MB) copied, 0.0810606 s, 64.7 MB/s
[root@oldboyedu ~]# ls -l /dev/sdc
-rw-r--r-- 1 root root 5242880 Mar 29 09:55 /dev/sdc
[root@oldboyedu ~]# file /dev/sdc
/dev/sdc: x86 boot sector; partition 1: ID=0x83, active, starthead 32, startsector 2048, 524288 sectors; partition 2: ID=0x82, starthead 194, startsector 526336, 1572864 sectors; partition 3: ID=0x83, starthead 170, startsector 2099200, 39843840 sectors, code offset 0x63
[root@oldboyedu ~]# cat /proc/partitions
major minor #blocks name
8 16 1048576 sdb
8 17 153600 sdb1
8 18 153600 sdb2
8 19 153600 sdb3
8 20 1 sdb4
8 21 153600 sdb5
8 22 153600 sdb6
8 23 153600 sdb7
8 0 20971520 sda
8 1 262144 sda1
8 2 786432 sda2
8 3 19921920 sda3
11 0 1048575 sr0
[root@oldboyedu ~]# partprobe /dev/sdb
[root@oldboyedu ~]# partprobe /dev/sdb
[root@oldboyedu ~]# partprobe /dev/sdb
作业:自学:如何用一条fdisk命令回车完成上述分区。
需求:RAID5大小6T,已经装了系统了, 额外添加4块2T盘
现有一个做了RAID5的硬盘,要求分三个区,
硬盘总分区大小: 6.2T
/data0 4.8T
/data1 1T
4G (无需格式化,作DRBD+Hearbeat+MySQL高可用集群)
parted /dev/sdb mklabel gpt #<==修改分区格式为gpt。
parted /dev/sdb mkpart primary 0 4800000 #<==创建一个4.8T主分区
parted /dev/sdb mkpart primary 4800001 5800001 #<==创建一个1T主分区
parted /dev/sdb mkpart primary 5800002 5804098 #<==创建一个4G主分区
parted /dev/sdb p
=====================一键分区============================
parted /dev/sdb mklabel gpt
parted /dev/sdb mkpart primary 0 480 I
parted /dev/sdb mkpart primary 481 580 I
parted /dev/sdb p
=========================================================
[root@oldboyedu ~]# 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
resizepart NUMBER END resize 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
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? Yes
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
(parted)
(parted) mkpart primary 481 580 I
(parted) mkpart primary 481 580
Warning: You requested a partition from 481MB to 580MB (sectors 939453..1132812).
The closest location we can manage is 481MB to 481MB (sectors 940031..940031).
Is this still acceptable to you?
Yes/No? yes
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? I
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 17.4kB 480MB 480MB primary
3 481MB 481MB 512B primary
2 481MB 580MB 98.6MB primary
(parted) mkpart logic 581 600
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 17.4kB 480MB 480MB primary
3 481MB 481MB 512B primary
2 481MB 580MB 98.6MB primary
4 581MB 600MB 18.9MB logic
(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
resizepart NUMBER END resize 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) rm 4
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 17.4kB 480MB 480MB primary
3 481MB 481MB 512B primary
2 481MB 580MB 98.6MB primary
(parted)
(parted) rm 4 #删除
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 17.4kB 480MB 480MB primary
3 481MB 481MB 512B primary
2 481MB 580MB 98.6MB primary
======================================================================
[root@oldboyedu ~]# parted /dev/sdb #交互式开始分区
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) help
(parted) mklabel gpt #修改分区格式为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? Yes
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt #修改结果
(parted) mkpart primary 0 480 #创建第一个主分区480M。
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? Ignore #忽略提示。
(parted) mkpart primary 481 580 #创建第二个主分区100M。
Warning: You requested a partition from 481MB to 580MB (sectors 939453..1132812).
The closest location we can manage is 481MB to 481MB (sectors 940031..940031).
Is this still acceptable to you?
Yes/No? Y
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? I #忽略提示。
(parted) mkpart logic 581 600 #创建一个20M逻辑分区。
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 17.4kB 480MB 480MB primary
3 481MB 481MB 512B primary
2 481MB 580MB 98.6MB primary
4 581MB 600MB 18.9MB logic
(parted) rm 4 #删除
(parted) p
问题需求:刚买的服务器 4块2T 刚买,要做RAID5,装系统怎么搞定?
方法1:Raid制作视频,Raid里可以支持RAID5后,6T,允许你把6T分成虚拟磁盘。
200G分成第一个虚拟磁盘剩下不分留着装系统后(parted)。
方法2:装系统过程中有这个功能,系统镜像支持GPT格式分区,很隐蔽。
方法3:引导工具,进入然后用parted分区。
生产场景分区方案:
3种。
分区知识:
(1)什么是分区,为什么要分区?
(2)磁盘和分区在Linux里的命名。
(3)磁盘分区类型和特点:
(4)磁盘分区工作原理:
(5)磁盘分区实战
(6)生产场景分区方案:4种。参考前面课程。
获得使用的磁盘过程====买房入住生活的过程
磁盘: 房子
RAID: 多套房子打通
分区: 隔断/几居室/卧室/卫生间/厨房
==============================
文件系统:装修风格/中式/欧式/美式
格式化过程: 装修的过程
挂载: 开门、开窗住人使用
磁盘管理:生活中收拾屋子,打扫卫生,修修补补。
满足女生本能的需求,比满足意识层的需求更重要。
文件系统:
1、什么是文件系统?
计算机存储和组织数据的方法或者机制。落地是一个软件。
2、为什么需要文件系统?
磁盘、物理介质、磁粒子物理元素。 硬件需要软件驱动使用,磁盘需要文件系统驱动。
文件系统实现通过磁盘管理规划、存取数据。
3、文件系统有哪些种类?
Windows:NTFS、fat32、msdos
Linux:ext2、ext3(C5)、ext4(C6)、Xfs(C7)、btrfs
4、创建文件系统实践
5、文件系统原理(ext文件系统)、文件系统特点
6、企业中如何选择文件系统。
7、企业里如何优化文件系统?
网友评论