linux system hard disk to start automatically mount

If the computer has two hard disks, then each boot need to mount another hard disk before they can operate their files. To solve this problem, you can set the boot automatically mount to omit this step.
Idea: by UUID codes corresponding to the hard disk partition, a partition was added to the / etc / fstab the system automatically mounted.

1. Locate the UUID partition

Use the command blkid query, blkid query all file system type of statement

sudo blkid

There output

/dev/loop0: TYPE="squashfs"
/dev/loop1: TYPE="squashfs"
/dev/loop2: TYPE="squashfs"
/dev/nvme0n1p1: UUID="116D-8C64" TYPE="vfat" PARTUUID="5363068d-4b0e-478b-a567-f25d188e1384"
/dev/nvme0n1p2: UUID="9fb2b3bc-baa1-4c50-aef0-58cff3289c3e" TYPE="swap" PARTUUID="32d48ea3-17fc-4f10-9082-eabbcaa7783f"
/dev/nvme0n1p3: UUID="afeae81b-99a3-4b9b-b42f-8f36cdb1f9af" TYPE="ext4" PARTUUID="03705555-147e-4d03-91b5-73591a54848b"
/dev/sda2: LABEL="sorfwore" UUID="1EEC07B1EC0781EF" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="c1fd3cd9-4cf4-4e73-9f96-ea77f0ddab40"
/dev/sda3: LABEL="WorkAndStudy" UUID="2ACC20BFCC208763" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="739f234b-1a76-4bec-a1bf-a921cb85f7b5"
/dev/sda4: LABEL="funny" UUID="0E622B23622B0F51" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="6e051abe-883d-48d7-98bd-2e33c981abe5"
/dev/sdb1: LABEL="SUN" UUID="76C2E1D1C2E19621" TYPE="ntfs" PTTYPE="atari" PARTLABEL="Elements" PARTUUID="e5d9dfbc-876b-4697-a4b6-8cb672be1402"
/dev/nvme0n1: PTUUID="8f09eb3e-389b-4c53-9a16-661d8ce112d3" PTTYPE="gpt"
/dev/sda1: PARTLABEL="Microsoft reserved partition" PARTUUID="c16fb186-84d1-4cc8-a4d6-01cf3d25ac3e"

Which includes all partitions, UUID coding each partition.

2. Mount

To / etc / fstab to mount automatically added

vim /etc/fstab

Output is as follows:

# /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).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/nvme0n1p3 during installation
UUID=afeae81b-99a3-4b9b-b42f-8f36cdb1f9af /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/nvme0n1p1 during installation
UUID=116D-8C64  /boot/efi       vfat    umask=0077      0       1
# swap was on /dev/nvme0n1p2 during installation
UUID=9fb2b3bc-baa1-4c50-aef0-58cff3289c3e none            swap    sw              0       0
UUID=0E622B23622B0F51 /media/sunkj/funny  ntfs defaults 0  0
UUID=2ACC20BFCC208763 /media/sunkj/WorkAndStudy ntfs defaults 0 0
UUID=1EEC07B1EC0781EF /media/sunkj/sofwore ntfs defaults 0 0

Wherein, the UUID is the number of earlier inquiries, / media / sunkj / funny as a mount point, NTFS file type mount, the mount is provided Defaults, two rear dump numerals denote the frequency and the self-test sequence. Details

So, to complete automatically mount

Published 12 original articles · won praise 2 · Views 2033

Guess you like

Origin blog.csdn.net/weixin_44134757/article/details/104802766