建立一個 20G 的分區,並格式化爲 ext4 文件系統

 建立一個 20G 的分區,並格式化爲 ext4 文件系統,並完成以下要求:node

(1)block 大小爲 2048,預留空間 20%,卷標爲 MYDATAvim

#fdisk /dev/sdb -->n -->p -->1 -->1 -->+20G -->w
#mkfs.ext4 -b 2048 -m 20 -L MYDATA  /dev/sdb1

2掛載至/mydata 目錄,要求掛載時禁止程序自動運行,且不更新文件的訪問時間戳。bash

#mkdir /mydata 
#mount  -o  noexec,nodiratime -t ext4 -L MYDATA  /mydata 
#mount |grep sdb1  --> /dev/sdb1 on /mydata type ext4 (rw,noexec,nodiratime)

(3)可開機自動掛載。ide

#vim /etc/fstab
#在最後一行添加:/dev/sdb1               /mydata                 ext4    defaults,rw,noexec,nodiratime  0 0
 按照格式:要掛載的設備或僞文件系統         掛載點               文件系統類型  掛載選項 轉儲頻率 自檢次序 

附操做步驟:ui

[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)
相關文章
相關標籤/搜索