公司配的电脑,安装的是redhat6。
df -h如下:
[root@oc7070153642 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_oc2886812530-lv_root
226G 20G 205G 9% /
tmpfs 3.8G 136K 3.8G 1% /dev/shm
/dev/sda1 969M 106M 813M 12% /boot
可以看到并没有swap分区,但是free -g如下:
[root@oc7070153642 ~]# free -g
total used free shared buffers cached
Mem: 7 4 3 0 0 1
-/+ buffers/cache: 2 5
Swap: 7 0 7
可以看到swap分区其实是有的,也可以用free -t查看内存总数,是有16G的。
然后查看一下lvm的信息,首先,fdisk-l如下:
[root@oc7070153642 ~]# fdisk -l
Disk /dev/sda: 256.1 GB, 256060514304 bytes
255 heads, 63 sectors/track, 31130 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: 0x130e9499
Device Boot Start End Blocks Id System
/dev/sda1 * 1 128 1024000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 128 31131 249033728 83 Linux
Disk /dev/mapper/luks-bbe7f461-8a2f-4e05-b249-2438fe29610f: 255.0 GB, 255008440320 bytes
255 heads, 63 sectors/track, 31003 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: 0x00000000
Disk /dev/mapper/vg_oc2886812530-lv_root: 246.4 GB, 246390194176 bytes
255 heads, 63 sectors/track, 29955 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: 0x00000000
Disk /dev/mapper/vg_oc2886812530-lv_swap: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 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: 0x00000000
可以看到lvm的信息为:
1)radi之后的磁盘为sda,sda硬盘;
2)sda分了两个区,sda1给了boot,sda2给了lvm;
3) /dev/mapper/luks的软链接指向为dm-0(可以通过ll文件夹看到),可能是总的lvm大小?
4)创建了一个vg_oc2886812530的VG,从这个VG分了两个lv,一个是root一个是swap;
5)如果cd进/dev下的mapper和两个vg,能看到软链接都是一样的,指向dm。
然后lvdispay如下:
[root@oc7070153642 dev]# lvdisplay
--- Logical volume ---
LV Path /dev/vg_oc2886812530/lv_root
LV Name lv_root
VG Name vg_oc2886812530
LV UUID 0tHDLS-Ob2p-a2C8-KT3Y-Wtzg-d5HZ-7W3cLv
LV Write Access read/write
LV Creation host, time oc5343464833.ibm.com, 2015-11-23 09:46:01 +0800
LV Status available
# open 1
LV Size 229.47 GiB
Current LE 7343
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Logical volume ---
LV Path /dev/vg_oc2886812530/lv_swap
LV Name lv_swap
VG Name vg_oc2886812530
LV UUID gI5aIW-B7gH-jt4o-ZLRr-G9Nv-cxOF-G9lcDa
LV Write Access read/write
LV Creation host, time oc5343464833.ibm.com, 2015-11-23 09:46:15 +0800
LV Status available
# open 1
LV Size 8.00 GiB
Current LE 256
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
可以看到root和swap两个lv的路径,但是看不到文件类型。
mount /dev/vg_oc2886812530/lv_root,可以看到正常的挂载。
mount /dev/vg_oc2886812530/lv_root/mnt,会报:
/dev/mapper/vg_oc2886812530-lv_swap looks like swapspace - not mounted
mount: you must specify the filesystem type
可以发现系统已经认出了这个lv是swap分区,不能挂载。
然后cat /etc/fstab(开机启动的挂载):
[root@oc7070153642 dev]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Mon Nov 23 09:55:40 2015
#
# 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/vg_oc2886812530-lv_root / ext4 defaults 1 1
UUID=b4589dfe-05d2-4396-8bb0-ebe070c7a779 /boot ext4 defaults 1 2
/dev/mapper/vg_oc2886812530-lv_swap swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0 动态分配虚拟内存
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0 物理内核信息
会发现标蓝色的,root和boot是ext4分区,swap是swap分区,说明在创建lv时已经定义了swap文件系统那个,比较隐蔽。
橙色的几个挂载点都是内核调用的。
总结:
1)如果是用lvm分的swap分区,df -h是看不到的;
2)用cat /etc/fstab是可以看到所有开机启动挂载点的文件格式的;
3)free -g,free-t可以查看详细的物理和虚拟内存;
4)/dev/mapper和/dev/vg_*的软链接指向是一样的,都是dm-*;