Use the fdisk and partprobe commands in Linux to create and format partitions without restarting the system (1)
Due to work needs, I have been learning Linux for some time. To learn a new knowledge, I like to learn from a book or a certain video system, so that I can have a comprehensive understanding and understanding of the new learning knowledge. So before learning, I bought a private house dish of laruence as a reference book and started to study Linux systematically.
According to laruence's suggestion, an empty capacity is reserved for exercise partition during Virtual Machine installation. Therefore, when Linux system partition is installed on a virtual machine, only a 4G capacity is allocated to the root directory "/", and only a 2G swap partition is divided. There are still 14 GB capacity not allocated.
When learning disk management, use fdisk to continue partitioning the remaining capacity. However, after the partition is created, you cannot use partprobe to reload the partition.
The procedure is as follows:
1. Use fdisk to create a partition
....) The partition operation record is not saved. After executing the command w, the following information appears:
- 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: 0x000b604c Device Boot Start End Blocks Id System
- /Dev/sda1*1 523 4194304 83 Linux
- Partition 1 does not end on cylinder boundary.
- /Dev/sda2 523 784 2097152 82 Linux swap/Solaris
- Partition 2 does not end on cylinder boundary.
- /Dev/sda3 784 2610 14672345 5 Extended
- /Dev/sda5 784 1421 5121671 83 LinuxCommand (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: the device or resource is busy.
- The kernel still uses the old table. The new table will be used
- The next reboot or after you run partprobe (8) or kpartx (8)
- Syncing disks.
-
Save the new partition and prompt "the device or resource is busy". The operation was performed on the/dev/sda hard disk and thought the prompt was normal, so ignore it and continue the next step.
2. Use partprobe to reload the partition table to avoid restarting the system.
- [Root @ stduy/] # partprobe
- Warning: WARNING: the kernel failed to re-read the partition table on/dev/sda (the device or resource is busy ). as a result, it may not reflect all of your changes until after reboot.
- Warning: you cannot open/dev/sr0 in read/write mode (read-only file system ). /Dev/sr0 is enabled in read-only mode.
- Warning: you cannot open/dev/sr0 in read/write mode (read-only file system ). /Dev/sr0 is enabled in read-only mode.
- Error: the Partition Table-/dev/sr0 is invalid and recursive partitions appear.
In the above information, the warning "the device or resource is busy, you need to restart the system to make the change take effect" is directly ignored as a normal phenomenon. However, the Error message "Error: Invalid Partition Table-/dev/sr0 indicates recursive partition ." I am a little confused. However, since the prompt "invalid Partition Table" is displayed, I will check the partition information.