Disk resizing for CentOS
After installing CentOS, I found that the space is too small. How can I increase the hard disk capacity? That is, create another hard disk:
Enable virtual economy settings and add a hard disk
View existing disk space
Fdisk-l
[Root @ localhost ~] # Fdisk-l
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: 0x000e4bd8
Device Boot Start End Blocks Id System
/Dev/sda1*1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/Dev/sda2 64 2611 20458496 8e Linux LVM
Disk/dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 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: 0x00000000
I added/dev/sdb.
Partition the newly added Hard Disk
Fdisk/dev/sdb
Enter m to view help information.
Command (m for help): m
Command action
A toggle a bootable flag
B edit bsd disklabel
C toggle the dos compatibility flag
D delete a partition
L list known partition types
M print this menu
N add a new partition
O create a new empty DOS partition table
P print the partition table
Q quit without saving changes
S create a new empty Sun disklabel
T change a partition's system id
U change display/entry units
V verify the partition table
W write table to disk and exit
X extra functionality (experts only)
Command (m for help ):
Add new partition
Command (m for help): n
Select basic information partition and enter: p
Command (m for help): n
Command action
E extended
P primary partition (1-4)
Enter
First cylinder (1-15908, default 1): Enter
(This is the default split size when you press Enter)
Write and exit
Command (m for help): w
Format the disk partition.
Format/dev/sdb1 in ext4 format
Mkfs. ext4/dev/sdb1
[Root @ localhost ~] # Mkfs. ext4/dev/sdb
Mke2fs 1.41.12 (17-May-2010)
/Dev/sdb is entire device, not just one partition!
What should I do? (Y, n) y
/Dev/sdb has been mounted; will not make a file system here!
[Root @ localhost ~] #
Because my extended drive letter has been attached and is in use.
Mount a partition
Create a mount point first
Mkdir/work
Mount-t ext4/dev/sdb1/work
View Mount status
Df-h
[Root @ localhost ~] # Df-h
Filesystem Size Used Avail Use % Mounted on
/Dev/mapper/VolGroup-lv_root 18G 11G 6.2G 63%/
Tmpfs 932 M 72 K 932 M 1%/dev/shm
/Dev/sda1 485 M 40 M 421 M 9%/boot
/Dev/sdb 5.0G 138 M 4.6G 3%/work
[Root @ localhost ~] #
Add the mounted directory to auto mount upon startup
/Dev/sdb1/work ext4 errors = remount-ro 0 1
Complete.