Home  >  Article  >  System Tutorial  >  How to set Ubuntu 20.04 to automatically mount shared folders at startup in VirtualBox?

How to set Ubuntu 20.04 to automatically mount shared folders at startup in VirtualBox?

PHPz
PHPzforward
2023-12-29 23:47:271372browse

Today we will take a look at how to automatically mount the VirtualBox shared folder on startup after installing Ubuntu 20.04 on the VirtualBox virtual machine? Please see the introduction below for details.

Install Ubuntu20.04LTS, and install the built-in enhancements of VirtualBox, and shut down the virtual machine.

How to set Ubuntu 20.04 to automatically mount shared folders at startup in VirtualBox?

In the VirtualBox main interface, corresponding to the virtual machine of Ubuntu20.04, select "Settings", locate "Shared Folder" in the settings, and click Add a button on the right, as shown in the figure:

How to set Ubuntu 20.04 to automatically mount shared folders at startup in VirtualBox?

How to set Ubuntu 20.04 to automatically mount shared folders at startup in VirtualBox?

In the pop-up dialog box, set the location of the file that needs to be shared in Windows. For other options, check the box in front of "Fixed mount" and click "OK ". Select "OK" in the "Settings" dialog box as shown:

How to set Ubuntu 20.04 to automatically mount shared folders at startup in VirtualBox?

How to set Ubuntu 20.04 to automatically mount shared folders at startup in VirtualBox?

Start the virtual machine. After the startup is completed, press Ctrl Alt T to open the terminal and enter: sudo gedit /lib/systemd/system/rc-local.service,"Enter ", open and edit the content of rc-local.service, and finally append:

[Install]
WantedBy=multi-user.target
Alias=rc-local.service

Save and close. As shown in the picture:

How to set Ubuntu 20.04 to automatically mount shared folders at startup in VirtualBox?

How to set Ubuntu 20.04 to automatically mount shared folders at startup in VirtualBox?

Enter in the terminal:

sudo gedit /etc/rc.local

Enter

Fill in the following content in the pop-up file:

#!/bin/sh
mount -t vboxsf shared /mnt/shared
exit 0

Where "shared" is the name of the shared file in the previously shared folder.

Save and close.

How to set Ubuntu 20.04 to automatically mount shared folders at startup in VirtualBox?

How to set Ubuntu 20.04 to automatically mount shared folders at startup in VirtualBox?

Enter the following command in the terminal:

1. Create a new connection folder:

sudo mkdir /mnt/shared

2. Create a soft link under /systemd/system:

sudo ln -s /lib/systemd/system/rc-local.service /etc/systemd/system/

After restarting, you can see the contents of the mounted folder under /mnt/shared. If you want to create a soft link (shortcut) on the desktop, you can enter in the terminal:

ln -s /mnt/shared ~/Desktop/

If it is an English system input

ln -s /mnt/shared ~/desktop/

How to set Ubuntu 20.04 to automatically mount shared folders at startup in VirtualBox?

The above is the detailed content of How to set Ubuntu 20.04 to automatically mount shared folders at startup in VirtualBox?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:jb51.net. If there is any infringement, please contact admin@php.cn delete