Linux Disk partitioning

Source: Internet
Author: User

One, FDISK partition
1. Fdisk–l View Disk
disk/dev/sda:107.4 GB, 107374182400 bytes
255 heads, Sectors/track, 13054 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk IDENTIFIER:0X0005BC15

Device Boot Start End Blocks Id System
/DEV/SDA1 * 1 307200 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 549 4096000 Swap/solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 549 13055 100453376-up Linux

disk/dev/sdb:21.5 GB, 21474836480 bytes
255 heads, Sectors/track, 2610 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x00000000
2, the/DEV/SDB partition
Fdisk/dev/sdb
M

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 0x0305dd84.
Changes'll remain in memory only, until the decide to write them.
After that, of course, the previous content won ' t is recoverable.

Warning:invalid flag 0x0000 of partition Table 4 would be a 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): M
Command 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)

Command (M for help): N
Command Action
E Extended
P primary partition (1-4)
P
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using Default value 1
Last cylinder, +cylinders or +size{k,m,g} (1-2610, default 2610): +10g

Command (M for help): M
Command 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)
Command (M for help): M
Command 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)

Command (M for help): P

disk/dev/sdb:21.5 GB, 21474836480 bytes
255 heads, Sectors/track, 2610 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x0305dd84

Device Boot Start End Blocks Id System
/DEV/SDB1 1 1306 10490413+ Linux

Command (M for help): M
Command Action
A toggle a bootable flag
b Edit BSD Disklabel
C Toggle the DOS compatibility flag
d Delete a partition delete a partition
L list known partition types view number of partition type
M Print this menu print Help menu
n Add a new partition create a partition
o Create a new empty DOS partition table
P Print the partition table printing partition list
Q Quit without saving changes do not save exit
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 save exit
X Extra functionality (experts only)

Command (M for help): N
Command Action
E Extended
P primary partition (1-4)
E
Partition number (1-4): 2
First cylinder (1307-2610, default 1307):
Using Default Value 1307
Last cylinder, +cylinders or +size{k,m,g} (1307-2610, default 2610):
Using Default Value 2610

Command (M for help): P

disk/dev/sdb:21.5 GB, 21474836480 bytes
255 heads, Sectors/track, 2610 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x0305dd84

Device Boot Start End Blocks Id System
/DEV/SDB1 1 1306 10490413+ Linux
/DEV/SDB2 1307 2610 10474380 5 Extended

Command (M for help): N
Command Action
L logical (5 or over)
P primary partition (1-4)
P
Partition number (1-4): 3
No Free sectors Available

Command (M for help): N
Command Action
L logical (5 or over)
P primary partition (1-4)
L
First cylinder (1307-2610, default 1307):
Using Default Value 1307
Last cylinder, +cylinders or +size{k,m,g} (1307-2610, default 2610): +1g

Command (M for help): P

disk/dev/sdb:21.5 GB, 21474836480 bytes
255 heads, Sectors/track, 2610 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x0305dd84

Device Boot Start End Blocks Id System
/DEV/SDB1 1 1306 10490413+ Linux
/DEV/SDB2 1307 2610 10474380 5 Extended
/DEV/SDB5 1307 1438 1060258+-up Linux

Command (M for help): N
Command Action
L logical (5 or over)
P primary partition (1-4)
L
First cylinder (1439-2610, default 1439):
Using Default Value 1439
Last cylinder, +cylinders or +size{k,m,g} (1439-2610, default 2610):
Using Default Value 2610

Command (M for help): P

disk/dev/sdb:21.5 GB, 21474836480 bytes
255 heads, Sectors/track, 2610 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x0305dd84

Device Boot Start End Blocks Id System
/DEV/SDB1 1 1306 10490413+ Linux
/DEV/SDB2 1307 2610 10474380 5 Extended
/DEV/SDB5 1307 1438 1060258+-up Linux
/DEV/SDB6 1439 2610 9414058+-up Linux
Command (M for help): W
The partition table has been altered!

Calling IOCTL () to re-read partition table.
Syncing disks.
3, modify the partition to take effect
Partprobe/dev/sdb modifying partitions in effect
FDISK partition complete
The essence of partitioning with Fdisk is to modify the 64-byte partition table information
4. Format the disk
Mkfs.ext4/dev/sdb1
Mount/dev/sdb1/data temporarily hangs on disk
Umount/data Cancel hangs on

Second, parted partition
1. Using parted partition
Parted/dev/sdb
2. Conversion format
Parted/dev/sdb Mklabel GPT
3. Add Primary partition
Parted/dev/sdb Mkpart Primary 0 10240
4. Adding logical partitions
Parted/dev/sdb Mkpart Logical 10241 20480
5. Format the partition
Mkfs–t EXT4/DEV/SDB1/DEV/SDB2
6. Mount to Directory
Mount/dev/sdb2/data
7. Delete a partition using parted
Parted/dev/sdb
GNU Parted 2.1
Using/dev/sdb
Welcome to GNU parted! Type ' help ' to view a list of commands.
(parted) RM 6
Error:partition doesn ' t exist.
(parted) RM 5
(parted) p
Model:vmware, VMware Virtual S (SCSI)
Disk/dev/sdb:21.5gb
Sector size (logical/physical): 512b/512b
Partition Table:msdos

Number Start End Size Type File system Flags
1 32.3kB 10.7GB 10.7GB primary Ext4
2 10.7GB 21.5GB 10.7GB Extended

(parted) RM 2
(parted) RM 1
(parted) p
Model:vmware, VMware Virtual S (SCSI)
Disk/dev/sdb:21.5gb
Sector size (logical/physical): 512b/512b
Partition Table:msdos

Adding a partition case using parted
Parted/dev/sdb

Parted/dev/sdb
GNU Parted 2.1
Using/dev/sdb
Welcome to GNU parted! Type ' help ' to view a list of commands.
(parted) Help
Align-check type N check partition N for TYPE (min|opt)
Alignment
Check number do a simple check on the file system
CP [From-device] from-number to-number Copy file system to another
Partition
Help [COMMAND] Print general help, or help on
COMMAND
Mklabel,mktable Label-type Create a new Disklabel (partition
Table
MKFS number Fs-type make a Fs-type file system on
Partition number
Mkpart Part-type [Fs-type] START END make a partition
Mkpartfs part-type fs-type START END make a partition with a file system
Move number START END move partition number
Name Number name name partition number as name
Print [devices|free|list,all| Number] Display the partition table,
Available devices, free space, all found partitions, or a particular
Partition
Quit Exit Program
Rescue start END Rescue a lost partition near START
and END
Resize number START END Resize partition number and its file
System
RM Number Delete Partition number
Select Device Choose the DEVICE to edit
Set number flag state change the FLAG on partition number
Toggle [Number [FLAG]] toggle the state of FLAG on
Partition number
Unit unit Set the default unit to unit
Version display the version number and
Copyright information of the GNU Parted
(parted) Mklabel GPT
Warning:the existing disk label On/dev/sdb is destroyed and all data on
This disk would be lost. Want to continue?
Yes/no? Yes
(parted) p
Model:vmware, VMware Virtual S (SCSI)
Disk/dev/sdb:21.5gb
Sector size (logical/physical): 512b/512b
Partition TABLE:GPT

Number Start End Size File system Name Flags

(parted) Mkpart primary 0 10240
Warning:the resulting partition is not properly aligned for best performance.
Ignore/cancel? Yes
Parted:invalid Token:yes
Ignore/cancel? Ignore
(parted) p
Model:vmware, VMware Virtual S (SCSI)
Disk/dev/sdb:21.5gb
Sector size (logical/physical): 512b/512b
Partition TABLE:GPT

Number Start End Size File system Name Flags
1 17.4kB 10.2GB 10.2GB Primary

(parted) Mkpart logical 10241 20480
(parted) p
Model:vmware, VMware Virtual S (SCSI)
Disk/dev/sdb:21.5gb
Sector size (logical/physical): 512b/512b
Partition TABLE:GPT
Number Start End Size File system Name Flags
1 17.4kB 10.2GB 10.2GB Primary
2 10.2GB 20.5GB 10.2GB logical

(parted) quit
Information:you need to Update/etc/fstab.
[Email protected] ~]# Ll/dev/sdb
BRW-RW----. 1 root disk 8, June 6 14:12/dev/sdb
BRW-RW----. 1 root disk 8, June 6 14:11/DEV/SDB1
BRW-RW----. 1 root disk 8, June 6 14:11/DEV/SDB2
[Email protected] ~]# LL/DEV/SD

BRW-RW----. 1 root Disk 8, 0 June 6 13:48/DEV/SDA
BRW-RW----. 1 root disk 8, 1 June 6 13:30/dev/sda1
BRW-RW----. 1 root Disk 8, 2 June 6 13:30/dev/sda2
BRW-RW----. 1 root Disk 8, 3 June 6 13:30/dev/sda3
BRW-RW----. 1 root disk 8, June 6 14:12/dev/sdb
BRW-RW----. 1 root disk 8, June 6 14:11/DEV/SDB1
BRW-RW----. 1 root disk 8, June 6 14:11/DEV/SDB2
[Email protected] ~]# MKFS.EXT4/DEV/SDB2
MKE2FS 1.41.12 (17-may-2010)
Filesystem label=
OS Type:linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
625856 inodes, 2499584 blocks
124979 blocks (5.00%) reserved for the Super user
First Data block=0
Maximum filesystem blocks=2562719744
Groups block
32768 blocks per group, 32768 fragments per group
8128 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing Inode Tables:done
Creating Journal (32768 blocks): Done
Writing superblocks and filesystem accounting Information:done

This filesystem'll be automatically checked every mounts or
Whichever comes first. Use Tune2fs-c or-i to override.
[Email protected] ~]# Mount/dev/sdb2/data
[Email protected] ~]# df-h
Filesystem Size used Avail use% mounted on
/dev/sda3 95G 4.6G 85G 6%/
Tmpfs 935M 76K 935M 1%/DEV/SHM
/DEV/SDA1 291M 39M 238M 14%/boot
/DEV/SDB2 9.4G 150M 8.8G 2%/data
Three, the difference between Fdisk and parted
The parted command can divide a single partition that is larger than 2T in GPT format, or divide a normal MBR partition. The fdisk command is not partitioned for partitions larger than 2T (storage space greater than 2.2TB is not supported with Fdisk and needs to be partitioned with parted), so it is not possible to use Fdisk to see parted partitioned GPT-formatted partitions.

Linux Disk partitioning

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.