服务器
型号:x3650 内存:164g 共有8块900M硬盘
磁盘阵列(RAID)
概念
优点:可以将多个磁盘划分为一块逻辑磁盘使用
RAID控制
- 硬件RAID:IBM自带RAID控制
- 软件RAID:mdadm
划分RAID方式:
- RAID0:把2块以上硬盘划组合在一起,将数据顺序写到2块硬盘。优点是数据按照顺序分别写入2块磁盘,提高磁盘吞吐量。缺点:硬盘损坏不可恢复
- RAID1:2块以上硬盘组合,将数据同时写到多块硬盘,任何一块硬盘损坏都可恢复
- RAID5:3块以上硬盘组合,前2块硬盘写数据,第3块硬盘写前2块硬盘的奇偶校验。缺点:只有一块硬盘损坏才能恢复
- RAID10:RAID1+RAID0的组合。优点:只要不是同一侧的硬盘损坏就能恢复
配置
2块硬盘做RAID1,6块硬盘做RAID5
开机后根据快捷键提示ctrl+h进入webbios
配置RAID1
选择【Add Configuration】,点击【Next】下一步
选择【Manual Configuration】,点击【Next】下一步
将左侧2块硬盘加到右侧的组中
点击【Accept DG】,创建磁盘组
【Next】进入下一步 点击【Add to SPAN】,将刚才创建好的磁盘组加入到右侧方框内
点击【Next】下一步
配置阵列参数:”Raid Level”选择Raid1,其余保持默认 ”Select Size”输入阵列容量大小,最大值可参考右侧绿字提示
配置完成后点击【Accept】
确认写入
初始化磁盘,选择Fast Initialize后点击Go,等待初始化完毕,第一次会比较慢
点击【Set Boot Driver】,这一块盘将作为系统盘
等待进度完成后,点击【HOME】返回首页
配置RAID5
进入配置向导
重复上述操作,将剩余磁盘划分到新组,配置为RAID5,格式化磁盘
安装系统
准备启动盘:ubuntu server 24.04
重启系统,按下【F12】选择启动介质
选择语言,默认
配置网络 按tab键配置IP相关地址,使用 DHCP 或者 静态IP。
配置分区
添加一个系统分区,剩余的磁盘安装系统后分配
等待安装完毕后重启
划分lvm
目标:安装系统时已将300g分给根目录,将剩余空间划分到一个逻辑卷,挂载到/mydata
概念
传统分区存在分区后空间固定,扩展时需要备份数据,卸载硬盘。但是磁盘数据较大一般不动,亦需停止程序。 优点:可以动态扩展空间。并且支持热加载,无需卸载磁盘或终止程序。
配置
和RAID结构类似,都是在物理盘上划分出逻辑盘。 过程:格式化为PE,划分VG,再从VG池中划分LV
分区前
一块900g,一块4T,300g分给系统
tyjfwy@tyjfwy:~$ sudo fdisk -l
Disk /dev/loop0: 4 KiB, 4096 bytes, 8 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 /dev/loop1: 74.24 MiB, 77844480 bytes, 152040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 <img src="bytes" alt="" width="30%" />
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop2: 268.65 MiB, 281702400 bytes, 550200 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 /dev/loop3: 505.09 MiB, 529625088 bytes, 1034424 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 /dev/loop4: 91.69 MiB, 96141312 bytes, 187776 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 /dev/loop5: 38.83 MiB, 40714240 bytes, 79520 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 /dev/loop6: 138.87 MiB, 145612800 bytes, 284400 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 /dev/sdb: 4.54 TiB, 4994996633600 bytes, 9755852800 sectors
Disk model: ServeRAID M5110e
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 /dev/sda: 930.39 GiB, 998999326720 bytes, 1951170560 sectors
Disk model: ServeRAID M5110e
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: B54948E4-C75E-4317-B652-765B5454DBB1
Device Start End Sectors Size Type
/dev/sda1 2048 2203647 2201600 1G EFI System
/dev/sda2 2203648 631349247 629145600 300G Linux filesystem
将900g的剩余空间分区
在 fdisk 提示符下,输入 n 创建新分区。
选择分区类型:输入 p 代表主分区,或者 e 代表扩展分区。
输入分区号(例如2,如果 /dev/sda1 是唯一存在的分区)。
输入分区的起始扇区,你可以接受默认值,这通常会从未被分配的空间开始。
输入分区的大小,你可以指定如 +600G,或者直接敲击回车键来使用整个剩余空间
tyjfwy@tyjfwy:~$ sudo fdisk /dev/sda
Welcome to fdisk (util-linux 2.39.3).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
This disk is currently in use - repartitioning is probably a bad idea.
It's recommended to umount all file systems, and swapoff all swap
partitions on this disk.
Command (m for help): n
Partition number (3-128, default 3): p #分区号一个磁盘的不能重复
Value out of range.
Partition number (3-128, default 3): 3
First sector (631349248-1951170526, default 631349248):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (631349248-1951170526, default 1951168511):
Created a new partition 3 of type 'Linux filesystem' and of size 629.3 GiB.
Command (m for help): wq
The partition table has been altered.
Syncing disks.
划分后:
tyjfwy@tyjfwy:~$ sudo fdisk -l
Disk /dev/loop0: 4 KiB, 4096 bytes, 8 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 /dev/loop1: 74.24 MiB, 77844480 bytes, 152040 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 /dev/loop2: 268.65 MiB, 281702400 bytes, 550200 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 /dev/loop3: 505.09 MiB, 529625088 bytes, 1034424 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 /dev/loop4: 91.69 MiB, 96141312 bytes, 187776 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 /dev/loop5: 38.83 MiB, 40714240 bytes, 79520 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 /dev/loop6: 138.87 MiB, 145612800 bytes, 284400 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 /dev/sdb: 4.54 TiB, 4994996633600 bytes, 9755852800 sectors
Disk model: ServeRAID M5110e
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 /dev/sda: 930.39 GiB, 998999326720 bytes, 1951170560 sectors
Disk model: ServeRAID M5110e
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: B54948E4-C75E-4317-B652-765B5454DBB1
Device Start End Sectors Size Type
/dev/sda1 2048 2203647 2201600 1G EFI System
/dev/sda2 2203648 631349247 629145600 300G Linux filesystem
/dev/sda3 631349248 1951168511 1319819264 629.3G Linux filesystem
初始化物理卷
tyjfwy@tyjfwy:~$ sudo pvcreate /dev/sdb /dev/sda3
Physical volume "/dev/sdb" successfully created.
Physical volume "/dev/sda3" successfully created.
查看
tyjfwy@tyjfwy:~$ sudo pvs
[sudo] password for tyjfwy:
PV VG Fmt Attr PSize PFree
/dev/sda3 lvm2 --- <629.34g <629.34g
/dev/sdb lvm2 --- 4.54t 4.54t
将2个分区加入卷组
tyjfwy@tyjfwy:~$ sudo vgcreate linuxvg /dev/sdb /dev/sda3
Volume group "linuxvg" successfully created
查看
tyjfwy@tyjfwy:~$ sudo vgs
VG #PV #LV #SN Attr VSize VFree
linuxvg 2 0 0 wz--n- <5.16t <5.16t
卷组剩余空间分配给逻辑卷
tyjfwy@tyjfwy:~$ sudo lvcreate -n linuxlv -l +100%FREE linuxvg
Logical volume "linuxlv" created.
查看
tyjfwy@tyjfwy:~$ sudo lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
linuxlv linuxvg -wi-a----- <5.16t
tyjfwy@tyjfwy:~$ sudo lvdisplay
--- Logical volume ---
LV Path /dev/linuxvg/linuxlv
LV Name linuxlv
VG Name linuxvg
LV UUID Vy3UJL-vBpO-Y4gL-kDbl-kDpt-bcSA-oZw50x
LV Write Access read/write
LV Creation host, time tyjfwy, 2024-06-27 11:49:42 +0000
LV Status available
# open 0
LV Size <5.16 TiB
Current LE 1352009
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:0
格式化逻辑卷
tyjfwy@tyjfwy:~$ sudo mkfs.ext4 /dev/linuxvg/linuxlv
mke2fs 1.47.0 (5-Feb-2023)
Creating filesystem with 1384457216 4k blocks and 173060096 inodes
Filesystem UUID: 370b121f-8a3c-47cc-8df6-454e200b3278
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848, 512000000, 550731776, 644972544
Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done
挂载
tyjfwy@tyjfwy:~$ sudo mount /dev/linuxvg/linuxlv /mydata/
tyjfwy@tyjfwy:/mydata$ sudo fdisk -l
Disk /dev/loop0: 4 KiB, 4096 bytes, 8 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 /dev/loop1: 74.24 MiB, 77844480 bytes, 152040 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 /dev/loop2: 268.65 MiB, 281702400 bytes, 550200 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 /dev/loop3: 505.09 MiB, 529625088 bytes, 1034424 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 /dev/loop4: 91.69 MiB, 96141312 bytes, 187776 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 /dev/loop5: 38.83 MiB, 40714240 bytes, 79520 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 /dev/loop6: 138.87 MiB, 145612800 bytes, 284400 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 /dev/sdb: 4.54 TiB, 4994996633600 bytes, 9755852800 sectors
Disk model: ServeRAID M5110e
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 /dev/sda: 930.39 GiB, 998999326720 bytes, 1951170560 sectors
Disk model: ServeRAID M5110e
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: B54948E4-C75E-4317-B652-765B5454DBB1
Device Start End Sectors Size Type
/dev/sda1 2048 2203647 2201600 1G EFI System
/dev/sda2 2203648 631349247 629145600 300G Linux filesystem
/dev/sda3 631349248 1951168511 1319819264 629.3G Linux filesystem
Disk /dev/mapper/linuxvg-linuxlv: 5.16 TiB, 5670736756736 bytes, 11075657728 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
tyjfwy@tyjfwy:/mydata$ df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 16G 2.3M 16G 1% /run
efivarfs 192K 39K 149K 21% /sys/firmware/efi/efivars
/dev/sda2 295G 15G 265G 6% /
tmpfs 79G 0 79G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda1 1.1G 6.2M 1.1G 1% /boot/efi
tmpfs 16G 124K 16G 1% /run/user/1000
/dev/mapper/linuxvg-linuxlv 5.2T 32K 4.9T 1% /mydata
写入配置
- 写入分区后是临时缓存,重启后失效,需要写入分区表
/dev/linuxvg/linuxlv /mydata ext4 defaults 0 0
重载配置
systemctl daemon-reload