linux4 分区
分区
对硬盘分区:安装操作系统的时候有一个分区过程,新增加硬盘也会涉及到分区,如何给操作系统新增一台硬件设备。
启动操作系统。
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 分区的更多相关文章
- linux4.10.8 内核移植(二)---初步裁剪、分区修改和文件系统
一.初步裁剪 在内核根目录下 执行: make menuconfig 1.1 system type裁剪 选择 SAMSUNG S3C24XX SoCs Support 进入其中,这里是配置我们的单板 ...
- 向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/ 修改 ...
- s3c2440 移值新内核 linux-4.1.36
arm-linuxgcc version 4.3.2 经过试验,最高可以编译到 linux-4.1.36 ,在高的版本会有错误 ,可能是 GCC 编译器版本较低造成. 解压比较麻烦还要装一个 xz x ...
- 移植linux4.7.2与ubifs到jz2440
前言 整个暑假跟着韦东山的视频和书籍移植了linux2.3.6到jz2440,现在自己尝试移植linux4.7.2到板子上,并使用ubifs文件系统代替旧的jffs2文件系统. 下载交叉编译工具链 工 ...
- linux4.10.8 内核移植(三)---裁剪内核
一.裁剪内核 1.1 第一次修改 现在的内核大小为2.8M左右,要裁剪到2.0M以下,毕竟给内核分区就只有2.0M. 这两个设备我们没有,裁剪掉. 进入make menuconfig中,搜索mouse ...
- 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 ...
- linux4.11内核设备编译时出现的问题(参考博客并更改的)
AllWinnerH3 linux4.11版本的bsp下载: https://pan.baidu.com/s/1mhU4a8K 密码: b375 H3-linux4.11_bsp目录就是所需的源码及编 ...
- SQL Server表分区
什么是表分区 一般情况下,我们建立数据库表时,表数据都存放在一个文件里. 但是如果是分区表的话,表数据就会按照你指定的规则分放到不同的文件里,把一个大的数据文件拆分为多个小文件,还可以把这些小文件放在 ...
- win7安装时,避免产生100m系统保留分区的办法
在通过光盘或者U盘安装Win7操作系统时,在对新硬盘进行分区时,会自动产生100m的系统保留分区.对于有洁癖的人来说,这个不可见又删不掉的分区是个苦恼.下面介绍通过diskpart消灭保留分区的办法: ...
随机推荐
- js-关于微信页面分享(取消或打开)
在微信二次开发中,我们会遇到页面可以分享或不能分享的情况(私人隐私页面不能.禁止分享) 1.禁止页面分享(取消微信开打页面的分享功能) <script> function onBridge ...
- Codeforces 946 B.Weird Subtraction Process
B. Weird Subtraction Process time limit per test 1 second memory limit per test 256 megabytes inpu ...
- Codeforces 932 A.Palindromic Supersequence (ICM Technex 2018 and Codeforces Round #463 (Div. 1 + Div. 2, combined))
占坑,明天写,想把D补出来一起写.2/20/2018 11:17:00 PM ----------------------------------------------------------我是分 ...
- BZOJ 4540 [Hnoi2016]序列 (单调栈 + ST表 + 莫队算法)
题目链接 BZOJ4540 考虑莫队算法. 这题难在$[l, r]$到$[l, r+1]$的转移. 根据莫队算法的原理,这个时候答案应该加上 $cal(l, r+1) + cal(l+1, r+1) ...
- 客户端负载均衡Ribbon之源码解析
什么是负载均衡器? 假设有一个分布式系统,该系统由在不同计算机上运行的许多服务组成.但是,当用户数量很大时,通常会为服务创建多个副本.每个副本都在另一台计算机上运行.此时,出现 "Load ...
- SG函数学习总结
有点散乱, 将就着看吧. 首先是博弈论的基础, 即 N 和 P 两种状态: N 为必胜状态, P 为必败状态. 对于N, P两种状态, 则有 1. 没有任何合法操作的状态, P; 2. 可以移动到P局 ...
- Leetcode总结之Graph
package Graph; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collections ...
- 邁向IT專家成功之路的三十則鐵律 鐵律十四:IT人言談之道-守中
人與人之間的互動交談最重要的莫過於真誠與頃聽.老子曾在所著的道德經之中,言道:「多言數窮,不如守中」,其意思簡單來說就是不要說多餘的話.人與人之間的相處,常為了一個面子問題,你來我往的爭論不休,其實真 ...
- iOS -- SpriteKit框架之SKPhysicsBody的移动和连接
SKPhysicsBody的受力移动 SKPhysicsBody对象不同于SKSpriteNode对象.SKSpriteNode对象可以通过添加动作来进行移动,SKPhysicsBody对象却没有 ...
- iOS -- YYText富文本
NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString: [NSString strin ...