suse和linux其他发行版本分区和LVM没有区别,主要是两个步骤:
一是分区,主要步骤是分区—刷新分区表—格式化,具体用什么方式分区、用什么方式刷新分区表、格式化成什么格式,方法有很多,根据实际情况而定,但总体思路不变;
二是创建物理卷、卷组和逻辑卷,主要步骤是依次创建物理卷、卷组、逻辑卷—格式化—挂载—配置/etc/fstab开机自动挂载;
Cluster:/mnt # fdisk -l
Disk /dev/sda: 384.4 GB, 384369164288 bytes
255 heads, 63 sectors/track, 46730 cylinders, total 750721024 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 identifier: 0x00024239
Device Boot Start End Blocks Id System
/dev/sda1 2048 4208639 2103296 82 Linux swap / Solaris
/dev/sda2 * 4208640 209715199 102753280 83 Linux
#由以上结果可知只有一块384G的硬盘/dev/sda,已经分了两个区/dev/sda1和/dev/sda2,已使用100G;
Cluster:/mnt # fdisk /dev/sda
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
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
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): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4, default 3):
Using default value 3
First sector (209715200-750721023, default 209715200):
Using default value 209715200
Last sector, +sectors or +size{K,M,G} (209715200-750721023, default 750721023): +100G
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
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
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/sda: 384.4 GB, 384369164288 bytes
255 heads, 63 sectors/track, 46730 cylinders, total 750721024 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 identifier: 0x00024239
Device Boot Start End Blocks Id System
/dev/sda1 2048 4208639 2103296 82 Linux swap / Solaris
/dev/sda2 * 4208640 209715199 102753280 83 Linux
/dev/sda3 209715200 419430399 104857600 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: 设备或资源忙.
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)
Syncing disks.
#fdisk分区完成之后,警告说内核仍然使用旧的分区表,需要重启系统或者执行partprobe、kpartx这两个其中一个命令;
#使用fdisk对/dev/sda分出第三个区,跟着提示操作,是在不知道的话输入m看提示;
Cluster:/mnt # fdisk -l
Disk /dev/sda: 384.4 GB, 384369164288 bytes
255 heads, 63 sectors/track, 46730 cylinders, total 750721024 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 identifier: 0x00024239
Device Boot Start End Blocks Id System
/dev/sda1 2048 4208639 2103296 82 Linux swap / Solaris
/dev/sda2 * 4208640 209715199 102753280 83 Linux
/dev/sda3 209715200 419430399 104857600 83 Linux
#显示磁盘分区,第三个区/dev/sda3已经分出来;
Cluster:/mnt # lsblk
NAME MAJ:MIN RM SIZE RO MOUNTPOINT
sda 8:0 0 358G 0
├─sda1 8:1 0 2G 0 [SWAP]
└─sda2 8:2 0 98G 0 /
sr0 11:0 1 3.1G 0
fd0 2:0 1 4K 0
loop0 7:0 0 3.1G 1 /mnt
#查看块设备信息的时候,还没有显示/dev/sda3,跟上面告警相关;
Cluster:/ # cat /proc/partitions
major minor #blocks name
8 0 375360512 sda
8 1 2103296 sda1
8 2 102753280 sda2
8 3 104857600 sda3
7 0 3283968 loop0
#查看分区信息,没有/dev/sda3;
Cluster:/ # partprobe
Warning: 无法以读写方式打开 /dev/sr0 (只读文件系统)。/dev/sr0 已按照只读方式打开。
Warning: 无法以读写方式打开 /dev/sr0 (只读文件系统)。/dev/sr0 已按照只读方式打开。
Error: 无效的分区表 - /dev/sr0 出现递归分区。
#刷新分区表;
Cluster:/ # lsblk
NAME MAJ:MIN RM SIZE RO MOUNTPOINT
sda 8:0 0 358G 0
├─sda1 8:1 0 2G 0 [SWAP]
├─sda2 8:2 0 98G 0 /
└─sda3 8:3 0 100G 0
sr0 11:0 1 3.1G 0
fd0 2:0 1 4K 0
loop0 7:0 0 3.1G 1 /mnt
#查看分区信息,显示/dev/sda3;
Cluster:/ # mkfs.ext3 /dev/sda3
mke2fs 1.41.9 (22-Aug-2009)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
6553600 inodes, 26214400 blocks
1310720 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=4294967296
800 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
This filesystem will be automatically checked every 21 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
#格式化分区,因为是suse,所以格式化为ext3;
Cluster:/ # pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created
Cluster:/ # pvs
PV VG Fmt Attr PSize PFree
/dev/sda3 lvm2 a-- 100.00g 100.00g
#创建物理卷,pvs查看物理卷;
Cluster:/ # vgcreate datavg /dev/sda3
Volume group "datavg" successfully created
Cluster:/ # vgs
VG #PV #LV #SN Attr VSize VFree
datavg 1 0 0 wz--n- 100.00g 100.00g
#创建卷组 datavg,vgs查看卷组;
Cluster:/ # lvcreate -L +99G -n lv_data datavg
Logical volume "lv_data" created
Cluster:/ # lvs
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
lv_data datavg -wi-a---- 99.00g
#创建逻辑卷 lv_data,lvs查看逻辑卷;
Cluster:/ # mkfs.ext3 /dev/datavg/lv_data
mke2fs 1.41.9 (22-Aug-2009)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
6488064 inodes, 25952256 blocks
1297612 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=4294967296
792 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
This filesystem will be automatically checked every 29 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
#格式化逻辑卷;
Cluster:/ # mount /dev/datavg/lv_data /upload
#挂载逻辑卷到/upload目录下;
Cluster:/ # df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda2 97G 86G 10G 90% /
udev 16G 100K 16G 1% /dev
tmpfs 16G 0 16G 0% /dev/shm
/dev/loop0 3.2G 3.2G 0 100% /mnt
/dev/mapper/datavg-lv_data 98G 188M 93G 1% /upload
#显示分区;
Cluster:/ # cat /etc/fstab | grep upload
/dev/mapper/datavg-lv_data /upload ext3 defaults 0 0
#将df -h显示结果的逻辑卷,填写到/etc/fstab下,如果不填下次重启服务器,系统会无法正常启动;