linux磁盘管理基础,xxh

作者:小辉
[root@zxc qwe]# ll  /dev/sd*
brw-rw---- 1 root disk 8, 0 9月 19 14:38 /dev/sda
brw-rw---- 1 root disk 8, 1 9月 19 14:38 /dev/sda1
brw-rw---- 1 root disk 8, 2 9月 19 14:38 /dev/sda2
brw-rw---- 1 root disk 8, 16 9月 19 15:04 /dev/sdb
[root@zxc qwe]#



[

root@zxc qwe]# lsblk     列出  磁盘得名称 ,磁盘的分区   磁盘的大小


2.创建磁盘的分区

找到你的新添加的磁盘 ,进行磁盘分区

[root@zxc qwe]# fdisk -l

#列出磁盘分区

磁盘 /dev/sda:21.5 GB, 21474836480 字节,41943040 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000c7718

设备 Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 41943039 19921920 8e Linux LVM

磁盘 /dev/sdb:5368 MB, 5368709120 字节,10485760 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x109c410c

设备 Boot Start End Blocks Id System

磁盘 /dev/mapper/centos-root:18.2 GB, 18249416704 字节,35643392 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节


磁盘 /dev/mapper/centos-swap:2147 MB, 2147483648 字节,4194304 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节

进行磁盘分区

[root@zxc qwe]# fdisk   /dev/sdb

 


#回车

[root@zxc qwe]# fdisk /dev/sdb
欢迎使用 fdisk (util-linux 2.23.2)。

更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。


命令(输入 m 获取帮助):

#这个冒号后面数入  :m












会出现命令操作

命令操作
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)

命令(输入 m 获取帮助):








输入命名 :n    #新建分区

命令(输入 m 获取帮助):n
Partition type:
          p primary (0 primary, 0 extended, 4 free)   #主分区
          e extended                                                  #扩展分区
Select (default p): p

#输入p

输入1,#创建编号位 1 的 磁盘 ,,,,,当然也可以为 2,3,4

#这个只能创建四个分区

Partition type:
                p primary (0 primary, 0 extended, 4 free)
                e extended
Select (default p): p
分区号 (1-4,默认 1): 1

起始 扇区 (2048-10485759,默认为 2048): #回车,会用默认值
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-10485759,默认为 10485759) :+1G     #输入你要分的内存,磁盘分区的总和    不要超过你的磁盘内存
分区 1 已设置为 Linux 类型,大小设为 1 GiB

#完成了 ,但是还没用生效

 

要输入   w   保存退出

命令(输入 m 获取帮助):w

The partition table has been altered!

Calling ioctl() to re-read partition table.

正在同步磁盘。

[root@zxc qwe]#

 

刷新分区

[root@zxc qwe]# partprobe /dev/sdb

查看创建的分区   输入 :p  

#红色的线上的内容 ,就是新建的分区

也可以输入    [root@zxc qwe]# lsblk

sdb 下面的sdb1 是刚创建的磁盘的分区     

 删除分区

命令操作
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)

命令(输入 m 获取帮助):d

#输入  d

命令(输入 m 获取帮助):d
       分区号 (1,2,默认 2):1        #删除的分区号
        分区 1 已删除

 

posted @ 2022-09-19 16:13  python,菜鸟  阅读(48)  评论(0)    收藏  举报