暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

linux 磁盘分区

原创 Shubing Wu 2021-09-07
875

磁盘分区

fdisk /dev/sda

WARNING: DOS-compatible mode is deprecated. It’s strongly recommended to
switch off the mode (command ‘c’) and change display units to
sectors (command ‘u’).

Command (m for help): p

Disk /dev/sda: 579.8 GB, 579820584960 bytes
255 heads, 63 sectors/track, 70492 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003628d

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 5222 41430016 8e Linux LVM

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (5222-70492, default 5222):
Using default value 5222
Last cylinder, +cylinders or +size{K,M,G} (5222-70492, default 70492): +250G

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 or after you run partprobe(8) or kpartx(8)

创建PV 
pvcreate /dev/sda1

创建VG
vgcreate VolGroup-backup /dev/sda1

创建一个LV
lvcreate -L 200G -n lvbackup VolGroup-backup
lvcreate -l 100%VG -n lvoracle VolGroup-oracle 将剩余的空间都给到新的lv

格式化LV
mkfs -t ext4 /dev/VolGroup-backup/lvbackup

创建目录并挂载
创建目录:mkdir /backup
挂载:mount /dev/VolGroup-backup/lvbackup /backup
查看:df -h

设置开机挂载
#Vi /etc/fstab
/dev/VolGroup-backup/lvbackup /backup ext4 defaults 1 2

lv扩容:
创建PV 
pvcreate /dev/sdc1

创建VG(将pv加入到要扩容的vg,同一个组的vg才能扩容lv)
vgcreate oracledata /dev/sdc1

格式化

mkfs.ext4 /dev/sdc1

mke2fs 1.43.8 (1-Jan-2018)
/dev/sdc1 contains a LVM2_member file system
Proceed anyway? (y,N) y
Discarding device blocks: done
Creating filesystem with 26214144 4k blocks and 6553600 inodes
Filesystem UUID: 85a9c843-ff55-4800-9935-f0f9f341ac9a
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done
Writing inode tables: done
Creating journal (131072 blocks): done
Writing superblocks and filesystem accounting information: done

扩容VG
linux-069x:/u01/app/oracle # vgextend oracledata /dev/sdc1

WARNING: ext4 signature detected on /dev/sdc1 at offset 1080. Wipe it? [y/n]: y
Wiping ext4 signature on /dev/sdc1.
Physical volume “/dev/sdc1” successfully created.
Volume group “oracledata” successfully extended

扩容lv
lvextend -l +100%free /dev/oracledata/lvoracle

刷新lv磁盘存储(不同格式化不同方式,刷新后才能看到扩容的空间)
resize2fs /dev/vg_name/lv_name #ext4格式
xfs_growfs /dev/vg_name/lv_name #xfs格式

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论