RHEL5.4 online Change the disk partition size

Source: Internet
Author: User
The disk partitions mentioned here refer to non-system partitions and non-LVM partitions. The following describes how to scale down and expand the current partition structure: [root @ vm3 ~] # Fdisk-lDisk/dev/sda: 10.7 GB, listen 37418240bytes255heads, 63 sectors/track, 1305 cylindersUnits = cylindersof16065 * 512 =

The disk partitions mentioned here refer to non-system partitions and non-LVM partitions. The following describes how to scale up and down

Current partition structure: [root @ vm3 ~] # Fdisk-l

Disk/dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065*512 = 8225280 bytes

Device Boot Start End Blocks Id System
/Dev/sda1*1 1239 9952236 83 Linux
/Dev/sda2 1240 1304 522112 + 82 Linux swap/Solaris

Disk/dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065*512 = 8225280 bytes

Device Boot Start End Blocks Id System
/Dev/sdb1 1 1305 10482381 83 Linux File System usage [root @ vm3 ~] # Df
File System 1 K-block used available % mount point
/Dev/sda1 9640260 5056192 408646056%/
Tmpfs 383616 03836160%/dev/shm
/Dev/sdb1 10317828 2182424792576022%/data 1. To reduce the capacity of sdb1, we can see that the available space of sdb1 is 7925760 kb, we split it into 2 GB. 1. unmount the mounted partition [root @ vm3 ~]. # Umount/data
Umount:/data: device is busy
Umount:/data: device is busy
[Root @ vm3 ~] # Fuser-vm/data

USER PID ACCESS COMMAND
/Data: mysql 5522 F. c .. mysqld

[Root @ vm3 ~] # Killed 5522
[Root @ vm3 ~] # Umount/data2 for file system detection [root @ vm3 ~] # E2fsck-f/dev/sdb1
E2fsck 1.39 (29-May-2006)
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
/Dev/sdb1: 197/1310720 files (22.3% non-contiguous), 586743/2620595 blocks3, resize File System [root @ vm3 ~] # Resize2fs/dev/sdb1 8317828 k
Resize2fs 1.39 (29-May-2006)
Resizing the filesystem on/dev/sdb1 to 2079457 (4 k) blocks.
The filesystem on/dev/sdb1 is now 2079457 blocks long. the size set here is reduced by 2000 k based on the original total size, that is, 10317828-2000000 = 83178284. How to Determine the partition size by adjusting the partition size? The above red text indicates that the file system size has been reset to 2079457 (4 k) blocks, that is, 2079457*4 k = 8317828 k [root @ vm3 ~] # Fdisk/dev/sdb <
> D
> N
> P
> 1
>
> + 8317828 K
> W
> EOF Note: Here is the capital K, 1 k = 1000 bytes, 1 K = 1024bytes5, and then run the file system detection [root @ vm3 ~] # E2fsck-f/dev/sdb1
E2fsck 1.39 (29-May-2006)
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
/Dev/sdb1: 197/1048576 files (22.3% non-contiguous), 578519/2079457 blocksok, no problem. The file system has been detected. If k is used in the preceding case, an error occurs as follows: [root @ vm3 ~] # E2fsck-f/dev/sdb1
E2fsck 1.39 (29-May-2006)
The filesystem size (according to the superblock) is 2079457 blocks
The physical size of the device is 2032214 blocks
Either the superblock or the partition table is likely to be uploaded upt!
Abort ? Yes means that the partition size is smaller than the file system size 6. Mount the partition [root @ vm3 ~] # Mount/dev/sdb1/data
[Root @ vm3 ~] # Ls/data
Db1 db2 log lost + found mongodb mysqlok. The data is still there. The adjustment is successful! 7. Create partitions for the remaining space [root @ vm3 ~] # Fdisk/dev/sdb <
> N
> P
> 2
>
>
> W
> EOF8: Format partitions and mount partitions [root @ vm3 ~] # Mkfs. ext3/dev/sdb2
[Root @ vm3 ~] # Mount/dev/sdb2/mnt
[Root @ vm3 ~] # Ls/mnt
Lost + found9. File System usage [root @ vm3 ~] # Df
File System 1 K-block used available % mount point
/Dev/sda1 96402605055024408762856%/
Tmpfs 38361603836160%/dev/shm
/Dev/sdb1 8186172 2182420 600375227%/data
/Dev/sdb2 21188646877619424564%/mnt

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.