16. Hard disk mount

This chapter describes the hard disk mounting of Lubancat series boards

16.1. Check hard drive

16.1.1. lsblk

List information about all available block devices, showing dependencies between them.

1
lsblk

As shown below:

未找到图片05|
  • As shown in the figure above: The left side of the text lists the information of all available blocks, and the far right side of the text is the mounted position of the current hard disk.

  1. You can see that there are currently 5 available blocks, namely sda, sdb, mmcblk0, mmcblk0boot0, mmcblk0boot1

  2. mmcblk0boot0 and mmcblk0boot1 are some information of mmcblk0, it can be seen in lsblk that they are read-only, so we don’t need to use this as an available block.

  3. sda is an msata hard disk, does not support hot swap, RM=0, the size is 16G, converted to 14.8G in the system, readable and writable. It has only one partition is sda1, which is mounted to /root/test_blk superior.

  4. sdb is a USB flash drive that supports hot swap, RM=1, size 32G, converted to 28.7G in the system, readable and writable. It has only one partition is sdb1, which is not mounted.

  5. mmcblk0 is onboard emmc, does not support hot swap, RM=0, size 32G, converted to system is 29.1G, readable and writable.It has three partitions: mmcblk0p1 is uboot and system boot related partition, size is 4M ; mmcblk0p2 is the boot partition, which stores the kernel, device tree, configuration files, etc., and is mounted on the /boot partition; mmcblk0p3 is the root file partition, which stores the root file system and is mounted to / (under the root directory).

16.1.2. fdisk

fdisk can view some basic information of the hard disk.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#List the basic information of the hard disk or partition
fdisk [options] -l [<disk>]

#Modify the information of the hard disk or partition (to understand by yourself)
fdisk [options] [<disk>]

Example as shown below:

root@lubancat:~/rt-tests# fdisk -l /dev/mmcblk0
Disk /dev/mmcblk0: 29.13 GiB, 31272730624 bytes, 61079552 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
Disklabel type: gpt
Disk identifier: D9500000-0000-4945-8000-362C000010D3

Device          Start      End  Sectors  Size Type
/dev/mmcblk0p1  16384    24575     8192    4M unknown
/dev/mmcblk0p2  24576   286719   262144  128M unknown
/dev/mmcblk0p3 286720 61079487 60792768   29G unknown
root@lubancat:~/rt-tests#
  • You can see some basic information of emmc

  • fdisk can also modify the configuration of the hard disk. The specific method is not described here. You can learn by yourself

16.1.3. SD card

The information of sd card is similar to that of emmc. They use the same type of driver. The default device of sd card in Lubancat rk series system is /dev/mmcblk1. The sd card is a bit special. It is shown in lsblk that it is not removable. It may be because the SD card can be used as a system image to start Lubancat, so the SD card is not marked as a removable device.

The partition number is /dev/mmcblk1p# (# is 1,2,3,4,5,6,7).

16.1.4. U disk

The default device of the U disk in the Lubancat rk series system is /dev/sdx (x is a, b, c, d, e…), which needs to determine its device number according to the number of devices you install. lsblk will show that the device is a removable device.

The partition device number is /dev/sdx# (x is a, b, c, d, e…) (# is 1, 2, 3, 4, 5, 6, 7)

16.1.5. sata hard drive

The default device of sata hard drive in Lubancat rk series system is /dev/sdx (x stands for a, b, c, d, e…), which needs to determine its device number according to the number of devices you install.

The partition device number is /dev/sdx# (x is a, b, c, d, e…) (# is 1, 2, 3, 4, 5, 6, 7)

16.1.6. nvme hard drive

The default device of nvme hard disk in Lubancat rk series system is /dev/nvme0n1

The partition device number is /dev/nvme0n1p# (# is 1,2,3,4,5,6,7)

16.2. Manual mount

16.2.1. Mount hard drive

  • Basic commands

1
2
3
4
5
#Create the folder you want to mount to (if you have your own folder to mount, you don’t need to create it)
mkdir /mnt/mydir

#mount hard drive
mount /dev/xxx /mnt/mydir
  • /dev/xxx is the partition device of your hard disk

  • /mnt/mydir is the folder you want to mount, because the commonly used folders are mounted to /mnt or /media, so mount the hard disk at /mnt/mydir here.

The function of mount is very rich. Here is just a brief introduction to the basic usage of mount. If necessary, you can find the specific usage of mount by yourself.

16.2.2. Unmount hard drive

1
umount /mnt/mydir
  • /mnt/mydir is the folder you have mounted, you can view it with lsblk.

16.2.3. fstab auto mount (device partition)

注解

This method is suitable for automatic mounting when the storage device is single and the hard disk device number remains unchanged.

1
2
#Modify the /etc/fstab file
vi /etc/fstab
1
2
3
#Add the following

/dev/sdx   /mnt/mydir   auto   defaults   0   2
  • /dev/sdx is the hard disk partition to be mounted

  • /mnt/mydir is the folder to mount

  • auto is the file system format of the hard disk partition to be mounted. “auto” is to automatically judge the file according to the system format. In addition to “ext4”, “ntfs” and so on.

  • defaults The mode of the configuration file, “defaults” is the default option, in addition to “mode=1777”, “rw, noauto”, etc.

  • 0 and 2 are backup and check order respectively

16.2.4. fstab automount (UUID)

注解

This method is suitable for the situation where there are many storage devices and the storage device number will change at any time

UUID is an abbreviation for “Universally Unique Identifier”. It is an identifier used to uniquely identify various resources (such as disks, partitions, files, directories, etc.) in a computer system.

UUID is a 128-bit numeric identifier, usually expressed in hexadecimal. Its purpose is to maintain uniqueness across different systems and environments, avoiding conflicts and duplication. Every UUID should be unique, even across different computers or networks.

1
2
3
4
5
#Method 1: List the UUIDs of the hard disk partitions
lsblk -o NAME,UUID

#Method 2: List the UUIDs of the hard disk partitions
blkid
  • Get the UUID of your hard disk partition

1
2
#Modify the /etc/fstab file
vi /etc/fstab
1
2
3
#Add the following

UUID=xxxxx  /mnt/mydir   auto   defaults   0   2

注解

In addition to UUID, PARTUUID also has the same function as UUID, so I won’t go into details here.