Linux下磁盘两种分区方式

原创 2017年09月05日 16:52:09

使用fdisk管理磁盘分区

使用fdisk命令对sdc硬盘分区:

# fdisk /dev/sdc 
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
## m 调出帮助说明
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
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   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)

##p 打印分区表
Command (m for help): p

Disk /dev/sdc: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x2ebdc3b7

   Device Boot      Start         End      Blocks   Id  System
##n 新建分区
Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
##p代表主分区,e代表扩展分区
Select (default p): p
##1表示分区编号为1
Partition number (1-4, default 1): 1
##输入磁盘起始扇区,直接回车表示使用默认值
First sector (2048-104857599, default 2048): 
Using default value 2048
##输入磁盘结束扇区,直接回车表示使用默认值(这里表示超出磁盘大小了)
Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599): +50G
Value out of range.
Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599): +49G
Partition 1 of type Linux and of size 49 GiB is set
##p 打印分区表,这里就可以看到分区表信息了
Command (m for help): p

Disk /dev/sdc: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x2ebdc3b7

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048   102762495    51380224   83  Linux
## w 将分区信息写入磁盘
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
##格式化磁盘
# mkfs.ext4 /dev/sdc1 

##创建挂载点
# mkdir -p /data/sdv1

##挂载
# mount /dev/sdc1 /data/sdv1/

fdisk

使用parted管理磁盘分区

使用fdisk命令对sdd硬盘分区(大于2T磁盘挂载可使用):

[root@cy1 ~]# parted /dev/sdf 
GNU Parted 3.1
Using /dev/sde
Welcome to GNU Parted! Type 'help' to view a list of commands.
##help 打印帮助信息
(parted) help 
  align-check TYPE N                        check partition N for TYPE(min|opt) alignment
  help [COMMAND]                           print general help, or help on COMMAND
  mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)
  mkpart PART-TYPE [FS-TYPE] START END     make a partition
  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
  rm NUMBER                                delete partition NUMBER
  select DEVICE                            choose the device to edit
  disk_set FLAG STATE                      change the FLAG on selected device
  disk_toggle [FLAG]                       toggle the state of FLAG on selected device
  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 GNU Parted
##打印当前磁盘信息
(parted) print                                                            
Error: /dev/sde: unrecognised disk label
Model: VMware Virtual disk (scsi)                                         
Disk /dev/sde: 53.7GB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags: 
##转换磁盘分区格式(大于2T使用GPT格式)
(parted) mklabel gpt                                                      
##设置单位
(parted) unit GB                                                          
##创建分区(0为起始,53.7为结束)
(parted) mkpart primary 0 53.7
##打印当前分区信息
(parted) print                                                            
Model: VMware Virtual disk (scsi)
Disk /dev/sde: 53.7GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name     Flags
 1      0.00GB  53.7GB  53.7GB               primary

##退出
(parted) quit                                                             
Information: You may need to update /etc/fstab.

parted

##格式化磁盘
# mkfs.ext4 /dev/sdf1 

##创建挂载点
# mkdir -p /data/sdv2

##挂载
# mount /dev/sdf1 /data/sdv2/

添加交换分区

交换分区添加方式和普通分区差不多:

# fdisk /dev/sdd 
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p

Disk /dev/sdd: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000d2019

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-104857599, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599): +8G
Partition 1 of type Linux and of size 8 GiB is set

Command (m for help): p

Disk /dev/sdd: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000d2019

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1            2048    16779263     8388608   83  Linux
##t 修改分区类型
Command (m for help): t
Selected partition 1
##l 列出支持的分区类型
Hex code (type L to list all codes): l

 0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris        
 1  FAT12           27  Hidden NTFS Win 82  Linux swap / So c1  DRDOS/sec (FAT-
 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  84  OS/2 hidden C:  c6  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     85  Linux extended  c7  Syrinx         
 5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data    
 6  FAT16           42  SFS             87  NTFS volume set db  CP/M / CTOS / .
 7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility   
 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt         
 9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access     
 a  OS/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O        
 b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor      
 c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad hi eb  BeOS fs        
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         ee  GPT            
 f  W95 Ext'd (LBA) 54  OnTrackDM6      a6  OpenBSD         ef  EFI (FAT-12/16/
10  OPUS            55  EZ-Drive        a7  NeXTSTEP        f0  Linux/PA-RISC b
11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f1  SpeedStor      
12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f4  SpeedStor      
14  Hidden FAT16 <3 61  SpeedStor       ab  Darwin boot     f2  DOS secondary  
16  Hidden FAT16    63  GNU HURD or Sys af  HFS / HFS+      fb  VMware VMFS    
17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE 
18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fd  Linux raid auto
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fe  LANstep        
1c  Hidden W95 FAT3 75  PC/IX           be  Solaris boot    ff  BBT            
1e  Hidden W95 FAT1 80  Old Minix      
##82 表示Linux swap
Hex code (type L to list all codes): 82
Changed type of partition 'Linux' to 'Linux swap / Solaris'

Command (m for help): p

Disk /dev/sdd: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000d2019

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1            2048    16779263     8388608   82  Linux swap / Solaris

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
##格式化磁盘
#  mkswap /dev/sdd1 

##开启swap
# swapon /dev/sdd1

设置开机自动挂载

##在/etc/fstab添加配置:
# vi /etc/fstab
/dev/sdc1 /data/sdv1/                   ext4    defaults,noatime        1 2     
/dev/sdf1 /data/sdv2/                   ext4    defaults,noatime        1 2  
/dev/sdd1 swap                  swap    defaults                        0 0  

fstab

版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

linux下磁盘分区方法详解

[root@docker ~]# fdisk -l #找出机器中所有硬盘个数及设备名称Disk /dev/sda: 107.4 GB, 107374182400 bytes 255 head...

Linux下的两种磁盘分区工具的使用

今天我们来说一下如何使用fdisk和parted分区工具来进行硬盘分区,、下面我来说一下在Linux系统中这两种硬盘分区工具的使用方法:   ----------fdisk分区工具------...
  • zj0910
  • zj0910
  • 2012-09-05 23:27
  • 1266

linux磁盘的两种分区方法

MBR(Master Boot Record)和GPT(GUID Partition Table)是在磁盘上存储分区信息的两种不同方式,使用fdisk对磁盘sdb进行MBR分区,使用Parted工具进...

Linux下的两种磁盘分区工具的使用

from:http://lanmh.iteye.com/blog/743793 一、.下面来介绍fdisk分区工具的命令格式:     fdisk是传统的Linux硬盘分区工具,也是Lin...

Linux下的两种磁盘分区工具的使用

一直对linux的分区不理解,不会操作,幸好看到了这个

linux下磁盘分区详解

  • 2013-12-05 19:23
  • 456KB
  • 下载

linux下磁盘分区详解

  • 2013-08-09 18:40
  • 444KB
  • 下载

linux下磁盘分区与格式化

先使用fdisk -l 列出设备的分区。我这里的/dev/sdb 磁盘是我向运行在virtualbox的虚拟机 添加的虚拟磁盘。顺便来说下往运行在virtualbox 中的系统添加虚拟磁盘的方法...

linux下对磁盘分区详细步骤

今天晚上无事学习了一下linux下硬盘分区的知识,利用公司发的8G U盘实验了一下。把分区的过程总结一下。   linux下硬盘设备名IDE硬盘为hdx(x为从a—d)因为IDE硬盘最多四个,S...

20151117 Linux下磁盘管理(centos 6.5)1.添加硬盘 2.硬盘分区 3.格式化硬盘 4.挂载硬盘 5.设置开机自动挂载】

1. 查看磁盘或者目录的容量    df  查看磁盘各分区使用情况    不加参数以k为单位    df -i inode数,df -h ...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)