创建一个2G的文件系统,块大小为2048byte,预留1%可用空间,文件系统 ext4,卷标为TEST,要求此分区开机后自动挂载至/test目录,且默认有acl挂载选项

1.查看块设备信息

[root@centos7 ~]#lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  200G  0 disk 
├─sda1   8:1    0    1G  0 part /boot
├─sda2   8:2    0  100G  0 part /
├─sda3   8:3    0   50G  0 part /data
├─sda4   8:4    0    1K  0 part 
├─sda5   8:5    0    4G  0 part [SWAP]
├─sda6   8:6    0    1G  0 part 
└─sda7   8:7    0    2G  0 part 
sdb      8:16   0  200G  0 disk 
sdc      8:32   0   20G  0 disk 
sdd      8:48   0   10G  0 disk 
sr0     11:0    1 1024M  0 rom  
sr1     11:1    1 1024M  0 rom  

以下将在sdb磁盘作为操作目标

  1. 在sdb磁盘上创建大小为2G的分区
[root@centos7 ~]#fdisk /dev/sdd
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 0x87a3f767.

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): 
First sector (2048-20971519, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +2G
Partition 1 of type Linux and of size 2 GiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
  1. 在sdd2分区上创建文件系统
[root@centos7 ~]#mkfs.ext4 -b 2048 -m 1 -L TEST /dev/sdd1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=TEST
OS type: Linux
Block size=2048 (log=1)
Fragment size=2048 (log=1)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 1048576 blocks
10485 blocks (1.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=269484032
64 block groups
16384 blocks per group, 16384 fragments per group
2048 inodes per group
Superblock backups stored on blocks: 
	16384, 49152, 81920, 114688, 147456, 409600, 442368, 802816

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

查看结果如下:

[root@centos7 ~]#blkid
/dev/sda1: UUID="793af41e-2bb7-4c31-9f0f-571251920f22" TYPE="xfs" 
/dev/sda2: UUID="5e9ce9bf-255f-4fc9-8ec1-2ca462b11486" TYPE="xfs" 
/dev/sda3: UUID="4366d641-77fb-4f52-8115-250792bbdf64" TYPE="xfs" 
/dev/sda5: UUID="17b04a6b-f52d-4407-91d8-ca6052b65974" TYPE="swap" 
/dev/sda6: LABEL="/mnt/sda6" UUID="137e7f1f-126b-430d-8379-1303dc8b4482" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sda7: UUID="cbd2ed35-eeaa-40d4-8244-bce465365808" TYPE="ext4" 
/dev/sdd1: LABEL="TEST" UUID="8895b7eb-ed2f-41c6-9ff2-2878b1355d1b" TYPE="ext4" 
  1. 将分区挂载到指定文件夹
    在/etc/fstab文件中添加以下内容
UUID=8895b7eb-ed2f-41c6-9ff2-2878b1355d1b /test ext4 acl 0 0
  1. 创建目标文件夹,使配置文件生效
[root@centos7 ~]#mkdir /test
[root@centos7 ~]#mount -a
  1. 最终,查看结果如下:
[root@centos7 ~]#lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  200G  0 disk 
├─sda1   8:1    0    1G  0 part /boot
├─sda2   8:2    0  100G  0 part /
├─sda3   8:3    0   50G  0 part /data
├─sda4   8:4    0    1K  0 part 
├─sda5   8:5    0    4G  0 part [SWAP]
├─sda6   8:6    0    1G  0 part 
└─sda7   8:7    0    2G  0 part 
sdb      8:16   0  200G  0 disk 
sdc      8:32   0   20G  0 disk 
sdd      8:48   0   10G  0 disk 
└─sdd1   8:49   0    2G  0 part /test
sr0     11:0    1 1024M  0 rom  
sr1     11:1    1 1024M  0 rom
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值