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

What is the add and delete partition command in the Linux system

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Editor to share with you what the add and delete partition command is in the Linux system. I hope you will get something after reading this article. Let's discuss it together.

In the Linux system, if you want to add and delete partitions, you can use the fdisk command. After executing the command, you will be prompted, and you only need to follow the prompts step by step.

Fdisk command: add a partition fdisk-l to view partition information on the system

[root@fei] # fdisk-l Disk / dev/sda: 21.5 GB, 21474836480 bytes / / Total 21.5g 255heads, 63 sectors/track, 2610 cylinders / / 255magnetic planes, 63 sectors 2610 pillars Units = cylinders of 16065 * 512 = 8225280 bytes / / per column capacity Sector size (logical/physical): 512 bytes / 512 bytes I size O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0005936c Device Boot Start End Blocks Id System / dev/sda1 * 1 26 204800 83 Linux Partition 1 does not end on cylinder boundary. / dev/sda2 26 1332 10485760 83 Linux / dev/sda3 1332 1593 2097152 82 Linux swap / Solaris 1234567891011121314fdisk / dev/sda: partition / dev/sda/ means: hda1 hda2 hdb1 hdb2... Sda1 sda2 sdb1 sdb2... Hd is mostly IDE hard disk, and sd is mostly SCSI or removable storage.

[root@fei ~] # fdisk / dev/sda 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): 1234567 Note: / / Command (m for help): view help information: enter m See the following information Command action # output help information a toggle a bootable flag # set startup information b edit bsd disklabel # catalogue partition label c toggle the dos compatibility flag d delete a partition # this is the action to delete a partition l list known partition types # l is to list the partition type The type m print this menu # m that allows us to set the corresponding partition is to list help information N add a new partition # add a partition; o create a new empty DOS partition table # create a new DOS partition table p print the partition table # p list partition tables; q quit without saving changes # do not save exit S create a new empty Sun disklabel t change a partition's system id # t change partition type id u change display/entry units change reality unit v verify the partition table w write table to disk and exit # write partition table to hard disk and exit x extra functionality (experts only) # extended application Expert function 123456789101112131415161718192021-Select n to add a partition Command (m for help): n Command action e extended # e, extended partition p primary partition (1-4) # p, main partition 1-4 p Selected partition 4 # because sda1-3 has been divided, all default sda4 First cylinder (1593-2610, default 1593): # magnetic column start position, default Direct enter Using default value 1593 # Pillar start position Last cylinder, + cylinders or + size {KMagneM MagneG} (1593-2610, default 2610): + 100m # Pillar explanation position Set disk partition size Command (m for help): P # check the current disk information Disk / dev/sda: 21.5disk, 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 O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0005936c Device Boot Start End Blocks Id System / dev/sda1 * 1 26 204800 83 Linux Partition 1 does not end on cylinder boundary. / dev/sda2 26 1332 10485760 83 Linux / dev/sda3 1332 1593 2097152 82 Linux swap / Solaris / dev/sda4 1593 1606 111459 83 Linux / / added successfully, sda4 Command (m for help): wq / / Save exit 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 are 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. After 1234567891011121314151617181920212223242526272829303132333435363738partprobe or partx-a / dev/sda partition, let the kernel update the partition information, otherwise the kernel will not recognize the new partition until the system needs restart.

Mkfs.ext4 / dev/sda4 creates the ext4 file system and formats it.

[root@fei ~] # mkfs.ext4 / dev/sda4 mke2fs 1.41.12 (17-May-2010) File system tag = operating system: Linux Block size = 1024 (log=0) Block size = 1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 3776 inodes, 15068 blocks 753 blocks (5.00%) reserved for the super user first data block = 1 Maximum filesystem blocks=15466496 2 block groups 8192 blocks per group 8192 fragments per group 1888 inodes per group Superblock backups stored on blocks: 8193 is writing inode table: complete Creating journal (1024 blocks): complete Writing superblocks and filesystem accounting information: complete This filesystem will be automatically checked every 38 mounts or 180days, whichever comes first. Use tune2fs-c or-i to override. 1234567891011121314151617181920212223 mount / dev/sda4

[root@fei ~] # mount / dev/sda4 / mnt [root@fei ~] # df-h-bash: df-h: command not found [root@fei ~] # df-h Filesystem Size Used Avail Use% Mounted on / dev/sda2 9.8G 1.4G 8.0G 15% / tmpfs 931m 0931m 0% / dev/shm / dev/sda1 190M 35M 145m 20% / boot / dev/sr0 3.7G 3 .7G 0 100% / media / dev/sda4 14M 130K 13m 2% / mnt / / the / dev/sda4 mount 12345678910 has deleted a partition [root@fei ~] # fdisk / dev/sda 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): d / delete a partition Partition number (1-4): 4 / / choose to delete a partition, if you delete an extended partition All logical partitions under the extended partition will delete Command (m for help): P 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 O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0005936c Device Boot Start End Blocks Id System / dev/sda1 * 1 26 204800 83 Linux Partition 1 does not end on cylinder boundary. / dev/sda2 26 1332 10485760 83 Linux / dev/sda3 1332 1593 2097152 82 Linux swap / Solaris / / sda4 has been deleted Command (m for help): wq / / if there is an erroneous operation before, you can read this article only by typing Q instead of w. I believe you have a certain understanding of "what is the command to add and delete partitions in Linux system". If you want to know more related knowledge, welcome to follow the industry information channel, thank you for reading!

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

Development

Wechat

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

12
Report