Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of creating and formatting Partition under Linux

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "the method of new partition and formatting under Linux". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the method of new partition and formatting under Linux".

When learning disk management, use fdisk to continue partitioning the remaining capacity. However, it was found that after creating a new partition, the partition could not be reloaded through partprobe.

The specific actions are as follows:

1. Create a new partition using fdisk

(no, no, no. no, no, no. The partition operation record is not saved. After performing w, the following information appears

Disk / dev/sda: 21.5GB, 21474836480 bytes 255heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000b604c Device Boot Start End Blocks Id System / dev/sda1 * 1523 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 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: equipment or resources busy. The kernel still uses the old table. The new table will be used at 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 done on the / dev/sda hard disk at that time thought the prompt was normal, so ignored it and moved on to the next step.

2. Avoid restarting the system by reloading the partition table through partprobe

[root@stduy /] # partprobe Warning: WARNING: the kernel failed to re-read the partition table on / dev/sda (device or resource busy). As a result, it may not reflect all of your changes until after reboot. Warning: / dev/sr0 (read-only file system) cannot be opened read-write. / dev/sr0 has been opened as read-only. Warning: / dev/sr0 (read-only file system) cannot be opened read-write. / dev/sr0 has been opened as read-only. Error: invalid partition table-recursive partition occurs in / dev/sr0.

In the above message that appeared in the overloaded partition, the warning that "the device or resources are busy and the system needs to be rebooted for the change to take effect" was directly ignored as a normal phenomenon. But for the error message "Error: invalid partition table-/ dev/sr0 recursive partition occurs." I was a little confused, but since I was prompted for "invalid partition table", I checked the partition information.

3. Use the fdisk-l command to view partition information

[root@stduy /] # fdisk-l Disk / dev/sda: 21.5GB, 21474836480 bytes 255heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I bytes Sector size O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000b604c Device Boot Start End Blocks Id System / dev/sda1 * 1523 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 Linux

Check the partition information, it's normal, and the new extended partition / dev/sda3 and logical partition / dev/sda5 are there. The newly created partition / dev/sda5 is formatted directly.

4. Format the newly created logical partition / dev/sda5

[root@stduy /] # mkfs-t ext3 / dev/sda5 mke2fs 1.41.12 (17-May-2010)

Unable to make a stat call to / dev/sda5-there is no file or directory

The device apparently does not exist; did you specify it correctly?

When formatting, the prompt "there is no such file or directory". This is strange, the operation is based on the reference book step by step, why not? So Baidu Linux under the new partition of some information, hope to find similar errors, learn from the solution. After looking around, there was a similar mistake, but no solution was given.

Re-analyze the process of creating a new partition and reloading the partition table, for the prompt that "the device or resource is busy", because it was operated on the / dev/sda hard disk at that time, it should be normal to restart. But after rebooting, / dev/sda5 is still not found, but there is a fdisk-l check. So it is suspected that the "Error: invalid partition table-/ dev/sr0 has a recursive partition when the partition table is overloaded." What about the wrong message?

Check the sr0 under / dev

[root@stduy dev] # ls-lh | grep sr0 lrwxrwxrwx. 1 root root 3 August 5 00:12 cdrom-> sr0 lrwxrwxrwx. 1 root root 3 August 5 00:12 cdrw-> sr0 lrwxrwxrwx. 1 root root 3 August 5 00:12 dvd-> sr0 lrwxrwxrwx. 1 root root 3 August 5 00:12 dvdrw-> sr0 lrwxrwxrwx. 1 root root 3 August 5 00:12 scd0-> sr0 brw-rw----. 1 root cdrom 11, August 5 00:12 sr0

From the above results, sr0 is the optical drive device, Baidu / dev/sr0 this device, is also the optical drive. So it doesn't matter whether it failed to reload the partition table because "Error: invalid partition table-/ dev/sr0 has a recursive partition." Cause, first remove the optical drive, anyway, it is on the virtual machine.

After removing the optical drive device from the virtual machine, restart the system, re-create the partition, and re-execute the partprobe command to reload the partition table with the error message "Error: invalid partition table-/ dev/sr0 has a recursive partition." No, it's just a warning that "equipment or resources are busy" is still there. At this point, directly format the newly created logical partition / dev/sda5 or prompt "there is no such file or directory". So restart the system and format / dev/sda5, which works this time.

That is, the previously created partition format failed because the partition table recursion was caused by the optical drive / dev/sr0 device of the virtual machine. In addition, because it is operating on the same hard disk, the system must be rebooted for the newly created partition to write to the partition table.

In Brother Bird's private dish, he said to reserve a piece of capacity for zoning exercises. How did Brother Bird succeed?

So I found some videos and materials related to Linux disk management and found that they used fdisk to create new partitions using multiple hard drives. Then go back to see Brother Bird's private dishes and find that the hard drive reserved by Brother Bird is / dev/hdc, then there must be / dev/hda and / dev/hdb in Bird's environment, so the experiment is also completed on the basis of how fast the hard drive is.

Then I'll try to assign another hard disk to the virtual machine. So the system is shut down and a 5G virtual disk space is allocated to the system on the virtual machine. Then boot into the system to partition and format the newly added disk space.

The steps are the same as above, partition, reload partition table, view partition, format, here no longer follow the steps, directly give the completed operation record.

[root@stduy] # fdisk-l Disk / dev/sda: 21.5GB, 21474836480 bytes 255heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I bytes Sector size O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000b604c Device Boot Start End Blocks Id System / dev/sda1 * 1523 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 2610 14672345 5 Extended / dev/sda5 2610 14672313 + 83 Linux Disk / dev/sdb: 5368 MB, 5368709120 bytes 255heads, 63 sectors/track, 652 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I bytes Sector size O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 [root@stduy] # fdisk / dev/sdb Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0x851e79cc. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w (rite) WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): P Disk / dev/sdb: 5368 MB, 5368709120 bytes 255heads, 63 sectors/track, 652 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I logical/physical O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x851e79cc Device Boot Start End Blocks Id System Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-652, default 1): Using default value 1 Last cylinder + cylinders or + size {K default default G}: Using default value 652 Command (m for help): P Disk / dev/sdb: 5368 MB, 5368709120 bytes 255heads, 63 sectors/track, 652 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I hand O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x851e79cc Device Boot Start End Blocks Id System / dev/sdb1 1,652 5237158 + 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl () to re-read partition table. Syncing disks. [root@stduy ~] # partprobe / dev/sdb [root@stduy ~] # mkfs-t ext4 / dev/sdb1 mke2fs 1.41.12 (17-May-2010)

File system tag = operating system: Linux Block size = 4096 (log=2) Block size = 4096 (log=2) Stride=0 blocks, Stripe width=0 blocks327680 inodes, 1309289 blocks65464 blocks (5.00%) reserved for the super user

* blocks = 0Maximum filesystem blocks=134217728040 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks: 32768, 98304, 163840,229376,294912,819200884736

Writing inode table: complete

Creating journal (32768 blocks): complete Writing superblocks and filesystem accounting information: complete This filesystem will be automatically checked every 36 mounts or180 days, whichever comes first. Use tune2fs-c or-i to override.

This time there is no warning or error prompt for either creating a new partition or reloading the partition table. Successfully add the hard disk and partition and format the new hard disk without rebooting the system.

Thank you for your reading, the above is the content of "New Partition and formatting method under Linux". After the study of this article, I believe you have a deeper understanding of the new partition and formatting method under Linux, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report