Online adjustment of ext3 disk capacity

Source: Internet
Author: User
Before you adjust the ext3 disk capacity online, use tarcfdiskhometarhome for packaging and backup. 1. check the disk partition information. fdisk-lDiskdevsda: 2919 GB, 291999055872bytes255heads, 63 sectorstrack, and tar cf/disk/home.tar/home must be used for packaging and backup before resizing the ext3 disk capacity online. 1. View disk partitions fdisk-lDisk/dev/sda: 291.9 GB, 291999055872 bytes255 heads, 63 sectors/track, 35500 cylindersUnits = cylinders of 16065*512 = 8225280 bytes disk size, block size and cylinder condition [root @ localhost ~] # Df-B 4 k Filesystem 4K-blocks Used Available Use % Mounted on/dev/sda2 990087 500195 438786 54% 3575306 // dev/sda5 41828 3348932 2% 11659/home/dev/sda1 2638 8419 24%/boot tmpfs 67424 0 67424 0%/dev/shm df-B 4 k in 4 k, it is convenient to calculate the modified size of the subsequent partition [root @ localhost ~] # Df-h Filesystem Size Used Avail Use % Mounted on/dev/sda2 3.8G 2.0G 1.7G 54%/dev/sda5 14G 164 M 13G 2%/home/dev/ sda1 46 M 11 M 33 M 24%/boot tmpfs 264 M 0 264 M 0%/dev/shm disk partition and directory mounting 2. record disk cylinder and partition size to be divided calculate the ending cylinder number e. g: the size of the original/usr/local is 5000 MB, the start cylinder number is 2550, and the end cylinder number is 3157. now I want to change its size to 1000 MB, so we should calculate the end cylindrical number ([3.2] = 4): end cylindrical number = 2550 + [(1000*1024*1024) /8225280] = 2678 use fdisk to delete the original partition (data in the previous partition will not be lost !). Then create a new partition. The only difference between the new partition and the old partition is that the partition size is different, which is manifested in the fact that they terminate different cylindrical numbers. increase partition size: the ending cylinder number is set to the last cylinder number of the free space. reduce partition size: the ending cylinder number is calculated. 3. adjust the umount/dev/sda5 # unmount the partition fsck-n/dev/sda5 #-n parameter to output only disk information, tune2fs-O ^ has_journal/dev/sda5 # Convert ext3 to ext2, because only ext2 supports adjusting the partition size e2fsck-f/dev/sda5 # check whether the ext2 file system is normal and then adjust the partition size, however, make sure that the size of the adjusted partition is greater than the space used by the current partition. For example, if the current partition uses 180 M, you must reserve at least 1 GB of space for the partition. Resize2fs/dev/sda5 5000 M # adjust the partition to 5 Gfdisk/dev/sda # note that sda is not sda5. Re-create the partition information (note that you must select the correct Partition identifier. this is sda5, so select 5 when you delete it) [root @ localhost ~] # Fdisk/dev/sda note: Here is/dev/sda instead of/dev/sda5 The number of cylinders for this disk is set to 2610. there is nothing wrong with that, but this is larger than 1024, and cocould in certain setups cause problems with: 1) software that runs at boot time (e.g ., old versions of LILO) 2) booting and partitioning software from other OSs (e.g ., dos fdisk, OS/2 FDISK) Command (m for help): m Command action a toggl E 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 ta Ble to disk and exit x extra functionality (experts only) Command (m for help): Delete a partition (/dev/sda5) Command (m for help ): d Partition number (1-5): 5 create a new Partition Command (m for help): n First cylinder (773-2610, default 773 ): 773 you will be asked to fill in the size of the new partition, and start the cylindrical default. now the key is to end the calculation of the cylindrical. We can see from the previous data that the size of the file system is 1280000*4 K. to ensure that our partition is large enough to include the file system, you can increase the file system size by 3% -- 5% as the partition size. Therefore, the partition Size is size = 1280000*4 K * 1.05 = 5376000 K Last cylinder or + Size or + sizeM or + sizeK (773-2610, default 2610 ): + 5376000 K then use the parameter a Command (m for help): a Partition number (1-5): 5 Option a is interpreted as toggle a bootable flag, which is not very understandable for this option, however, an obvious function is to allocate a zone number for the new partition. here, select 5 (/dev/sda5 ). Write The modification to The partition table and exit fdisk Command (m for help): w 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. restart the system with Syncing disks. Rebootfsck-n/dev/sda5 # Check the adjusted partition information tune2fs-j/dev/sda5 # convert ext2 to ext3reboot # restart the system again and check the size of/home df- if B 4kdf-hfdisk-l is not mounted, after editing the/etc/fstab file, run mount-a to mount the file. You can use fdisk/dev/sda to create new partitions for the split free partitions. Note the start and end positions of the disk cylinder number.
Related Article

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.