This document describes how to initialize a data disk in the Lighthouse console. After creating a cloud disk and attaching it to the Lighthouse instance as a data disk, you need to initialize the disk to use it.
Attach a cloud disk to your Lighthouse instance. See Attaching a Cloud Disk.
Select the initialization method according to your actual use cases:
NoteThis example uses a Lighthouse instance using CentOS 8.0 operating system. Note that the steps may vary according to the operating system version.
sudo fdisk -l
/dev/vda
is the system disk (40 GB) and /dev/vdb
is the new data disk (20 GB)./dev/vdb
bare device.sudo mkfs -t <File system format> /dev/vdb
EXT4
as the file system:sudo mkfs -t ext4 /dev/vdb
NoteThe formatting takes a while. Please pay attention to the system’s running status and do not exit.
/data
as the new mount point:sudo mkdir /data
/data
as the new mount point:sudo mount /dev/vdb /data
sudo df -TH
/dev/vdb
is mounted to /data
successfully.NoteThis example uses the parted partition tool in the CentOS 8.0 operating system to configure data disk
/dev/vdc
as the primary partition. MBR is used as the default partition format, EXT4 format as the file system, and/data/newpart
as the mount point. Disk automount at startup is configured. Note that the formatting operation may vary according to the operating system.
sudo fdisk -l
/dev/vda
is the system disk (40 GB) and /dev/vdb
is the new data disk (20 GB)./dev/vdb
as the newly attached data disk:sudo fdisk /dev/vdb
p
and press Enter to start creating a primary partition. The following information is returned:Partition number indicates the number of the primary partition. Valid range: 1-4.
6. Take partition 1 as an example. Enter the primary partition number 1 and press Enter. The following information is returned:
First sector indicates the start sector. Valid range: 2048 (default value) - 41943039.
7. Take selecting the default start sector number 2048 as an example. Press Enter. The following information is returned:
Last sector indicates the end sector. Valid range: 2048 - 41943039 (default value).
8. Take selecting the default end sector number 41943039 as an example. Press Enter. The following information is returned:
9. The partitioning is complete. A new partition has been created on the 20 GB data disk.
10. Enter p and press Enter to view the details of the new partition /dev/vdb1
.
NoteIf an error occurs during the partitioning operation, enter q to exit the fdisk tool and the prior partition result will not be retained.
partprobe
sudo mkfs -t <File system format> /dev/vdb1
EXT4
as the file system:sudo mkfs -t ext4 /dev/vdb1
NoteThe formatting takes a while. Please pay attention to the system’s running status and do not exit.
/data/newpart
as the new mount point:sudo mkdir /data/newpart
/data/newpart
as the new mount point:sudo mount /dev/vdb1 /data/newpart
sudo df -TH
/dev/vdb1
has been mounted to /data/newpart
.Confirm the mounting method and obtain the corresponding information.
Based on business needs, you can use a cloud disk's soft link, file system's UUID (universally unique identifier), or device name to automatically mount a disk. The descriptions and information acquisition methods are as follows:
Mounting method | Pros and cons | Information acquisition method |
---|---|---|
Use the soft link of the cloud disk (recommended) |
Pros: The soft link of a cloud disk is fixed and unique. It does not change with operations such as mounting, unmounting, and formatting partitions. Cons: Only a cloud disk can use the soft link, which operates imperceptibly for the partition formatting operation. |
Run the following command to obtain the soft link of the cloud disk.sudo ls -l /dev/disk/by-id |
Use the UUID of the file system | Auto-mounting configuration may fail due to changes in a file system's UUID. For example, reformatting a file system will change its UUID. |
Run the following command to obtain the UUID of the file system.sudo blkid /dev/vdb |
Use device name | Auto-mounting configuration may fail due to changes in device name. | Run the following command to obtain the device name.sudo fdisk -l |
Run the following command to back up the /etc/fstab
file to the /home
directory, for example:
sudo cp -r /etc/fstab /home
Run the following command to use VI editor to open the /etc/fstab
file.
sudo vi /etc/fstab
Press i to enter edit mode.
Move the cursor to the end of the file and press Enter, then add the following content.
<Device information> <Mount point> <File system format> <File system installation option> <File system dump frequency> <File system check sequence at launch>
/dev/disk/by-id/virtio-disk-xxxxx /data ext4 defaults 0 0
For mounting the partition, add the following content:
/dev/disk/by-id/virtio-disk-xxxxx-part1 /data/newpart ext4 defaults 0 2
- Take automatic mounting using the UUID of the disk partition as an example. Add the following content:NoteIf you have multiple cloud disks, you can distinguish them by comparing the
xxxxx
invirtio-disk-xxxxx
with the cloud disk IDlhdisk-xxxxxx
in the console. The cloud disk ID in the console is shown below:
UUID=d489ca1c-5057-4536-81cb-ceb2847f9954 /data ext4 defaults 0 0
For mounting the partition, add the following content:
UUID=d489ca1c-5057-4536-81cb-ceb2847f9954 /data/newpart ext4 defaults 0 2
/dev/vdb /data ext4 defaults 0 0
For mounting the partition, add the following content:
/dev/vdb1 /data/newpart /data/newpart ext4 defaults 0 2
sudo mount -a
If the command runs successfully, the file has been written. The newly created file system will automatically mount when the operating system starts up.
Was this page helpful?