● BIOS 加电自检 ( Power On Self Test – POST )BIOS执行内存地址的跳转指令,跳转到固化在ROM中的自检程序,对系统硬件(包括内存)进行检查 ● 读取主引导记录(MBR),当BIOS检查到硬件正常并与 CMOS 中的设置相符后,按照 CMOS 中对启动设备的设置顺序检测可用的启动设备,BIOS将相应启动设备的第一个扇区(也就是MBR扇区)读入内存 ● 检查MBR的结束标志位是否等于55AAH,若不等于则转去尝试其他启动设备,如果没有启动设备满足要求则显示“NO ROM BASIC”然后死机 ● 当检测到有启动设备满足要求后,BIOS将控制权交给相应启动设备,启动设备的MBR将自己复制到0000:0600H处,然后继续执行 ● 根据MBR中的引导代码启动引导程序,进入下一个引导环节
mke2fs 1.42.9 (28-Dec-2013) /dev/sdb is entire device, not just one partition! Proceed anyway? (y,n) y Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 1310720 inodes, 5242880 blocks 262144 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2153775104 160 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000
Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
注:若报错Device or resource busy. The kernel still uses the old table.The new table will be used at the next reboot。则需要重启系统,重新加载硬盘,才能进一步操作。 partprobe 强制读取所有分区
[root@localhost ~]# 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 0x5b3d4ae9.
Command (m forhelp):
3.开始分区,下面将逐个解释其分区含义
[root@localhost ~]# 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 0x5b3d4ae9.
Command (m forhelp): p #打印当前分区信息
Disk /dev/sdb: 10.7 GB, 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 label type: dos Disk identifier: 0x5b3d4ae9
Device Boot Start End Blocks Id System -------------------------------------------------------------------------------- [划分主分区]
Command (m forhelp): 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-20971519, default 2048): 2048 #默认从哪里开始划分 Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +5G #指定划分5个GB Partition 1 of type Linux and of size 5 GiB is set
Command (m forhelp): p #打印分区情况
Disk /dev/sdb: 10.7 GB, 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 label type: dos Disk identifier: 0x5b3d4ae9
Device Boot Start End Blocks Id System /dev/sdb1 2048 10487807 5242880 83 Linux #此处可看到一个主分区了 -------------------------------------------------------------------------------- [划分拓展分区]
Command (m forhelp): n #继续创建分区
Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): e #这次选择创建逻辑分区 Partition number (2-4, default 2): 2 #默认从2开始 First sector (10487808-20971519, default 10487808): 10487808 #默认开始无需动 Last sector, +sectors or +size{K,M,G} (10487808-20971519, default 20971519): #由于是拓展分区,所以这里不能指定大小 Using default value 20971519 Partition 2 of type Extended and of size 5 GiB is set
Command (m forhelp): p
Disk /dev/sdb: 10.7 GB, 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 label type: dos Disk identifier: 0x5b3d4ae9
Device Boot Start End Blocks Id System /dev/sdb1 2048 10487807 5242880 83 Linux /dev/sdb2 10487808 20971519 5241856 5 Extended #这里可以看到已经有一个拓展结构了,接下来分区 -------------------------------------------------------------------------------- [在拓展分区的基础上划分逻辑分区]
Command (m forhelp): n
Partition type: p primary (1 primary, 1 extended, 2 free) l logical (numbered from 5) #这里选择l新建逻辑分区 Select (default p): l Adding logical partition 5 First sector (10489856-20971519, default 10489856): 10489856 #默认开始位置 Last sector, +sectors or +size{K,M,G} (10489856-20971519, default 20971519): #划分全部空间 Using default value 20971519 Partition 5 of type Linux and of size 5 GiB is set
Command (m forhelp): w #保存分区表并退出 The partition table has been altered!
Calling ioctl() to re-read partition table. Syncing disks.
[root@localhost ~]#
4.接下来使用fdisk -l 可以查看分区情况
[root@localhost ~]# fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes, 20971520 sectors #这是/dev/sda逻辑磁盘 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: 0x000cc3ff
Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 20971519 9436160 8e Linux LVM
Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors #这是/dev/sdb逻辑磁盘 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: 0x5b3d4ae9
Device Boot Start End Blocks Id System /dev/sdb1 2048 10487807 5242880 83 Linux #这就是刚刚划分的主分区 /dev/sdb2 10487808 20971519 5241856 5 Extended #这是拓展结构 /dev/sdb5 10489856 20971519 5240832 83 Linux #这是逻辑分区
[root@localhost ~]# parted GNU Parted 3.1 Using /dev/sda 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 创建新的磁盘卷标(分区表) mkpart PART-TYPE [FS-TYPE] START END 创建一个分区 name NUMBER NAME name partition NUMBER as NAME print [devices|free|list,all|NUMBER] 打印当前分区信息
quit exit program rescue START END rescue a lost partition near START and END
resizepart NUMBER END resize partition NUMBER rm NUMBER 删除一个分区 select DEVICE 选择需要编辑的设备 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]] 切换分区表状态 unit UNIT set the default unit to UNIT version display the version number and copyright information of GNU Parted (parted)
parted 分区实例
1.磁盘参数解释
-------------------------------------------------------------------------------- [root@localhost ~]# parted /dev/sdb GNU Parted 3.1 Using /dev/sdb Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) print
[root@localhost ~]# free -h total used free shared buff/cache available Mem: 218M 109M 3.2M 2.8M 105M 75M Swap: 1.1G 2.8M 1.1G
[root@localhost ~]# cat /etc/fstab
# # /etc/fstab # Created by anaconda on Tue Sep 18 09:05:06 2018 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/centos-root / xfs defaults 0 0 UUID=13d5ccc2-52db-4aec-963a-f88e8edcf01c /boot xfs defaults 0 0 /dev/mapper/centos-swap swap swap defaults 0 0
[root@localhost ~]# mkfs -t ext4 /dev/sdb1 #格式化一个磁盘 mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 327680 inodes, 1310720 blocks 65536 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=1342177280 40 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736
Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
2.接着挂载这个磁盘
[root@localhost ~]# mkdir /sdb1 #创建挂载点
[root@localhost ~]# mount -t ext4 /dev/sdb1 /sdb1/ #将磁盘挂载
# # /etc/fstab # Created by anaconda on Tue Sep 18 09:05:06 2018 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/centos-root / xfs defaults 0 0 UUID=13d5ccc2-52db-4aec-963a-f88e8edcf01c /boot xfs defaults 0 0 /dev/mapper/centos-swap swap swap defaults 0 0