第十二章:

1、基本存储配置

(1) 添加一块10G大小的磁盘,将该磁盘分为两个主分区,大小为1G、2G。将剩余的空间全部划分为扩展分 区。划分一个逻辑分区,大小为3G。(主分区文件系统类型为ext4,逻辑分区文件系统类型为xfs)

先添加一个新的硬盘

 

 

 

 

 

用lsblk查看硬盘信息 ,nvme0n2就是我们添加的新硬盘

 

用fdisk命令修改硬盘信息

fdisk /dev/nvme0n2
#选项n,添加分区
Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
#回车会选择默认选项,此处默认为p
Select (default p): 

Using default response p.
Partition number (1-4, default 1): 
First sector (2048-20971519, default 2048): 
#可以直接写字节大小,也可以用+数字单位表示
Last sector, +sectors or +size{K,M,G,T,P} (2048-20971519, default 20971519): +1G
Created a new partition 1 of type 'Linux' and of size 1 GiB

 

Command (m for help): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): 

Using default response p.
Partition number (2-4, default 2): 
First sector (2099200-20971519, default 2099200): 
Last sector, +sectors or +size{K,M,G,T,P} (2099200-20971519, default 20971519): +2G 

Created a new partition 2 of type 'Linux' and of size 2 GiB.
 

 

Command (m for help): n
Partition type
   p   primary (2 primary, 0 extended, 2 free)
   e   extended (container for logical partitions)
#选项e为扩展分区
Select (default p): e
Partition number (3,4, default 3): 3
First sector (6293504-20971519, default 6293504): 
Last sector, +sectors or +size{K,M,G,T,P} (6293504-20971519, default 20971519):    

Created a new partition 3 of type 'Extended' and of size 7 GiB. 

 n
All space for primary partitions is in use.
Adding logical partition 5
First sector (6295552-20971519, default 6295552): 
Last sector, +sectors or +size{K,M,G,T,P} (6295552-20971519, default 20971519): +3G

Created a new partition 5 of type 'Linux' and of size 3 GiB.

w

The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.

保存退出

然后将主分区文件系统类型设置为ext4,,将逻辑分区文件系统类型设置为xfs

mkfs.ext4 /dev/nvme0n2p1
mke2fs 1.45.4 (23-Sep-2019)
Creating filesystem with 262144 4k blocks and 65536 inodes
Filesystem UUID: a71d6019-08bd-424f-b5f8-30b7382e58f3
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

 

mkfs.ext4 /dev/nvme0n2p2
mke2fs 1.45.4 (23-Sep-2019)
Creating filesystem with 524288 4k blocks and 131072 inodes
Filesystem UUID: 89bdde83-e4b6-4b67-878f-c07318ffcc45
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
 

 mkfs.xfs /dev/nvme0n2p5
meta-data=/dev/nvme0n2p5         isize=512    agcount=4, agsize=196608 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=786432, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

 

(2) 将三个分区分别挂载到/dir1、/dir2、/dir3。

挂载分区首先要创建挂载点目录

 然后用mount命令将需要挂载的分区挂载到挂载点目录

 

 查看挂载信息可以发现需要挂载的目录都挂载到挂载点目录上了

 

(3) 在第一个主分区中创建一个文件为file1,内容为this is partition1。在第二个分区中创建一个文 件为file2,内容为this is partition2。在第三个分区中创建一个文件为file3,内容为this is partition3。

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值