0

I need to make another parition (/dev/vda2) on an existing disk (/dev/vda, 20G).

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

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

So it's ok on this side, but not for 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 is still seen as 20G.

However, tune2fs is correct:

 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

block count * block size is 10G so what happens to fdisk? How could I partition the remaining 10G?

2
  • Both tools are right. A "filesystem" doesn't necessarily span over an entire "partition". Nov 23, 2017 at 19:12
  • @don_crissti, how would I reduce the partition then? lvreduce? Nov 23, 2017 at 19:18

1 Answer 1

0

You have to delete the partition and create a new one.

Show partition information:

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

delete the partition:

Command (m for help): d
Partition number (1,2, default 2): 2 

Partition 2 has been deleted.

create a new partition:

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.

Show partition information:

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

Write the changes with the w option when you are sure they are correct.

Check the filesystem:

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
3
  • Thanks for the extensive reply but I don't have a vda2 partition, that's what I want. I only have the main partition (20G with a 10G FS) and the boot (vda15). Nov 23, 2017 at 19:32
  • @user8036224 You made the file system smaller. Yes, delete /dev/vda1 and create it new. Its only the partition layout the data will stay there. The new partition can be smaller and create one extra /dev/vda2
    – donnie
    Nov 23, 2017 at 19:33
  • I was very suspicious but after reading the original article (access.redhat.com/articles/1190213) you're right. Once should never forget the warning: Warning: If you are recreating a partition in order to allow for more room on a mounted file system, ensure you create it with the same starting disk sector as before. Otherwise the resize operation will not work and the entire file system may be lost. Nov 23, 2017 at 20:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .