首页 > 代码库 > 管理系统中的简单分区和文件系统
管理系统中的简单分区和文件系统
第四单元
管理系统中的简单分区和文件系统
一 查看系统设备信息
1 fdisk -l ###显示系统中所有可以使用的设备信息
2 blkid ###显示系统中正在使用的设备id
3 df ### 查看已挂载的设备###
二 创建新分区
1 fdisk -l ###查看当前磁盘分区信息,主要是分区表信息
如下:
Disk /dev/vda: 10.7 GB, 10737418240 bytes, 20971520 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
Disk label type: dos
Disk identifier: 0x00013f3e
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 20970332 10484142+ 83 Linux
Disk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 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
2 fdisk /dev/vdb ### 创建/dev/vdb分区###
Partprobe ###同步分区表###
Cat /proc/partitions ##查看磁盘分区,若是有就表示分区划分成功###
blkid ###查看可用的设备###
mkfs.xfs /dev/vdb1 ###格式化,磁盘分区如果没有格式化,加上文件系统就不能使用###
Mount /dev/vdb1 /mnt ###挂载###
如果想开机自动挂载,编辑/etc/fstab文件,不要在/etc/rc.d/rc.local下编辑,因为它是最后读取的
Vim /etc/fstab
Mount -a ###立即生效####
/dev/vdb1 /mnt xfs defaults 0 0
设备 挂载点 文件系统 参数 不备份 不检测
过程如下:
[root@station ~]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).
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
Building a new DOS disklabel with disk identifier 0x7718cb65.
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition ###删除分区###
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
l list known partition types
m print this menu
n add a new partition ###创建分区###
o create a new empty DOS partition table
p print the partition table ###显示分区###
q quit without saving changes ###退出###
s create a new empty Sun disklabel
t change a partition‘s system id ###修改分区功能id###
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): p
Disk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 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
Disk label type: dos
Disk identifier: 0x7718cb65
Device Boot Start End Blocks Id System
Command (m for help): n ##创建一个新分区
Partition type:
p primary (0 primary, 0 extended, 4 free) ###主分区###
e extended ##扩展分区##
Select (default p): p ##主分区
Partition number (1-4, default 1): 1
First sector (2048-20971519, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +1G ##所划分大小
Partition 1 of type Linux and of size 1 GiB is set
Command (m for help): wq ##保存退出
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@station ~]# partprobe ##同步分区表
[root@station ~]# cat /proc/partitions ##查看磁盘分区
major minor #blocks name
253 0 10485760 vda
253 1 10484142 vda1
253 16 10485760 vdb
253 17 102400 vdb1
[root@station ~]# blkid ##查看可用分区
/dev/vda1: UUID="9bf6b9f7-92ad-441b-848e-0257cbb883d1" TYPE="xfs"
/dev/vdb5: UUID="e8fc576b-5c7c-4cba-9541-68d6ecca5958" TYPE="xfs"
[root@station ~]# mkfs.xfs /dev/vdb3 ##格式化vdb3分区
meta-data=http://www.mamicode.com/dev/vdb3 isize=256 agcount=4, agsize=6400 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0
data = bsize=4096 blocks=25600, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=853, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@station ~]# blkid ##查看可用分区
/dev/vda1: UUID="9bf6b9f7-92ad-441b-848e-0257cbb883d1" TYPE="xfs"
/dev/vdb5: UUID="e8fc576b-5c7c-4cba-9541-68d6ecca5958" TYPE="xfs"
/dev/vdb3: UUID="24af62cd-d6a3-4a62-8954-e7e0b9261cfb" TYPE="xfs"
注:主分区一共有四个,如果主分区建完了,那么剩下的空间也不能够建立分区了,因此要想建立超过四个分区,就要将最后一个主分区删除,建成扩展分区,然后就可以在扩展房内去内建立逻辑分区。
三 swap 交换分区
换空间或交换区是磁盘驱动器上的空间,用做当前未使用部分内存的溢出。这样,系统就能在主内存中留出空间用于存储当前正在处理的数据,并在系统面临内存空间不足的风险是提供应急溢出。
(1) 创建swap 分区
swapon -s ###显示当前分区状态###
Fdisk /dev/vdb ###划分分区###
Partprobe ###同步分区表###
mkswap /dev/vdb1 ###格式化###
swapon -a /dev/vdb1 ###激活分区###
swapon -s
注意:在wq保存退出之前要更改分区类型,更改为Linux swap
过程如下:
[root@localhost ~]# swapon -s
[root@localhost ~]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-20971519, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +4G
Partition 1 of type Linux and of size 4 GiB is set
Command (m for help): p
Disk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 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
Disk label type: dos
Disk identifier: 0xa8f3c8c4
Device Boot Start End Blocks Id System
/dev/vdb1 2048 8390655 4194304 83 Linux
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): l
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 C: 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 eb BeOS fs
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD ee GPT
f W95 Ext‘d (LBA) 54 OnTrackDM6 a6 OpenBSD ef EFI (FAT-12/16/
10 OPUS 55 EZ-Drive a7 NeXTSTEP f0 Linux/PA-RISC b
11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f1 SpeedStor
12 Compaq diagnost 5c Priam Edisk a9 NetBSD f4 SpeedStor
14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f2 DOS secondary
16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ fb VMware VMFS
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fc VMware VMKCORE
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fd Linux raid auto
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 75 PC/IX be Solaris boot ff BBT
1e Hidden W95 FAT1 80 Old Minix
Hex code (type L to list all codes): 82
Changed type of partition ‘Linux‘ to ‘Linux swap / Solaris‘
Command (m for help): wq
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# partprobe
[root@localhost ~]# mkswap /dev/vdb2
Setting up swapspace version 1, size = 1048572 KiB
no label, UUID=e003521f-7ee7-432f-bef9-27b9cdc8afa9
[root@localhost ~]# swapon -a /dev/vdb2
[root@localhost ~]# swapon -s
FilenameTypeSizeUsedPriority
/dev/vdb1 partition41943000-1
/dev/vdb2 partition10485720-2
Priority :优先级,-1比-2优先级高
(2) 修改swap 分区优先级
1 直接在激活分区时修改
swapoff /dev/vdb2 ###将/dev/vdb2停用###
swapon -a /dev/vdb2 -p 1 ###修改优先级为1###
swapon -s
过程如下:
[root@localhost ~]# swapoff /dev/vdb2
[root@localhost ~]# swapon -a /dev/vdb2 -p 1
[root@localhost ~]# swapon -s
FilenameTypeSizeUsedPriority
/dev/vdb1 partition41943000-1
/dev/vdb2 partition104857201
2 在/etc/fstab下修改
swapoff /dev/vdb2 ###将/dev/vdb2停用###
swapoff /dev/vdb1 ###将/dev/vdb1停用###
vim /etc/fstab 编辑/etc/fstab
swapon -a ###识别并立即生效###
Swapon -s
/etc/fstab下编辑的内容:
/dev/vdb1 swap swap defaults 0 0
/dev/vdb2 swap swap defaults,pri=1 0 0
不用写挂载点
过程如下:
[root@localhost ~]# swapoff /dev/vdb2
[root@localhost ~]# swapoff /dev/vdb1
[root@localhost ~]# vim /etc/fstab
[root@localhost ~]# vim /etc/fstab
[root@localhost ~]# swapon -a
[root@localhost ~]# swapon -s
FilenameTypeSizeUsedPriority
/dev/vdb1 partition41943000-1
/dev/vdb2 partition10485720 1
(3) 删除swap分区
swapon -a
Swapoff /dev/vdb{1,2} ###停用###
vim /etc/fstab ###删除刚才写的内容###
fdisk /dev/vdb ###删除分区###
过程如下:
[root@localhost ~]# swapon -a
[root@localhost ~]# swapoff /dev/vdb{1,2}
[root@localhost ~]# vim /etc/fstab
[root@localhost ~]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): d
Partition number (1,2, default 2): 1
Partition 1 is deleted
Command (m for help): d
Selected partition 2
Partition 2 is deleted
Command (m for help): wq
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# partprobe
[root@localhost ~]# cat /proc/partitions
major minor #blocks name
253 0 10485760 vda
253 1 10484142 vda1
253 16 10485760 vdb
四 磁盘配额
fdisk /dev/vdb ###划分分区###
Partprobe ###同步分区表###
Mkfs.xfs /dev/vdb1 ###格式化###
测试:
Mkdir /pub
mount -o usrquota,grpquota /dev/vdb1 /pub/ ###要用磁盘配额的参数(-o)去挂载 -o usrquota,grpquota :指对用户和组进行磁盘配额#######
ls -ld /pub/
chmod 777 /pub/
quotaon -ugv /dev/vdb1 ######指对用户和组激活,-v指显示激活过程。######
Edquota -u westos ######设定westos的磁盘额####
内容:(Disk quotas for user westos (uid 1001):
Filesystem blocks soft hard inodes soft hard
/dev/vdb1 0 0 204800 2 0 0
Blocks指原有的文件内容大小,inodes指文件个数,hard指你要限定的额度。
Su - westos
dd if=/dev/zero of=/pub/file bs=1M count=20
dd if=/dev/zero of=/pub/file1 bs=10M count=21
过程如下:
fdisk /dev/vdb
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-20971519, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +1G
Partition 1 of type Linux and of size 1 GiB is set
Command (m for help): wq
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# partprobe
[root@localhost ~]# mkfs.xfs /dev/vdb1
mkfs.xfs: /dev/vdb1 appears to contain an existing filesystem (swap).
mkfs.xfs: Use the -f option to force overwrite.
[root@localhost ~]# mkfs.xfs /dev/vdb1 -f
meta-data=http://www.mamicode.com/dev/vdb1 isize=256 agcount=4, agsize=65536 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0
data = bsize=4096 blocks=262144, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@localhost ~]# blkid
/dev/vda1: UUID="9bf6b9f7-92ad-441b-848e-0257cbb883d1" TYPE="xfs"
/dev/vdb1: UUID="aef5c924-3e58-4032-978a-c0eeaa6e5011" TYPE="xfs"
[root@localhost ~]# mkdir /pub
[root@localhost ~]# mount -o usrquota,grpquota /dev/vdb1 /pub/ ###要用磁盘配额的参数(-o)去挂载 -o usrquota,grpquota :指对用户和组进行磁盘配额#######
[root@localhost ~]# ls -ld /pub/ ###一定要先挂载,再修改权限#####
drwxr-xr-x. 2 root root 6 Apr 22 01:45 /pub/
[root@localhost ~]# chmod 777 /pub/
[root@localhost ~]# ls -ld /pub/
drwxrwxrwx. 2 root root 6 Apr 22 01:45 /pub/
[root@localhost ~]# quotaon -ugv /dev/vdb1 ######指对用户和组激活,-v指显示激活过程。######
quotaon: Enforcing group quota already on /dev/vdb1
quotaon: Enforcing user quota already on /dev/vdb1
[root@localhost ~]# edquota -u westos ######设定westos的磁盘额
[root@localhost ~]# su - westos
[westos@localhost ~]$ dd if=/dev/zero of=/pub/file bs=1M count=20
20+0 records in
20+0 records out
20971520 bytes (21 MB) copied, 0.0232917 s, 900 MB/s
[westos@localhost ~]$ du -sh /pub/file
20M/pub/file
[westos@localhost ~]$ dd if=/dev/zero of=/pub/file1 bs=10M count=21
dd: error writing ‘/pub/file1’: Disk quota exceeded ######
19+0 records in
18+0 records out
188743680 bytes (189 MB) copied, 0.488675 s, 386 MB/s
五 磁盘阵列(raid)
加快读取的速度
Raid 1 :加快读的速度
Raid 0 : 加快写的速度
1 创建raid
在/proc/mdstat查看raid的信息
Fdisk /dev/vdb ###创建分区,至少要三个###
注意:在wq保存之前要修改分区类型为raid
Partprobe
mdadm -C /dev/md0 -a yes -l 1 -n 2 -x 1 /dev/vdb{1..3}
-C:指创建
/dev/md0:raid设备
-a yes :指原本文件不存在,现在要创建出来
-l 1 :指raid 1
-n 2 :使用两块分区
-x 1 :闲置一块
/dev/vdb{1..3} :使用的分区
Mkfs.xfs /dev/md0 ###格式化###
mount /dev/md0 /mnt/ ###挂载###
过程如下:
[root@localhost ~]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-20971519, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +1G
Partition 1 of type Linux and of size 1 GiB is set
Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): p
Partition number (2-4, default 2):
First sector (2099200-20971519, default 2099200):
Using default value 2099200
Last sector, +sectors or +size{K,M,G} (2099200-20971519, default 20971519): +1G
Partition 2 of type Linux and of size 1 GiB is set
Command (m for help): n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): p
Partition number (3,4, default 3):
First sector (4196352-20971519, default 4196352):
Using default value 4196352
Last sector, +sectors or +size{K,M,G} (4196352-20971519, default 20971519): +1G
Partition 3 of type Linux and of size 1 GiB is set
Command (m for help): t
Hex code (type L to list all codes): fd
Changed type of partition ‘Linux‘ to ‘Linux raid autodetect‘
Command (m for help): t
Partition number (1-3, default 3): 2
Hex code (type L to list all codes): fd
Changed type of partition ‘Linux‘ to ‘Linux raid autodetect‘
Command (m for help): t
Partition number (1-3, default 3): 3
Hex code (type L to list all codes): fd
Changed type of partition ‘Linux‘ to ‘Linux raid autodetect‘
Command (m for help): wq
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# partprobe
[root@localhost ~]# cat /proc/partitions
major minor #blocks name
253 0 10485760 vda
253 1 10484142 vda1
253 16 10485760 vdb
253 17 1048576 vdb1
253 18 1048576 vdb2
253 19 1048576 vdb3
[root@localhost ~]# mdadm -C /dev/md0 -a yes -l 1 -n 2 -x 1 /dev/vdb{1..3}
mdadm: Note: this array has metadata at the start and
may not be suitable as a boot device. If you plan to
store ‘/boot‘ on this device please ensure that
your boot-loader understands md/v1.x metadata, or use
--metadata=http://www.mamicode.com/0.90
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
[root@localhost ~]# mkfs.xfs /dev/md0
meta-data=http://www.mamicode.com/dev/md0 isize=256 agcount=4, agsize=65500 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0
data = bsize=4096 blocks=262000, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=853, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@localhost ~]# mount /dev/md0 /mnt/
[root@localhost ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 10473900 3153448 7320452 31% /
devtmpfs 927072 0 927072 0% /dev
tmpfs 942660 472 942188 1% /dev/shm
tmpfs 942660 17080 925580 2% /run
tmpfs 942660 0 942660 0% /sys/fs/cgroup
/dev/md0 1044588 32928 1011660 4% /mnt
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 10G 3.1G 7.0G 31% /
devtmpfs 906M 0 906M 0% /dev
tmpfs 921M 472K 921M 1% /dev/shm
tmpfs 921M 17M 904M 2% /run
tmpfs 921M 0 921M 0% /sys/fs/cgroup
/dev/md0 1021M 33M 988M 4% /mnt
2 Mdadm的一些参数
mdadm -D /dev/md0 ###查看raid 状态###
mdadm -f /dev/md0 /dev/vdb2 ###使/dev/vdb2不能用####
Mdadm -r /dev/md0 /dev/vdb2 ###删除#####
mdadm -a /dev/md0 /dev/vdb2 ###添加####
监控命令:
Watch -n 1 Cat /proc/mdstst
过程如下:
[root@localhost ~]# mdadm -D /dev/md0 #####查看raid 状态#####
/dev/md0:
Version : 1.2
Creation Time : Sat Apr 22 02:44:17 2017
Raid Level : raid1
Array Size : 1048000 (1023.61 MiB 1073.15 MB)
Used Dev Size : 1048000 (1023.61 MiB 1073.15 MB)
Raid Devices : 2
Total Devices : 3
Persistence : Superblock is persistent
Update Time : Sat Apr 22 02:53:16 2017
State : clean
Active Devices : 2
Working Devices : 3
Failed Devices : 0
Spare Devices : 1
Name : localhost:0 (local to host localhost)
UUID : f06a5e38:cc4a82f0:2dac3467:b47f207d
Events : 17
Number Major Minor RaidDevice State
0 253 17 0 active sync /dev/vdb1 ###工作##
1 253 18 1 active sync /dev/vdb2 ###工作###
2 253 19 - spare /dev/vdb3 ###闲置###
[root@localhost ~]# mdadm -f /dev/md0 /dev/vdb2
mdadm: set /dev/vdb2 faulty in /dev/md0
[root@localhost ~]# mdadm -D /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Sat Apr 22 02:44:17 2017
Raid Level : raid1
Array Size : 1048000 (1023.61 MiB 1073.15 MB)
Used Dev Size : 1048000 (1023.61 MiB 1073.15 MB)
Raid Devices : 2
Total Devices : 3
Persistence : Superblock is persistent
Update Time : Sat Apr 22 02:54:46 2017
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 1
Spare Devices : 0
Name : localhost:0 (local to host localhost)
UUID : f06a5e38:cc4a82f0:2dac3467:b47f207d
Events : 36
Number Major Minor RaidDevice State
0 253 17 0 active sync /dev/vdb1
2 253 19 1 active sync /dev/vdb3
1 253 18 - faulty /dev/vdb2
[root@localhost ~]# mdadm -r /dev/md0 /dev/vdb2 ###删除#####
mdadm: hot removed /dev/vdb2 from /dev/md0
[root@localhost ~]# mdadm -D /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Sat Apr 22 02:44:17 2017
Raid Level : raid1
Array Size : 1048000 (1023.61 MiB 1073.15 MB)
Used Dev Size : 1048000 (1023.61 MiB 1073.15 MB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Update Time : Sat Apr 22 02:55:48 2017
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Name : localhost:0 (local to host localhost)
UUID : f06a5e38:cc4a82f0:2dac3467:b47f207d
Events : 37
Number Major Minor RaidDevice State
0 253 17 0 active sync /dev/vdb1
2 253 19 1 active sync /dev/vdb3
[root@localhost ~]# mdadm -a /dev/md0 /dev/vdb2 ###添加####
mdadm: added /dev/vdb2
[root@localhost ~]# mdadm -D /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Sat Apr 22 02:44:17 2017
Raid Level : raid1
Array Size : 1048000 (1023.61 MiB 1073.15 MB)
Used Dev Size : 1048000 (1023.61 MiB 1073.15 MB)
Raid Devices : 2
Total Devices : 3
Persistence : Superblock is persistent
Update Time : Sat Apr 22 02:56:47 2017
State : clean
Active Devices : 2
Working Devices : 3
Failed Devices : 0
Spare Devices : 1
Name : localhost:0 (local to host localhost)
UUID : f06a5e38:cc4a82f0:2dac3467:b47f207d
Events : 38
Number Major Minor RaidDevice State
0 253 17 0 active sync /dev/vdb1
2 253 19 1 active sync /dev/vdb3
3 253 18 - spare /dev/vdb2
3 删除raid
umount /mnt/ ###卸载####
mdadm -D /dev/md0 ###查看状态###
Mdadm -S /dev/md0 ####停止工作####
Fdisk /dev/vdb ###删除分区#####
partprobe ###同步分区表###
过程如下:
[root@localhost ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 10473900 3153660 7320240 31% /
devtmpfs 927072 0 927072 0% /dev
tmpfs 942660 472 942188 1% /dev/shm
tmpfs 942660 17112 925548 2% /run
tmpfs 942660 0 942660 0% /sys/fs/cgroup
/dev/md0 1044588 32928 1011660 4% /mnt
[root@localhost ~]# umount /mnt/ ###卸载####
[root@localhost ~]# mdadm -D /dev/md0 ###查看状态###
/dev/md0:
Version : 1.2
Creation Time : Sat Apr 22 02:44:17 2017
Raid Level : raid1
Array Size : 1048000 (1023.61 MiB 1073.15 MB)
Used Dev Size : 1048000 (1023.61 MiB 1073.15 MB)
Raid Devices : 2
Total Devices : 3
Persistence : Superblock is persistent
Update Time : Sat Apr 22 03:03:55 2017
State : clean
Active Devices : 2
Working Devices : 3
Failed Devices : 0
Spare Devices : 1
Name : localhost:0 (local to host localhost)
UUID : f06a5e38:cc4a82f0:2dac3467:b47f207d
Events : 38
Number Major Minor RaidDevice State
0 253 17 0 active sync /dev/vdb1
2 253 19 1 active sync /dev/vdb3
3 253 18 - spare /dev/vdb2
[root@localhost ~]# mdadm -S /dev/md0 ####停止工作####
mdadm: stopped /dev/md0
[root@localhost ~]# fdisk /dev/vdb ###删除分区#####
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): d
Partition number (1-3, default 3): 3
Partition 3 is deleted
Command (m for help): d
Partition number (1,2, default 2): 2
Partition 2 is deleted
Command (m for help): d
Selected partition 1
Partition 1 is deleted
Command (m for help): wq
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# partprobe
管理系统中的简单分区和文件系统