文件系统磁盘

磁盘挂载

partprobe  #同步内存于分区表
[root@cs-18 ~]# partprobe
Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only.
[root@cs-18 ~]# lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda           8:0    0  200G  0 disk 
├─sda1        8:1    0    1G  0 part /boot
└─sda2        8:2    0  199G  0 part 
  ├─cl-root 253:0    0   70G  0 lvm  /
  ├─cl-swap 253:1    0    2G  0 lvm  
  └─cl-home 253:2    0  127G  0 lvm  /home
sdb           8:16   0   20G  0 disk 
sdc           8:32   0   10G  0 disk /app
sr0          11:0    1  9.3G  0 rom 
[root@cs-18 ~]# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.32.1).
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 number (1-128, default 1):    #不输入,默认主分区
First sector (34-41943006, default 2048):    #不输入,默认主分区
Last sector, +sectors or +size{K,M,G,T,P} (2048-41943006, default 41943006): +2G    

Created a new partition 1 of type 'Linux filesystem' and of size 2 GiB.
Partition #1 contains a xfs signature.

Do you want to remove the signature? [Y]es/[N]o: Y

The signature will be removed by a write command.

Command (m for help): p
Disk /dev/sdb: 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: gpt
Disk identifier: 55384697-F876-47F3-B772-8DB6B3016E97

Device     Start     End Sectors Size Type
/dev/sdb1   2048 4196351 4194304   2G Linux filesystem

Filesystem/RAID signature on partition 1 will be wiped.

Command (m for help): t   #改ID
Selected partition 1
Partition type (type L to list all types): L  #显示出所有id类型,选择lvm。如果是硬盘则无需修改
 1 EFI System                     C12A7328-F81F-11D2-BA4B-00A0C93EC93B
  2 MBR partition scheme           024DEE41-33E7-11D3-9D69-0008C781F39F
  3 Intel Fast Flash               D3BFE2DE-3DAF-11DF-BA40-E3A556D89593
  4 BIOS boot                      21686148-6449-6E6F-744E-656564454649
  5 Sony boot partition            F4019732-066E-4E12-8273-346C5641494F
  6 Lenovo boot partition          BFBFAFE7-A34F-448A-9A5B-6213EB736C22
  7 PowerPC PReP boot              9E1A2D38-C612-4316-AA26-8B49521E5A8B
Partition type (type L to list all types): 31
Changed type of partition 'Linux filesystem' to 'Linux LVM'.

Command (m for help): p
Disk /dev/sdb: 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: gpt
Disk identifier: 55384697-F876-47F3-B772-8DB6B3016E97

Device     Start     End Sectors Size Type
/dev/sdb1   2048 4196351 4194304   2G Linux LVM    #可以看到修改

Filesystem/RAID signature on partition 1 will be wiped
Command (m for help): p
Disk /dev/sdb: 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: gpt
Disk identifier: 55384697-F876-47F3-B772-8DB6B3016E97

Device       Start      End Sectors Size Type
/dev/sdb1     2048  4196351 4194304   2G Linux LVM
/dev/sdb2  4196352 12584959 8388608   4G Linux LVM   #同理做sdb2

Filesystem/RAID signature on partition 1 will be wiped.

Command (m for help): w  #保存
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
[root@cs-18 ~]# lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda           8:0    0  200G  0 disk 
├─sda1        8:1    0    1G  0 part /boot
└─sda2        8:2    0  199G  0 part 
  ├─cl-root 253:0    0   70G  0 lvm  /
  ├─cl-swap 253:1    0    2G  0 lvm  
  └─cl-home 253:2    0  127G  0 lvm  /home
sdb           8:16   0   20G  0 disk 
├─sdb1        8:17   0    2G  0 part  # 分区
└─sdb2        8:18   0    4G  0 part    # 分区
sdc           8:32   0   10G  0 disk     #硬盘。硬盘可以于分区混用
sr0          11:0    1  9.3G  0 rom
##########################################块设备准备完成,接着将块设备边物理卷
[root@cs-18 ~]# pvs
  PV         VG Fmt  Attr PSize    PFree
  /dev/sda2  cl lvm2 a--  <199.00g    0 
[root@cs-18 ~]# pvcreate /dev/sd{b1,c}
WARNING: xfs signature detected on /dev/sdc at offset 0. Wipe it? [y/n]: y
  Wiping xfs signature on /dev/sdc.
  Physical volume "/dev/sdb1" successfully created.
  Physical volume "/dev/sdc" successfully created.
[root@cs-18 ~]# pvs
  PV         VG Fmt  Attr PSize    PFree 
  /dev/sda2  cl lvm2 a--  <199.00g     0 
  /dev/sdb1     lvm2 ---     2.00g  2.00g
  /dev/sdc      lvm2 ---    10.00g 10.00g   #可以看到多了两个物理卷vg处显示无卷组
[root@cs-18 ~]# vgcreate vg00 /dev/sdb1 /dev/sdc    #创建vg00卷组
Volume group "vg00" successfully created
[root@cs-18 ~]# pvs
  PV         VG   Fmt  Attr PSize    PFree  
  /dev/sda2  cl   lvm2 a--  <199.00g      0 
  /dev/sdb1  vg00 lvm2 a--    <2.00g  <2.00g
  /dev/sdc   vg00 lvm2 a--   <10.00g <10.00g    可以看到加到vg00的卷组中
[root@cs-18 ~]# vgs
  VG   #PV #LV #SN Attr   VSize    VFree 
  cl     1   3   0 wz--n- <199.00g     0 
  vg00   2   0   0 wz--n-   11.99g 11.99g     #可以看到卷组,并是sdb1与sdc容量的综合
[root@cs-18 ~]# lvcreate -n gaussdb -L 2G vg00   -n指定逻辑卷组名,-L大小 vg00
  Logical volume "gaussdb" created.
[root@cs-18 ~]# lvs
  LV      VG   Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  home    cl   -wi-ao---- 126.96g                                                    
  root    cl   -wi-ao----  70.00g                                                    
  swap    cl   -wi-a-----   2.03g                                                    
  gaussdb vg00 -wi-a-----   2.00g                                                    
root@cs-18 ~]# ls /dev/vg00/gaussdb -l  其实软连接,正是名字/dm-3
lrwxrwxrwx 1 root root 7 Jun 23 07:33 /dev/vg00/gaussdb -> ../dm-3
[root@cs-18 ~]# mkfs.xfs /dev/vg00/gaussdb 
meta-data=/dev/vg00/gaussdb      isize=512    agcount=4, agsize=131072 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=524288, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
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@cs-18 ~]# vim /etc/fstab
[root@cs-18 ~]# cat /etc/fstab |grep vg00
/dev/vg00/gaussdb      /app            xfs        defaults    0 0   
[root@cs-18 ~]# mount -a
[root@cs-18 ~]# df -Th
Filesystem               Type      Size  Used Avail Use% Mounted on
devtmpfs                 devtmpfs  877M     0  877M   0% /dev
tmpfs                    tmpfs     896M     0  896M   0% /dev/shm
tmpfs                    tmpfs     896M  8.7M  887M   1% /run
tmpfs                    tmpfs     896M     0  896M   0% /sys/fs/cgroup
/dev/mapper/cl-root      xfs        70G  2.0G   68G   3% /
/dev/sda1                xfs      1014M  195M  820M  20% /boot
tmpfs                    tmpfs     180M     0  180M   0% /run/user/0
/dev/mapper/cl-home      xfs       127G  939M  126G   1% /home
/dev/mapper/vg00-gaussdb xfs       2.0G   47M  2.0G   3% /app   #给这个gaussdb逻辑卷两个G
pv物理卷--vg卷组--lv逻辑卷
#####################################扩容
[root@cs-18 ~]# lvextend -L +50%free /dev/vg00/gaussdb 
  Can't parse size argument.
  Invalid argument for --size: +50%free
  Error during parsing of command line.
[root@cs-18 ~]# lvextend -l +50%free /dev/vg00/gaussdb   #加-r就不需要同步文件系统
  Size of logical volume vg00/gaussdb changed from 2.00 GiB (512 extents) to <7.00 GiB (1791 extents).
  Logical volume vg00/gaussdb successfully resized.
 root@cs-18 ~]# df -Th
/dev/mapper/vg00-gaussdb xfs       2.0G   47M  2.0G   3% /app  #因为加的没有文件系统,所以看不到
[root@cs-18 ~]# lvs
  LV      VG   Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  home    cl   -wi-ao---- 126.96g                                                    
  root    cl   -wi-ao----  70.00g                                                    
  swap    cl   -wi-a-----   2.03g                                                    
  gaussdb vg00 -wi-ao----  <7.00g                                                    
[root@cs-18 ~]# xfs_growfs /app   #xfs同步文件系统,ext4用resize2fs
meta-data=/dev/mapper/vg00-gaussdb isize=512    agcount=4, agsize=131072 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=524288, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
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
data blocks changed from 524288 to 1833984
[root@cs-18 ~]# df -Th |grep vg00
/dev/mapper/vg00-gaussdb xfs       7.0G   83M  7.0G   2% /app
[root@cs-18 ~]# 



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值