这篇博文主要总结了Linux磁盘的一些操作,主要是硬盘的加载,分区(MBR分区和GPT分区),分区的挂载,以及swap分区的加载设置。


基础命令

  • df查看磁盘分区使用状况
    1. -l //仅显示本地磁盘(默认)
    2. -a //显示所有文件系统的磁盘使用情况,包含比如/proc/
    3. -h //以1024进制计算最合适的单位显示磁盘容量
    4. -H //以1000进制计算最合适的单位显示磁盘容量
    5. -t //显示指定类型文件系统的磁盘分区
    6. -T //显示磁盘分区类型
    7. -x //不显示指定类型文件系统的磁盘分区
  • du统计磁盘上的文件大小
    1. -b //以byte为单位统计文件
    2. -k //以KB为单位统计文件
    3. -m //以MB为单位统计文件
    4. -h //以1024进制计算最合适的单位显示磁盘容量
    5. -H //以1000进制计算最合适的单位显示磁盘容量
    6. -s //统计指定目标
  • 常用命令
    1. df -lhT
    2. df -lhT -t ext4(分区类型)
    3. df -lhT -x ext4
    4. du -s [指定目录]
    5. du -sb *.zip //模糊匹配
    6. du -sm *.zip
    7. du -sh *.zip

回顾磁盘分区时的注意事项:

  • 主分区和扩展分区总数不能超过4个。
  • 扩展分区最多只能有一个
  • 扩展分区不能直接存取数据
    小知识:

  • Linux系统中硬件设备都是以文件的形式存在于根目录下的Dev目录下。
  • 硬件设备都是有Linux系统自动识别的。
  • 添加的新硬盘,必须进行分区、格式化、挂载后才能使用。
  • MBR分区模式:主分区不超过4个,单个分区容量最大为2TB
  • GPT分区模式:主分区个数“几乎”没有限制,单个分区容量“几乎”没有限制。GPT分区中,最多可以支持128个主分区,且每个分区的大小突破了MBR分区的2TB的限制,最大为18EB=18432PB=18874368TB。缺点是GPT的主分区中,不适合安装X86架构的系统。

当硬盘空间消耗殆尽时怎么办?

比较好的做法应该是:在保留原硬盘的基础上,给服务器添加新的硬盘。


为虚拟机添加硬盘

  1. 将虚拟机关机(poweroff)。(当然,也有服务器的主板支持热插拔的。可以带电连接新硬盘。)
  2. 虚拟机设置->下面的“添加”->类型选择“硬盘”->下一步->选择硬盘类型(默认的(SCSI)就好)->创建一个新的虚拟机硬盘(下一步)->设置磁盘最大值;(没什么特殊要求,基本都是下一步,最后一步OK)。
  3. 重启Linux系统,使用fdisk -l//显示每个硬盘的分区列表(新添加的硬盘是没有分区表的)可以看到Disk /dev/sdb:和Disk /dev/sda:2块硬盘,以及sda的分区表,没有sdb的分区表。
  4. 先使用MBR分区模式为sdb分区。
    1. [root@joe dev]#

    fdisk /dev/sdb

    1. //进入分区模式
    2. Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
    3. Building a new DOS disklabel with disk identifier 0x9ce83f46.
    4. Changes will remain in memory only, until you decide to write them.
    5. After that, of course, the previous content won't be recoverable.
    6.  
    7. Warning: invalid flag 0x0000 of partition table will be corrected by w(rite)
    8.  
    9. WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
    10. switch off the mode (command 'c') and change display units to
    11. sectors (command 'u').
    12.  
    13. Command (m for help):

    m

    1. //查看帮助
    2. Command action
    3. a toggle a bootable flag
    4. b edit bsd disklabel
    5. c toggle the dos compatibility flag
    6. d delete a partition //删除一个分区
    7. l list known partition types
    8. m print this menu
    9. n add a new partition //添加新的分区
    10. o create a new empty DOS partition table
    11. p print the partition table //打印分区表
    12. q quit without saving changes //取消保存并退出
    13. s create a new empty Sun disklabel
    14. t change a partition's system id //修改分区的系统ID
    15. u change display/entry units
    16. v verify the partition table
    17. w write table to disk and exit //写分区表并退出
    18. x extra functionality (experts only)
    19.  
    20. Command (m for help): n
    21. Command action
    22. e extended //扩展分区
    23. p primary partition (-)//主分区
    24. p
    25. Partition number (-):
    1. First cylinder (-, default ): //扇区的范围(1-2610),默认开始1,直接回车则使用默认数值
    2. Using default value
    3. Last cylinder, +cylinders or +size{K,M,G} (-, default ): 500M
    4.  
    5. Command (m for help): p
    6.  
    7. Disk /dev/sdb: 21.5 GB, bytes
    8. heads, sectors/track, cylinders
    9. Units = cylinders of * = bytes
    10. Sector size (logical/physical): bytes / bytes
    11. I/O size (minimum/optimal): bytes / bytes
    12. Disk identifier: 0x9ce83f46
    13.  
    14. Device Boot Start End Blocks Id System
    15. /dev/sdb1 + Linux //分配好的主分区1
    16. //添加第二个分区
    17. Command (m for help): n
    18. Command action
    19. e extended
    20. p primary partition (-)
    21. p
    22. Partition number (-):
    23. Value out of range.
    24. Partition number (-): 2
    25. First cylinder (-, default ):
    26. Using default value
    27. Last cylinder, +cylinders or +size{K,M,G} (-, default ): 500M
    28. Value out of range.
    29. Last cylinder, +cylinders or +size{K,M,G} (-, default ):
    30. Using default value
    31.  
    32. Command (m for help): p
    33.  
    34. Disk /dev/sdb: 21.5 GB, bytes
    35. heads, sectors/track, cylinders
    36. Units = cylinders of * = bytes
    37. Sector size (logical/physical): bytes / bytes
    38. I/O size (minimum/optimal): bytes / bytes
    39. Disk identifier: 0x9ce83f46
    40.  
    41. Device Boot Start End Blocks Id System
    42. /dev/sdb1 + Linux
    43. /dev/sdb2 Linux //第二个分区
    44. //由于分配不合适主观意愿,想删除分区
    45. Command (m for help): d
    46. Partition number (-):

    2

    1. //分区编号
    2.  
    3. Command (m for help): p
    4.  
    5. Disk /dev/sdb: 21.5 GB, bytes
    6. heads, sectors/track, cylinders
    7. Units = cylinders of * = bytes
    8. Sector size (logical/physical): bytes / bytes
    9. I/O size (minimum/optimal): bytes / bytes
    10. Disk identifier: 0x9ce83f46
    11.  
    12. Device Boot Start End Blocks Id System
    13. /dev/sdb1 + Linux //第二个分区已经删除
    14.  
    15. Command (m for help): n
    16. Command action
    17. e extended
    18. p primary partition (-)
    19. p
    20. Partition number (-):

    2

    1. First cylinder (-, default ):
    2. Using default value
    3. Last cylinder, +cylinders or +size{K,M,G} (-, default ): 1000
    4.  
    5. Command (m for help): p
    6.  
    7. Disk /dev/sdb: 21.5 GB, bytes
    8. heads, sectors/track, cylinders
    9. Units = cylinders of * = bytes
    10. Sector size (logical/physical): bytes / bytes
    11. I/O size (minimum/optimal): bytes / bytes
    12. Disk identifier: 0x9ce83f46
    13.  
    14. Device Boot Start End Blocks Id System
    15. /dev/sdb1 + Linux
    16. /dev/sdb2 Linux
    17.  
    18. Command (m for help): n
    19. Command action
    20. e extended
    21. p primary partition (-)
    22. e //建立扩展分区
    23. Partition number (-):

    3

    1. First cylinder (-, default ):
    2. Using default value
    3. Last cylinder, +cylinders or +size{K,M,G} (-, default ):
    4. Using default value
    5.  
    6. Command (m for help): p
    7.  
    8. Disk /dev/sdb: 21.5 GB, bytes
    9. heads, sectors/track, cylinders
    10. Units = cylinders of * = bytes
    11. Sector size (logical/physical): bytes / bytes
    12. I/O size (minimum/optimal): bytes / bytes
    13. Disk identifier: 0x9ce83f46
    14.  
    15. Device Boot Start End Blocks Id System
    16. /dev/sdb1 + Linux
    17. /dev/sdb2 Linux
    18. /dev/sdb3 Extended
    19.  
    20. Command (m for help): n
    21. Command action
    22. l logical (

    or over)

    1. //此时扩展分区e没有了,说明MBR只能有一个扩展分区,接下来是逻辑分区
    2. p primary partition (-)
    3. l
    4. First cylinder (-, default ):
    5. Using default value
    6. Last cylinder, +cylinders or +size{K,M,G} (-, default ):
    7.  
    8. Command (m for help): p
    9.  
    10. Disk /dev/sdb: 21.5 GB, bytes
    11. heads, sectors/track, cylinders
    12. Units = cylinders of * = bytes
    13. Sector size (logical/physical): bytes / bytes
    14. I/O size (minimum/optimal): bytes / bytes
    15. Disk identifier: 0x9ce83f46
    16.  
    17. Device Boot Start End Blocks Id System
    18. /dev/sdb1 + Linux
    19. /dev/sdb2 Linux
    20. /dev/sdb3 Extended
    21. /dev/sdb5 + Linux //逻辑分区是从5开始的,1-4只能是主分区和扩展分区的编号
    22.  
    23. Command (m for help): n
    24. Command action
    25. l logical ( or over)
    26. p primary partition (-)
    27. l
    28. First cylinder (-, default ):
    29. Using default value
    30. Last cylinder, +cylinders or +size{K,M,G} (-, default ):
    31. Using default value
    32.  
    33. Command (m for help): p
    34.  
    35. Disk /dev/sdb: 21.5 GB, bytes
    36. heads, sectors/track, cylinders
    37. Units = cylinders of * = bytes
    38. Sector size (logical/physical): bytes / bytes
    39. I/O size (minimum/optimal): bytes / bytes
    40. Disk identifier: 0x9ce83f46
    41.  
    42. Device Boot Start End Blocks Id System
    43. /dev/sdb1 + Linux
    44. /dev/sdb2 Linux
    45. /dev/sdb3 Extended
    46. /dev/sdb5 + Linux
    47. /dev/sdb6 + Linux
    48.  
    49. Command (m for help):

    w //保存写

    1. The partition table has been altered!
    2.  
    3. Calling ioctl() to re-read partition table.
    4. Syncing disks.
    5. [root@joe dev]# fdisk

    -

    1. l
    2.  
    3. Disk

    /dev/sdb

    1. : 21.5 GB, bytes
    2. heads, sectors/track, cylinders
    3. Units = cylinders of * = bytes
    4. Sector size (logical/physical): bytes / bytes
    5. I/O size (minimum/optimal): bytes / bytes
    6. Disk identifier: 0x9ce83f46
    7.  
    8. Device Boot Start End Blocks Id System
    9. /dev/sdb1 + Linux
    10. /dev/sdb2 Linux
    11. /dev/sdb3 Extended
    12. /dev/sdb5 + Linux
    13. /dev/sdb6 + Linux
    14.  
    15. Disk

    /dev/sda

    1. : 21.5 GB, bytes
    2. heads, sectors/track, cylinders
    3. Units = cylinders of * = bytes
    4. Sector size (logical/physical): bytes / bytes
    5. I/O size (minimum/optimal): bytes / bytes
    6. Disk identifier: 0x000a030a
    7.  
    8. Device Boot Start End Blocks Id System
    9. /dev/sda1 * Linux
    10. Partition does not end on cylinder boundary.
    11. /dev/sda2 Linux swap / Solaris
    12. Partition does not end on cylinder boundary.
    13. /dev/sda3 Linux
    14. Partition does not end on cylinder boundary.
    15. /dev/sda4 Extended
    16. /dev/sda5 Linux
  5. 使用GPT分区模式分区(同时GPT的分区工具parted也可以MBR分区)
    1. [root@joe dev]# parted
    2. GNU Parted 2.1
    3. 使用

    /dev/sda

    1. //注意正在使用的是sda
    2. Welcome to GNU Parted! Type 'help' to view a list of commands.
    3. (parted) print all
    4. Model: VMware, VMware Virtual S (scsi)
    5. Disk /dev/sda: .5GB
    6. Sector size (logical/physical): 512B/512B
    7. Partition Table: msdos
    8.  
    9. Number Start End Size Type File system 标志
    10. 1049kB 211MB 210MB primary ext4 启动
    11. 211MB 2308MB 2097MB primary linux-swap(v1)
    12. 2308MB 4405MB 2097MB primary ext4
    13. 4405MB .5GB .1GB extended
    14. 4406MB .5GB .1GB logical ext4
    15.  
    16. Model: VMware, VMware Virtual S (scsi)
    17. Disk

    /dev/sdb:

    1. .5GB
    2. Sector size (logical/physical): 512B/512B
    3. Partition Table: msdos //sdb的应该是我们需要的gpt
    4.  
    5. Number Start End Size Type File system 标志
    6.  
    7. 警告: 无法以读写方式打开 /dev/sr0 (只读文件系统)。/dev/sr0 已按照只读方式打开。
    8. 错误: /dev/sr0: unrecognised disk label
    9.  
    10. (parted)

    select /dev/sdb

    1. //选择sdb
    2. 使用 /dev/sdb
    3. (parted) mkpart //如果不进行gpt的选择设置,直接mkpart那么我们还是使用的MBR模式
    4. 分区类型? primary/主分区/extended/扩展分区? primary
    5. 文件系统类型? [ext2]? ^Z
    6. --------------------------------------------------------------------------------------------------
    7. (parted)

    select /dev/

    1. sdb
    2. 使用 /dev/sdb
    3. (parted) mklabel gpt
    4. 警告: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you
    5. want to continue?
    6. 是/Yes/否/No? yes
    7. (parted) print all
    8. Model: VMware, VMware Virtual S (scsi)
    9. Disk

    /dev/sda:

    1. .5GB
    2. Sector size (logical/physical): 512B/512B
    3. Partition Table: msdos
    4.  
    5. Number Start End Size Type File system 标志
    6. 1049kB 211MB 210MB primary ext4 启动
    7. 211MB 2308MB 2097MB primary linux-swap(v1)
    8. 2308MB 4405MB 2097MB primary ext4
    9. 4405MB .5GB .1GB extended
    10. 4406MB .5GB .1GB logical ext4
    11.  
    12. Model: VMware, VMware Virtual S (scsi)
    13. Disk

    /dev/sdb:

    1. .5GB
    2. Sector size (logical/physical): 512B/512B
    3. Partition Table: gpt
    4.  
    5. Number Start End Size File system Name 标志
    6.  
    7. 警告: 无法以读写方式打开 /dev/sr0 (只读文件系统)。/dev/sr0 已按照只读方式打开。
    8. 错误: /dev/sr0: unrecognised disk label
    9.  
    10. (parted) mkpart
    11. 分区名称? []? test1
    12. 文件系统类型? [ext2]? ext4
    13. 起始点?

    1

    1. //以1开始,默认单位是M unit GB 指定为GB为单位
    2. 结束点? 1000M
    3. (parted) print
    4. Model: VMware, VMware Virtual S (scsi)
    5. Disk /dev/sdb: .5GB
    6. Sector size (logical/physical): 512B/512B
    7. Partition Table: gpt
    8.  
    9. Number Start End Size File system Name 标志
    10. 1049kB 1000MB 999MB test1
    11.  
    12. (parted)

    rm

    1. //删除分区
    2. (parted) print
    3. Model: VMware, VMware Virtual S (scsi)
    4. Disk /dev/sdb: .5GB
    5. Sector size (logical/physical): 512B/512B
    6. Partition Table: gpt
    7.  
    8. Number Start End Size File system Name 标志
    9.  
    10. (parted) mkpart
    11. 分区名称? []? test1
    12. 文件系统类型? [ext2]? ext4
    13. 起始点?0 //以0开始,出现了警告,这里是字节对齐的原因造成的,所以一般为了避免警告,我们不以0开始。
    14. 结束点? 1000M
    15. 警告: The resulting partition is not properly aligned for best performance.
    16. 忽略/Ignore/放弃/Cancel? cancel
    17. (parted) mkpart
    18. 分区名称? []? test1
    19. 文件系统类型? [ext2]? ext4
    20. 起始点?1
    21. 结束点?1000M
    22. (parted) print
    23. Model: VMware, VMware Virtual S (scsi)
    24. Disk /dev/sdb: .5GB
    25. Sector size (logical/physical): 512B/512B
    26. Partition Table: gpt
    27.  
    28. Number Start End Size File system Name 标志
    29. 1049kB 1000MB 999MB test1
    30.  
    31. (parted) mkpart
    32. 分区名称? []? test2
    33. 文件系统类型? [ext2]? ext4
    34. 起始点? 1000M
    35. 结束点? 1500M
    36. (parted) print
    37. Model: VMware, VMware Virtual S (scsi)
    38. Disk /dev/sdb: .5GB
    39. Sector size (logical/physical): 512B/512B
    40. Partition Table: gpt
    41.  
    42. Number Start End Size File system Name 标志
    43. 1049kB 1000MB 999MB test1
    44. 1000MB 1500MB 500MB test2
    45. //上面是交互模式,下面是命令模式
    46. (parted) mkpart test3
    1. //使用一条命令直接搞定 分区名 起始位 结束位
    2. 警告: The resulting partition is not properly aligned for best performance. //出现分区的原因是起始的1500和上次结束的1500重叠了。
    3. 忽略/Ignore/放弃/Cancel? cancel
    4. (parted) mkpart test3 1501M 1700M
    5. (parted) mkpart test4 1701M 1800M
    6. (parted) mkpart test5 1801M 1900M
    7. (parted) print
    8. Model: VMware, VMware Virtual S (scsi)
    9. Disk /dev/sdb: .5GB
    10. Sector size (logical/physical): 512B/512B
    11. Partition Table: gpt
    12.  
    13. Number Start End Size File system Name 标志
    14. 1049kB 1000MB 999MB test1
    15. 1000MB 1500MB 500MB test2
    16. 1501MB 1700MB 199MB test3
    17. 1701MB 1800MB .6MB test4
    18. 1801MB 1900MB .6MB test5
    19.  
    20. (parted)

    rm

    1. (parted) quit
  6. 分区完以后,就是格式化和挂载分区了。也就是设置文件系统。在这里需要注意以下内容:MBR分区只能格式化主分区和扩展分区,逻辑分无不能格式化 GPT分区,在格式化以后,只能使用parted 的print查看格式结果 挂载分区:分区默认的挂载目录/mnt目录挂载点必须存在。
    1. [root@joe dev]#

    ls -l /dev/sdb*

    1. brw-rw----. root disk , 5 : /dev/sdb
    2. brw-rw----. root disk , 5 : /dev/sdb1
    3. brw-rw----. root disk , 5 : /dev/sdb2
    4. brw-rw----. root disk , 5 : /dev/sdb3
    5. brw-rw----. root disk , 5 : /dev/sdb5
    6. brw-rw----. root disk , 5 : /dev/sdb6
    7. [root@joe dev]# mkfs.ext3

    /dev/sdb1

    1. //第一种设置方式
    2. mke2fs 1.41. (-May-)
    3. 文件系统标签=
    4. 操作系统:Linux
    5. 块大小= (log=)
    6. 分块大小= (log=)
    7. Stride= blocks, Stripe width= blocks
    8. inodes, blocks
    9. blocks (5.00%) reserved for the super user
    10. 第一个数据块=
    11. Maximum filesystem blocks=
    12. block groups
    13. blocks per group, fragments per group
    14. inodes per group
    15. Superblock backups stored on blocks:
    16. , , , , , , ,
    17.  
    18. 正在写入inode表: 完成
    19. Creating journal ( blocks): 完成
    20. Writing superblocks and filesystem accounting information: 完成
    21.  
    22. This filesystem will be automatically checked every mounts or
    23. days, whichever comes first. Use tune2fs -c or -i to override.
    24. [root@joe dev]# mkfs

    -t ext4 /dev/sdb2

    1. //第二种方法
    2. mke2fs 1.41. (-May-)
    3. 文件系统标签=
    4. 操作系统:Linux
    5. 块大小= (log=)
    6. 分块大小= (log=)
    7. Stride= blocks, Stripe width= blocks
    8. inodes, blocks
    9. blocks (5.00%) reserved for the super user
    10. 第一个数据块=
    11. Maximum filesystem blocks=
    12. block groups
    13. blocks per group, fragments per group
    14. inodes per group
    15. Superblock backups stored on blocks:
    16. , ,
    17.  
    18. 正在写入inode表: 完成
    19. Creating journal ( blocks): 完成
    20. Writing superblocks and filesystem accounting information: 完成
    21.  
    22. This filesystem will be automatically checked every mounts or
    23. days, whichever comes first. Use tune2fs -c or -i to override.
    24. [root@joe dev]#

    mkdir -p /mnt/joetest

    1. //首先建立挂载点
    2. [root@joe dev]#

    mount /dev/sdb1 /mnt/joetest/

    1. //挂载分区
    2. [root@joe dev]#

    umount /mnt/joetest/

    1. //卸载挂载点
    2.  
    3. 上面这中挂载方式是临时的,永久性的应该如下:
    4. vim

    + /etc/

    1. fstab
    2. 在末尾插入一行

    /dev/sdb1 /mnt/imooc ext3 default

    1. 设备名称 挂载点 文件系统类型
    2. 保存退出即可
  7. swap交换分区(步骤为:建立一个普通的Linux分区,修改分区类型的16进制编码,格式化交换分区,启用交换分区。
    1. [root@joe dev]#

    fdisk /dev/

    1. sdb
    2.  
    3. WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.
    4. WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
    5. switch off the mode (command 'c') and change display units to
    6. sectors (command 'u').
    7.  
    8. Command (m for help): p
    9.  
    10. Disk /dev/sdb: 21.5 GB, bytes
    11. heads, sectors/track, cylinders
    12. Units = cylinders of * = bytes
    13. Sector size (logical/physical): bytes / bytes
    14. I/O size (minimum/optimal): bytes / bytes
    15. Disk identifier: 0x00000000
    16.  
    17. Device Boot Start End Blocks Id System
    18. /dev/sdb1 + Linux
    19. /dev/sdb2 Linux
    20. /dev/sdb3 Extended
    21. /dev/sdb5 + Linux
    22. /dev/sdb6 + Linux
    23.  
    24. Command (m for help): t
    25. Partition number (-):
    1. //修改ID
    2. Hex code (type L to list codes): L
    3.  
    4. Empty NEC DOS Minix / old Lin bf Solaris
    5. FAT12 Plan

    Linux swap

    1. / So c1 DRDOS/sec (FAT-
    2. XENIX root 3c PartitionMagic

    Linux

    1. c4 DRDOS/sec (FAT-
    2. XENIX usr Venix OS/ hidden C: c6 DRDOS/sec (FAT-
    3.  
    4. Hex code (type L to list codes): 82
    5. Changed system type of partition to (Linux swap / Solaris)
    6.  
    7. Command (m for help): w
    8. The partition table has been altered!
    9.  
    10. Calling ioctl() to re-read partition table.
    11. Syncing disks.
    12. [root@joe dev]# fdisk

    /dev/

    1. sdb
    2.  
    3. WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.
    4. WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
    5. switch off the mode (command 'c') and change display units to
    6. sectors (command 'u').
    7.  
    8. Command (m for help): p
    9.  
    10. Disk /dev/sdb: 21.5 GB, bytes
    11. heads, sectors/track, cylinders
    12. Units = cylinders of * = bytes
    13. Sector size (logical/physical): bytes / bytes
    14. I/O size (minimum/optimal): bytes / bytes
    15. Disk identifier: 0x00000000
    16.  
    17. Device Boot Start End Blocks Id System
    18. /dev/sdb1 + Linux
    19. /dev/sdb2

    Linux swap /

    1. Solaris
    2. /dev/sdb3 Extended
    3. /dev/sdb5 + Linux
    4. /dev/sdb6 + Linux
    5.  
    6. Command (m for help): q
    7.  
    8. [root@joe dev]# mkswap

    /dev/sdb2

    1. //设置交换区
    2. Setting up swapspace version , size = KiB
    3. no label, UUID=c7d31434--4bbb-b68e-29b501934377
    4. [root@joe dev]# swapon

    /dev/sdb2

    1. //开启交换区
    2. [root@joe dev]# free
    3. total used free shared buffers cached
    4. Mem:
    5. -/+ buffers/cache:
    6. Swap:
    1. [root@joe dev]# swapoff

    /dev/sdb2

    1. //关闭交换区
    2. [root@joe dev]#

Linux-磁盘管理小结的更多相关文章

  1. Linux 磁盘管理

    Linux磁盘管理好坏管理直接关系到整个系统的性能问题. Linux磁盘管理常用三个命令为df.du和fdisk. df:列出文件系统的整体磁盘使用量 du:检查磁盘空间使用量 fdisk:用于磁盘分 ...

  2. df、du、fdisk:Linux磁盘管理三板斧的使用心得(转载)

    From:http://os.51cto.com/art/201012/240726_all.htm 作者介绍:李洋(博客),博士毕业于中科院计算所.10多年来一直从事计算机网络信息安全研发工作,曾主 ...

  3. linux 磁盘管理学习笔记

    磁盘管理命令:fdisk df du fdisk #查看硬盘分区表 df #查看分区使用情况 du #查看文件占用空间情况lvdisplay #逻辑分区 [1] 李洋.df.du.fdisk:Linu ...

  4. linux磁盘管理系列-软RAID的实现

    1 什么是RAID RAID全称是独立磁盘冗余阵列(Redundant Array of Independent Disks),基本思想是把多个磁盘组合起来,组合一个磁盘阵列组,使得性能大幅提高. R ...

  5. linux磁盘管理系列-LVM的使用

    LVM是什么 LVM是Linux操作系统的逻辑卷管理器. 现在有两个Linux版本的LVM,分别是 LVM1,LVM2.LVM1是一种已经被认为稳定了几年的成熟产品,LVM2 是最新最好的LVM版本. ...

  6. linux磁盘管理系列三:LVM的使用

    磁盘管理系列 linux磁盘管理系列一:磁盘配额管理   http://www.cnblogs.com/zhaojiedi1992/p/zhaojiedi_linux_040_quota.html l ...

  7. linux磁盘管理系列二:软RAID的实现

    磁盘管理系列 linux磁盘管理系列一:磁盘配额管理   http://www.cnblogs.com/zhaojiedi1992/p/zhaojiedi_linux_040_quota.html l ...

  8. linux磁盘管理系列一:磁盘配额管理

    磁盘管理系列 linux磁盘管理系列一:磁盘配额管理   http://www.cnblogs.com/zhaojiedi1992/p/zhaojiedi_linux_040_quota.html l ...

  9. Linux磁盘管理,vi编辑器以及包管理器

    一.Linux磁盘管理 Linux磁盘管理常用的三个命令为df,du,fdisk df:列出文件系统的整体磁盘使用量,利用这个命令来获取磁盘被占用了多少空间,,目前还剩下多少空间用法:df [-ahi ...

  10. Linux 磁盘管理的命令

    Linux   磁盘管理 磁盘分区及挂载: 先查询系统的使用情况: 使用fdisk -l语句 查询结果: 进行磁盘的新建:***添加磁盘时系统必须处于关机状态** 在进行对系统磁盘的使用情况的查询 查 ...

随机推荐

  1. LINQ - 在Where條件式中使用in與not in

    希望对大家在以后的项目中能用到,我也是在项目中碰到了这个问题: 算算時間,接觸LINQ也有一個月的時間了,可以算是落伍兼新生,不過最近在寫專案的時候,遇到了在LINQ的Where條件式中要如何使用in ...

  2. 不支持C++11 decltype的噩耗

    前言:因为公司现在使用vs2008,所以很多c++11的新特性还未能使用,导致写了很多冤枉代码. 最初引擎的数学库非常简单,使用起来也不方便,例如: float FastLerp(const floa ...

  3. max min 与 min max 的差别

    在求解最优化问题时,遇到一个对偶问题的转换:对于形如 的问题,可以转换为求解 即原问题的对偶问题.而在一般情况下: 对于这个为题的说明我参照http://math.stackexchange.com/ ...

  4. 开启Python之路

    开始自学Python 环境配置 自己百度去!!! 计算与变量 字符创.列表.元组和字典 简单的画图 使用if和else条件控制语句 循环 使用函数和模块来重用代码 使用类和对象 Python内建函数的 ...

  5. bootstrap 模态框禁用空白处点击关闭

    bootstrap 3 模态框为信息编辑窗口,默认点击空白处会自动关闭,但是有的时候这个功能需要关闭,比如编辑信息,一不小心点击了空白处,那就要重新编辑了. bootstrap 3 模态框禁用空白处点 ...

  6. flashftp连接虚拟机centos报错的解决方法

    flashftp连接虚拟机centos报错,一般情况可能是因为端口(22)的权限没有开放 先在centos中检查并开放22端口,执行:iptables -I INPUT -p tcp --dport ...

  7. 黑马程序员-scanf函数

    变量的内存:字节和地址:1.变量的存储单位是字节,每个字节都有存储地址.2.不同的数据大小占用的内存带下不同拥有的字节数也是不同的.变量的存储:1.存储是按照,先存储的放在地址教高的位置,优先存储的地 ...

  8. (01背包 排序+特判)饭卡(hdu 2546)

    http://acm.hdu.edu.cn/showproblem.php?pid=2546   Problem Description 电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额 ...

  9. If you really want to compile without asm, configure with --disable-asm.

    真是一个奇葩问题,对我来说是的,完全不知道是什么意思,但是他就是出现了. 找到了一个相关问题http://trac.ffmpeg.org/wiki/How%20to%20quickly%20compi ...

  10. Python学习之路--Socket

    Socket socket通常也称作"套接字",用于描述IP地址和端口,是一个通信链的句柄,应用程序通常通过"套接字"向网络发出请求或者应答网络请求. sock ...