linux系統將硬碟設定為開機自動掛載

2021-10-03 18:49:17 字數 2734 閱讀 6530

若電腦有雙硬碟,則每次開機都需要先掛載另乙個硬碟,才可對其檔案進行操作。為解決這一問題,可以通過設定開機自動掛載,以省去這一步驟。

思路:通過硬碟對應分割槽的uuid碼,將分割槽加入到/etc/fstab的系統自動掛載中。

1. 找到分割槽的uuid

使用命令 blkid 查詢,blkid為查詢所有檔案系統型別的語句

sudo blkid
有輸出

/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"

其中包括了所有分割槽,uuid為每個分割槽的編碼。

2. 進行掛載

對/etc/fstab新增自動掛載

vim /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/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

其中,uuid為剛才查詢的編號,/media/sunkj/funny 為掛載點,ntfs為掛載的檔案型別,defaults為掛載的設定,後兩數字分別表示轉存頻率和自檢次序。詳細介紹

如此,即可完成自動掛載

Linux下將Weblogic設定為開機啟動

cd etc rc.d init.d vi weblogic bin bash chkconfig 34520 80 description weblogic server auto start stop script etc rc.d init.d weblogic please edit the...

Linux系統設定nginx為開機自啟

來自nginx官方,傳送門 注意有兩行 要與自己nginx安裝位置一致 nginxd usr local nginx sbin nginx nginx config usr local nginx conf nginx.conf 不知道nginx安裝位置的可以用whereis nginx來尋找 命令...

為Linux系統設定開機啟動項

aws 在aws 建立ec2階段 可以是red hat系統 可以使用如下一段指令碼,使得當ec2開機後,為系統新增乙個靜態網頁。下面的教程將介紹如何將命令或程式配置為開機啟動時自動執行的服務。完成配置之後,就可以通過 linux 命令列來 啟動 停止 禁用 這個服務了。建立服務 在樹莓派上建立乙個 ...