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

启动操作系统。

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. windows命令行更改IP地址

    修改IP地址时,提示出现一个意外情况 netsh interface ip set address "以太网" static 192.168.3.151 255.255.255.0 ...

  2. Oracle 12c JDBC方式连接PDB数据库

    1.配置监听 这里假定CDB数据库名为ORCL,PDB在CDB下面名称为PDBORCLlistener.ora添加(#后面为注释,不要添加进去) SID_LIST_LISTENER = (SID_LI ...

  3. 洛谷——P1187 3D模型

    P1187 3D模型 题目描述 一座城市建立在规则的n×m网格上,并且网格均由1×1正方形构成.在每个网格上都可以有一个建筑,建筑由若干个1×1×1的立方体搭建而成(也就是所有建筑的底部都在同一平面上 ...

  4. JS没有contains方法,可以用indexof实现

    我们很多时候会不自觉的在js代码里对一个字符串进行如下操作: str.contains("substr"); 但是js里面没有这个方法去判断字符串str是不是包含substr,而j ...

  5. [bug]Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding

    写在前面 在mysql中这个异常是非常常见的,超时分为连接超时和执行超时,而连接超时,大部分原因是网络问题,或客户端到服务端的端口问题造成. bug场景 有的时候,使用MySqlDataReader在 ...

  6. Android NDK 环境配置

    1. 下载NDK 官方链接地址: http://developer.android.com/tools/sdk/ndk/index.html 下载下来的应该是这个东西(以后可能会有更新,但步骤变动不会 ...

  7. go 协程与主线程强占运行

    最近在学习了Go 语言 ,  正好学习到了 协程这一块 ,遇到了困惑的地方.这个是go语言官方文档 . 在我的理解当中是,协程只能在主线程释放时间片后才会经过系统调度来运行协程,其实正确的也确实是这样 ...

  8. [Bash] Understand and Use Functions in Bash

    n this lesson, we'll go over how bash functions work. Bash functions work like mini bash scripts--yo ...

  9. Git以及github的使用方法(三),git status查看工作区的状态,git diff查看具体修改内容

    我们已经成功地添加并提交了一个readme.txt文件,现在,是时候继续工作了,于是,我们继续修改readme.txt文件,改成如下内容: Git is a distributed version c ...

  10. Android加壳native实现

    本例仅在Android2.3模拟器跑通过,假设要适配其它机型.请自行研究,这里不过抛砖引玉. 0x00 在Android中的Apk的加固(加壳)原理解析和实现,一文中脱壳代码都写在了java层非常ea ...