You often use FDISK to partition your hard disk under a Linux system
First, view the system hard disk information
[[email protected] ~]# fdisk -ldisk /dev/sda: 214.7 gb, 214748364800 bytes255 heads, 63 sectors/track, 26108 cylindersunits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (Minimum/optimal): 512 bytes / 512 bytesdisk identifier: 0x00049d20 device boot Start End Blocks Id System/dev/sda1 * 1 26 204800 83 linuxpartition 1 does not end on cylinder boundary./dev/sda2 26 281 2048000 82 linux swap / solarispartition 2 does not end on cylinder boundary./dev/sda3 281 26109 207461376 83 linuxdisk /dev/sdb: 21.5 gb, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersunits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesdisk identifier: 0x00000000disk&nbSp;/dev/sdc: 3221.2 gb, 3221225472000 bytes255 heads, 63 sectors/track, 391625 cylindersunits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesi/o size (Minimum/optimal): 512 bytes / 512 bytesdisk identifier: 0x00000000
Second, through the view results can be seen, the system has 3 hard disks, respectively, is/DEV/SDA,/DEV/SDB,/DEV/SDC.
Partitioning the/dev/sdb
[[Email protected] ~]# fdisk /dev/sdbdevice contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelBuilding a new dos disklabel with disk identifier 0xc1760957. 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 '). #输入m显示帮助信息Command (m for help): mcommand action a toggle a bootable flag b edit bsd disklabel c toggle the dos Compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table 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) #输入n创建一个新分区Command (m  FOR HELP): ncommand action e extended #表示扩展分区 p primary partition (1-4) #表示主分区 # input P , create primary partition p Partition number (1-4): 1 #输入主分区标号, there can be up to 4 primary partitions first cylinder (1-2610, default  1): using default value 1# input +200m, which means to create a 200M partition Last cylinder, +cylinders or +size{k,m,g} (1-2610, default 2610): +200m# input P View partition information command (M FOR HELP): pDisk /dev/sdb: 21.5 gb, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersunits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesi/o size (Minimum/optimal): 512 bytes / 512 bytesdisk identifier: 0xc1760957 device boot start End Blocks Id System/dev/sdb1 1 26 208813+ 83 linux# Input W, Writes partition information to disk command (M FOR HELP): wthe partition table has been altered! Calling ioctl () to re-read partition table. Syncing disks.
View the hard disk information again with FDISK to see if a newly created hard disk exists.
[[email protected] ~]# fdisk -ldisk /dev/sda: 214.7 gb, 214748364800 bytes255 heads, 63 sectors/track, 26108 cylindersunits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (Minimum/optimal): 512 bytes / 512 bytesdisk identifier: 0x00049d20 device boot Start End Blocks Id System/dev/sda1 * 1 26 204800 83 linuxpartition 1 does not end on cylinder boundary./dev/sda2 26 281 2048000 82 linux swap / solarispartition 2 does not end on cylinder boundary./dev/sda3 281 26109 207461376 83 linuxdisk /dev/sdb: 21.5 gb, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersunits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesdisk identifier: 0xc1760957# just to/de.200M partitions created by V/SDB have been displayed Device Boot Start end blocks id System/dev/sdb1 1 26 208813+ 83 LinuxDisk /dev/sdc: 3221.2 GB, 3221225472000 Bytes255 heads, 63 sectors/track, 391625 cylindersunits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (Minimum/optimal): 512 bytes / 512 bytesdisk identifier: 0x00000000
mount the partition under the/data directory
#修改的分区信息刷新到内核中 [[email protected] ~]# partprobe /dev/sdb1# Formats the partition as a Ext4 file system [[email protected] ~]# mkfs.ext4 /dev/sdb1mke2fs 1.41.12 (17-may-2010) Filesystem label= os type: linuxblock size=1024 (log=0) fragment size=1024 (log=0) Stride=0 blocks, stripe width=0 blocks52208 inodes, 208812 blocks10440 blocks ( 5.00%) reserved for the super userfirst data block=1maximum filesystem blocks=6737100826 block groups8192 blocks per group, 8192 fragments per group2008 inodes per groupSuperblock backups stored on Blocks: 8193, 24577, 40961, 57345, 73729, 204801writing inode tables: done creating journal (4096 blocks): doneWriting Superblocks and filesystem accounting information: donethis filesystem will be automatically checked every 39 mounts or180 days, whichever comes first. use tune2fs -c or -i to override. Create mount Directory and Mount [[ Email protected] ~]# mkdir /data[[email protected] ~]# mount /dev/sdb1  /DATA3 View the results of the Mount [[email protected] ~]# df -hfilesystem size used avail use% mounted on/dev/ sda3 195g 1.4g 184G 1% /tmpfs &nBsp; 495m 0 495m 0% /dev/shm/dev/sda1 194M 28M 156M 16% /boot/dev/sdb1 198M 5.8M 182M 4% /data #新创建的200M分区已经能够使用
This article is from the "ly36843" blog, please be sure to keep this source http://ly36843.blog.51cto.com/3120113/1641620
Partitioning with Fdisk under Linux