4.1 df命令 4.2 du命令 4.3/4.4 磁盘分区html
经常使用选择:node
tmpfs 表示这个文件是个临时的文件系统
linux
能够单独用-s ;
h表示在后面加上适当的单位centos
[root@centos001 ~]# du /etc/passwd 4 /etc/passwd [root@centos001 ~]# du /root/ 24 /root/.ssh 0 /root/123 0 /root/234/am 0 /root/234/am1 0 /root/234 0 /root/dir3 0 /root/111 76 /root/ [root@centos001 ~]# du -s /root/ //只有s时不显示单位 76 /root/ [root@centos001 ~]# du -sh /r root/ run/ [root@centos001 ~]# du -sh /root/ //加上h就有单位了 76K /root/
这里添加了磁盘 可是尚未加载 还须要要在linux机器上操做app
划分磁盘时经常使用的命令:
m :获取帮助
p :显示当前磁盘分区情况 n :创建一个新的分区
w :保存并退出
q :取消并退出
d :删除一个分区 //当扩展分区中有子分区(逻辑分区)的时候,删除扩展分区会连同子分区一块儿删除ssh
p :主分区 //只能有4个 而且删除以后其余的序号不会变
e:扩展分区 //扩展分区至关于一个空壳子,是不能够格式化的(不可使用),只有它的子分区才能够格式化。
l:逻辑分区 //扩展分区的字分区默认从分区5开始;能够有多个 ,而且删除以后 其余的分区数字会变成顺序,中间不为空学习
[root@centos001 ~]# fdisk /dev/sdb 欢迎使用 fdisk (util-linux 2.23.2)。 更改将停留在内存中,直到您决定将更改写入磁盘。 使用写入命令前请三思。 Device does not contain a recognized partition table 使用磁盘标识符 0xf690e23a 建立新的 DOS 磁盘标签。 命令(输入 m 获取帮助):m //获取帮助 命令操做 a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition g create a new empty GPT partition table G create an IRIX (SGI) partition table l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) 命令(输入 m 获取帮助):n //建立一个分区 Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p 分区号 (1-4,默认 1):1 起始 扇区 (2048-20971519,默认为 2048): 将使用默认值 2048 Last 扇区, +扇区 or +size{K,M,G} (2048-20971519,默认为 20971519):+2G 分区 1 已设置为 Linux 类型,大小设为 2 GiB 命令(输入 m 获取帮助):n Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): p 分区号 (2-4,默认 2):2 起始 扇区 (4196352-20971519,默认为 4196352): 将使用默认值 4196352 Last 扇区, +扇区 or +size{K,M,G} (4196352-20971519,默认为 20971519):+2G 分区 2 已设置为 Linux 类型,大小设为 2 GiB 命令(输入 m 获取帮助):n Partition type: p primary (2 primary, 0 extended, 2 free) e extended Select (default p): p 分区号 (3,4,默认 3):3 起始 扇区 (8390656-20971519,默认为 8390656): 将使用默认值 8390656 Last 扇区, +扇区 or +size{K,M,G} (8390656-20971519,默认为 20971519):+1G 分区 3 已设置为 Linux 类型,大小设为 1 GiB 命令(输入 m 获取帮助):n Partition type: p primary (3 primary, 0 extended, 1 free) e extended Select (default e): p //建立4个主分区 已选择分区 4 起始 扇区 (10487808-20971519,默认为 10487808): 将使用默认值 10487808 Last 扇区, +扇区 or +size{K,M,G} (10487808-20971519,默认为 20971519): 将使用默认值 20971519 分区 4 已设置为 Linux 类型,大小设为 5 GiB 命令(输入 m 获取帮助):n If you want to create more than four partitions, you must replace a primary partition with an extended partition first. 命令(输入 m 获取帮助):d 分区号 (1-4,默认 4):4 //删除一个主分区 分区 4 已删除 命令(输入 m 获取帮助):n Partition type: p primary (3 primary, 0 extended, 1 free) e extended Select (default e): e 已选择分区 4 起始 扇区 (10487808-20971519,默认为 10487808): 将使用默认值 10487808 Last 扇区, +扇区 or +size{K,M,G} (10487808-20971519,默认为 20971519):+4G 分区 4 已设置为 Extended 类型,大小设为 4 GiB 命令(输入 m 获取帮助):P 磁盘 /dev/sdb:10.7 GB, 10737418240 字节,20971520 个扇区 Units = 扇区 of 1 * 512 = 512 bytes 扇区大小(逻辑/物理):512 字节 / 512 字节 I/O 大小(最小/最佳):512 字节 / 512 字节 磁盘标签类型:dos 磁盘标识符:0xf690e23a 设备 Boot Start End Blocks Id System /dev/sdb1 2048 4196351 2097152 83 Linux /dev/sdb2 4196352 8390655 2097152 83 Linux /dev/sdb3 8390656 10487807 1048576 83 Linux /dev/sdb4 10487808 18876415 4194304 5 Extended 命令(输入 m 获取帮助):n All primary partitions are in use 添加逻辑分区 5 起始 扇区 (10489856-18876415,默认为 10489856): 将使用默认值 10489856 Last 扇区, +扇区 or +size{K,M,G} (10489856-18876415,默认为 18876415):+1G 分区 5 已设置为 Linux 类型,大小设为 1 GiB 命令(输入 m 获取帮助):p 磁盘 /dev/sdb:10.7 GB, 10737418240 字节,20971520 个扇区 Units = 扇区 of 1 * 512 = 512 bytes 扇区大小(逻辑/物理):512 字节 / 512 字节 I/O 大小(最小/最佳):512 字节 / 512 字节 磁盘标签类型:dos 磁盘标识符:0xf690e23a 设备 Boot Start End Blocks Id System /dev/sdb1 2048 4196351 2097152 83 Linux /dev/sdb2 4196352 8390655 2097152 83 Linux /dev/sdb3 8390656 10487807 1048576 83 Linux /dev/sdb4 10487808 18876415 4194304 5 Extended //这里能看到磁盘标识符并非都是同样的 /dev/sdb5 10489856 12587007 1048576 83 Linux 命令(输入 m 获取帮助):n All primary partitions are in use 添加逻辑分区 6 起始 扇区 (12589056-18876415,默认为 12589056): 将使用默认值 12589056 Last 扇区, +扇区 or +size{K,M,G} (12589056-18876415,默认为 18876415):+1G 分区 6 已设置为 Linux 类型,大小设为 1 GiB 命令(输入 m 获取帮助):p 磁盘 /dev/sdb:10.7 GB, 10737418240 字节,20971520 个扇区 Units = 扇区 of 1 * 512 = 512 bytes 扇区大小(逻辑/物理):512 字节 / 512 字节 I/O 大小(最小/最佳):512 字节 / 512 字节 磁盘标签类型:dos 磁盘标识符:0xf690e23a 设备 Boot Start End Blocks Id System /dev/sdb1 2048 4196351 2097152 83 Linux /dev/sdb2 4196352 8390655 2097152 83 Linux /dev/sdb3 8390656 10487807 1048576 83 Linux /dev/sdb4 10487808 18876415 4194304 5 Extended /dev/sdb5 10489856 12587007 1048576 83 Linux /dev/sdb6 12589056 14686207 1048576 83 Linux 命令(输入 m 获取帮助):d 分区号 (1-6,默认 6):1 分区 1 已删除 (输入 m 获取帮助):p 磁盘 /dev/sdb:10.7 GB, 10737418240 字节,20971520 个扇区 Units = 扇区 of 1 * 512 = 512 bytes 扇区大小(逻辑/物理):512 字节 / 512 字节 I/O 大小(最小/最佳):512 字节 / 512 字节 磁盘标签类型:dos 磁盘标识符:0xf690e23a 设备 Boot Start End Blocks Id System /dev/sdb2 4196352 8390655 2097152 83 Linux //删除了主分区1后 就空着了 /dev/sdb3 8390656 10487807 1048576 83 Linux /dev/sdb4 10487808 18876415 4194304 5 Extended /dev/sdb5 10489856 12587007 1048576 83 Linux /dev/sdb6 12589056 14686207 1048576 83 Linux 命令(输入 m 获取帮助):d 分区号 (2-6,默认 6):5 分区 5 已删除 命令(输入 m 获取帮助):p 磁盘 /dev/sdb:10.7 GB, 10737418240 字节,20971520 个扇区 Units = 扇区 of 1 * 512 = 512 bytes 扇区大小(逻辑/物理):512 字节 / 512 字节 I/O 大小(最小/最佳):512 字节 / 512 字节 磁盘标签类型:dos 磁盘标识符:0xf690e23a //可是当咱们删除逻辑分区后再看,里面又变顺序了 设备 Boot Start End Blocks Id System /dev/sdb2 4196352 8390655 2097152 83 Linux /dev/sdb3 8390656 10487807 1048576 83 Linux /dev/sdb4 10487808 18876415 4194304 5 Extended /dev/sdb5 12589056 14686207 1048576 83 Linux 命令(输入 m 获取帮助):q [root@centos001 ~]# fdisk /dev/sdb 欢迎使用 fdisk (util-linux 2.23.2)。 更改将停留在内存中,直到您决定将更改写入磁盘。 使用写入命令前请三思。 Device does not contain a recognized partition table 使用磁盘标识符 0x580ced86 建立新的 DOS 磁盘标签。 命令(输入 m 获取帮助):n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): e 分区号 (1-4,默认 1): 起始 扇区 (2048-20971519,默认为 2048): 将使用默认值 2048 Last 扇区, +扇区 or +size{K,M,G} (2048-20971519,默认为 20971519):+3G 分区 1 已设置为 Extended 类型,大小设为 3 GiB 命令(输入 m 获取帮助):p 磁盘 /dev/sdb:10.7 GB, 10737418240 字节,20971520 个扇区 Units = 扇区 of 1 * 512 = 512 bytes 扇区大小(逻辑/物理):512 字节 / 512 字节 I/O 大小(最小/最佳):512 字节 / 512 字节 磁盘标签类型:dos 磁盘标识符:0x580ced86 设备 Boot Start End Blocks Id System /dev/sdb1 2048 6293503 3145728 5 Extended 命令(输入 m 获取帮助):n Partition type: p primary (0 primary, 1 extended, 3 free) l logical (numbered from 5) Select (default p): p 分区号 (2-4,默认 2):3 起始 扇区 (6293504-20971519,默认为 6293504): 将使用默认值 6293504 Last 扇区, +扇区 or +size{K,M,G} (6293504-20971519,默认为 20971519):+1G 分区 3 已设置为 Linux 类型,大小设为 1 GiB 命令(输入 m 获取帮助):n Partition type: p primary (1 primary, 1 extended, 2 free) l logical (numbered from 5) Select (default p): l 添加逻辑分区 5 起始 扇区 (4096-6293503,默认为 4096): 将使用默认值 4096 Last 扇区, +扇区 or +size{K,M,G} (4096-6293503,默认为 6293503):+1G 分区 5 已设置为 Linux 类型,大小设为 1 GiB 命令(输入 m 获取帮助):p 磁盘 /dev/sdb:10.7 GB, 10737418240 字节,20971520 个扇区 Units = 扇区 of 1 * 512 = 512 bytes 扇区大小(逻辑/物理):512 字节 / 512 字节 I/O 大小(最小/最佳):512 字节 / 512 字节 磁盘标签类型:dos 磁盘标识符:0x580ced86 设备 Boot Start End Blocks Id System /dev/sdb1 2048 6293503 3145728 5 Extended /dev/sdb3 6293504 8390655 1048576 83 Linux /dev/sdb5 4096 2101247 1048576 83 Linux 命令(输入 m 获取帮助):n Partition type: p primary (1 primary, 1 extended, 2 free) l logical (numbered from 5) Select (default p): l 添加逻辑分区 6 起始 扇区 (2103296-6293503,默认为 2103296): 将使用默认值 2103296 Last 扇区, +扇区 or +size{K,M,G} (2103296-6293503,默认为 6293503):+100M 分区 6 已设置为 Linux 类型,大小设为 100 MiB 命令(输入 m 获取帮助):n Partition type: p primary (1 primary, 1 extended, 2 free) l logical (numbered from 5) Select (default p): l 添加逻辑分区 7 起始 扇区 (2310144-6293503,默认为 2310144): 将使用默认值 2310144 Last 扇区, +扇区 or +size{K,M,G} (2310144-6293503,默认为 6293503):+100M 分区 7 已设置为 Linux 类型,大小设为 100 MiB 命令(输入 m 获取帮助):d 分区号 (1,3,5-7,默认 7):6 分区 6 已删除 命令(输入 m 获取帮助):p 磁盘 /dev/sdb:10.7 GB, 10737418240 字节,20971520 个扇区 Units = 扇区 of 1 * 512 = 512 bytes 扇区大小(逻辑/物理):512 字节 / 512 字节 I/O 大小(最小/最佳):512 字节 / 512 字节 磁盘标签类型:dos 磁盘标识符:0x580ced86 设备 Boot Start End Blocks Id System /dev/sdb1 2048 6293503 3145728 5 Extended /dev/sdb3 6293504 8390655 1048576 83 Linux /dev/sdb5 4096 2101247 1048576 83 Linux /dev/sdb6 2310144 2514943 102400 83 Linux 命令(输入 m 获取帮助):q [root@centos001 ~]# fdisk -l 磁盘 /dev/sda:21.5 GB, 21474836480 字节,41943040 个扇区 Units = 扇区 of 1 * 512 = 512 bytes 扇区大小(逻辑/物理):512 字节 / 512 字节 I/O 大小(最小/最佳):512 字节 / 512 字节 磁盘标签类型:dos 磁盘标识符:0x000c29e8 设备 Boot Start End Blocks Id System /dev/sda1 * 2048 411647 204800 83 Linux /dev/sda2 411648 41943039 20765696 8e Linux LVM 磁盘 /dev/sdb:10.7 GB, 10737418240 字节,20971520 个扇区 Units = 扇区 of 1 * 512 = 512 bytes 扇区大小(逻辑/物理):512 字节 / 512 字节 I/O 大小(最小/最佳):512 字节 / 512 字节 磁盘 /dev/mapper/cl-root:19.1 GB, 19113443328 字节,37330944 个扇区 Units = 扇区 of 1 * 512 = 512 bytes 扇区大小(逻辑/物理):512 字节 / 512 字节 I/O 大小(最小/最佳):512 字节 / 512 字节 磁盘 /dev/mapper/cl-swap:2147 MB, 2147483648 字节,4194304 个扇区 Units = 扇区 of 1 * 512 = 512 bytes 扇区大小(逻辑/物理):512 字节 / 512 字节 I/O 大小(最小/最佳):512 字节 / 512 字节 [root@centos001 ~]# fdisk /dev/sdb 欢迎使用 fdisk (util-linux 2.23.2)。 更改将停留在内存中,直到您决定将更改写入磁盘。 使用写入命令前请三思。 Device does not contain a recognized partition table 使用磁盘标识符 0xcadefdea 建立新的 DOS 磁盘标签。 命令(输入 m 获取帮助):n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p 分区号 (1-4,默认 1): //这里咱们吧主分区设为一个 起始 扇区 (2048-20971519,默认为 2048): 将使用默认值 2048 Last 扇区, +扇区 or +size{K,M,G} (2048-20971519,默认为 20971519):+5G 分区 1 已设置为 Linux 类型,大小设为 5 GiB 命令(输入 m 获取帮助):w The partition table has been altered! Calling ioctl() to re-read partition table. 正在同步磁盘。 [root@centos001 ~]# fdisk -l 磁盘 /dev/sda:21.5 GB, 21474836480 字节,41943040 个扇区 Units = 扇区 of 1 * 512 = 512 bytes 扇区大小(逻辑/物理):512 字节 / 512 字节 I/O 大小(最小/最佳):512 字节 / 512 字节 磁盘标签类型:dos 磁盘标识符:0x000c29e8 设备 Boot Start End Blocks Id System /dev/sda1 * 2048 411647 204800 83 Linux /dev/sda2 411648 41943039 20765696 8e Linux LVM 磁盘 /dev/sdb:10.7 GB, 10737418240 字节,20971520 个扇区 Units = 扇区 of 1 * 512 = 512 bytes 扇区大小(逻辑/物理):512 字节 / 512 字节 I/O 大小(最小/最佳):512 字节 / 512 字节 磁盘标签类型:dos 磁盘标识符:0xcadefdea 设备 Boot Start End Blocks Id System /dev/sdb1 2048 10487807 5242880 83 Linux 磁盘 /dev/mapper/cl-root:19.1 GB, 19113443328 字节,37330944 个扇区 Units = 扇区 of 1 * 512 = 512 bytes 扇区大小(逻辑/物理):512 字节 / 512 字节 I/O 大小(最小/最佳):512 字节 / 512 字节 磁盘 /dev/mapper/cl-swap:2147 MB, 2147483648 字节,4194304 个扇区 Units = 扇区 of 1 * 512 = 512 bytes 扇区大小(逻辑/物理):512 字节 / 512 字节 I/O 大小(最小/最佳):512 字节 / 512 字节 [root@centos001 ~]# fdisk /dev/sdb 欢迎使用 fdisk (util-linux 2.23.2)。 更改将停留在内存中,直到您决定将更改写入磁盘。 使用写入命令前请三思。 命令(输入 m 获取帮助):d 已选择分区 1 分区 1 已删除 命令(输入 m 获取帮助):1 1: unknown command 命令操做 a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition g create a new empty GPT partition table G create an IRIX (SGI) partition table l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) 命令(输入 m 获取帮助):w The partition table has been altered! Calling ioctl() to re-read partition table. 正在同步磁盘。 [root@centos001 ~]# fdisk -l 磁盘 /dev/sda:21.5 GB, 21474836480 字节,41943040 个扇区 Units = 扇区 of 1 * 512 = 512 bytes 扇区大小(逻辑/物理):512 字节 / 512 字节 I/O 大小(最小/最佳):512 字节 / 512 字节 磁盘标签类型:dos 磁盘标识符:0x000c29e8 设备 Boot Start End Blocks Id System /dev/sda1 * 2048 411647 204800 83 Linux /dev/sda2 411648 41943039 20765696 8e Linux LVM 磁盘 /dev/sdb:10.7 GB, 10737418240 字节,20971520 个扇区 Units = 扇区 of 1 * 512 = 512 bytes 扇区大小(逻辑/物理):512 字节 / 512 字节 I/O 大小(最小/最佳):512 字节 / 512 字节 磁盘标签类型:dos 磁盘标识符:0xcadefdea 设备 Boot Start End Blocks Id System 磁盘 /dev/mapper/cl-root:19.1 GB, 19113443328 字节,37330944 个扇区 Units = 扇区 of 1 * 512 = 512 bytes 扇区大小(逻辑/物理):512 字节 / 512 字节 I/O 大小(最小/最佳):512 字节 / 512 字节 磁盘 /dev/mapper/cl-swap:2147 MB, 2147483648 字节,4194304 个扇区 Units = 扇区 of 1 * 512 = 512 bytes 扇区大小(逻辑/物理):512 字节 / 512 字节 I/O 大小(最小/最佳):512 字节 / 512 字节