Wiki
Clone wikiLinux / How-To-Extend-Non-LVM-Partition-Linux
###This Wiki how to extend standard / (root) partition in Ubuntu Linux. Which is Non-LVM Partition###
Requirement
-
One Working Linux BOX. In My scenario, I am using Centos6.8 Final release
-
My Current Partition details are as follow
#!php [root@cent ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 15G 1.4G 13G 10% / tmpfs 372M 0 372M 0% /dev/shm
#!php [root@cent ~]# fdisk -l Disk /dev/sda: 17.2 GB, 17179869184 bytes 255 heads, 63 sectors/track, 2088 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: 0x00046e53 Device Boot Start End Blocks Id System /dev/sda1 1 128 1024000 82 Linux swap / Solaris Partition 1 does not end on cylinder boundary. /dev/sda2 * 128 2089 15752192 83 Linux [root@cent ~]# df -T Filesystem Type 1K-blocks Used Available Use% Mounted on /dev/sda2 ext4 15373716 1369360 13216748 10% / tmpfs tmpfs 379988 0 379988 0% /dev/shm [root@cent ~]#
Now Extend HDD Size As per your Requirement
- Current Virtual HDD is 16G.
- Extended size 4G more Now Virtual HDD Total size is 20G
- Virtual HDD has been extended from VMWare properties, Lets check partition size and Virtual HDD size to verify is it extended or not.
- Lest perform action to extend partition, We will use fdisk utility
#!php [root@cent ~]# fdisk -l ## fdisk utility Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 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: 0x00046e53 Device Boot Start End Blocks Id System /dev/sda1 1 128 1024000 82 Linux swap / Solaris Partition 1 does not end on cylinder boundary. /dev/sda2 * 128 2089 15752192 83 Linux [root@cent ~]# fdisk /dev/sda ## Select HDD to perform action 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 ## P command to list current partition Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 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: 0x00046e53 Device Boot Start End Blocks Id System /dev/sda1 1 128 1024000 82 Linux swap / Solaris Partition 1 does not end on cylinder boundary. /dev/sda2 * 128 2089 15752192 83 Linux Command (m for help): d ## d command to delete partition in this case we will delete partition number 2, ## make sure not write partition before get process complete. Partition number (1-4): 2 Command (m for help): n ## n to create new partition Command action e extended p primary partition (1-4) p Partition number (1-4): 2 ## Create same partition and give same number First cylinder (128-2610, default 128): Using default value 128 Last cylinder, +cylinders or +size{K,M,G} (128-2610, default 2610): 2610 Command (m for help): p ## Again list partition Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 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: 0x00046e53 Device Boot Start End Blocks Id System /dev/sda1 1 128 1024000 82 Linux swap / Solaris Partition 1 does not end on cylinder boundary. /dev/sda2 128 2610 19939801 83 Linux Command (m for help): w ## w command to write change The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: 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) Syncing disks. [root@cent ~]#
Restart PC to make sure reread partition table
*Now resize partition using resize2fs command
#!php [root@cent ~]# resize2fs /dev/sda2 resize2fs 1.41.12 (17-May-2010) Filesystem at /dev/sda2 is mounted on /; on-line resizing required old desc_blocks = 1, new_desc_blocks = 2 Performing an on-line resize of /dev/sda2 to 4984950 (4k) blocks. The filesystem on /dev/sda2 is now 4984950 blocks long. [root@cent ~]#
- Now run df -h command to check extended partiton size
#!php [root@cent ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 19G 1.4G 17G 8% / tmpfs 372M 0 372M 0% /dev/shm [root@cent ~]#
- Now partition has been extended, New size is lested below.
That's all
Cheers
Updated