Record of mounting hard disk on Hikvision platform server
先前有一台海康平台型服务器,我们配备了三块240GB的固态硬盘,两块2T的机械硬盘,我们针对三块固态硬盘做了RAID5配置,针对两块机械硬盘做了RAID1配置。
操作系统这一块,我们安装了麒麟高级服务器v10,安装的时候,系统安装在三块固态硬盘组成的冗余磁盘阵列上,计划将两块机械硬盘组成的冗余磁盘阵列做为数据盘挂载。
- 查看分区
[scsp@kylin10 ~]$ sudo fdisk -l
[sudo] password for scsp:
Disk /dev/sda: 446.13 GiB, 479023071232 bytes, 935591936 sectors
Disk model: MR9361-8i
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytes
Disklabel type: dos
Disk identifier: 0xf2fdb5f3Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 230688767 230686720 110G 83 Linux
/dev/sda2 230688768 461375487 230686720 110G 83 Linux
/dev/sda3 * 461375488 462604287 1228800 600M 6 FAT16
/dev/sda4 462604288 935591935 472987648 225.5G 5 Extended
/dev/sda5 462606336 464703487 2097152 1G 83 Linux
/dev/sda6 464705536 935591935 470886400 224.5G 8e Linux LVMDisk /dev/sdb: 1.82 TiB, 1999844147200 bytes, 3905945600 sectors
Disk model: MR9361-8i
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytesDisk /dev/mapper/klas_kylin-root: 158.94 GiB, 170662035456 bytes, 333324288 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytesDisk /dev/mapper/klas_kylin-swap: 15.59 GiB, 16743661568 bytes, 32702464 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytesDisk /dev/mapper/klas_kylin-backup: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytes
[scsp@kylin10 ~]$
- 为数据盘做分区
[scsp@kylin10 ~]$ sudo fdisk /dev/sdbWelcome to fdisk (util-linux 2.35.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x4c344fe6.Command (m for help): mHelp:DOS (MBR)a toggle a bootable flagb edit nested BSD disklabelc toggle the dos compatibility flagGenericd delete a partitionF list free unpartitioned spacel list known partition typesn add a new partitionp print the partition tablet change a partition typev verify the partition tablei print information about a partitionMiscm print this menuu change display/entry unitsx extra functionality (experts only)ScriptI load disk layout from sfdisk script fileO dump disk layout to sfdisk script fileSave & Exitw write table to disk and exitq quit without saving changesCreate a new labelg create a new empty GPT partition tableG create a new empty SGI (IRIX) partition tableo create a new empty DOS partition tables create a new empty Sun partition tableCommand (m for help): p
Disk /dev/sdb: 1.82 TiB, 1999844147200 bytes, 3905945600 sectors
Disk model: MR9361-8i
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytes
Disklabel type: dos
Disk identifier: 0x4c344fe6Command (m for help): g
Created a new GPT disklabel (GUID: 71AD0D75-D893-BB41-B4CB-56FB893F403B).Command (m for help): n
Partition number (1-128, default 1):
First sector (2048-3905945566, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-3905945566, default 3905945566): Created a new partition 1 of type 'Linux filesystem' and of size 1.8 TiB.Command (m for help): p
Disk /dev/sdb: 1.82 TiB, 1999844147200 bytes, 3905945600 sectors
Disk model: MR9361-8i
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytes
Disklabel type: gpt
Disk identifier: 71AD0D75-D893-BB41-B4CB-56FB893F403BDevice Start End Sectors Size Type
/dev/sdb1 2048 3905945566 3905943519 1.8T Linux filesystemCommand (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.[scsp@kylin10 ~]$
- 查看分区
[scsp@kylin10 ~]$ sudo fdisk -l
Disk /dev/sda: 446.13 GiB, 479023071232 bytes, 935591936 sectors
Disk model: MR9361-8i
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytes
Disklabel type: dos
Disk identifier: 0xf2fdb5f3Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 230688767 230686720 110G 83 Linux
/dev/sda2 230688768 461375487 230686720 110G 83 Linux
/dev/sda3 * 461375488 462604287 1228800 600M 6 FAT16
/dev/sda4 462604288 935591935 472987648 225.5G 5 Extended
/dev/sda5 462606336 464703487 2097152 1G 83 Linux
/dev/sda6 464705536 935591935 470886400 224.5G 8e Linux LVMDisk /dev/sdb: 1.82 TiB, 1999844147200 bytes, 3905945600 sectors
Disk model: MR9361-8i
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytes
Disklabel type: gpt
Disk identifier: 71AD0D75-D893-BB41-B4CB-56FB893F403BDevice Start End Sectors Size Type
/dev/sdb1 2048 3905945566 3905943519 1.8T Linux filesystemDisk /dev/mapper/klas_kylin-root: 158.94 GiB, 170662035456 bytes, 333324288 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytesDisk /dev/mapper/klas_kylin-swap: 15.59 GiB, 16743661568 bytes, 32702464 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytesDisk /dev/mapper/klas_kylin-backup: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytes
[scsp@kylin10 ~]$
- create volume group
[scsp@kylin10 ~]$ sudo vgcreate vgdate /dev/sdb1
[sudo] password for scsp: Physical volume "/dev/sdb1" successfully created.Volume group "vgdate" successfully created
[scsp@kylin10 ~]$
- create logical volume
[scsp@kylin10 ~]$ sudo lvcreate -L 1.8TB -n lv01 vgdateRounding up size to full physical extent 1.80 TiBLogical volume "lv01" created.
[scsp@kylin10 ~]$
- 查看分区
[scsp@kylin10 ~]$ sudo fdisk -l
Disk /dev/sda: 446.13 GiB, 479023071232 bytes, 935591936 sectors
Disk model: MR9361-8i
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytes
Disklabel type: dos
Disk identifier: 0xf2fdb5f3Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 230688767 230686720 110G 83 Linux
/dev/sda2 230688768 461375487 230686720 110G 83 Linux
/dev/sda3 * 461375488 462604287 1228800 600M 6 FAT16
/dev/sda4 462604288 935591935 472987648 225.5G 5 Extended
/dev/sda5 462606336 464703487 2097152 1G 83 Linux
/dev/sda6 464705536 935591935 470886400 224.5G 8e Linux LVMDisk /dev/sdb: 1.82 TiB, 1999844147200 bytes, 3905945600 sectors
Disk model: MR9361-8i
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytes
Disklabel type: gpt
Disk identifier: 71AD0D75-D893-BB41-B4CB-56FB893F403BDevice Start End Sectors Size Type
/dev/sdb1 2048 3905945566 3905943519 1.8T Linux filesystemDisk /dev/mapper/klas_kylin-root: 158.94 GiB, 170662035456 bytes, 333324288 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytesDisk /dev/mapper/klas_kylin-swap: 15.59 GiB, 16743661568 bytes, 32702464 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytesDisk /dev/mapper/klas_kylin-backup: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytesDisk /dev/mapper/vgdate-lv01: 1.8 TiB, 1979124285440 bytes, 3865477120 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 262144 bytes / 262144 bytes
[scsp@kylin10 ~]$
- 用xfs格式格式化逻辑卷
[scsp@kylin10 ~]$ sudo mkfs.xfs /dev/vgdate/lv01
meta-data=/dev/vgdate/lv01 isize=512 agcount=32, agsize=15099520 blks= sectsz=4096 attr=2, projid32bit=1= crc=1 finobt=1, sparse=1, rmapbt=0= reflink=1
data = bsize=4096 blocks=483184640, imaxpct=5= sunit=64 swidth=64 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=235930, version=2= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[scsp@kylin10 ~]$ sudo xfs_info /dev/vgdate/lv01
meta-data=/dev/vgdate/lv01 isize=512 agcount=32, agsize=15099520 blks= sectsz=4096 attr=2, projid32bit=1= crc=1 finobt=1, sparse=1, rmapbt=0= reflink=1
data = bsize=4096 blocks=483184640, imaxpct=5= sunit=64 swidth=64 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=235930, version=2= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[scsp@kylin10 ~]$ sudo blkid /dev/vgdate/lv01
/dev/vgdate/lv01: UUID="1506e826-9021-4095-b704-cdf7255120c3" BLOCK_SIZE="4096" TYPE="xfs"
[scsp@kylin10 ~]$
说明
上面,我们采用
sudo mkfs.xfs /dev/vgdate/lv01
完成了逻辑卷的格式化,这里要说的是,采用
sudo mkfs.xfs /dev/mapper/vgdate-lv01
的效果也是一样的,因为/dev/mapper/vgdate-lv01
与/dev/vgdate/lv01
都是文件/dev/dm-3
的软链接,证据如下:
[scsp@kylin10 ~]$ ll /dev/vgdate/
total 0
lrwxrwxrwx 1 root root 7 Jun 12 10:33 lv01 -> ../dm-3
[scsp@kylin10 ~]$ ll /dev/mapper/
total 0
crw------- 1 root root 10, 236 Jun 12 10:33 control
lrwxrwxrwx 1 root root 7 Jun 12 10:33 klas_kylin-backup -> ../dm-2
lrwxrwxrwx 1 root root 7 Jun 12 10:33 klas_kylin-root -> ../dm-0
lrwxrwxrwx 1 root root 7 Jun 12 10:33 klas_kylin-swap -> ../dm-1
lrwxrwxrwx 1 root root 7 Jun 12 10:33 vgdate-lv01 -> ../dm-3
[scsp@kylin10 ~]$ ll /dev/ |grep dm
crw------- 1 root root 10, 56 Jun 12 10:33 cpu_dma_latency
brw-rw---- 1 root disk 253, 0 Jun 12 10:33 dm-0
brw-rw---- 1 root disk 253, 1 Jun 12 10:33 dm-1
brw-rw---- 1 root disk 253, 2 Jun 12 10:33 dm-2
brw-rw---- 1 root disk 253, 3 Jun 12 10:33 dm-3
[scsp@kylin10 ~]$
- 将逻辑卷添加到自动挂载文件中
sudo tee -a /etc/fstab <<-'EOF'
UUID="1506e826-9021-4095-b704-cdf7255120c3" /data xfs defaults 0 0
EOF
- 查看系统自动挂载文件
[scsp@kylin10 ~]$ cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Wed Jun 11 10:46:24 2025
#
# 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.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
/dev/mapper/klas_kylin-root / xfs defaults 0 0
/dev/mapper/klas_kylin-backup /backup xfs defaults 0 0
UUID=80266231-d10a-4497-a79e-6cba167b3f58 /boot xfs defaults 0 0
UUID=E7C8-7248 /boot/efi vfat umask=0077,shortname=winnt 0 2
/dev/mapper/klas_kylin-swap none swap defaults 0 0
UUID="1506e826-9021-4095-b704-cdf7255120c3" /data xfs defaults 0 0
[scsp@kylin10 ~]$
- 重启电脑
sudo reboot