• ubuntu 磁盘分区


    1:查看分区情况:df -h

    admin@iZwz92c0zpe8t65qe996ckZ:/$ df -h
    Filesystem      Size  Used Avail Use% Mounted on
    udev            983M     0  983M   0% /dev
    tmpfs           201M   24M  177M  12% /run
    /dev/vda1        40G  9.3G   28G  25% /
    tmpfs          1001M     0 1001M   0% /dev/shm
    tmpfs           5.0M  4.0K  5.0M   1% /run/lock
    tmpfs          1001M     0 1001M   0% /sys/fs/cgroup
    tmpfs           201M     0  201M   0% /run/user/1000

    2:查看某一个目录挂载在哪一个分区下面:df -h 目录

    admin@iZwz92c0zpe8t65qe996ckZ:/$ df -h /srv/
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/vda1        40G  9.3G   28G  25% /

    3:给磁盘进行分区:sudo fdisk /dev/vda

    admin@iZwz92c0zpe8t65qe996ckZ:/$ sudo fdisk /dev/vda
    
    Welcome to fdisk (util-linux 2.27.1).
    Changes will remain in memory only, until you decide to write them.
    Be careful before using the write command.
    
    
    Command (m for help): m

    使用m查看命令的使用方法

      Misc
       m   print this menu
       u   change display/entry units
       x   extra functionality (experts only)
    
      Script
       I   load disk layout from sfdisk script file
       O   dump disk layout to sfdisk script file
    
      Save & Exit
       w   write table to disk and exit
       q   quit without saving changes
    
      Create a new label
       g   create a new empty GPT partition table
       G   create a new empty SGI (IRIX) partition table
       o   create a new empty DOS partition table
       s   create a new empty Sun partition table
    
    
    Command (m for help):

    命令p打印分区情况:

    Command (m for help): p
    Disk /dev/vda: 40 GiB, 42949672960 bytes, 83886080 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: dos
    Disk identifier: 0xd6804155
    
    Device     Boot Start      End  Sectors Size Id Type
    /dev/vda1  *     2048 83884031 83881984  40G 83 Linux

    d 删除分区

    命令n 添加分区:

    Command (m for help): d
    Selected partition 1
    Partition 1 has been deleted.
    
    Command (m for help): n
    Partition type
       p   primary (0 primary, 0 extended, 4 free)
       e   extended (container for logical partitions)
    Select (default p):

    添加分区

    Select (default p): p
    Partition number (1-4, default 1): 1
    First sector (2048-83886079, default 2048):
    Last sector, +sectors or +size{K,M,G,T,P} (2048-83886079, default 83886079): 40000000
    
    Created a new partition 1 of type 'Linux' and of size 19.1 GiB.
    
    Command (m for help): p
    Disk /dev/vda: 40 GiB, 42949672960 bytes, 83886080 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: dos
    Disk identifier: 0xd6804155
    
    Device     Boot Start      End  Sectors  Size Id Type
    /dev/vda1        2048 40000000 39997953 19.1G 83 Linux

    再添加一个分区:

    Using default response p.
    Partition number (2-4, default 2): 2
    First sector (40000001-83886079, default 40001536):
    Last sector, +sectors or +size{K,M,G,T,P} (40001536-83886079, default 83886079): 83886079
    
    Created a new partition 2 of type 'Linux' and of size 20.9 GiB.
    
    Command (m for help): p
    Disk /dev/vda: 40 GiB, 42949672960 bytes, 83886080 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: dos
    Disk identifier: 0xd6804155
    
    Device     Boot    Start      End  Sectors  Size Id Type
    /dev/vda1           2048 40000000 39997953 19.1G 83 Linux
    /dev/vda2       40001536 83886079 43884544 20.9G 83 Linux

    使用命令w保存修改

    命令q是修改失效,上面修改没用

    Command (m for help): w
    The partition table has been altered.
    Calling ioctl() to re-read partition table.
    Re-reading the partition table failed.: Device or resource busy
    
    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).

    执行 partprobe

    admin@iZwz92c0zpe8t65qe996ckZ:~$ partprobe

    提示 /dev/vda2不存在

     执行:sudo mknod /dev/vda2 b 8 4     http://blog.itpub.net/28874898/viewspace-774249/

    admin@iZwz92c0zpe8t65qe996ckZ:~$ sudo mknod  /dev/vda2  b 8 4
    sudo: unable to resolve host iZwz92c0zpe8t65qe996ckZ
    admin@iZwz92c0zpe8t65qe996ckZ:~$ ll /dev/vda*
    brw-rw---- 1 root disk 253, 0 Oct 30 16:08 /dev/vda
    brw-rw---- 1 root disk 253, 1 Oct 30 16:08 /dev/vda1
    brw-r--r-- 1 root root   8, 4 Oct 30 16:28 /dev/vda2

    3:卸载磁盘挂载:

    admin@iZwz92c0zpe8t65qe996ckZ:/$ sudo umount /dev/vda
    sudo: unable to resolve host iZwz92c0zpe8t65qe996ckZ
    umount: /dev/vda: not mounted

    4:阿里云安装完系统之后,只有一个分区,想要变成多个分区?

    可以先缩小分区的容量,然后用多余的容量去再分区。

  • 相关阅读:
    Altera Coding Style 之多路选择器
    Altera Coding Style 之 时钟切换
    Altera Coding Style 之状态机
    Altera Coding Style 之 Latch
    Altera Coding Style 之 加法器
    JS代码小集合
    汉字转换字符C#(c shap) 代码
    php动态调用方法
    JavaScript 拖放效果
    C# 取得域名及目录地址
  • 原文地址:https://www.cnblogs.com/liyafei/p/9875778.html
Copyright © 2020-2023  润新知