码迷,mamicode.com
首页 > 系统相关 > 详细

Linux磁盘分区

时间:2018-05-30 17:34:42      阅读:264      评论:0      收藏:0      [点我收藏+]

标签:Linux磁盘分区

[root@bogon ~]# part
parted partprobe partx
[root@bogon ~]# parted
anaconda-ks.cfg .cache/ initial-setup-ks.cfg
.bash_history .config/ .tcshrc
.bash_logout .cshrc .Xauthority
.bash_profile g3308l
.bashrc g3308l.1
[root@bogon ~]# parted /dev/sdb mklabel gpt
gpt是改磁盘格式
警告: The existing disk label on /dev/sdb will be destroyed and all data on this
disk will be lost. Do you want to continue?
是/Yes/否/No? yes
信息: You may need to update /etc/fstab.

[root@bogon ~]#
[root@bogon ~]# parted /dev/sdb print
Model: DELL PERC H330 Adp (scsi)
Disk /dev/sdb: 490GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name 标志

[root@bogon ~]#
[root@bogon ~]#
[root@bogon ~]# parted /dev/sdb mkpart primary ext4 1 50G
mkprat 创建
信息: You may need to update /etc/fstab.

[root@bogon ~]# parted /dev/sdb print
Model: DELL PERC H330 Adp (scsi)
Disk /dev/sdb: 490GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name 标志
1 1049kB 50.0GB 50.0GB primary

[root@bogon ~]# parted /dev/sdb mkpart primary ext4 50G 220G
信息: You may need to update /etc/fstab.

[root@bogon ~]# parted /dev/sdb print
Model: DELL PERC H330 Adp (scsi)
Disk /dev/sdb: 490GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name 标志
1 1049kB 50.0GB 50.0GB primary
2 50.0GB 220GB 170GB primary

[root@bogon ~]# parted /dev/sdb mkpart primary ext4 220G 400G
信息: You may need to update /etc/fstab.

[root@bogon ~]# parted /dev/sdb print
Model: DELL PERC H330 Adp (scsi)
Disk /dev/sdb: 490GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name 标志
1 1049kB 50.0GB 50.0GB primary
2 50.0GB 220GB 170GB primary
3 220GB 400GB 180GB primary

[root@bogon ~]# parted /dev/sdb mkpart primary ext4 400G 450G
信息: You may need to update /etc/fstab.

[root@bogon ~]# parted /dev/sdb print
Model: DELL PERC H330 Adp (scsi)
Disk /dev/sdb: 490GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name 标志
1 1049kB 50.0GB 50.0GB primary
2 50.0GB 220GB 170GB primary
3 220GB 400GB 180GB primary
4 400GB 450GB 50.0GB primary

[root@bogon ~]# parted /dev/sdb mkpart primary ext4 450G 490.4G
信息: You may need to update /etc/fstab.

[root@bogon ~]#
[root@bogon ~]# parted /dev/sdb print
Model: DELL PERC H330 Adp (scsi)
Disk /dev/sdb: 490GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name 标志
1 1049kB 50.0GB 50.0GB primary
2 50.0GB 220GB 170GB primary
3 220GB 400GB 180GB primary
4 400GB 450GB 50.0GB primary
5 450GB 490GB 40.4GB primary
[root@bogon ~]#
[root@bogon ~]# mkf
mkfifo mkfs mkfs.ext2 mkfs.fat mkfs.vfat
mkfontdir mkfs.btrfs mkfs.ext3 mkfs.minix mkfs.xfs
mkfontscale mkfs.cramfs mkfs.ext4 mkfs.msdos
[root@bogon ~]# mkfs.ext
mkfs.ext2 mkfs.ext3 mkfs.ext4
[root@bogon ~]# mkfs.ext4 /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
3055616 inodes, 12206848 blocks
610342 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=2160066560
373 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424

Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

[root@bogon ~]# mkfs.ext4 /dev/sdb2
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
10379264 inodes, 41503744 blocks
2075187 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=2189426688
1267 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

[root@bogon ~]# mkfs.ext4 /dev/sdb3
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
10993664 inodes, 43945472 blocks
2197273 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=2191523840
1342 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

[root@bogon ~]# mkfs.ext4 /dev/sdb4
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
3055616 inodes, 12206848 blocks
610342 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=2160066560
373 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424

Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

[root@bogon ~]# mkfs.ext4 /dev/sdb5
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
2469152 inodes, 9870848 blocks
493542 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=2157969408
302 block groups
32768 blocks per group, 32768 fragments per group
8176 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624

Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
[root@bogon ~]#
[root@bogon ~]# fdisk - l
用法:
fdisk [选项] <磁盘> 更改分区表
fdisk [选项] -l <磁盘> 列出分区表
fdisk -s <分区> 给出分区大小(块数)

选项:
-b <大小> 扇区大小(512、1024、2048或4096)
-c[=<模式>] 兼容模式:“dos”或“nondos”(默认)
-h 打印此帮助文本
-u[=<单位>] 显示单位:“cylinders”(柱面)或“sectors”(扇区,默认)
-v 打印程序版本
-C <数字> 指定柱面数
-H <数字> 指定磁头数
-S <数字> 指定每个磁道的扇区数

[root@bogon ~]# fdisk -l

磁盘 /dev/sda:108.4 GB, 108447924224 字节,211812352 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000f1e5e

设备 Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 211812351 105393152 8e Linux LVM
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.

磁盘 /dev/sdb:490.4 GB, 490431578112 字节,957874176 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:gpt
Disk identifier: B191B484-44AF-438D-938F-11D274A49EB4

Start End Size Type Name

1 2048 97656831 46.6G Microsoft basic primary
2 97656832 429686783 158.3G Microsoft basic primary
3 429686784 781250559 167.7G Microsoft basic primary
4 781250560 878905343 46.6G Microsoft basic primary
5 878905344 957872127 37.7G Microsoft basic primary

磁盘 /dev/mapper/centos-root:53.7 GB, 53687091200 字节,104857600 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节

磁盘 /dev/mapper/centos-swap:8321 MB, 8321499136 字节,16252928 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节

磁盘 /dev/mapper/centos-home:45.8 GB, 45843742720 字节,89538560 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节

创建多个目录挂载(同级目录)!
[root@bogon ~]#mkdir -p /{data,data_db,data_mm,data_zk,data-bak}
[root@bogon /]#
挂载
[root@bogon /]# mount /dev/sdb1 /data
[root@bogon /]# mount /dev/sdb2 /data_db
[root@bogon /]# mount /dev/sdb3 /data_mm
[root@bogon /]# mount /dev/sdb4 /data_zk
[root@bogon /]# mount /dev/sdb5 /data_bak
[root@bogon /]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 50G 4.2G 46G 9% /
devtmpfs 7.7G 0 7.7G 0% /dev
tmpfs 7.7G 0 7.7G 0% /dev/shm
tmpfs 7.7G 35M 7.6G 1% /run
tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup
/dev/mapper/centos-home 43G 38M 43G 1% /home
/dev/sda1 497M 207M 290M 42% /boot
tmpfs 1.6G 12K 1.6G 1% /run/user/42
tmpfs 1.6G 0 1.6G 0% /run/user/0
/dev/sdb1 46G 53M 44G 1% /data
/dev/sdb2 156G 61M 148G 1% /data_db
/dev/sdb3 165G 61M 157G 1% /data_mm
/dev/sdb4 46G 53M 44G 1% /data_zk
/dev/sdb5 37G 49M 35G 1% /data_bak
[root@bogon /]#
添加开机自启
[root@bogon /]# vi /etc/fstab
#

/etc/fstab

Created by anaconda on Thu May 10 21:49:38 2018

#

Accessible filesystems, by reference, are maintained under ‘/dev/disk‘

See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

#
/dev/mapper/centos-root / xfs defaults 0 0
UUID=b1d9e140-abb0-4d5c-b79e-fdd0ef5b5c3d /boot xfs defaults 0 0
/dev/mapper/centos-home /home xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
~
~

#

/etc/fstab

Created by anaconda on Thu May 10 21:49:38 2018

#

Accessible filesystems, by reference, are maintained under ‘/dev/disk‘

See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

#
/dev/mapper/centos-root / xfs defaults 0 0
UUID=b1d9e140-abb0-4d5c-b79e-fdd0ef5b5c3d /boot xfs defaults 0 0
/dev/mapper/centos-home /home xfs defaults 0 0
/dev/sdb3 on /data_mm type ext4 (rw,relatime,seclabel,data=ordered)
"/etc/fstab" 17L, 916C written
[root@bogon /]#
[root@bogon /]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 50G 4.2G 46G 9% /
devtmpfs 7.7G 0 7.7G 0% /dev
tmpfs 7.7G 0 7.7G 0% /dev/shm
tmpfs 7.7G 35M 7.6G 1% /run
tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup
/dev/mapper/centos-home 43G 38M 43G 1% /home
/dev/sda1 497M 207M 290M 42% /boot
tmpfs 1.6G 12K 1.6G 1% /run/user/42
tmpfs 1.6G 0 1.6G 0% /run/user/0
/dev/sdb1 46G 53M 44G 1% /data
/dev/sdb2 156G 61M 148G 1% /data_db
/dev/sdb3 165G 61M 157G 1% /data_mm
/dev/sdb4 46G 53M 44G 1% /data_zk
/dev/sdb5 37G 49M 35G 1% /data_bak
[root@bogon /]#
[root@bogon /]# parted /dev/sdb print
Model: DELL PERC H330 Adp (scsi)
Disk /dev/sdb: 490GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name 标志
1 1049kB 50.0GB 50.0GB ext4 primary
2 50.0GB 220GB 170GB ext4 primary
3 220GB 400GB 180GB ext4 primary
4 400GB 450GB 50.0GB ext4 primary
5 450GB 490GB 40.4GB ext4 primary

Linux磁盘分区

标签:Linux磁盘分区

原文地址:http://blog.51cto.com/10158955/2122083

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!