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消灭保留分区的办法: ...
随机推荐
- AC日记——Milking Grid poj 2185
Milking Grid Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 8314 Accepted: 3586 Desc ...
- MySQL创建存储过程/函数需要的权限
alter routine---修改与删除存储过程/函数 create routine--创建存储过程/函数 execute--调用存储过程/函数 下面有一篇介绍MySQL所有权限的博文 http:/ ...
- 机器学习实战读书笔记(二)k-近邻算法
knn算法: 1.优点:精度高.对异常值不敏感.无数据输入假定 2.缺点:计算复杂度高.空间复杂度高. 3.适用数据范围:数值型和标称型. 一般流程: 1.收集数据 2.准备数据 3.分析数据 4.训 ...
- 《从零开始搭建游戏服务器》项目管理工具Maven
简介 什么是Maven?Maven是一个项目管理和综合工具,提供了开发人员构建一个完整的生命周期框架. Maven使用标准的目录结构和默认构建生命周期,在多个开发团队环境时,Maven可以设置按标准在 ...
- spring springmvc js websocket 监听
第一步:web.xml中支持异步.所有的filter及servlet <filter> <filter-name>characterEncoding</filter-na ...
- SSM整合案例
使用IDEA整合SSM spring核心配置文件:beans_core.xml/applicationContext.xml <?xml version="1.0" enco ...
- 【java】google的zxing架包生成二维码和读取二维码【可带文字和logo】
承接RC4生成不重复字符串的需求之后,因为优惠码要方便用户使用的缘故,所以思来想去,觉得还是直接生成二维码给用户直接扫比较实用,也不用用户专门记录冗长的优惠码编号. ================= ...
- 最新最全的 Android 开源项目合集
原文链接:https://github.com/opendigg/awesome-github-android-ui 在 Github 上做了一个很新的 Android 开发相关开源项目汇总,涉及到 ...
- Spring HTTP Service
基于Spring MVC, 使用Http Service Invoke远程调用方法 (参考: http://blog.csdn.net/hanqunfeng/article/details/43031 ...
- 《从0到1》读书笔记第一章"未来的挑战"第2记:做老子还是做孙子
从1到N VS 从0到1 - 别让自己的小鸡鸡抓在别人的手上 近几年国内互联网创业上非常流行一种C2C(也就是Copy to China - 复制到中国)的创业模式,打的就是一个时间差和地域差.将在国 ...