AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题 / 406637
Accepted
user8036224
user8036224
Asked: 2017-11-24 11:06:58 +0800 CST2017-11-24 11:06:58 +0800 CST 2017-11-24 11:06:58 +0800 CST

fdisk 没有看到 resize2fs 缩小未挂载的分区

  • 772

我需要在现有磁盘(/dev/vda,20G)上创建另一个分区(/dev/vda2)。

umount /mnt/
resize2fs /dev/vda1 10G
df -h

...
/dev/vda1       9.8G  7.8G  1.5G  85% /mnt

所以这边没问题,但是fdisk不行:

 fdisk -l /dev/vda
Disk /dev/vda: 20 GiB, 21474836480 bytes, 41943040 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: gpt
Disk identifier: XXX

Device     Start      End  Sectors Size Type
/dev/vda1   4096 41943006 41938911  20G Linux filesystem
/dev/vda15  2048     4095     2048   1M BIOS boot

/dev/vda1 仍被视为 20G。

但是, tune2fs 是正确的:

 tune2fs -l /dev/vda1
tune2fs 1.43.4 (31-Jan-2017)
Filesystem volume name:   DOROOT
Last mounted on:          /mnt
Filesystem UUID:          XXX
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize
Filesystem flags:         signed_directory_hash
Default mount options:    user_xattr acl
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              652800
Block count:              2621440
Reserved block count:     129948
Free blocks:              510232
Free inodes:              438179
First block:              0
Block size:               4096
Fragment size:            4096
Reserved GDT blocks:      1023
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         8160
Inode blocks per group:   510
Flex block group size:    16
Filesystem created:       Fri Oct 21 16:17:46 2016
Last mount time:          Thu Nov 23 17:35:09 2017
Last write time:          Thu Nov 23 17:42:31 2017
Mount count:              1
Maximum mount count:      -1
Last checked:             Thu Nov 23 17:31:54 2017
Check interval:           0 (<none>)
Lifetime writes:          456 GB
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               256
Required extra isize:     28
Desired extra isize:      28
Journal inode:            8
Default directory hash:   half_md4
Directory Hash Seed:      XXX
Journal backup:           inode blocks

块数 * 块大小为 10G 那么 fdisk 会发生什么?剩下的10G怎么分区?

partition fdisk
  • 1 1 个回答
  • 627 Views

1 个回答

  • Voted
  1. Best Answer
    donnie
    2017-11-24T11:27:10+08:002017-11-24T11:27:10+08:00

    您必须删除分区并创建一个新分区。

    显示分区信息:

    Command (m for help): p
    Disk /dev/vda: 407.6 GiB, 437629485056 bytes, 854745088 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    Disklabel type: dos
    Disk identifier: 0x5c873cba 
    Partition 2 does not start on physical sector boundary. 
    
    Device        Boot        Start     End         Blocks      Id    System 
    /dev/vda1      *          2048      1026047     512000      83    Linux
    /dev/vda2                 1026048   1640447     307200      8e    Linux LVM
    

    删除分区:

    Command (m for help): d
    Partition number (1,2, default 2): 2 
    
    Partition 2 has been deleted.
    

    创建一个新分区:

    Command (m for help): n 
    
    Partition type: 
      p  primary (1 primary, 0 extended, 3 free) 
      e  extended 
    Select (default p): *Enter* 
    
    Using default response p. 
    Partition number (2-4, default 2): *Enter*
    First sector (1026048-854745087, default 1026048): *Enter* 
    Last sector, +sectors or +size{K,M,G,T,P} (1026048-854745087, default 854745087): +500M 
    
    Created a new partition 2 of type 'Linux' and of size 500 MiB.
    

    显示分区信息:

    Command (m for help): p 
    Disk /dev/vda: 407.6 GiB, 437629485056 bytes, 854745088 sectors 
    Units: sectors of 1 * 512 = 512 bytes 
    Sector size (logical/physical): 512 bytes / 4096 bytes 
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes 
    Disklabel type: dos 
    Disk identifier: 0xf6e2b6cb 
    
    Device        Boot        Start     End         Blocks      Id    System 
    /dev/vda1      *          2048      1026047     512000      83    Linux 
    /dev/vda2                 1026048   2050047     512000      8e    Linux LVM
    

    当您确定更改正确时,请使用 w 选项写入更改。

    检查文件系统:

    e2fsck /dev/vdb1
    e2fsck 1.41.12 (17-May-2010)
    Pass 1:Checking inodes, blocks, and sizes
    Pass 2:Checking directory structure
    Pass 3:Checking directory connectivity
    Pass 4:Checking reference counts
    Pass 5:Checking group summary information
    ext4-1:11/131072 files (0.0% non-contiguous),27050/524128 blocks
    
    • 0

相关问题

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    JSON数组使用jq来bash变量

    • 4 个回答
  • Marko Smith

    日期可以为 GMT 时区格式化当前时间吗?[复制]

    • 2 个回答
  • Marko Smith

    bash + 通过 bash 脚本从文件中读取变量和值

    • 4 个回答
  • Marko Smith

    如何复制目录并在同一命令中重命名它?

    • 4 个回答
  • Marko Smith

    ssh 连接。X11 连接因身份验证错误而被拒绝

    • 3 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Marko Smith

    systemctl 命令在 RHEL 6 中不起作用

    • 3 个回答
  • Marko Smith

    rsync 端口 22 和 873 使用

    • 2 个回答
  • Marko Smith

    以 100% 的利用率捕捉 /dev/loop -- 没有可用空间

    • 1 个回答
  • Marko Smith

    jq 打印子对象中所有的键和值

    • 2 个回答
  • Martin Hope
    EHerman JSON数组使用jq来bash变量 2017-12-31 14:50:58 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST
  • Martin Hope
    Drux 日期可以为 GMT 时区格式化当前时间吗?[复制] 2017-12-26 11:35:07 +0800 CST
  • Martin Hope
    AllisonC 如何复制目录并在同一命令中重命名它? 2017-12-22 05:28:06 +0800 CST
  • Martin Hope
    Steve “root”用户的文件权限如何工作? 2017-12-22 02:46:01 +0800 CST
  • Martin Hope
    Bagas Sanjaya 为什么 Linux 使用 LF 作为换行符? 2017-12-20 05:48:21 +0800 CST
  • Martin Hope
    Cbhihe 将默认编辑器更改为 vim for _ sudo systemctl edit [unit-file] _ 2017-12-03 10:11:38 +0800 CST
  • Martin Hope
    showkey 如何下载软件包而不是使用 apt-get 命令安装它? 2017-12-03 02:15:02 +0800 CST
  • Martin Hope
    youxiao 为什么目录 /home、/usr、/var 等都具有相同的 inode 编号 (2)? 2017-12-02 05:33:41 +0800 CST
  • Martin Hope
    user223600 gpg —list-keys 命令在将私钥导入全新安装后输出 uid [未知] 2017-11-26 18:26:02 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve