Linux Add new hard disk, Fdisk new partition

Source: Internet
Author: User
Tags uuid

fdisk new partition:
[[email protected] ~]# fdisk -ldisk /dev/sda: 21.5 gb, 21474836480  bytes255 heads, 63 sectors/track, 2610 cylindersunits = cylinders  of 16065 * 512 = 8225280bytesSector size  (logical/physical):  512  bytes /512 bytesI/O size  (Minimum/optimal): 512 bytes /  512bytesdisk identifier: 0x000e7df7   device boot       start         end      blocks   Id  System/dev/sda1  *            1         511    4096000    83  linuxpartition 1 does not end on cylinderboundary./dev /sda2             511        1020     4096000   83  LinuxPartition 2 does not  end on cylinderboundary./dev/sda3             1020        1275    2048000    82  Linux swap / Solaris/dev/sda4             1275        2611    10730496    5  extended/dev/sda5             1276        2611   10729472    83  linux disk /dev/sdb: 21.5gb, 21474836480 bytes255  heads, 63sectors/track, 2610 cylindersunits = cylinders of16065 * 512 = 8225280  Bytessector size (logical/physical):  512 bytes / 512 bytesi/o size (minimum/ Optimal):  512 bytes / 512 bytesdisk identifier:0x00000000[[email protected]  ~]# fdisk /dev/sdb  Start Partition device contains neither a valid  Dospartition table, nor sun, sgi or osf disklabelbuilding a new  dos disklabel with diskidentifier 0x6811b6b9. Changes will remain in memory only, untilyou decide to write  them. After that, of course, the previous contentwon ' t be recoverable.  warning: invalid flag 0x0000 of partitiontable 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 ') . command  (M FOR HELP):  m  #查看帮助Command  action  a   toggle a bootable flag   b   edit bsd disklabel  c   toggle the  dos compatibilityflag  d   delete a partition  l    list known partition types  m   print this menu    n   add a new partition  #添加一个新分区   o    create a new empty dospartition table   p   print the partition table  #查看当前分区情况   q   quit without  saving changes  s   create a new empty sundisklabel   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  (expertsonly)  Command  (m for help):  n # Add a new partition command action  e   extended  p   primary  partition  (1-4) p  #主分区Partition  number  (1-4): 1  #分区号First  cylinder  ( 1-2610, default 1): 1  #柱面Last  cylinder, +cylinders or +size{k,m,g}   (1-2610, default 2610): +4g  #分配大小 (not cylinder)  Command  (m for help): p  #查看一下  disk /dev/ sdb: 21.5 gb, 21474836480 bytes255 heads, 63 sectors/track, 2610  cylindersunits = cylinders of 16065 * 512 = 8225280bytessector  size  (logical/physical): 512 bytes /512 bytesi/o size  (minimum/optimal):  512 bytes / 512bytesDisk identifier: 0x6811b6b9   Device  boot      start         end       Blocks  Id  System/dev/sdb1                1          523    4200966   83  linux Success!  Command  (m for help):  n  #继续添加分区Command  action  e   extended  p   primary  partition  (1-4) e  #扩展分区Partition  number  (1-4): 2  #分区号First  cylinder   (524-2610, default 524):  #默认起始柱面-Enter using default value 524last  Cylinder, +cylinders or +size{k,m,g} (524-2610, default 2610):  #默认结束柱面-Enter using  default value 2610 Command  (m for help): p  #查看一下  Disk  /dev/sdb: 21.5 gb, 21474836480 bytes255 heads, 63 sectors/track, 2610  cylindersunits = cylinders of 16065 * 512 = 8225280bytessector  size  (logical/physical): 512 bytes /512 bytesi/o size  (minimum/ Optimal): 512 bytes / 512bytesdisk identifier: 0x6811b6b9    device boot      start         end       blocks  id  system/dev/sdb1                1         523     4200966   83  Linux/dev/sdb2              524        2610    16763827+   5  extended  #扩展分区成功!  Command  (m for help): n  #继续分逻辑分区Command  action  l    logical  (5 or over)   p   primary partition  (1-4) L   #选逻辑分区First  cylinder  (524-2610, default 524):  #默认起始柱面-Enter Using default  value 524last cylinder, +cylinders or +size{k,m,g} (524-2610, default 2610):  #默认结束柱面-Enter using default value 2610 command  (m  FOR HELP): p  #查看一下  disk /dev/sdb: 21.5 gb, 21474836480 bytes255  heads, 63 sectors/track, 2610 cylindersUnits = cylinders of  16065 * 512 = 8225280bytessector size  (logical/physical):  512 bytes  /512 bytesI/O size  (Minimum/optimal): 512 bytes / 512bytesdisk  identifier: 0x6811b6b9   device boot      start          end      blocks  id   System/dev/sdb1                1         523    4200966    83  linux/dev/sdb2             524         2610   16763827+   5  extended/dev/sdb5              524         2610   16763796   83  Linux  Success!  Command  (m for help): w  #保存The  partition table has been  altered! calling ioctl ()  to re-read partition table. Syncing disks. [[email protected] ~]# partprobe  #重新读取分区表信息 [[Email protected] ~]# mkfs  -t ext4 /dev/sdb1  #格式化 [[Email protected] ~]# mkdir /disk1 /disk5   #创建两个挂载点 [[email protected] ~]# mount /dev/sdb1 /disk1  #挂载 [[email  Protected] ~]# mount /dev/sdb5 /disk5  #挂载 


Automatic mount on Boot:

[[email protected] ~]# dumpe2fs /dev/sdb1  #查看分区UUIDdumpe2fs  1.41.12  (17- May-2010) filesystem volume name:   <none>last mounted on:           <not available>Filesystem UUID:           968fc705-506d-4977-a469-32be93467a97[[email protected]  ~]# dumpe2fs /dev/sdb5 |moredumpe2fs 1.41.12  (17-may-2010) filesystem  volume name:   <none>last mounted on:           <not available>Filesystem UUID:           987dd564-5d12-4d0b-9706-c5bdf860e927## /etc/fstab# Created by  Anaconda on wed jan  6 23:44:24 2016## accessible filesystems,  by reference, aremaintained under  '/dev/disk ' # see man pages fstab (5),  findfs (8), Mount (8)  and/or blkid (8)  for more info[[email protected] ~]# vim /etc/ fstab#uuid=b943e84c-2d74-4098-85ed-096353ff1815/              ext4   defaults        1 1uuid= 4f4b30ad-e3e4-45c3-bb60-6f6c0dd8cd62/boot         ext4     defaults        1 2uuid= 41c2e8a6-10f0-4a10-b1a8-fe8db32ce708/home         ext4    defaults        1 2uuid= 289dd6bc-687b-48e9-9d10-e34aa360228fswap         swap     defaults        0 0tmpfs                    /dev/shm                 tmpfs   defaults        0 0devpts                   /dev/pts                 devpts   gid=5,mode=620  0 0sysfs                    /sys                     sysfs   defaults         0 0proc                     /proc                    proc    defaults         0 0UUID=968fc705-506d-4977-a469-32be93467a97/disk1         ext4    defaults        12/dev/sdb5                /disk5                          ext4    defaults        1 2 [[email protected] ~]# mount –a  #测试一下, all partitions are re-mounted as per the configuration file/etc/fstab /etc/fstab

Fix when file is wrong:

[[email protected] ~]# mount-o remount,rw/#重新将/mount as read/write permission only for/etc/fstab file bug fix.





Linux Add new hard disk, Fdisk new partition

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.