df 查看磁盘空间使用情况
df: disk free 空余硬盘
- 基本语法
df 选项 (功能描述:列出文件系统的整体磁盘使用量,检查文件系统的磁盘空间占用情况) - 选项说明
选项 | 功能 |
---|---|
-h | 以人们较易阅读的 GBytes, MBytes, KBytes 等格式自行显示; |
3.案例实操
(1)查看磁盘使用情况
[root@hadoop100 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 15G 3.3G 11G 24% /
tmpfs 996M 72K 996M 1% /dev/shm
/dev/sda1 190M 39M 142M 22% /boot
/dev/sr0 3.7G 3.7G 0 100% /mnt/cdrom
.host:/ 82G 14G 69G 17% /mnt/hgfs
fdisk 查看分区
- 基本语法
fdisk -l (功能描述:查看磁盘分区详情) - 选项说明
选项 | 功能 |
---|---|
-l | 显示所有硬盘的分区列表 |
-
经验技巧
该命令必须在root用户下才能使用 -
功能说明
Linux分区:
Device:分区序列
Boot:引导
Start:从X磁柱开始
End:到Y磁柱结束
Blocks:容量
Id:分区类型ID
System:分区类型
5.案例实操
(1)查看系统分区情况
[root@hadoop100 ~]# fdisk -l
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00085b2e
Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 1984 15728640 83 Linux
/dev/sda3 1984 2611 5037056 82 Linux swap / Solaris
mount/umount 挂载/卸载
对于Linux用户来讲,不论有几个分区,分别分给哪一个目录使用,它总归就是一个根目录、一个独立且唯一的文件结构。
Linux中每个分区都是用来组成整个文件系统的一部分,它在用一种叫做“挂载”的处理方法,它整个文件系统中包含了一整套的文件和目录,并将一个分区和一个目录联系起来,要载入的那个分区将使它的存储空间在这个目录下获得。
- 挂载前准备(必须要有光盘或者已经连接镜像文件)
- 基本语法
mount [-t vfstype] [-o options] device dir (功能描述:挂载设备)
umount 设备文件名或挂载点 (功能描述:卸载设备) - 参数说明
参数 | 功能 |
---|---|
-t | vfstype 指定文件系统的类型,通常不必指定。mount 会自动选择正确的类型。 |
常用类型有:
光盘或光盘镜像:iso9660
DOS fat16文件系统:msdos
Windows 9x fat32文件系统:vfat
Windows NT ntfs文件系统:ntfs
Mount Windows文件网络共享:smbfs
UNIX(LINUX) 文件网络共享:nfs
-o options|主要用来描述设备或档案的挂接方式。
常用的参数有:
loop:用来把一个文件当成硬盘分区挂接上系统
ro:采用只读方式挂接设备
rw:采用读写方式挂接设备
iocharset:指定访问文件系统所用字符集
device|要挂接(mount)的设备
dir|设备在系统上的挂接点(mount point)
4.案例实操
(1)挂载光盘镜像文件
[root@hadoop101 ~]# mkdir /mnt/cdrom/ 建立挂载点
[root@hadoop101 ~]# mount -t iso9660 /dev/cdrom /mnt/cdrom/ 设备 /dev/cdrom挂载到 挂载点 : /mnt/cdrom中
[root@hadoop100 ~]# ll /mnt/cdrom/
总用量 558
-r--r--r--. 2 root root 14 5月 22 2016 CentOS_BuildTag
dr-xr-xr-x. 3 root root 2048 5月 22 2016 EFI
-r--r--r--. 2 root root 212 11月 27 2013 EULA
-r--r--r--. 2 root root 18009 11月 27 2013 GPL
dr-xr-xr-x. 3 root root 2048 5月 23 2016 images
dr-xr-xr-x. 2 root root 2048 5月 22 2016 isolinux
dr-xr-xr-x. 2 root root 528384 5月 23 2016 Packages
-r--r--r--. 2 root root 1359 5月 22 2016 RELEASE-NOTES-en-US.html
dr-xr-xr-x. 2 root root 4096 5月 23 2016 repodata
-r--r--r--. 2 root root 1706 11月 27 2013 RPM-GPG-KEY-CentOS-6
-r--r--r--. 2 root root 1730 11月 27 2013 RPM-GPG-KEY-CentOS-Debug-6
-r--r--r--. 2 root root 1730 11月 27 2013 RPM-GPG-KEY-CentOS-Security-6
-r--r--r--. 2 root root 1734 11月 27 2013 RPM-GPG-KEY-CentOS-Testing-6
-r--r--r--. 1 root root 3380 5月 23 2016 TRANS.TBL
(2)卸载光盘镜像文件
[root@hadoop101 ~]# umount /mnt/cdrom
5.设置开机自动挂载
[root@hadoop101 ~]# vim /etc/fstab
添加红框中内容,保存退出,重启即可生效。
引用自尚硅谷课件