linux生成20g的文件,创建一个 20G 的分区,并格式化为 ext4 文件系统

创建一个 20G 的分区,并格式化为 ext4 文件系统,并完成如下要求:

(1)block 大小为 2048,预留空间 20%,卷标为 MYDATA

#fdisk /dev/sdb -->n -->p -->1 -->1 -->+20G -->w

#mkfs.ext4 -b 2048 -m 20 -L MYDATA /dev/sdb1

(2)挂载至/mydata目录,要求挂载时禁止程序自动运行,且不更新文件的访问时间戳。

#mkdir /mydata

#mount -o noexec,nodiratime -t ext4 -L MYDATA /mydata

#mount |grep sdb1 --> /dev/sdb1 on /mydata type ext4 (rw,noexec,nodiratime)

(3)可开机自动挂载。

#vim /etc/fstab

#在最后一行添加:/dev/sdb1 /mydata ext4 defaults,rw,noexec,nodiratime 0 0

按照格式:要挂载的设备或伪文件系统 挂载点 文件系统类型 挂载选项 转储频率 自检次序

附操作步骤:

[root@localhost ~]# fdisk /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0xa4c9dc26.

Changes will remain in memory only, until you decide to write them.

After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

switch off the mode (command 'c') and change display units to

sectors (command 'u').

Command (m for help): n

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-5221, default 1): 1

Last cylinder, +cylinders or +size{K,M,G} (1-5221, default 5221): +20G

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

[root@localhost ~]# mkfs.ext4 -b 2048 -m 20 -L MYDATA /dev/sdb1

mke2fs 1.41.12 (17-May-2010)

Filesystem label=MYDATA

OS type: Linux

Block size=2048 (log=1)

Fragment size=2048 (log=1)

Stride=0 blocks, Stripe width=0 blocks

1312768 inodes, 10490428 blocks

2098085 blocks (20.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=548405248

641 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, 1327104,

2048000, 3981312, 5619712, 10240000

Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 39 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

[root@localhost ~]# mkdir /mydata

[root@localhost ~]# mount -o noexec,nodiratime -t ext4 -L MYDATA /mydata

[root@localhost ~]# mount |grep sdb1

/dev/sdb1 on /mydata type ext4 (rw,noexec,nodiratime)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值