标签:保存 而且 default wap alter its sector mib command
今天心情不高兴,做IT不容易被公司重视,一定要速度学会运营,成为一个高逼格的技术男。
今天我要熟练掌握linux系统分区的能力。大家都知道,linux系统分区有两种分区格式:GTP和MBR。
MBR作为传统legacy的bios启动方式被我们经常使用,新老主板bios都支持而且分区简单,操作方便。
1、 MBR特点
① 最多支持4个主分区
② 最大支持2.1tb硬盘
③ 扩展分区一个硬盘只能有一个
2、 mbr结构:
引导占用硬盘开头的512字节,前446字节为引导代码,中间64个字节为4个主分区表信息,最后两个字节为启动标识。
3、 mbr分区实战:
fdisk命令
语法:fdisk [选项] [参数]
选项:-b 指定每个分区大小
-l 列出分区表信息
-v 显示fdisk版本
添加硬盘后,首先使用ll /dev/sd*查看设备是否识别,使用fdisk -l命令列出磁盘信息。
对/dev/sdb进行mbr分区
[root@linux-node2 ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Command (m for help): m        #查看帮助
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition‘s system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)
 
Command (m for help): n                   #新建分区
Partition type:
   p   primary (0 primary, 0 extended, 4 free)     #主分区
   e   extended              #扩展分区
Select (default p): p           #选择新建主分区
Partition number (1-4, default 1): 1          #主分区表示,会生成/dev/sdb1
First sector (2048-6291455, default 2048):               #开始扇区,回车默认从2048
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-6291455, default 6291455): +100M
Partition 1 of type Linux and of size 100 MiB is set
Command (m for help): n          #新建分区
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): e           #选择扩展分区
Partition number (2-4, default 2): 3          #扩展分区编号/dev/sdb3
First sector (206848-6291455, default 206848):              #默认回车,从当前扇区开始
Using default value 206848
Last sector, +sectors or +size{K,M,G} (206848-6291455, default 6291455): #默认回车分配所有剩余空间
Using default value 6291455
Partition 3 of type Extended and of size 2.9 GiB is set
 
Command (m for help): n
Partition type:
   p   primary (1 primary, 1 extended, 2 free)
   l   logical (numbered from 5)
Select (default p): l             #新建逻辑分区
Adding logical partition 5          #默认逻辑分区编号为5
First sector (208896-6291455, default 208896):     #逻辑分区起始位置
Using default value 208896
Last sector, +sectors or +size{K,M,G} (208896-6291455, default 6291455): +500M
Partition 5 of type Linux and of size 500 MiB is set
Command (m for help): n          #新建第二个逻辑分区,分配剩余空间
Partition type:
   p   primary (1 primary, 1 extended, 2 free)
   l   logical (numbered from 5)
Select (default p): l
Adding logical partition 6
First sector (1234944-6291455, default 1234944):
Using default value 1234944
Last sector, +sectors or +size{K,M,G} (1234944-6291455, default 6291455):
Using default value 6291455
Partition 6 of type Linux and of size 2.4 GiB is set
 
Command (m for help): w         保存退出
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
Syncing disks.
查看分区:
[root@linux-node2 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 19.5G 0 part
├─rhel-root 253:0 0 17.5G 0 lvm /
└─rhel-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 3G 0 disk
├─sdb1 8:17 0 100M 0 part
├─sdb3 8:19 0 1K 0 part
├─sdb5 8:21 0 500M 0 part
└─sdb6 8:22 0 2.4G 0 part
格式化分区:
[root@linux-node2 ~]# mkfs.ext4 /dev/sdb1
手动挂载:
[root@linux-node2 ~]# mkdir /datasdb1
[root@linux-node2 ~]# mount /dev/sdb1 /datasdb1/
开机自动挂载:
[root@linux-node2 ~]# echo "/dev/sdb1 /datasdb1 ext4 defaults 0 0 " >> /etc/fstab
检查挂载情况:
[root@linux-node2 ~]# df -h
标签:保存 而且 default wap alter its sector mib command
原文地址:https://www.cnblogs.com/zhanbing/p/10319856.html