Ubuntu 增加硬碟

最近打算新建一個用Veeam B&R的Offsite backup, 然後就選中了QNAP 251+的2Bays NAS, 在Bios設定了由8TB硬碟啟動OS
先在8TB硬碟安裝Ubuntu 22.04 LTS, 用了沒多久又找到了4TB硬碟, 一開始沒有規劃好, 所以又要再來加硬碟

root@repository:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 63.5M 1 loop /snap/core20/2015
loop1 7:1 0 40.8M 1 loop /snap/snapd/20092
loop2 7:2 0 63.3M 1 loop /snap/core20/1822
loop3 7:3 0 111.9M 1 loop /snap/lxd/24322
loop4 7:4 0 49.8M 1 loop /snap/snapd/18357
sda 8:0 1 3.6T 0 disk
sdb 8:16 1 7.3T 0 disk
├─sdb1 8:17 1 1M 0 part
├─sdb2 8:18 1 2G 0 part /boot
└─sdb3 8:19 1 7.3T 0 part
└─ubuntu--vg-ubuntu--lv 253:0 0 7.3T 0 lvm /
sdc 8:32 1 492M 0 disk
├─sdc1 8:33 1 5.1M 0 part
├─sdc2 8:34 1 235.1M 0 part
├─sdc3 8:35 1 235.1M 0 part
├─sdc4 8:36 1 1K 0 part
├─sdc5 8:37 1 8.1M 0 part
└─sdc6 8:38 1 8.5M 0 part

在這裏看到8TB硬碟是sdb, 4TB硬碟是sda, 為什麼只有一個/, 因為懶

root@repository:~# fdisk -l /dev/sda
Disk /dev/sda: 3.64 TiB, 4000787030016 bytes, 7814037168 sectors
Disk model: WDC WD40EJRX-89T
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: E7BA0DAB-A6B8-4F61-B750-4AAAE4166127

Double check沒有看到sda有partition

root@repository:~# fdisk /dev/sda

Welcome to fdisk (util-linux 2.37.2).
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-7814037134, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-7814037134, default 7814037134):

Created a new partition 1 of type 'Linux filesystem' and of size 3.6 TiB.
Partition #1 contains a VMFS_volume_member signature.

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

The signature will be removed by a write command.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

這個硬碟之前是在ESXi中使用, 可以remove signature, 而且我要使用全部空間, 所以default就可以

root@repository:~# fdisk -l /dev/sda
Disk /dev/sda: 3.64 TiB, 4000787030016 bytes, 7814037168 sectors
Disk model: WDC WD40EJRX-89T
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: E7BA0DAB-A6B8-4F61-B750-4AAAE4166127

Device Start End Sectors Size Type
/dev/sda1 2048 7814037134 7814035087 3.6T Linux filesystem

這裏看到已經有一個partition sda1

root@repository:~# mkfs -t xfs /dev/sda1
meta-data=/dev/sda1 isize=512 agcount=4, agsize=244188597 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1 bigtime=0 inobtcount=0
data = bsize=4096 blocks=976754385, imaxpct=5
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=476930, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0

再來就是format為xfs格式, Veeam B&R的Linux repository要用XFS才能使用duplicate及fast clone

Remark
後來在Veeam的教學書中看到使用這句command, "mkfs.xfs -b size=4096 -m reflink=1,crc=1 /dev/sdb" -b size=4096就是block size用多小, 簡單的想成如果小於4096都會當成4096, 占用的空間就會增加, 但是我用來做backup的話, 這個數值增加應該較能是會提升, 而且單一file的大小都會支持更高(之前在Windows format refs就是這樣的, 當時用default refs, 單一個veeam backup file不能超過4TB, xfs應該一樣), reflink和crc就不知道是什麼, 而且我已經在使用, 我就沒有再重新format了, 不過在上面看到bsize都是4096, reflink=1, crc=1, 可能都只是預設值, 我就不理了

root@repository:~# lsblk -d -fs /dev/sda1
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
sda1 xfs 2ec625e4-99d0-4aa7-ab05-e3e7e728feb5 518.5G 86% /Backup2
└─sda

看看這個sda1的UUID然後加到fstab

root@repository:~# cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# # / was on /dev/ubuntu-vg/ubuntu-lv during curtin installation
/dev/disk/by-id/dm-uuid-LVM-cvZKVdtM6CYu3c14duUPu7bK2ySuebuGh45McCfUjDxZcuIzyqlKNfKcMlXdyZbN / xfs defaults 0 1
# /boot was on /dev/sda2 during curtin installation
/dev/disk/by-uuid/e2d58859-73f0-483f-9ade-6181425babe4 /boot ext4 defaults 0 1
/swap.img none swap sw 0 0

UUID=2ec625e4-99d0-4aa7-ab05-e3e7e728feb5 /Backup2 xfs defaults 0

另外需要建立/Backup2
root@repository:~# mkdir -p /Backup2

可以選擇重啟, 或者打mount即時生效
root@repository:~# mount /dev/sda1 /Backup2

Comments

No comments yet. Why don’t you start the discussion?

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

*