linux 分区 物理卷 逻辑卷
今天我们主要说说分区、格式化、SWAP、LVM、软件RAID的创建哈~
#fdisk /dev/sda
D删除一个分区
#pvcreate /dev/sdax
sdax就是你刚才创建的分区
从硬盘驱动器中创建物理卷(physical volumes-PV)。
从物理卷中创建卷组(volume groups-VG)。
从卷组中创建逻辑卷(logical volumes-LV),并分派逻辑卷挂载点
其中只有逻辑卷才可以写数据
#vgcreate myvg /dev/sda8
我就从卷组里面分100M出来创建一个逻辑卷
#lvcreate -L 100M myvg -n mylv1
[root@rhel5 /mnt/mylv1]# fdisk -l
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 1318 10482412+ 83 Linux /dev/sda3 1319 1971 5245222+ 83 Linux /dev/sda4 1972 3916 15623212+ 5 Extended /dev/sda5 1972 2624 5245191 83 Linux /dev/sda6 2625 2689 522081 82 Linux swap / Solaris /dev/sda7 2690 2751 497983+ 83 Linux /dev/sda8 2752 2788 297171 8e Linux LVM [root@rhel5 /mnt/mylv1]# lvdisplay --- Logical volume --- LV Name /dev/myvg/mylv1 VG Name myvg LV UUID xXbNEd-LAQa-xLtB-c92X-3BJ9-qfWu-z54ejZ LV Write Access read/write LV Status available # open 1 LV Size 100.00 MB Current LE 25 Segments 1 Allocation inherit Read ahead sectors 0 Block device 253:0 [root@rhel5 /mnt/mylv1]# |
#lvresize -L 绝对大小 对象
#lvresize -L 100M /dev/myvg/mylv2
resize2fs /dev/myvg/mylv2
1:不要进行对该分区的任何写入操作,最好是也不read
2:用lvresize2fs重新扩大该分区,且扩大的容量是刚刚缩小的容量(数字一定要和刚刚的一致哈~)。
3:缩小文件系统
4:最后缩小逻辑卷哈。
5:确认文件系统和逻辑卷大小一致。
[root@rhel5 ~]# umount /mnt/mylv2
[root@rhel5 ~]# lvresize -L 150M /dev/myvg/mylv2 Rounding up size to full physical extent 152.00 MB Extending logical volume mylv2 to 152.00 MB Logical volume mylv2 successfully resized [root@rhel5 ~]# e2fsck -f /dev/myvg/mylv2 e2fsck 1.39 (29-May-2006) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/myvg/mylv2: 12/38912 files (8.3% non-contiguous), 10580/155648 blocks [root@rhel5 ~]# resize2fs /dev/myvg/mylv2 100M resize2fs 1.39 (29-May-2006) Resizing the filesystem on /dev/myvg/mylv2 to 102400 (1k) blocks. The filesystem on /dev/myvg/mylv2 is now 102400 blocks long.
[root@rhel5 ~]# lvresize -L 100M /dev/myvg/mylv2
WARNING: Reducing active logical volume to 100.00 MB THIS MAY DESTROY YOUR DATA (filesystem etc.) Do you really want to reduce mylv2? [y/n]: y Reducing logical volume mylv2 to 100.00 MB Logical volume mylv2 successfully resized [root@rhel5 ~]# e2fsck -f /dev/myvg/mylv2 e2fsck 1.39 (29-May-2006) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/myvg/mylv2: 12/26624 files (8.3% non-contiguous), 9032/102400 blocks [root@rhel5 ~]# mount -t ext3 /dev/myvg/mylv2 /mnt/mylv2 [root@rhel5 ~]# |
#resize2fs /dev/myvg/mylv1
[root@rhel5 /mnt/mylv1]# fdisk /dev/sda
The number of cylinders for this disk is set to 3916.
There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): n
First cylinder (2789-3916, default 2789): Using default value 2789 Last cylinder or +size or +sizeM or +sizeK (2789-3916, default 3916): +500M
Command (m for help): p
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 1318 10482412+ 83 Linux /dev/sda3 1319 1971 5245222+ 83 Linux /dev/sda4 1972 3916 15623212+ 5 Extended /dev/sda5 1972 2624 5245191 83 Linux /dev/sda6 2625 2689 522081 82 Linux swap / Solaris /dev/sda7 2690 2751 497983+ 83 Linux /dev/sda8 2752 2788 297171 8e Linux LVM /dev/sda9 2789 2850 497983+ 83 Linux
Command (m for help): t
Partition number (1-9): 9 Hex code (type L to list codes): 8e Changed system type of partition 9 to 8e (Linux LVM)
Command (m for help): p
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 1318 10482412+ 83 Linux /dev/sda3 1319 1971 5245222+ 83 Linux /dev/sda4 1972 3916 15623212+ 5 Extended /dev/sda5 1972 2624 5245191 83 Linux /dev/sda6 2625 2689 522081 82 Linux swap / Solaris /dev/sda7 2690 2751 497983+ 83 Linux /dev/sda8 2752 2788 297171 8e Linux LVM /dev/sda9 2789 2850 497983+ 8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at the next reboot. Syncing disks. [root@rhel5 /mnt/mylv1]# |
#vgedtend myvg /dev/sda9
#umount /mnt/mylv1
#umount /mnt/mylv2
[root@rhel5 ~]# fdisk /dev/sda
The number of cylinders for this disk is set to 3916.
There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 1318 10482412+ 83 Linux /dev/sda3 1319 1971 5245222+ 83 Linux /dev/sda4 1972 3916 15623212+ 5 Extended /dev/sda5 1972 2624 5245191 83 Linux /dev/sda6 2625 2689 522081 82 Linux swap / Solaris /dev/sda7 2690 2751 497983+ 83 Linux /dev/sda8 2752 2788 297171 8e Linux LVM /dev/sda9 2789 2850 497983+ 8e Linux LVM
Command (m for help): d
Partition number (1-9): 9
Command (m for help): p
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 1318 10482412+ 83 Linux /dev/sda3 1319 1971 5245222+ 83 Linux /dev/sda4 1972 3916 15623212+ 5 Extended /dev/sda5 1972 2624 5245191 83 Linux /dev/sda6 2625 2689 522081 82 Linux swap / Solaris /dev/sda7 2690 2751 497983+ 83 Linux /dev/sda8 2752 2788 297171 8e Linux LVM
Command (m for help): d
Partition number (1-8): 8
Command (m for help): p
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 1318 10482412+ 83 Linux /dev/sda3 1319 1971 5245222+ 83 Linux /dev/sda4 1972 3916 15623212+ 5 Extended /dev/sda5 1972 2624 5245191 83 Linux /dev/sda6 2625 2689 522081 82 Linux swap / Solaris /dev/sda7 2690 2751 497983+ 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at the next reboot. Syncing disks. [root@rhel5 ~]# partprobe [root@rhel5 ~]# |
RAID0
RAID1
RAID5
优点:廉价
缺点:不稳定,如果系统坏了,RAID整列也就损坏,容易造成数据丢失
相对于软件RAID
优点:可靠性高,易管理。稳定
缺点:成本过高
因为RAID5至少需要3个或者更多的硬盘,我们就要分3个分区,然后再加一个热备份的分区,就是4个分区
the new table will be used at the next reboot
warning: unable to open /dev/h dc read-wirte ( read-only file system)
[root@rhel5 ~]# fdisk -l
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 1318 10482412+ 83 Linux /dev/sda3 1319 1971 5245222+ 83 Linux /dev/sda4 1972 3916 15623212+ 5 Extended /dev/sda5 1972 2624 5245191 83 Linux /dev/sda6 2625 2689 522081 82 Linux swap / Solaris [root@rhel5 ~]# fdisk /dev/sda
The number of cylinders for this disk is set to 3916.
There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): n
First cylinder (2690-3916, default 2690): Using default value 2690 Last cylinder or +size or +sizeM or +sizeK (2690-3916, default 3916): +100M
Command (m for help): n
First cylinder (2703-3916, default 2703): Using default value 2703 Last cylinder or +size or +sizeM or +sizeK (2703-3916, default 3916): +100M
Command (m for help): n
First cylinder (2716-3916, default 2716): Using default value 2716 Last cylinder or +size or +sizeM or +sizeK (2716-3916, default 3916): +100M
Command (m for help): n
First cylinder (2729-3916, default 2729): Using default value 2729 Last cylinder or +size or +sizeM or +sizeK (2729-3916, default 3916): +100M
Command (m for help): p
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 1318 10482412+ 83 Linux /dev/sda3 1319 1971 5245222+ 83 Linux /dev/sda4 1972 3916 15623212+ 5 Extended /dev/sda5 1972 2624 5245191 83 Linux /dev/sda6 2625 2689 522081 82 Linux swap / Solaris /dev/sda7 2690 2702 104391 83 Linux /dev/sda8 2703 2715 104391 83 Linux /dev/sda9 2716 2728 104391 83 Linux /dev/sda10 2729 2741 104391 83 Linux
Command (m for help): t
Partition number (1-10): 7 Hex code (type L to list codes): fd Changed system type of partition 7 to fd (Linux raid autodetect)
Command (m for help): t
Partition number (1-10): 8 Hex code (type L to list codes): fd Changed system type of partition 8 to fd (Linux raid autodetect)
Command (m for help): t
Partition number (1-10): 9 Hex code (type L to list codes): fd Changed system type of partition 9 to fd (Linux raid autodetect)
Command (m for help): t
Partition number (1-10): 10 Hex code (type L to list codes): fd Changed system type of partition 10 to fd (Linux raid autodetect)
Command (m for help): p
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 1318 10482412+ 83 Linux /dev/sda3 1319 1971 5245222+ 83 Linux /dev/sda4 1972 3916 15623212+ 5 Extended /dev/sda5 1972 2624 5245191 83 Linux /dev/sda6 2625 2689 522081 82 Linux swap / Solaris /dev/sda7 2690 2702 104391 fd Linux raid autodetect /dev/sda8 2703 2715 104391 fd Linux raid autodetect /dev/sda9 2716 2728 104391 fd Linux raid autodetect /dev/sda10 2729 2741 104391 fd Linux raid autodetect
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at the next reboot. Syncing disks. [root@rhel5 ~]# partprobe Warning: Unable to open /dev/hdc read-write (Read-only file system). /dev/hdc has been opened read-only. [root@rhel5 ~]# partprobe [root@rhel5 ~]# |
#mdadm --detail /dev/md1
查看RAID状态
[root@rhel5 ~]# mdadm -C /dev/md1 -l 5 -n 3 -x 1 /dev/sda7 /dev/sda8 /dev/sda9 /dev/sda10
mdadm: array /dev/md1 started. [root@rhel5 ~]# mdadm --detail /dev/md1 /dev/md1: Version : 00.90.03 Creation Time : Mon Dec 29 17:25:41 2008 Raid Level : raid5 Array Size : 208640 (203.78 MiB 213.65 MB) Device Size : 104320 (101.89 MiB 106.82 MB) Raid Devices : 3 Total Devices : 4 Preferred Minor : 1 Persistence : Superblock is persistent
Update Time : Mon Dec 29 17:25:44 2008
State : clean Active Devices : 3 Working Devices : 4 Failed Devices : 0 Spare Devices : 1
Layout : left-symmetric
Chunk Size : 64K
UUID : 2f7e30d2:f3f54047:e22d6b9f:16f2b256
Events : 0.2
Number Major Minor RaidDevice State
0 8 7 0 active sync /dev/sda7 1 8 8 1 active sync /dev/sda8 2 8 9 2 active sync /dev/sda9
3 8 10 - spare /dev/sda10
[root@rhel5 ~]# |
#mount -t ext3 /dev/md1 /mnt/raid
转载于:https://www.cnblogs.com/Yongzhouunknown/p/4845525.html
linux 分区 物理卷 逻辑卷相关推荐
- Linux系统之创建逻辑卷
Linux系统之创建逻辑卷 一.磁盘分区 二.创建PV物理卷 三.创建卷组,指定PE大小为12M 四.创建逻辑卷,大小50个PE 五.格式化逻辑卷,并挂载 1.格式化逻辑卷 2.永久挂载 一.磁盘分区 ...
- LVM逻辑卷 (概述lvm,管理卷组 物理卷 逻辑卷,磁盘配额)
文章目录 管理LVM逻辑卷 前言 lvm简述 pv物理卷 VG卷组 lv逻辑卷 管理LVM pv物理卷管理 pvscan命令--用于扫描系统中的物理卷 pvcreate命令--把整个硬盘转换成物理卷 ...
- Linux command lvextend 扩展逻辑卷设备
Linux command lvextend 扩展逻辑卷设备 tags: 设备 文章目录 Linux command lvextend 扩展逻辑卷设备 1. 简介 2. 语法 3. 常用参数 4. 安 ...
- LINUX下的LVM逻辑卷管理器
首先初始化 1 :pvcreat /dev/sda1 /dev/sda2 意思是说初始化设备/dev/sda1 和 /dev/sda2 然后用vgscan来描一下 2: vgcreate aaa /d ...
- Linux基础--存储管理(逻辑卷lvm,swap交换分区,mount,raid磁盘阵列)
一.存储管理2 要点:逻辑卷lvm,swap交换分区,mount,raid磁盘阵列 盛年不重来,一日难再晨. 及时当勉励,岁月不待人. 1.逻辑卷LVM–(Logical Volume Manager ...
- Linux中硬盘分区、创建逻辑卷
1.先添加一块硬盘 点击添加----->点击硬盘----->点击下一步 类型为SCSI(S),下一步 选中创建新虚拟磁盘 指定磁盘大小,这里以20G为例,下一步,完成. 2.使用lsblk ...
- Linux系统之磁盘分区(基本分区和LVM逻辑卷分区)
一.磁盘简介 1.磁盘属性简介 •定义: 磁盘=硬盘=disk,与内存不一样的是容量比较大. •类型 从工作原理上分为机械硬盘和固态硬盘 机械硬盘:机械硬盘即是传统普通硬盘,主要由:盘片,磁头, ...
- 管理员技术(六): 硬盘分区及格式化、 新建一个逻辑卷、调整现有磁盘的分区、扩展逻辑卷的大小、添加一个swap分区...
一.硬盘分区及格式化 问题: 本例要求熟悉硬盘分区结构,使用fdisk分区工具在磁盘 /dev/vdb 上按以下要求建立分区: 1> 采用默认的 msdos 分区模式 2> ...
- linux系统中扩展一个逻辑卷,Linux 创建及扩展逻辑卷
标签:系统 实验01 创建逻辑卷 实验目标 从两块磁盘上各取10GB组成20GB的卷组 从卷组中划分一个16GB的逻辑卷 将此逻辑卷格式化并挂载到/mbox 实验步骤 一.为新添加的两块硬盘分区 ...
最新文章
- Redis 命令整理
- 根据两点间的经纬度计算距离
- 对信号与系统课程的意见与建议
- VTK:Qt之EventQtSlotConnect
- .net 中通用的formatstring格式符整理
- LeetCode题 - 13 罗马数字转整数
- 火出边际的Serverless,你居然还不了解?
- 合作活动 | 鲸准产业价值峰会AI专场,共探AI商业模式
- maya前台渲染_maya前台渲染MEL
- Oracle 11g数据库基础教程(第2版)-课后习题-第十二章
- Java精品项目第33期前台展示+后台管理结合的在线购书系统
- Feed流之微博系统设计
- 模型解释器-LIME
- 使用ping检测MTU值
- C++ Reference: Standard C++ Library reference: C Library: cstdio: printf
- el-table 表格展开与折叠
- 丰田增设电池生产线,加快丰田电动化进程
- 生成Excel的” 源代码
- python的主要应用
- Elasticsearch8.2扩容挪数据master出现异常