Creating and Mounting a File System
Scenarios
After the logical volume is created, you need to create a file system on the logical volume and mount the file system on the corresponding directory. This section shows how to create an ext4 file system on a logical volume and mount the file system on /Data1.
Procedure
- Log in to the ECS as user root.
For how to log in to an ECS, see Logging In to an ECS.
- Create a file system.
mkfs.<file-system-format> <logical-volume-path>
Example command:
mkfs.ext4 /dev/vgdata/lvdata1
Information similar to the following is displayed:
[root@ecs-lvmtest ~]# mkfs.ext4 /dev/vgdata/lvdata1 mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 983040 inodes, 3932160 blocks 196608 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2151677952 120 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 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
- Create a mount point.
mkdir <mount-point>
Example command:
mkdir /Data1
- Mount the file system on the mount point.
mount <logical-volume-path> <mount-point>
Example command:
mount /dev/vgdata/lvdata1 /Data1
- Query the file system mount information.
mount | grep <mount-point>
Example command:
mount | grep /Data1
Information similar to the following is displayed:
[root@ecs-lvmtest ~]# mount | grep /Data1 /dev/mapper/vgdata-lvdata1 on /Data1 type ext4 (rw,relatime,data=ordered)
In the command output, dev/mapper/vgdata-lvdata1 indicates the file system path. Take note of this path, which will be used in 6.
- Perform the following operations to enable auto mount of the file system at the system start:
If it is not configured, you need to manually mount the file system every time the ECS is restarted.
- Query the file system UUID.
In this example, the UUID of dev/mapper/vgdata-lvdata1 is queried.
blkid /dev/mapper/vgdata-lvdata1
Information similar to the following is displayed:
[root@ecs-lvmtest ~]# blkid /dev/mapper/vgdata-lvdata1 /dev/mapper/vgdata-lvdata1: UUID="c6a243ce-5150-41ac-8816-39db54d1a4b8" TYPE="ext4"
In the command output, the UUID is c6a243ce-5150-41ac-8816-39db54d1a4b8.
- Open the /etc/fstab file.
vi /etc/fstab
Information similar to the following is displayed:[root@ecs-lvmtest ~]# vi /etc/fstab # # /etc/fstab # Created by anaconda on Tue Nov 7 14:28:26 2017 # # 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 # UUID=27f9be47-838b-4155-b20b-e4c5e013cdf3 / ext4 defaults 1 1 UUID=2b2000b1-f926-4b6b-ade8-695ee244a901 /boot ext4 defaults 1 2
- Press i to enter editing mode.
- Move the cursor to the end of the file and press Enter. Then add the following information:
UUID=c6a243ce-5150-41ac-8816-39db54d1a4b8 /Data1 ext4 defaults 0 0
The file content is described as follows:
- Column 1: indicates the UUID. Enter the UUID queried in 1.
- Column 2: indicates the file system's mounting directory. Enter mounting directory /Data1 created in 3.
- Column 3: indicates the file system format. Enter file system format ext4 configured in 2.
- Column 4: indicates the mounting option. In this example, defaults is used.
- Column 5: indicates the backup option. Enter either 1 (the system automatically backs up the file system) or 0 (does not back up the file system). In this example, 0 is used.
- Column 6: indicates the scanning option. Enter either 1 (the system automatically scans the file system at system start) or 0 (does not scan the file system). In this example, 0 is used.
- Press Esc, enter :wq!, and press Enter.
The system saves the modifications and exits the vi editor.
- Query the file system UUID.
- Verify that the file system can be auto-mounted at startup.
- Unmount the file system.
Example command:
umount /dev/vgdata/lvdata1
- Reload all the content in the /etc/fstab file.
mount -a
- Query the file system mount information.
Example command:
mount | grep /Data1
If information similar to the following is displayed, auto mount has taken effect:
[root@ecs-lvmtest ~]# mount | grep /Data1 /dev/mapper/vgdata-lvdata1 on /Data1 type ext4 (rw,relatime,data=ordered)
- Unmount the file system.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot