• Linux磁盘分区、格式化和挂载


    一、查看磁盘使用

    [root@iZ88rvassw1Z ~]# df -h
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/vda1        40G  2.3G   36G   7% /
    tmpfs           1.9G     0  1.9G   0% /dev/shm

    二、查看磁盘分区

    [root@iZ88rvassw1Z ~]# fdisk -l
    
    Disk /dev/vda: 42.9 GB, 42949672960 bytes
    255 heads, 63 sectors/track, 5221 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: 0x00078f9c
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/vda1   *           1        5222    41940992   83  Linux
    
    Disk /dev/vdb: 1099.5 GB, 1099511627776 bytes
    16 heads, 63 sectors/track, 2130440 cylinders
    Units = cylinders of 1008 * 512 = 516096 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000

    目前系统存在了两块磁盘,分别为“/dev/vda”和“/dev/vdb”;

    “/dev/vda”已经存在了一个分区“/dev/vda1”;

    “/dev/vda1”没有分区。

     

    三、磁盘分区命令

    clipboard

     

    四、执行分区操作

    [root@iZ88rvassw1Z ~]# fdisk /dev/vdb
    Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
    Building a new DOS disklabel with disk identifier 0x3d7d21d6.
    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): p
    
    Disk /dev/vdb: 1099.5 GB, 1099511627776 bytes
    16 heads, 63 sectors/track, 2130440 cylinders
    Units = cylinders of 1008 * 512 = 516096 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x3d7d21d6
    
       Device Boot      Start         End      Blocks   Id  System
    
    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)
    p
    Partition number (1-4): 1
    First cylinder (1-2130440, default 1): 
    Using default value 1
    Last cylinder, +cylinders or +size{K,M,G} (1-2130440, default 2130440): 
    Using default value 2130440
    
    
    Command (m for help): p
    
    Disk /dev/vdb: 1099.5 GB, 1099511627776 bytes
    16 heads, 63 sectors/track, 2130440 cylinders
    Units = cylinders of 1008 * 512 = 516096 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x3d7d21d6
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/vdb1               1     2130440  1073741728+  83  Linux
    
    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)
    p
    Partition number (1-4): 2
    No free sectors available
    
    Command (m for help): w
    The partition table has been altered!
    
    Calling ioctl() to re-read partition table.
    Syncing disks.
    [root@iZ88rvassw1Z ~]#

    再次查看分区:

    clipboard

     

    五、查看原有分区格式

    clipboard

    为ext4格式。

     

    六、格式化分区

    clipboard

     

    七、挂载分区

    clipboard

    八、开机自动挂载

    修改/etc/fstab,添加记录即可。

    clipboard

  • 相关阅读:
    Newtonsoft.Json 处理多态类型的反序列化
    33条C#和.NET经典面试题目及答案
    转:原码,反码,补码详解
    使用OpenXML操作Office文档
    WPF的Binding学习笔记(二)
    WPF的Binding学习笔记(一)
    M6: 使用摄像头(CameraCaptureUI)
    M5: 使用StorageFile
    NYOJ144_小珂的苦恼_C++
    搜索水题四连发_C++
  • 原文地址:https://www.cnblogs.com/xusweeter/p/8386359.html
Copyright © 2020-2023  润新知