How Linux is partitioned

Source: Internet
Author: User

Lab environment: Ubuntu 12.04 LTS

1 Disconnecting a virtual machine add a hard drive

Recommended SCSI

2 View New drive:

Fdisk-l including U disk floppy disk drive

     [Email protected]:~$ sudo fdisk-l

disk/dev/sda:42.9 GB, 42949672960 bytes

255 heads, Sectors/track, 5221 cylinders, total 83886080 sectors Here are 255 heads, 63 sectors, 5,221 cylinders per sector

Units = sectors of 1 * MB = bytes

Sector size (logical/physical): bytes/512 bytes

I/O size (minimum/optimal): bytes/512 bytes

Disk identifier:0x000a8b99


Device Boot Start End Blocks Id System The ID here is what Linux is identified by the ID partition, and 83 represents the Linux partition 5 for the extended partition 82 representing the swap partition

/dev/sda1 * 2048 81788927 40893440 Linux sda1 Total size from No. 2048 cylinder to 81788927 cylinder is 40893440

/dev/sda2 81790974 83884031 1046529 5 Extended

/dev/sda5 81790976 83884031 1046528, Linux Swap/solaris


disk/dev/sdb:2147 MB, 2147483648 bytes

255 heads, Sectors/track, 261 cylinders, total 4194304 sectors

Units = sectors of 1 * MB = bytes

Sector size (logical/physical): bytes/512 bytes

I/O size (minimum/optimal): bytes/512 bytes

Disk identifier:0x00000000

Disk/dev/sdb doesn ' t contain a valid partition table

Here you can see that SDB is a new hard disk, and there is no partition, so let's start the partition execution Fdisk/dev/sdb (your own disk)


3 fdisk/dev/sdb Start Partition

A toggle a bootable flag sets the bootable flag
b Edit BSD Disklabel editing BSD disk label
C Toggle DOS Compatibility flag set DOS operating system compatible tag
D Delete a partitionDelete a partition
L list known partition typesshows known file system type 82 swap partition 83linux partition 5 extended partition
M Print this menuShow Help Menu
n Add a new partitionNew Partition
o Create a new empty DOS partition table to create a blank DOS Partition list
P Print the partition tableShow Partition list
Q Quit without saving changesdo not save exit
s create a new empty sun Disklabel creates a blank sun disk label
t change a partition ' s system ID changes a partition's systems ID
U change display/entry units changing display recording unit
V Verify the Partition table verify partition tables
W Write table to disk and exitSave Exit
X Extra functionality (experts only) add-ons for expert use only


N-Key to add a partition

P (primary) add primary partition

E (extension) add an extended partition

L (logical) Add logical partition

What you need to say here is that if it doesn't, enter M to help view the information, and note that the primary partition can only be divided into 4 if you want to divide multiple partitions, divide an extended partition and then allocate multiple logical partitions within the extended partition.

After one pass Setup

Device Boot Start End Blocks Id System
/DEV/SDB1 2048 165887 81920-up Linux
/DEV/SDB2 165888 4194303 2014208 5 Extended
/DEV/SDB5 167936 4194303 2013184-up Linux

W Save

4 Execute Partprobe new read partition table without rebooting

[Email protected]:~$ sudo partprobe

5 Formatting partitions

Mkfs-t ext4/dev/sdb1 mkfs-t ext4/dev/sdb5

Formatting sdb1 SDB5 Note that SDB2 is an extended partition that cannot be formatted


6 Setting up mount points and mounting

Mkdir/disk1

Mkdir/disk5

Mount/dev/sdb1/disk1

Mount/dev/sdb5/disk5

View Partition MOUNT/DF Fdisk can only see that the partition is properly allocated and cannot see the partition being mounted there.

[Email protected]:~$ DF Here we can see just the new points have been successfully mounted!

/DEV/SDB1 79327 5646 69585 8%/disk1
/dev/sdb5 1981520 35720 1845144 2%/disk5



How Linux is partitioned

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.