Use the fdisk and partprobe command to add a new disk partition without restarting the system.

Source: Internet
Author: User
Use the fdisk command in combination with the partprobe command without restarting the system to add a new disk partition host with a hard disk exceeding 300 GB. Currently, only three primary partitions are used, less than 70 GB, as shown below: [root @ db2 ~] # Df-hFilesystemSizeUsedAvailUse % Mountedon/d... use the fdisk command in combination with the partprobe command without restarting the system to add a new disk partition host with a hard disk exceeding 300 GB. Currently, only three primary partitions are used, less than 70 GB, as shown below: [root @ db2 ~] # Df-h Filesystem Size Used Avail Use % Mounted on/dev/sda1 29G 3.7G 24G 14% // dev/sda2 29G 22G 5.2G 81%/oracle tmpfs 2.0G 0 2.0G 0%/dev/shm [root @ db2 ~] # Cat/proc/partitionsmajor minor # blocks name 8 0 311427072 sda sda1 8 2 30716280 sda2 8 3 8193150 sda3 8 16 976896 sdb 8 32 976896 sdc now you need to add a GB space to store data files, without affecting the operation of services on the existing system, use the fdisk and partprobe command to add a new disk partition without restarting the system. The procedure is as follows: Step 1: Add a new disk partition [root @ db2 ~] # Fdisk/dev/sdaThe number of cylinders for this disk is set to 38770. 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): p Disk/dev/sda: 318.9 GB, 318901321728 bytes255 head S, 63 sectors/track, 38770 cylindersUnits = cylinders of 16065*512 = 8225280 bytes Device Boot Start End Blocks Id System/dev/sda1 * 1 3824 30716248 + 83 Linux/dev/sda2 3825 7648 30716280 83 Linux/dev /sda3 7649 8668 8193150 82 Linux swap/Solaris Command (m for help): nCommand action e extended p primary partition (1-4) pSelected partition 4 First cylinder (8669-38770, default 8669): Using default Value 8669 Last cylinder or + size or + sizeM or + sizeK (8669-38770, default 38770): + 100G Command (m for help): wThe 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. syncing disks. [root @ db2 ~] # Step 2: Use the partprobe tool to allow the kernel to read partition information [root @ db2 ~] # Partprobe uses the fdisk tool to only write partition information to the disk. if mkfs disk partition is required, the system needs to be restarted. if partprobe is used, the kernel can re-read the partition information to avoid restarting the system. Step 2: format the file system [root @ db2 ~] # Mkfs. ext3/dev/sda4mke2fs 1.39 (29-May-2006) Filesystem label = OS type: LinuxBlock size = 4096 (log = 2) Fragment size = 4096 (log = 2) 12222464 inodes, 24416791 blocks1220839 blocks (5.00%) reserved for the super userFirst data block = 0 Maximum filesystem blocks = 4294967296746 block groups32768 blocks per group, 32768 fragments per group16384 inodes per groupSuperblock ups stored on blocks: 32768,983 04, 1 63840,229 376, 294912,819 200, 884736,160 5632, 2654208,409 6000, 7962624,112 39424, 20480000,238 87872 Writing inode tables: doneCreating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: done This filesystem will be automatically checked every 26 mounts or180 days, whichever comes first. use tune2fs-c or-I to override. [root @ db2 ~] # Step 2: mount the new partition/dev/sda4 [root @ db2 ~] # E2label/dev/sda4/data [root @ db2 ~] # Mkdir/data [root @ db2 ~] # Mount/dev/sda4/data [root @ db2 ~] # DfFilesystem 1K-blocks Used Available Use % Mounted on/dev/sda1 29753556 3810844 24406900 14% 29753588 // dev/sda2 11304616 16913160 41% 2023936/oracletmpfs 2023936 0 0%/dev/shm/dev/sda4 96132968 192312 91057300 1%/data [root @ db2 ~] # Conclusion: you can use partprobe to create a new partition with the fdisk tool without restarting the system.
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.