分区
对硬盘分区:安装操作系统的时候有一个分区过程,新增加硬盘也会涉及到分区,如何给操作系统新增一台硬件设备。

启动操作系统。

Home是当前账号的根目录,Computer是/系统根目录。

~是当前账号的根目录,/是系统的根目录。

root@ubuntu:~# pwd
/root
Passwd: root:x:0:0:root:/root:/bin/bash(所以root账号进来是/root目录)
root@ubuntu:~# ls root@ubuntu:/# ls
bin etc lib mnt root srv var
boot home lib64 nginx-1.13.8 run sys vmlinuz
cdrom initrd.img lost+found opt sbin tmp vmlinuz.old
dev initrd.img.old media proc snap usr yw yw1989@ubuntu:~$ pwd
/home/yw1989
Passwd: yw1989:x:1000:1000:ubuntu16.4,,,:/home/yw1989:/bin/bash(所以yw1989账号进来的根目录是/home/yw1989) yw1989@ubuntu:/$ ls
bin etc lib mnt root srv var
boot home lib64 nginx-1.13.8 run sys vmlinuz
cdrom initrd.img lost+found opt sbin tmp vmlinuz.old
dev initrd.img.old media proc snap usr yw
yw1989@ubuntu:/$ cd home/yw1989
yw1989@ubuntu:~$ ls
Desktop Documents examples.desktop Pictures Templates ywjuan
dockerfile Downloads Music Public Videos ywjuanxin
root@ubuntu:/# fdisk -l (当前操作系统有几块硬盘,每块硬盘的分区情况,每块硬盘的大小)
(硬盘也是一个硬件设备,存储在dev下面,第一块硬盘叫sda,第二快叫sdb,第三块叫sdc,sddd,20GB,后面是20GB有多少字节,)
Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 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
Disklabel type: dos
Disk identifier: 0xc48cecd2 (当前硬盘设备下有3个分区sda1,sda2,sda3,*表示这是一个启动分区,操作系统的时候就是基于sda1启动的,19G,占到2048 到39845887 扇区,sda2从39847934 到41940991, )
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 39845887 39843840 19G 83 Linux
/dev/sda2 39847934 41940991 2093058 1022M 5 Extended
/dev/sda5 39847936 41940991 2093056 1022M 82 Linux swap / Solaris (第二块硬盘sdb,2G大小,这块硬盘没有进行分区,是无法使用的,)
Disk /dev/sdb: 2 GiB, 2147483648 bytes, 4194304 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
root@ubuntu:/dev# fdisk /dev/sdb(对sdb硬盘进行分区,进入sdb硬盘)

Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command. Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x0cade2ce. Command (m for help): m Help: DOS (MBR)
a toggle a bootable flag
b edit nested BSD disklabel
c toggle the dos compatibility flag Generic
d delete a partition :删除一个分区
F list free unpartitioned space
l list known partition types
n add a new partition :创建一个新的分区
p print the partition table :打印分区表
t change a partition type :显示分区系统的id号
v verify the partition table
i print information about a partition Misc
m print this menu :打印菜单帮助信息
u change display/entry units
x extra functionality (experts only) Script
I load disk layout from sfdisk script file
O dump disk layout to sfdisk script file Save & Exit
w write table to disk and exit :写入分区表到硬盘并退出
q quit without saving changes :退出不保存相应分区操作 Create a new label
g create a new empty GPT partition table
G create a new empty SGI (IRIX) partition table
o create a new empty DOS partition table
s create a new empty Sun partition table
(针对当前这个硬盘,首先看有没有分区表,如果有就针对分区表进行操作,没有就创建新的分区,没有Device     Boot    Start      End  Sectors  Size Id Type
说明没有分区表,)
Command (m for help): p :打印分区表
Disk /dev/sdb: 2 GiB, 2147483648 bytes, 4194304 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
Disklabel type: dos
Disk identifier: 0x0cade2ce Command (m for help): n :添加一个新的分区(是要创建主分区还是扩展分区,)
Partition type
p primary (0 primary, 0 extended, 4 free) :主分区
e extended (container for logical partitions) :扩展分区
Select (default p): p :(一个硬盘里面最多只能拥有4个主分区,)
Partition number (1-4, default 1): 1 (只能有4个主分区1-4,主分区1)
First sector (2048-4194303, default 2048): 2048 (扇区数,默认从2048扇区开始,)
Last sector, +sectors or +size{K,M,G,T,P} (2048-4194303, default 4194303): 4194303 (要给这个主分区分多大空间,default 4194303表示就一个分区) Created a new partition 1 of type 'Linux' and of size 2 GiB.(这个硬盘就一个主分区)
Command (m for help): p
(硬盘信息)
Disk /dev/sdb: 2 GiB, 2147483648 bytes, 4194304 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
Disklabel type: dos
Disk identifier: 0x0cade2ce (这个硬盘的分区信息,sdb1这一个主分区)
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 4194303 4192256 2G 83 Linux Command (m for help): w
The partition table has been altered. (分区表已经被改变)
Calling ioctl() to re-read partition table.
Syncing disks. (可以重新读分区表并且同步硬盘) root@ubuntu:/dev# fdisk -l
(硬盘信息)
Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 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
Disklabel type: dos
Disk identifier: 0xc48cecd2
(这个硬盘的分区信息)
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 39845887 39843840 19G 83 Linux
/dev/sda2 39847934 41940991 2093058 1022M 5 Extended
/dev/sda5 39847936 41940991 2093056 1022M 82 Linux swap / Solaris (硬盘信息)
Disk /dev/sdb: 2 GiB, 2147483648 bytes, 4194304 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
Disklabel type: dos
Disk identifier: 0x7251b8e3
(这个硬盘的分区信息)
Device Boot Start End Sectors Size Id Type
/dev/sdb2 2048 4194303 4192256 2G 83 Linux

-----------------------前面是安装分区,后面是调整分区----------------------------------------------

root@ubuntu:/dev# fdisk sdb (进入这块硬盘,不是进入这个分区,)

Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command. Command (m for help): p (打印sdb硬盘的分区信息)
(硬盘信息)
Disk sdb: 2 GiB, 2147483648 bytes, 4194304 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
Disklabel type: dos
Disk identifier: 0x7251b8e3 (这个硬盘的分区信息)
Device Boot Start End Sectors Size Id Type
sdb2 2048 4194303 4192256 2G 83 Linux Command (m for help): d (删除分区)
Selected partition 2
Partition 2 has been deleted. Command (m for help): p (只有硬盘信息没有分区信息了)
Disk sdb: 2 GiB, 2147483648 bytes, 4194304 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
Disklabel type: dos
Disk identifier: 0x7251b8e3 Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-4194303, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-4194303, default 4194303): +500M (创建2个分区,第一个500M) Created a new partition 1 of type 'Linux' and of size 500 MiB. Command (m for help): p
(硬盘信息)
Disk sdb: 2 GiB, 2147483648 bytes, 4194304 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
Disklabel type: dos
Disk identifier: 0x7251b8e3
(分区信息,sdb1分区500M)
Device Boot Start End Sectors Size Id Type
sdb1 2048 1026047 1024000 500M 83 Linux (创建第二个分区)
Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2):
First sector (1026048-4194303, default 1026048): +500M
Value out of range.
First sector (1026048-4194303, default 1026048): +100M
Value out of range.
First sector (1026048-4194303, default 1026048): +1M
Value out of range.
First sector (1026048-4194303, default 1026048):
Last sector, +sectors or +size{K,M,G,T,P} (1026048-4194303, default 4194303): +500M Created a new partition 2 of type 'Linux' and of size 500 MiB. Command (m for help): p
Disk sdb: 2 GiB, 2147483648 bytes, 4194304 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
Disklabel type: dos
Disk identifier: 0x7251b8e3 Device Boot Start End Sectors Size Id Type
sdb1 2048 1026047 1024000 500M 83 Linux
sdb2 1026048 2050047 1024000 500M 83 Linux Command (m for help): n
Partition type
p primary (2 primary, 0 extended, 2 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (3,4, default 3):
First sector (2050048-4194303, default 2050048):
Last sector, +sectors or +size{K,M,G,T,P} (2050048-4194303, default 4194303): +500M Created a new partition 3 of type 'Linux' and of size 500 MiB. Command (m for help): w (保存退出)
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks. root@ubuntu:/dev# fdisk -l (对硬盘sdb就分了5个主分区一个扩展分区)
Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 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
Disklabel type: dos
Disk identifier: 0xc48cecd2 Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 39845887 39843840 19G 83 Linux
/dev/sda2 39847934 41940991 2093058 1022M 5 Extended
/dev/sda5 39847936 41940991 2093056 1022M 82 Linux swap / Solaris Disk /dev/sdb: 2 GiB, 2147483648 bytes, 4194304 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
Disklabel type: dos
Disk identifier: 0x7251b8e3 Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 1026047 1024000 500M 83 Linux
/dev/sdb2 1026048 2050047 1024000 500M 83 Linux
/dev/sdb3 2050048 3074047 1024000 500M 83 Linux
/dev/sdb4 3074048 4098047 1024000 500M 5 Extended
/dev/sdb5 3076096 3895295 819200 400M 83 Linux
/dev/sdb6 3897344 4081663 184320 90M 83 Linux root@ubuntu:/dev# fdisk sdb (进入第二块硬盘) Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command. Command (m for help): t
Partition number (1-6, default 6): 1
Partition type (type L to list all types): L (分区这种文件操作系统有很多种,这里是156种,FAT32和NTFS是windows的分区,LINUX SWAP,LINUX extended是linux的分区,)
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 or 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 ea Rufus alignment
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD eb BeOS fs
f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ee GPT
10 OPUS 55 EZ-Drive a7 NeXTSTEP ef EFI (FAT-12/16/
11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f0 Linux/PA-RISC b
12 Compaq diagnost 5c Priam Edisk a9 NetBSD f1 SpeedStor
14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f4 SpeedStor
16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ f2 DOS secondary
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fb VMware VMFS
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fc VMware VMKCORE
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fd Linux raid auto
1c Hidden W95 FAT3 75 PC/IX bc Acronis FAT32 L fe LANstep
1e Hidden W95 FAT1 80 Old Minix be Solaris boot ff BBT

linux4 分区的更多相关文章

  1. linux4.10.8 内核移植(二)---初步裁剪、分区修改和文件系统

    一.初步裁剪 在内核根目录下 执行: make menuconfig 1.1 system type裁剪 选择 SAMSUNG S3C24XX SoCs Support 进入其中,这里是配置我们的单板 ...

  2. 向tiny6410中移植中移植linux-4.5.1内核(最新)

    下载linux-4.5.1.tar.gz 解压在任意目录下.我解压在/home/tiny6410/ # tar xvzf linux-4.5.1.tar.gz # cd linux-4.5.1/ 修改 ...

  3. s3c2440 移值新内核 linux-4.1.36

    arm-linuxgcc version 4.3.2 经过试验,最高可以编译到 linux-4.1.36 ,在高的版本会有错误 ,可能是 GCC 编译器版本较低造成. 解压比较麻烦还要装一个 xz x ...

  4. 移植linux4.7.2与ubifs到jz2440

    前言 整个暑假跟着韦东山的视频和书籍移植了linux2.3.6到jz2440,现在自己尝试移植linux4.7.2到板子上,并使用ubifs文件系统代替旧的jffs2文件系统. 下载交叉编译工具链 工 ...

  5. linux4.10.8 内核移植(三)---裁剪内核

    一.裁剪内核 1.1 第一次修改 现在的内核大小为2.8M左右,要裁剪到2.0M以下,毕竟给内核分区就只有2.0M. 这两个设备我们没有,裁剪掉. 进入make menuconfig中,搜索mouse ...

  6. JZ2440 u-boot-2016.11、linux-4.17和busybox-1.28.4移植笔记

    2018年5月份开始在JZ2440上陆续移植了u-boot-2016.11.u-boot-spl-2016.11.linux-4.17和busybox-1.28.4,其中linux-4.17和busy ...

  7. linux4.11内核设备编译时出现的问题(参考博客并更改的)

    AllWinnerH3 linux4.11版本的bsp下载: https://pan.baidu.com/s/1mhU4a8K 密码: b375 H3-linux4.11_bsp目录就是所需的源码及编 ...

  8. SQL Server表分区

    什么是表分区 一般情况下,我们建立数据库表时,表数据都存放在一个文件里. 但是如果是分区表的话,表数据就会按照你指定的规则分放到不同的文件里,把一个大的数据文件拆分为多个小文件,还可以把这些小文件放在 ...

  9. win7安装时,避免产生100m系统保留分区的办法

    在通过光盘或者U盘安装Win7操作系统时,在对新硬盘进行分区时,会自动产生100m的系统保留分区.对于有洁癖的人来说,这个不可见又删不掉的分区是个苦恼.下面介绍通过diskpart消灭保留分区的办法: ...

随机推荐

  1. python 中各种数据类型的排序问题

    list #按照list的第二键值排序 disP2P = [[1,2,3],[2,3,4],[4,5,6]] disP2P = sorted(disP2P,key = lambda x:x[2]) s ...

  2. SPOJ 1825 Free tour II (树的点分治)

    题目链接 Free tour II 题意:有$N$个顶点的树,节点间有权值, 节点分为黑点和白点. 找一条最长路径使得 路径上黑点数量不超过K个 这是树的点分治比较基本的题,涉及树上启发式合并……仰望 ...

  3. Network | DHCP

    动态主机设置协议(Dynamic Host Configuration Protocol, DHCP)是一个局域网的网络协议,使用UDP协议工作,主要有两个用途: 给内部网络或网络服务供应商自动分配I ...

  4. NLP项目

    GitHub NLP项目:自然语言处理项目的相关干货整理 自然语言处理(NLP)是计算机科学,人工智能,语言学关注计算机和人类(自然)语言之间的相互作用的领域.本文作者为自然语言处理NLP初学者整理了 ...

  5. Android自定义xml解析

    <?xml version="1.0" encoding="utf-8"?> <resources> <Users> < ...

  6. iOS- Exception Type: 00000020:什么是看门狗机制(转)

    1.前言    前几天我们项目闪退之后遇到的一个Crash,之后逛了许多论坛,博客都没有找到满意的回复  在自己做了深入的研究之后,对iOS的看门狗机制有了一个基本的了解  而有很多奇怪的Crash可 ...

  7. [C++11]_[0基础]_[左值引用声明和右值引用声明]

    场景: 在 remove_reference 结构体中能看到右值引用的身影 &&, 那么这里的右值引用究竟有什么用呢? 常常也发现int& 和int&& 这两种 ...

  8. Eclipse出现&quot;Running Android Lint has encountered a problem&quot;解决方式

    近期打开Eclipse的时候,总是发生这种一个错误:"Running Android Lint has encountered a problem".截图例如以下: . 可是Ecl ...

  9. JSP自己定义标签继承哪个类

    JSP自己定义标签继承哪个类 解:JSP自己定义标签继承TagSupport

  10. vue2.0 vue-router

    一.SPA中路由的简单实现 main.js import Vue from 'vue' import App from './App' import VueRouter from 'vue-route ...