Disk partition format, mount, swap partition mount

Source: Internet
Author: User

Partition and mount the hard disk


Environment: Virtual machine, centos6.5


1. Add a hard drive 20G


2. View Fdisk-l partition, is a complete disk

# fdisk-ldisk/dev/sdb:21.5 GB, 21474836480 bytes255 heads, $ sectors/track, 2610 cylindersunits = cylinders of 16065 * 8225280 bytessector Size (logical/physical): bytes/512 bytesi/o size (minimum/optimal): bytes/512 bytes Disk identifier:0x00000000


3. Partitioning the disk

# FDISK/DEV/SDB

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) command  (m for help): ncommand action   e    extended   p   primary partition  (1-4) ppartition  number  (1-4): 1first cylinder  (1-2610, default 1): Using default  value 1last cylinder, +cylinders or +size{k,m,g}  (1-2610, default 2610 ): +5gcommand  (M FOR HELP): wthe partition table has been  altered! Calling ioctl ()  to re-read partition table. Syncing disks.


See if the kernel is actually reading the partition table

# cat/proc/partitions Major Minor #blocks name 8 0 20971520 SDA 8 1 409600 sda1 8 2 20560896 sda2 8 20971520 sdb 8 5253223 sdb1

4. Formatting partitions

# MKFS.EXT4/DEV/SDB1


5. Set the volume label

# E2LABEL/DEV/SDB1 Myfirst


6. Edit the/etc/fstab file and add the following:

# vim/etc/fstablabel=myfirst/mnt/firstsdb EXT4 Defaults 0 0


7. Create a new mount point

# MKDIR/MNT/FIRSTSDB


8. Mounting the file system

# mount/dev/sdb1/mnt/firstsdb/


To see if the mount was successful

# mount/dev/sda2 On/type ext4 (rw) proc On/proc type proc (rw) Sysfs On/sys type SYSFS (rw) devpts on/dev/pts type DEVPT S (rw,gid=5,mode=620) Tmpfs on/dev/shm type Tmpfs (rw,rootcontext= "System_u:object_r:tmpfs_t:s0") none on/proc/sys/fs/ Binfmt_misc type Binfmt_misc (rw)/dev/sdb1 on/mnt/firstsdb type EXT4 (rw)



Under Mount directory, a lost+found directory is generated

# cd/mnt/firstsdb/# Lslost+found



Follow the previous steps and create a new disk

# fdisk-cu/dev/sdb Device Boot Start End Blocks Id system/dev/sdb1 63 10506509 5253223+ linux/dev/sdb2 10506510 14700813 2097152 Linux


The SDB2 partition is not recognized when viewed

# cat/proc/partitions Major Minor #blocks name 8 0 20971520 SDA 8 1 409600 sda1 8 2 20560896 sda2 8 20971520 sdb 8 5253223 sdb1

You can now use PARTX to identify

# partx-a/dev/sdbblkpg:device or resource busyerror adding partition # cat/proc/partitions major minor #blocks name       8 0 20971520 SDA 8 1 409600 sda1 8 2 20560896 sda2 8 20971520 SDB 8 5253223 SDB1 8 2097152 sdb2

Then carry out the corresponding mount work


To view the volume label, use the E2label disk name

# E2label/dev/sdb1myfirst



Create a 1G swap partition

Command (M for help): Tpartition number (1-4): 3Hex code (type L to list codes): 82/DEV/SDB3 916 1046 1048576 Swap/solaris Linux


See how big the swap partition is before you mount it

# free -m              total       used        free     shared    buffers      cachedMem:          1006         161        844           0         20          69-/+ buffers/cache:          72        934Swap:           399          0         399 


Format swap partition

# mkswap/dev/sdb3setting up Swapspace version 1, size = 1048572 kibno label, uuid=71372e47-1252-4303-9fa2-6a1545820716
# VIM/ETC/FSTAB/DEV/SDB3 swap swap defaults 0 0

Activating swap partitions

# SWAPON/DEV/SDB3


To view the size of the swap partition after activating the swap partition

# free -m              total       used        free     shared    buffers      cachedMem:          1006         162        844           0         20          69-/+ buffers/cache:          72        933Swap:          1423          0        1423 







This article is from the "Small City Studio" blog, please be sure to keep this source http://xcroom.blog.51cto.com/7941996/1691660

Disk partition format, mount, swap partition mount

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.