Linux commands (25) Disk Management commands (iii) FDISK

Source: Internet
Author: User

I. Description of FDISK command

FDISK is a partition management tool under Linux, and it is a type of tool software such as partition Assistant under Windows. Anyone who has a sub-zone installed operating system knows that hard disk partitioning is necessary and important. The Help for Fdisk is as follows:

 [[email protected] hk]# fdisk/dev/sdbwelcome to fdisk (Util-linux 2.23.2). Changes'll remain in memory only, until the decide to write them. Be careful before using the Write command. Device does not contain a recognized partition tablebuilding a new DOS disklabel with disk identifier 0xb7af7b64. Command (M for help): Hh:unknown Commandcommand Action A toggle a bootable flag B edit BSD Disklabel c toggle The DOS Compatibility flag d Delete a partition G create a new empty GPT partition Table G Create an IRIX (SG I) partition table l list known partition types m print this menu n add a new partition O create a new emp Ty DOS partition table p print the partition table Q quit without saving changes s create a new empty Sun disk Label T change a partition ' s system ID u change display/entry units v Verify the partition table W write t Able to disk and exit X extra functionality (experts only) 

The parameters used in the above parameters are described:

Second, hard disk detailed partition and mount process complete demonstration
# view partition information first [[email protected] hk]# fdisk-ldisk/dev/sda:42.9 GB, 42949672960 bytes, 83886080 sectorsunits = sectors O F 1 * bytessector size (logical/physical): bytes/512 bytesi/o size (minimum/optimal): bytes/512 byte   Sdisk label Type:dosdisk IDENTIFIER:0X000C44FB Device Boot Start End Blocks Id system/dev/sda1 * 2048 2099199 1048576 linux/dev/sda2 2099200 83886079 40893440 8e Linux lvm# here/de V/sdb for unused partitions disk/dev/sdb:1073 MB, 1073741824 bytes, 2097152 sectorsunits = sectors of 1 * = bytessector size (l  ogical/physical): bytes/512 bytesi/o size (minimum/optimal): bytes/512 bytesdisk/dev/mapper/cl-root:39.7 GB, 39720058880 bytes, 77578240 sectorsunits = sectors of 1 * MB = bytessector size (logical/physical): bytes/512 BYTESI/O size (minimum/optimal): bytes/512 bytesdisk/dev/mapper/cl-swap:2147 MB, 2147483648 bytes, 4194304 sectors Units = sectors of 1 * 5Bytessector size (logical/physical): bytes/512 bytesi/o size (minimum/optimal): Up to bytes/512 bytes# started partition [[email protected] hk]# fdisk/dev/sdbwelcome to fdisk (Util-linux 2.23.2). Changes'll remain in memory only, until the decide to write them. Be careful before using the Write command. Device does not contain a recognized partition tablebuilding a new DOS disklabel with disk identifier 0xca00a0b9.# M view Help Co Mmand (M for help): Mcommand action A toggle a bootable flag B edit BSD Disklabel c toggle the DOS Compatibili   Ty Flag D Delete a partition G create a new empty GPT partition Table G Create an IRIX (SGI) partition table L list known partition types m print this menu n add a new partition o create a new empty DOS partition tab  Le 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 table to disk and exit X extra functionality (experts only) # Create a new partition Command (M for help): N Partition Type:p Primary (0 primary, 0 extended, 4 free) e Extended # p means the primary partition is created and E represents the extended partition select (Default p): Ppart  Ition number (1-4, default 1): 1 # select 1 or Use default first sector (2048-2097151, default 2048): # Start section using default    Value 2048# +400m represents allocating 400M space to a partition, the default allocation of all remaining space on the disk last sector, +sectors or +size{k,m,g} (2048-2097151, default 2097151): +400m Partition 1 of type Linux and of size set# MiB is to use W Save command (M for help): wthe Partition table have been altere D! Calling IOCTL () to re-read partition table. Syncing disks. #查看分区情况 [[email protected] hk]# fdisk-ldisk/dev/sda:42.9 GB, 42949672960 bytes, 83886080 sectorsunit s = sectors of 1 * bytessector size (logical/physical): bytes/512 bytesi/o size (minimum/optimal): byt    es/512 bytesdisk label Type:dosdisk identifier:0x000c44fb Device Boot Start End  Blocks Id system/dev/sda1 * 2048 2099199 1048576 2099200 83886079 40893440 8e Linux lvmdisk/dev/sdb:1073 MB, 1073741824 bytes, 2097152 sectorsunits = sectors of 1 * = Bytesse ctor Size (logical/physical): bytes/512 bytesi/o size (minimum/optimal): bytes/512 bytesdisk label TYPE:DOSDI SK identifier:0xca00a0b9# This is the partition that we just allocated Device Boot Start End Blocks Id system/dev/sdb1 2 048 821247 409600 linuxdisk/dev/mapper/cl-root:39.7 GB, 39720058880 bytes, 77578240 sectorsunits = Secto RS of 1 * The Bytessector size (logical/physical): bytes/512 bytesi/o size (minimum/optimal): bytes/512  bytesdisk/dev/mapper/cl-swap:2147 MB, 2147483648 bytes, 4194304 sectorsunits = sectors of 1 * = bytessector size (logical/physical): bytes/512 bytesi/o size (minimum/optimal): Up to bytes/512 bytes# format the newly created partition in ext3 format [[EMA Il protected] hk]#Mkfs-t ext3/dev/sdb1mke2fs 1.42.9 (28-dec-2013) Filesystem label=os type:linuxblock size=1024 (log=0) Fragment size=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks102400 inodes, 409600 blocks20480 blocks (5.00%) reserved for the Super Userfirst da Ta block=1maximum filesystem blocks=6763315250 block groups8192 blocks per group, 8192 fragments per group2048 inodes per  Groupsuperblock backups stored on blocks:8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409Allocating Group Tables:done Writing inode tables:done Creating Journal (8192 bloc KS): donewriting superblocks and filesystem accounting Information:done #创建挂载目录 [[email protected] hk]# mkdir/mnt/d isk2# Mount/dev/sdb1 to/mnt/disk2[[email protected] hk]# mount/dev/sdb1/mnt/disk2/# view partition is mounted properly [[email  Protected] hk]# df-hfilesystem Size used Avail use% mounted ONDEVTMPFS 463M 0 463M 0%/devt    MPFS 488M 0 488M 0%/dev/shmtmpfs 488M 13M 475M 3%/runtmpfs 488M 0 488M 0%/SYS/FS/CG     Roup/dev/mapper/cl-root 37G 3.6G 34G 10%//dev/sda1 1014M 246M 769M 25%/boottmpfs 98M  0 98M 0%/run/user/1000/dev/sdb1 380M 2.3M 358M 1%/mnt/disk2 #这里可以看见分区已经正常挂载 # Edit system Partition Table/etc/fstab Enable Auto-mount [[email protected] hk]# Vim/etc/fstab #/etc/fstab# Created by Anaconda on Tue Nov-20:59:37 2017## acce Ssible filesystems, by reference, is maintained under '/dev/disk ' # See mans Pages Fstab (5), Findfs (8), mount (8) and/or BLK ID (8) For more INFO#/DEV/MAPPER/CL-ROOT/XFS defaults 0 0uuid=03cf4f74-827e-40a1-a67    F-2227be43dee7/boot XFS defaults 0 0/dev/mapper/cl-swap swap Swap Defaults 0 0/dev/sdb1/mnt/disk2 ext3 default 0 0 # Add the partition information to the end of the/etc/fstab file, save and exit # Switch to the partition mounted directory, create a file test partition can with [[email protected] hk]# cd/mnt/disk2/[[email protected] disk2]# touch test.txt[[email protected] disk2]# lslost+found test.txt 

Linux Commands (25) Disk Management commands (iii) FDISK

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.