一、作业(练习)内容:
1、复习本次课程所讲的内容;
2、总结整理磁盘管理及文件系统管理中设计的各种命令的使用,并附注一定的示例;
3、创建一个10G的文件系统,类型为ext4,要求开机可自动挂载至/mydata目录
答:
[root@localhost ~]# fdisk /dev/sda 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 #创建新的分区 First cylinder (13321-15665, default 13321): Using default value 13321 Last cylinder, +cylinders or +size{K,M,G} (13321-15665, default 15665): +10G #大小10G Command (m for help): w #保存并退出 The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: 设备或资源忙. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks. [root@localhost ~]# partx -a /dev/sda #刷新分区表 BLKPG: Device or resource busy error adding partition 1 BLKPG: Device or resource busy error adding partition 2 BLKPG: Device or resource busy error adding partition 3 BLKPG: Device or resource busy error adding partition 4 BLKPG: Device or resource busy error adding partition 5 BLKPG: Device or resource busy error adding partition 6 BLKPG: Device or resource busy error adding partition 7 [root@localhost ~]# mkfs.ext4 /dev/sda8 #格式化为ext4 mke2fs 1.41.12 (17-May-2010) 文件系统标签= 操作系统:Linux 块大小=4096 (log=2) 分块大小=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 655776 inodes, 2622603 blocks 131130 blocks (5.00%) reserved for the super user 第一个数据块=0 Maximum filesystem blocks=2688548864 81 block groups 32768 blocks per group, 32768 fragments per group 8096 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 正在写入inode表: 完成 Creating journal (32768 blocks): 完成 Writing superblocks and filesystem accounting information: 完成 This filesystem will be automatically checked every 28 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@localhost ~]# mkdir /mydata [root@localhost ~]# blkid /dev/sda8 #查看磁盘uuid /dev/sda8: UUID="3d8c6632-8881-4c72-81d4-1e64ad4265e5" TYPE="ext4" [root@localhost ~]# vim /etc/fstab #编辑fstab文件实现开启挂载,完毕 # /etc/fstab # Created by anaconda on Tue Aug 25 21:09:00 2015 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/VolGroup-LogVol02 / ext4 defaults 1 1 UUID=dbde3019-886c-4eb3-8a79-b15825f7f929 /boot ext4 defaults 1 2 /dev/mapper/VolGroup-LogVol00 /usr ext4 defaults 1 2 /dev/mapper/VolGroup-LogVol01 /var ext4 defaults 1 2 UUID=4bb4b88a-0a7c-42d7-8e28-d6eb5ce64bb8 swap swap defaults 0 0 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 UUID=3d8c6632-8881-4c72-81d4-1e64ad4265e5 /mydata ext4 defaults,acl 0 0 [root@localhost ~]# mount /mydata/ [root@localhost ~]# df -h #查看当前分区使用情况 Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup-LogVol02 39G 545M 37G 2% / tmpfs 495M 72K 495M 1% /dev/shm /dev/sda1 477M 37M 415M 9% /boot /dev/mapper/VolGroup-LogVol00 9.8G 3.3G 6.0G 36% /usr /dev/mapper/VolGroup-LogVol01 9.8G 214M 9.1G 3% /var /dev/sda8 9.8G 23M 9.3G 1% /mydata